mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 877441: Add head.js in psm xpcshell tests to avoid copy-paste. r=bsmith
This commit is contained in:
parent
da93681728
commit
1cbdee58d5
27
security/manager/ssl/tests/unit/head_psm.js
Normal file
27
security/manager/ssl/tests/unit/head_psm.js
Normal file
@ -0,0 +1,27 @@
|
||||
/* 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";
|
||||
|
||||
const { 'classes': Cc, 'interfaces': Ci, 'utils': Cu, 'results': Cr } = Components;
|
||||
|
||||
let { NetUtil } = Cu.import("resource://gre/modules/NetUtil.jsm", {});
|
||||
|
||||
Cu.import("resource://gre/modules/FileUtils.jsm"); // XXX: tempScope?
|
||||
Cu.import("resource://gre/modules/Services.jsm"); // XXX: tempScope?
|
||||
|
||||
function readFile(file) {
|
||||
let fstream = Cc["@mozilla.org/network/file-input-stream;1"]
|
||||
.createInstance(Ci.nsIFileInputStream);
|
||||
fstream.init(file, -1, 0, 0);
|
||||
let data = NetUtil.readInputStreamToString(fstream, fstream.available());
|
||||
fstream.close();
|
||||
return data;
|
||||
}
|
||||
|
||||
function addCertFromFile(certdb, filename, trustString) {
|
||||
let certFile = do_get_file(filename, false);
|
||||
let der = readFile(certFile);
|
||||
certdb.addCert(der, trustString, null);
|
||||
}
|
@ -1,9 +1,5 @@
|
||||
"use strict";
|
||||
|
||||
let Cc = Components.classes;
|
||||
let Ci = Components.interfaces;
|
||||
let Cu = Components.utils;
|
||||
let Cr = Components.results;
|
||||
/* To regenerate the certificates and apps for this test:
|
||||
|
||||
cd security/manager/ssl/tests/unit/test_certificate_usages
|
||||
@ -20,26 +16,9 @@ let Cr = Components.results;
|
||||
tools or libraries built for the host platform.
|
||||
*/
|
||||
|
||||
let tempScope = {};
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm", tempScope);
|
||||
let NetUtil = tempScope.NetUtil;
|
||||
|
||||
|
||||
Cu.import("resource://gre/modules/FileUtils.jsm"); // XXX: tempScope?
|
||||
Cu.import("resource://gre/modules/Services.jsm"); // XXX: tempScope?
|
||||
|
||||
do_get_profile(); // must be called before getting nsIX509CertDB
|
||||
const certdb = Cc["@mozilla.org/security/x509certdb;1"].getService(Ci.nsIX509CertDB);
|
||||
|
||||
function readFile(file) {
|
||||
let fstream = Cc["@mozilla.org/network/file-input-stream;1"]
|
||||
.createInstance(Ci.nsIFileInputStream);
|
||||
fstream.init(file, -1, 0, 0);
|
||||
let data = NetUtil.readInputStreamToString(fstream, fstream.available());
|
||||
fstream.close();
|
||||
return data;
|
||||
}
|
||||
|
||||
var ca_usages = ['Client,Server,Sign,Encrypt,SSL CA,Status Responder',
|
||||
'SSL CA',
|
||||
'Client,Server,Sign,Encrypt,SSL CA,Status Responder',
|
||||
@ -116,11 +95,7 @@ function run_test() {
|
||||
for (var i = 0; i < ca_usages.length; i++) {
|
||||
var ca_name = "ca-" + (i + 1);
|
||||
var ca_filename = ca_name + ".der";
|
||||
var root_cert_der =
|
||||
do_get_file("test_certificate_usages/" + ca_filename, false);
|
||||
var der = readFile(root_cert_der);
|
||||
certdb.addCert(der, "CTu,CTu,CTu", ca_name);
|
||||
|
||||
addCertFromFile(certdb, "test_certificate_usages/" + ca_filename, "CTu,CTu,CTu");
|
||||
do_print("ca_name=" + ca_name);
|
||||
var cert;
|
||||
cert = certdb.findCertByNickname(null, ca_name);
|
||||
@ -136,10 +111,7 @@ function run_test() {
|
||||
var ee_name = "ee-" + (j + 1) + "-" + ca_name;
|
||||
var ee_filename = ee_name + ".der";
|
||||
//do_print("ee_filename" + ee_filename);
|
||||
var ee_cert_der =
|
||||
do_get_file("test_certificate_usages/" + ee_filename, false);
|
||||
var der = readFile(ee_cert_der);
|
||||
certdb.addCert(der, ",,", ee_name);
|
||||
addCertFromFile(certdb, "test_certificate_usages/" + ee_filename, ",,");
|
||||
var ee_cert;
|
||||
ee_cert = certdb.findCertByNickname(null, ee_name);
|
||||
var verified = {};
|
||||
|
@ -1,5 +1,3 @@
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
const DSV = Ci.nsIDataSignatureVerifier;
|
||||
|
||||
var keys = [
|
||||
|
@ -1,14 +1,7 @@
|
||||
"use strict";
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
const Cu = Components.utils;
|
||||
const Cr = Components.results;
|
||||
|
||||
const isB2G = ("@mozilla.org/b2g-keyboard;1" in Components.classes);
|
||||
|
||||
Cu.import("resource://gre/modules/FileUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
do_get_profile(); // must be called before getting nsIX509CertDB
|
||||
const certdb = Cc["@mozilla.org/security/x509certdb;1"].getService(Ci.nsIX509CertDB);
|
||||
|
||||
|
@ -1,9 +1,4 @@
|
||||
"use strict";
|
||||
var Cc = Components.classes;
|
||||
var Ci = Components.interfaces;
|
||||
var Cu = Components.utils;
|
||||
var Cr = Components.results;
|
||||
|
||||
/* To regenerate the certificates and apps for this test:
|
||||
|
||||
cd security/manager/ssl/tests/unit/test_signed_apps
|
||||
@ -25,13 +20,6 @@ const PR_RDWR = 0x04;
|
||||
const PR_CREATE_FILE = 0x08;
|
||||
const PR_TRUNCATE = 0x20;
|
||||
|
||||
let tempScope = {};
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm", tempScope);
|
||||
let NetUtil = tempScope.NetUtil;
|
||||
|
||||
Cu.import("resource://gre/modules/FileUtils.jsm"); // XXX: tempScope?
|
||||
Cu.import("resource://gre/modules/Services.jsm"); // XXX: tempScope?
|
||||
|
||||
do_get_profile(); // must be called before getting nsIX509CertDB
|
||||
const certdb = Cc["@mozilla.org/security/x509certdb;1"].getService(Ci.nsIX509CertDB);
|
||||
|
||||
@ -122,15 +110,6 @@ function truncateEntry(entry, entryInput) {
|
||||
return [entry, content]
|
||||
}
|
||||
|
||||
function readFile(file) {
|
||||
let fstream = Cc["@mozilla.org/network/file-input-stream;1"]
|
||||
.createInstance(Ci.nsIFileInputStream);
|
||||
fstream.init(file, -1, 0, 0);
|
||||
let data = NetUtil.readInputStreamToString(fstream, fstream.available());
|
||||
fstream.close();
|
||||
return data;
|
||||
}
|
||||
|
||||
function run_test() {
|
||||
var root_cert_der =
|
||||
do_get_file("test_signed_apps/trusted_ca1.der", false);
|
||||
|
@ -1,7 +1,3 @@
|
||||
var Cc = Components.classes;
|
||||
var Ci = Components.interfaces;
|
||||
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
var gSTSService = Cc["@mozilla.org/stsservice;1"]
|
||||
.getService(Ci.nsIStrictTransportSecurityService);
|
||||
|
@ -1,8 +1,3 @@
|
||||
var Cc = Components.classes;
|
||||
var Ci = Components.interfaces;
|
||||
var Cu = Components.utils;
|
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
function run_test() {
|
||||
let STSService = Cc["@mozilla.org/stsservice;1"]
|
||||
|
@ -1,6 +1,6 @@
|
||||
[DEFAULT]
|
||||
head =
|
||||
tail =
|
||||
head = head_psm.js
|
||||
tail =
|
||||
|
||||
[test_certificate_usages.js]
|
||||
[test_signed_apps.js]
|
||||
|
Loading…
Reference in New Issue
Block a user