Bug 1561716 - Add tests for buildChain.r=keeler

Differential Revision: https://phabricator.services.mozilla.com/D36089

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Carolina 2019-07-19 11:16:55 +00:00
Родитель 28467d53d6
Коммит f77ced0177
4 изменённых файлов: 59 добавлений и 1 удалений

Просмотреть файл

@ -10,5 +10,9 @@ BROWSER_CHROME_MANIFESTS += [
'tests/browser/browser.ini'
]
MOCHITEST_CHROME_MANIFESTS += [
'tests/chrome/chrome.ini'
]
with Files('**'):
BUG_COMPONENT = ("Firefox", "Security")
BUG_COMPONENT = ("Firefox", "Security")

Просмотреть файл

@ -0,0 +1,7 @@
"use strict";
module.exports = {
"parserOptions": {
"sourceType": "module",
}
};

Просмотреть файл

@ -0,0 +1,3 @@
[DEFAULT]
scheme=https
[test_certDecoder.html]

Просмотреть файл

@ -0,0 +1,44 @@
<!DOCTYPE html>
<html>
<head>
<title>certviewer parse test</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script src="chrome://global/content/certviewer/pvutils_bundle.js"></script>
<script src="chrome://global/content/certviewer/asn1js_bundle.js"></script>
<script src="chrome://global/content/certviewer/pkijs_bundle.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<script type="module">
import { parse } from "chrome://global/content/certviewer/certDecoder.js";
import { pemToDER } from "chrome://global/content/certviewer/utils.js";
// inputPEM is the same input to CS extension (https://github.com/april/certainly-something)
const inputPEM = "MIIGRjCCBS6gAwIBAgIQDJduPkI49CDWPd+G7+u6kDANBgkqhkiG9w0BAQsFADBNMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMScwJQYDVQQDEx5EaWdpQ2VydCBTSEEyIFNlY3VyZSBTZXJ2ZXIgQ0EwHhcNMTgxMTA1MDAwMDAwWhcNMTkxMTEzMTIwMDAwWjCBgzELMAkGA1UEBhMCVVMxEzARBgNVBAgTCk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Tpw1THIuqCGl/wpPgyQgcTM=%0D%0A-----END%20CERTIFICATE-----%0D%0A";
async function doTest() {
ok(parse, "parse should be available in this context");
ok(pemToDER, "pemToDER should be available in this context");
let input = inputPEM.trim()
.replace(/\r|\n|\0/g, "")
.split()
.filter(v => v.startsWith("MII"))[0];
let certDER = pemToDER(input);
let cert = await parse(certDER);
ok(cert, "There should be a result");
is(cert.files.pem, certOutputCS, "certificates output must be the same");
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
doTest();
</script>
</body>
</html>