Bug 1167254 - Convert test_bug234856.html mochitest to an xpcshell test. r=keeler

--HG--
extra : rebase_source : c8bad9f0d55aa2a037ae508da988a137c5239006
This commit is contained in:
Cykesiopka 2015-05-28 02:22:00 +02:00
Родитель cd5369751f
Коммит c2bc81fbea
4 изменённых файлов: 71 добавлений и 47 удалений

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

@ -2,7 +2,6 @@
tags = psm
skip-if = buildapp == 'b2g'
[test_bug234856.html]
[test_bug413909.html]
skip-if = buildapp == 'mulet'
[test_bug480619.html]

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

@ -1,46 +0,0 @@
<!doctype html>
<html><head>
<meta charset="utf-8">
<title>Test for Bug 234856</title>
<script src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"
></script>
<link rel="stylesheet"
href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head><body>
<script>
const Ci = Components.interfaces;
SimpleTest.waitForExplicitFinish();
window.onload = function RunTest()
{
var certDB = Components.classes["@mozilla.org/security/x509certdb;1"]
.getService(Ci.nsIX509CertDB);
var rawCert = document.getElementById("cert").firstChild.wholeText;
var cert = certDB.constructX509FromBase64(rawCert);
// all simple attributes that are properties of the cert itself
is(cert.certType, Ci.nsIX509Cert.EMAIL_CERT, "certType");
is(cert.isSelfSigned, false, "isSelfSigned");
is(cert.serialNumber, "00:98:99:6F", "serialNumber");
is(cert.sha1Fingerprint, "03:E2:EB:66:DC:D3:44:10:F5:FE:9E:C7:8D:51:3C:BF:9A:AD:7C:5E", "sha1Fingerprint");
is(cert.sha256Fingerprint, "A5:CE:5B:9C:F1:56:3D:D6:8D:03:C5:A0:6C:9E:D3:10:01:B3:81:C9:CF:21:5F:E4:D2:D4:A9:73:C4:8C:9E:30", "sha256Fingerprint");
is(cert.nickname, "(no nickname)", "nickname");
is(cert.emailAddress, "ludek.rasek@centrum.cz", "emailAddress");
is(cert.subjectName, "serialNumber=ICA - 10003769,SN=Rašek,name=Luděk Rašek,initials=LR,givenName=Luděk,E=ludek.rasek@centrum.cz,L=\"Pacov, Nádražní 769\",ST=Vysočina,CN=Luděk Rašek,C=CZ", "subjectName");
is(cert.commonName, "Luděk Rašek", "commonName");
is(cert.organization, "", "organization");
is(cert.organizationalUnit, "", "organizationalUnit");
is(cert.windowTitle, "Luděk Rašek", "windowTitle");
is(cert.issuerName, "OU=Akreditovaný poskytovatel certifikačních služeb,O=První certifikační autorita a.s.,L=\"Podvinný mlýn 2178/6, 190 00 Praha 9\",C=CZ,CN=I.CA - Qualified root certificate (kvalifikovaný certifikát poskytovatele) - PSEUDONYM", "issuerName");
is(cert.issuerCommonName, "I.CA - Qualified root certificate (kvalifikovaný certifikát poskytovatele) - PSEUDONYM", "issuerCommonName");
is(cert.issuerOrganization, "První certifikační autorita a.s.", "issuerOrganization");
is(cert.issuerOrganizationUnit, "Akreditovaný poskytovatel certifikačních služeb", "issuerOrganizationUnit");
SimpleTest.finish();
}
</script>
<div style="display:none" id="cert">MIIF3DCCBMSgAwIBAgIEAJiZbzANBgkqhkiG9w0BAQUFADCCAQ0xYTBfBgNVBAMMWEkuQ0EgLSBRdWFsaWZpZWQgcm9vdCBjZXJ0aWZpY2F0ZSAoa3ZhbGlmaWtvdmFuw70gY2VydGlmaWvDoXQgcG9za3l0b3ZhdGVsZSkgLSBQU0VVRE9OWU0xCzAJBgNVBAYTAkNaMS8wLQYDVQQHDCZQb2R2aW5uw70gbWzDvW4gMjE3OC82LCAxOTAgMDAgUHJhaGEgOTEsMCoGA1UECgwjUHJ2bsOtIGNlcnRpZmlrYcSNbsOtIGF1dG9yaXRhIGEucy4xPDA6BgNVBAsMM0FrcmVkaXRvdmFuw70gcG9za3l0b3ZhdGVsIGNlcnRpZmlrYcSNbsOtY2ggc2x1xb5lYjAeFw0wMjEyMTIxMzMzNDZaFw0wMzEyMTIxMzMzNDZaMIIBFDELMAkGA1UEBhMCQ1oxHzAdBgNVBAMeFgBMAHUAZAEbAGsAIABSAGEBYQBlAGsxGTAXBgNVBAgeEABWAHkAcwB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GA1UdDwEB/wQEAwIE8DANBgkqhkiG9w0BAQUFAAOCAQEAv2V+nnYYMIgabmmgHx49CtlZIHdGS3TuWKXw130xFhbXDnNhEbx3alaskNsvjQQRLqs1ZwKy58yynse+eJYHqenmHDACpAfVpCF9PXC/mDarVsoQw7NTcUpsAFhSd/zTv9jIf3twECyxx/RVzONVcob7nPePESHiKoG4FbtcuUh0wSHvCmTwRIQqPDCIuHcFStSt3Jr9iXcbXEhe4mSccOZ8N+r7Rv3ncKcevlRl7uFfDKDTyd43SZeRS/7J8KRfhD/h2nawrCFwc5gJW10aLJGFL/mcS7ViAIT9HCVk23j4TuBjsVmnZ0VKxB5edux+LIEqtU428UVHZWU/I5ngLw==</div>
</body></html>

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

