security/manager/ssl/tests/unit/test_sts_ipv4_ipv6.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 function check_ip(s, v, ip) {
     2   do_check_false(s.isSecureHost(Ci.nsISiteSecurityService.HEADER_HSTS, ip, 0));
     4   let str = "https://";
     5   if (v == 6) {
     6     str += "[";
     7   }
     8   str += ip;
     9   if (v == 6) {
    10     str += "]";
    11   }
    12   str += "/";
    14   let uri = Services.io.newURI(str, null, null);
    16   let parsedMaxAge = {};
    17   let parsedIncludeSubdomains = {};
    18   s.processHeader(Ci.nsISiteSecurityService.HEADER_HSTS, uri,
    19                   "max-age=1000;includeSubdomains", 0,
    20                   parsedMaxAge, parsedIncludeSubdomains);
    22   /* Test that processHeader will ignore headers for an uri, if the uri
    23    * contains an IP address not a hostname.
    24    * If processHeader indeed ignore the header, then the output parameters will
    25    * remain empty, and we shouldn't see the values passed as the header.
    26    */
    27   do_check_neq(parsedMaxAge.value, 1000);
    28   do_check_neq(parsedIncludeSubdomains.value, true);
    29 }
    31 function run_test() {
    32   let SSService = Cc["@mozilla.org/ssservice;1"]
    33                     .getService(Ci.nsISiteSecurityService);
    35   check_ip(SSService, 4, "127.0.0.1");
    36   check_ip(SSService, 4, "10.0.0.1");
    37   check_ip(SSService, 6, "2001:db8::1");
    38   check_ip(SSService, 6, "1080::8:800:200C:417A");
    39 }

mercurial