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

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

mercurial