1 // -*- indent-tabs-mode: nil; js-indent-level: 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/.
8 // In which we connect to a host and encounter OCSP responses with the
9 // Cache-Control header set, which normally Necko would cache. This test
10 // ensures that these responses aren't cached. PSM has its own OCSP cache, so
11 // Necko shouldn't also be caching them.
13 do_get_profile(); // must be called before getting nsIX509CertDB
15 const SERVER_PORT = 8888;
17 function add_flush_cache() {
19 // This appears to either fire multiple times or fire once for every
20 // observer that has ever been passed to flush. To prevent multiple calls to
21 // run_next_test, keep track of if this observer has already called it.
31 Services.cache2.QueryInterface(Ci.nsICacheTesting).flush(observer);
35 function add_ocsp_necko_cache_test(loadContext) {
36 // Pre-testcase cleanup/setup.
38 Services.cache2.clear();
47 responder = startOCSPResponder(
55 [["Cache-Control", "max-age=1000"]]
60 // Prepare a connection that will cause an OCSP request.
62 "ocsp-stapling-none.example.com",
67 loadContext.originAttributes
72 // Traverse the cache and ensure the response was not cached.
74 let foundEntry = false;
76 onCacheStorageInfo() {},
77 onCacheEntryInfo(aURI) {
80 "http://localhost:8888/",
81 "expected OCSP request URI should match"
85 onCacheEntryVisitCompleted() {
86 Assert.ok(!foundEntry, "should not find a cached entry");
89 QueryInterface: ChromeUtils.generateQI(["nsICacheStorageVisitor"]),
91 Services.cache2.asyncVisitAllStorages(visitor, true);
94 // Clean up (stop the responder).
96 responder.stop(run_next_test);
100 function run_test() {
101 Services.prefs.setIntPref("security.OCSP.enabled", 1);
102 add_tls_server_setup("OCSPStaplingServer", "ocsp_certs");
103 add_ocsp_necko_cache_test(Services.loadContextInfo.private);
104 add_ocsp_necko_cache_test(Services.loadContextInfo.default);