security/manager/ssl/tests/unit/test_ocsp_stapling_with_intermediate.js

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:43d320bdc91c
1 // -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // This Source Code Form is subject to the terms of the Mozilla Public
3 // License, v. 2.0. If a copy of the MPL was not distributed with this
4 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 "use strict";
6
7 // In which we connect to a server that staples an OCSP response for a
8 // certificate signed by an intermediate that has an OCSP AIA to ensure
9 // that an OCSP request is not made for the intermediate.
10
11 let gOCSPRequestCount = 0;
12
13 function add_ocsp_test(aHost, aExpectedResult) {
14 add_connection_test(aHost, aExpectedResult,
15 function() {
16 clearOCSPCache();
17 clearSessionCache();
18 });
19 }
20
21 function run_test() {
22 do_get_profile();
23 Services.prefs.setBoolPref("security.ssl.enable_ocsp_stapling", true);
24
25 let ocspResponder = new HttpServer();
26 ocspResponder.registerPrefixHandler("/", function(request, response) {
27 gOCSPRequestCount++;
28 response.setStatusLine(request.httpVersion, 500, "Internal Server Error");
29 let body = "Refusing to return a response";
30 response.bodyOutputStream.write(body, body.length);
31 });
32 ocspResponder.start(8080);
33
34 add_tls_server_setup("OCSPStaplingServer");
35
36 add_tests_in_mode(true);
37 add_tests_in_mode(false);
38
39 add_test(function () { ocspResponder.stop(run_next_test); });
40 add_test(function() {
41 do_check_eq(gOCSPRequestCount, 0);
42 run_next_test();
43 });
44 run_next_test();
45 }
46
47 function add_tests_in_mode(useMozillaPKIX) {
48 add_test(function () {
49 Services.prefs.setBoolPref("security.use_mozillapkix_verification",
50 useMozillaPKIX);
51 run_next_test();
52 });
53
54 add_ocsp_test("ocsp-stapling-with-intermediate.example.com", Cr.NS_OK);
55 }

mercurial