@ -0,0 +1,70 @@
// -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
"use strict";
// Checks that various nsIX509Cert attributes correctly handle UTF-8.
do_get_profile(); // Must be called before getting nsIX509CertDB
const certDB = Cc["@mozilla.org/security/x509certdb;1"]
.getService(Ci.nsIX509CertDB);
function run_test() {
let cert = certDB.constructX509FromBase64(
"MIIF3DCCBMSgAwIBAgIEAJiZbzANBgkqhkiG9w0BAQUFADCCAQ0xYTBfBgNVBAMM" +
"WEkuQ0EgLSBRdWFsaWZpZWQgcm9vdCBjZXJ0aWZpY2F0ZSAoa3ZhbGlmaWtvdmFu" +
"w70gY2VydGlmaWvDoXQgcG9za3l0b3ZhdGVsZSkgLSBQU0VVRE9OWU0xCzAJBgNV" +
"BAYTAkNaMS8wLQYDVQQHDCZQb2R2aW5uw70gbWzDvW4gMjE3OC82LCAxOTAgMDAg" +
"UHJhaGEgOTEsMCoGA1UECgwjUHJ2bsOtIGNlcnRpZmlrYcSNbsOtIGF1dG9yaXRh" +
"IGEucy4xPDA6BgNVBAsMM0FrcmVkaXRvdmFuw70gcG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GAQQBs2EBAQQEMIGaMC8GCCsGAQUFBwIBFiNodHRwOi8vd3d3" +
"LmljYS5jei9xY3AvY3BxcGljYTAyLnBkZjBnBggrBgEFBQcCAjBbGllUZW50byBj" +
"ZXJ0aWZpa2F0IGplIHZ5ZGFuIGpha28gS3ZhbGlmaWtvdmFueSBjZXJ0aWZpa2F0" +
"IHYgc291bGFkdSBzZSB6YWtvbmVtIDIyNy8yMDAwIFNiLjAYBggrBgEFBQcBAwQM" +
"MAowCAYGBACORgEBMA4GA1UdDwEB/wQEAwIE8DANBgkqhkiG9w0BAQUFAAOCAQEA" +
"v2V+nnYYMIgabmmgHx49CtlZIHdGS3TuWKXw130xFhbXDnNhEbx3alaskNsvjQQR" +
"Lqs1ZwKy58yynse+eJYHqenmHDACpAfVpCF9PXC/mDarVsoQw7NTcUpsAFhSd/zT" +
"v9jIf3twECyxx/RVzONVcob7nPePESHiKoG4FbtcuUh0wSHvCmTwRIQqPDCIuHcF" +
"StSt3Jr9iXcbXEhe4mSccOZ8N+r7Rv3ncKcevlRl7uFfDKDTyd43SZeRS/7J8KRf" +
"hD/h2nawrCFwc5gJW10aLJGFL/mcS7ViAIT9HCVk23j4TuBjsVmnZ0VKxB5edux+" +
"LIEqtU428UVHZWU/I5ngLw==");
equal(cert.nickname, "(no nickname)",
"Actual and expected nickname should match");
equal(cert.emailAddress, "ludek.rasek@centrum.cz",
"Actual and expected emailAddress should match");
equal(cert.subjectName, "serialNumber=ICA - 10003769,SN=Rašek,name=Luděk Rašek,initials=LR,givenName=Luděk,E=ludek.rasek@centrum.cz,L=\"Pacov, Nádražní 769\",ST=Vysočina,CN=Luděk Rašek,C=CZ",
"Actual and expected subjectName should match");
equal(cert.commonName, "Luděk Rašek",
"Actual and expected commonName should match");
equal(cert.organization, "",
"Actual and expected organization should match");
equal(cert.organizationalUnit, "",
"Actual and expected organizationalUnit should match");
equal(cert.windowTitle, "Luděk Rašek",
"Actual and expected windowTitle should match");
equal(cert.issuerName, "OU=Akreditovaný poskytovatel certifikačních služeb,O=První certifikační autorita a.s.,L=\"Podvinný mlýn 2178/6, 190 00 Praha 9\",C=CZ,CN=I.CA - Qualified root certificate (kvalifikovaný certifikát poskytovatele) - PSEUDONYM",
"Actual and expected issuerName should match");
equal(cert.issuerCommonName, "I.CA - Qualified root certificate (kvalifikovaný certifikát poskytovatele) - PSEUDONYM",
"Actual and expected issuerCommonName should match");
equal(cert.issuerOrganization, "První certifikační autorita a.s.",
"Actual and expected issuerOrganization should match");
equal(cert.issuerOrganizationUnit, "Akreditovaný poskytovatel certifikačních služeb",
"Actual and expected issuerOrganizationUnit should match");
}

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

@ -127,3 +127,4 @@ run-sequentially = hardcoded ports
run-sequentially = hardcoded ports
[test_nsCertType.js]
run-sequentially = hardcoded ports
[test_nsIX509Cert_utf8.js]