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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/security/manager/ssl/tests/unit/test_signed_apps-marketplace.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,43 @@
     1.4 +"use strict";
     1.5 +
     1.6 +const isB2G = ("@mozilla.org/b2g-process-global;1" in Cc);
     1.7 +
     1.8 +
     1.9 +do_get_profile(); // must be called before getting nsIX509CertDB
    1.10 +const certdb = Cc["@mozilla.org/security/x509certdb;1"].getService(Ci.nsIX509CertDB);
    1.11 +
    1.12 +function run_test() {
    1.13 +  run_next_test();
    1.14 +}
    1.15 +
    1.16 +function check_open_result(name, expectedRv) {
    1.17 +  return function openSignedAppFileCallback(rv, aZipReader, aSignerCert) {
    1.18 +    do_print("openSignedAppFileCallback called for " + name);
    1.19 +    do_check_eq(rv, expectedRv);
    1.20 +    do_check_eq(aZipReader != null,  Components.isSuccessCode(expectedRv));
    1.21 +    do_check_eq(aSignerCert != null, Components.isSuccessCode(expectedRv));
    1.22 +    run_next_test();
    1.23 +  };
    1.24 +}
    1.25 +
    1.26 +function original_app_path(test_name) {
    1.27 +  return do_get_file("test_signed_apps/" + test_name + ".zip", false);
    1.28 +}
    1.29 +
    1.30 +// Test that we no longer trust the test root cert that was originally used
    1.31 +// during development of B2G 1.0.
    1.32 +add_test(function () {
    1.33 +  certdb.openSignedAppFileAsync(
    1.34 +    Ci.nsIX509CertDB.AppMarketplaceProdPublicRoot,
    1.35 +    original_app_path("test-privileged-app-test-1.0"),
    1.36 +    check_open_result("test-privileged-app-test-1.0",
    1.37 +                      getXPCOMStatusFromNSS(SEC_ERROR_UNKNOWN_ISSUER)));
    1.38 +});
    1.39 +
    1.40 +// Test that we trust the root cert used by by the Firefox Marketplace.
    1.41 +add_test(function () {
    1.42 +  certdb.openSignedAppFileAsync(
    1.43 +    Ci.nsIX509CertDB.AppMarketplaceProdPublicRoot,
    1.44 +    original_app_path("privileged-app-test-1.0"),
    1.45 +    check_open_result("privileged-app-test-1.0", Cr.NS_OK));
    1.46 +});

mercurial