security/manager/ssl/tests/unit/test_signed_apps-marketplace.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 "use strict";
     3 const isB2G = ("@mozilla.org/b2g-process-global;1" in Cc);
     6 do_get_profile(); // must be called before getting nsIX509CertDB
     7 const certdb = Cc["@mozilla.org/security/x509certdb;1"].getService(Ci.nsIX509CertDB);
     9 function run_test() {
    10   run_next_test();
    11 }
    13 function check_open_result(name, expectedRv) {
    14   return function openSignedAppFileCallback(rv, aZipReader, aSignerCert) {
    15     do_print("openSignedAppFileCallback called for " + name);
    16     do_check_eq(rv, expectedRv);
    17     do_check_eq(aZipReader != null,  Components.isSuccessCode(expectedRv));
    18     do_check_eq(aSignerCert != null, Components.isSuccessCode(expectedRv));
    19     run_next_test();
    20   };
    21 }
    23 function original_app_path(test_name) {
    24   return do_get_file("test_signed_apps/" + test_name + ".zip", false);
    25 }
    27 // Test that we no longer trust the test root cert that was originally used
    28 // during development of B2G 1.0.
    29 add_test(function () {
    30   certdb.openSignedAppFileAsync(
    31     Ci.nsIX509CertDB.AppMarketplaceProdPublicRoot,
    32     original_app_path("test-privileged-app-test-1.0"),
    33     check_open_result("test-privileged-app-test-1.0",
    34                       getXPCOMStatusFromNSS(SEC_ERROR_UNKNOWN_ISSUER)));
    35 });
    37 // Test that we trust the root cert used by by the Firefox Marketplace.
    38 add_test(function () {
    39   certdb.openSignedAppFileAsync(
    40     Ci.nsIX509CertDB.AppMarketplaceProdPublicRoot,
    41     original_app_path("privileged-app-test-1.0"),
    42     check_open_result("privileged-app-test-1.0", Cr.NS_OK));
    43 });

mercurial