Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | "use strict"; |
michael@0 | 2 | |
michael@0 | 3 | const isB2G = ("@mozilla.org/b2g-process-global;1" in Cc); |
michael@0 | 4 | |
michael@0 | 5 | |
michael@0 | 6 | do_get_profile(); // must be called before getting nsIX509CertDB |
michael@0 | 7 | const certdb = Cc["@mozilla.org/security/x509certdb;1"].getService(Ci.nsIX509CertDB); |
michael@0 | 8 | |
michael@0 | 9 | function run_test() { |
michael@0 | 10 | run_next_test(); |
michael@0 | 11 | } |
michael@0 | 12 | |
michael@0 | 13 | function check_open_result(name, expectedRv) { |
michael@0 | 14 | return function openSignedAppFileCallback(rv, aZipReader, aSignerCert) { |
michael@0 | 15 | do_print("openSignedAppFileCallback called for " + name); |
michael@0 | 16 | do_check_eq(rv, expectedRv); |
michael@0 | 17 | do_check_eq(aZipReader != null, Components.isSuccessCode(expectedRv)); |
michael@0 | 18 | do_check_eq(aSignerCert != null, Components.isSuccessCode(expectedRv)); |
michael@0 | 19 | run_next_test(); |
michael@0 | 20 | }; |
michael@0 | 21 | } |
michael@0 | 22 | |
michael@0 | 23 | function original_app_path(test_name) { |
michael@0 | 24 | return do_get_file("test_signed_apps/" + test_name + ".zip", false); |
michael@0 | 25 | } |
michael@0 | 26 | |
michael@0 | 27 | // Test that we no longer trust the test root cert that was originally used |
michael@0 | 28 | // during development of B2G 1.0. |
michael@0 | 29 | add_test(function () { |
michael@0 | 30 | certdb.openSignedAppFileAsync( |
michael@0 | 31 | Ci.nsIX509CertDB.AppMarketplaceProdPublicRoot, |
michael@0 | 32 | original_app_path("test-privileged-app-test-1.0"), |
michael@0 | 33 | check_open_result("test-privileged-app-test-1.0", |
michael@0 | 34 | getXPCOMStatusFromNSS(SEC_ERROR_UNKNOWN_ISSUER))); |
michael@0 | 35 | }); |
michael@0 | 36 | |
michael@0 | 37 | // Test that we trust the root cert used by by the Firefox Marketplace. |
michael@0 | 38 | add_test(function () { |
michael@0 | 39 | certdb.openSignedAppFileAsync( |
michael@0 | 40 | Ci.nsIX509CertDB.AppMarketplaceProdPublicRoot, |
michael@0 | 41 | original_app_path("privileged-app-test-1.0"), |
michael@0 | 42 | check_open_result("privileged-app-test-1.0", Cr.NS_OK)); |
michael@0 | 43 | }); |