OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <utility> | 5 #include <utility> |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 | 8 |
9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
10 #include <windows.h> | 10 #include <windows.h> |
(...skipping 9206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9217 | 9217 |
9218 void SetUp() override { | 9218 void SetUp() override { |
9219 SetupContext(&context_); | 9219 SetupContext(&context_); |
9220 context_.Init(); | 9220 context_.Init(); |
9221 | 9221 |
9222 scoped_refptr<X509Certificate> root_cert = | 9222 scoped_refptr<X509Certificate> root_cert = |
9223 ImportCertFromFile(GetTestCertsDirectory(), "ocsp-test-root.pem"); | 9223 ImportCertFromFile(GetTestCertsDirectory(), "ocsp-test-root.pem"); |
9224 CHECK_NE(static_cast<X509Certificate*>(NULL), root_cert.get()); | 9224 CHECK_NE(static_cast<X509Certificate*>(NULL), root_cert.get()); |
9225 test_root_.reset(new ScopedTestRoot(root_cert.get())); | 9225 test_root_.reset(new ScopedTestRoot(root_cert.get())); |
9226 | 9226 |
9227 #if defined(USE_NSS_VERIFIER) | 9227 #if defined(USE_NSS_CERTS) |
9228 SetURLRequestContextForNSSHttpIO(&context_); | 9228 SetURLRequestContextForNSSHttpIO(&context_); |
9229 EnsureNSSHttpIOInit(); | 9229 EnsureNSSHttpIOInit(); |
9230 #endif | 9230 #endif |
9231 } | 9231 } |
9232 | 9232 |
9233 void DoConnection(const SpawnedTestServer::SSLOptions& ssl_options, | 9233 void DoConnection(const SpawnedTestServer::SSLOptions& ssl_options, |
9234 CertStatus* out_cert_status) { | 9234 CertStatus* out_cert_status) { |
9235 // We always overwrite out_cert_status. | 9235 // We always overwrite out_cert_status. |
9236 *out_cert_status = 0; | 9236 *out_cert_status = 0; |
9237 SpawnedTestServer test_server( | 9237 SpawnedTestServer test_server( |
9238 SpawnedTestServer::TYPE_HTTPS, | 9238 SpawnedTestServer::TYPE_HTTPS, |
9239 ssl_options, | 9239 ssl_options, |
9240 base::FilePath(FILE_PATH_LITERAL("net/data/ssl"))); | 9240 base::FilePath(FILE_PATH_LITERAL("net/data/ssl"))); |
9241 ASSERT_TRUE(test_server.Start()); | 9241 ASSERT_TRUE(test_server.Start()); |
9242 | 9242 |
9243 TestDelegate d; | 9243 TestDelegate d; |
9244 d.set_allow_certificate_errors(true); | 9244 d.set_allow_certificate_errors(true); |
9245 scoped_ptr<URLRequest> r( | 9245 scoped_ptr<URLRequest> r( |
9246 context_.CreateRequest(test_server.GetURL("/"), DEFAULT_PRIORITY, &d)); | 9246 context_.CreateRequest(test_server.GetURL("/"), DEFAULT_PRIORITY, &d)); |
9247 r->Start(); | 9247 r->Start(); |
9248 | 9248 |
9249 base::RunLoop().Run(); | 9249 base::RunLoop().Run(); |
9250 | 9250 |
9251 EXPECT_EQ(1, d.response_started_count()); | 9251 EXPECT_EQ(1, d.response_started_count()); |
9252 *out_cert_status = r->ssl_info().cert_status; | 9252 *out_cert_status = r->ssl_info().cert_status; |
9253 } | 9253 } |
9254 | 9254 |
9255 ~HTTPSOCSPTest() override { | 9255 ~HTTPSOCSPTest() override { |
9256 #if defined(USE_NSS_VERIFIER) | 9256 #if defined(USE_NSS_CERTS) |
9257 ShutdownNSSHttpIO(); | 9257 ShutdownNSSHttpIO(); |
9258 #endif | 9258 #endif |
9259 } | 9259 } |
9260 | 9260 |
9261 protected: | 9261 protected: |
9262 // SetupContext configures the URLRequestContext that will be used for making | 9262 // SetupContext configures the URLRequestContext that will be used for making |
9263 // connetions to testserver. This can be overridden in test subclasses for | 9263 // connetions to testserver. This can be overridden in test subclasses for |
9264 // different behaviour. | 9264 // different behaviour. |
9265 virtual void SetupContext(URLRequestContext* context) { | 9265 virtual void SetupContext(URLRequestContext* context) { |
9266 context->set_ssl_config_service(new TestSSLConfigService( | 9266 context->set_ssl_config_service(new TestSSLConfigService( |
(...skipping 19 matching lines...) Expand all Loading... |
9286 } | 9286 } |
9287 | 9287 |
9288 // SystemSupportsHardFailRevocationChecking returns true iff the current | 9288 // SystemSupportsHardFailRevocationChecking returns true iff the current |
9289 // operating system supports revocation checking and can distinguish between | 9289 // operating system supports revocation checking and can distinguish between |
9290 // situations where a given certificate lacks any revocation information (eg: | 9290 // situations where a given certificate lacks any revocation information (eg: |
9291 // no CRLDistributionPoints and no OCSP Responder AuthorityInfoAccess) and when | 9291 // no CRLDistributionPoints and no OCSP Responder AuthorityInfoAccess) and when |
9292 // revocation information cannot be obtained (eg: the CRL was unreachable). | 9292 // revocation information cannot be obtained (eg: the CRL was unreachable). |
9293 // If it does not, then tests which rely on 'hard fail' behaviour should be | 9293 // If it does not, then tests which rely on 'hard fail' behaviour should be |
9294 // skipped. | 9294 // skipped. |
9295 static bool SystemSupportsHardFailRevocationChecking() { | 9295 static bool SystemSupportsHardFailRevocationChecking() { |
9296 #if defined(OS_WIN) || defined(USE_NSS_VERIFIER) | 9296 #if defined(OS_WIN) || defined(USE_NSS_CERTS) |
9297 return true; | 9297 return true; |
9298 #else | 9298 #else |
9299 return false; | 9299 return false; |
9300 #endif | 9300 #endif |
9301 } | 9301 } |
9302 | 9302 |
9303 // SystemUsesChromiumEVMetadata returns true iff the current operating system | 9303 // SystemUsesChromiumEVMetadata returns true iff the current operating system |
9304 // uses Chromium's EV metadata (i.e. EVRootCAMetadata). If it does not, then | 9304 // uses Chromium's EV metadata (i.e. EVRootCAMetadata). If it does not, then |
9305 // several tests are effected because our testing EV certificate won't be | 9305 // several tests are effected because our testing EV certificate won't be |
9306 // recognised as EV. | 9306 // recognised as EV. |
(...skipping 18 matching lines...) Expand all Loading... |
9325 return base::win::GetVersion() >= base::win::VERSION_VISTA; | 9325 return base::win::GetVersion() >= base::win::VERSION_VISTA; |
9326 #elif defined(OS_ANDROID) | 9326 #elif defined(OS_ANDROID) |
9327 // TODO(jnd): http://crbug.com/117478 - EV verification is not yet supported. | 9327 // TODO(jnd): http://crbug.com/117478 - EV verification is not yet supported. |
9328 return false; | 9328 return false; |
9329 #else | 9329 #else |
9330 return true; | 9330 return true; |
9331 #endif | 9331 #endif |
9332 } | 9332 } |
9333 | 9333 |
9334 static bool SystemSupportsOCSPStapling() { | 9334 static bool SystemSupportsOCSPStapling() { |
9335 #if defined(USE_NSS_VERIFIER) | 9335 #if defined(USE_NSS_CERTS) |
9336 return true; | 9336 return true; |
9337 #elif defined(OS_WIN) | 9337 #elif defined(OS_WIN) |
9338 return base::win::GetVersion() >= base::win::VERSION_VISTA; | 9338 return base::win::GetVersion() >= base::win::VERSION_VISTA; |
9339 #else | 9339 #else |
9340 return false; | 9340 return false; |
9341 #endif | 9341 #endif |
9342 } | 9342 } |
9343 | 9343 |
9344 TEST_F(HTTPSOCSPTest, Valid) { | 9344 TEST_F(HTTPSOCSPTest, Valid) { |
9345 if (!SystemSupportsOCSP()) { | 9345 if (!SystemSupportsOCSP()) { |
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10105 AddTestInterceptor()->set_main_intercept_job(std::move(job)); | 10105 AddTestInterceptor()->set_main_intercept_job(std::move(job)); |
10106 | 10106 |
10107 req->Start(); | 10107 req->Start(); |
10108 req->Cancel(); | 10108 req->Cancel(); |
10109 base::RunLoop().RunUntilIdle(); | 10109 base::RunLoop().RunUntilIdle(); |
10110 EXPECT_EQ(URLRequestStatus::CANCELED, req->status().status()); | 10110 EXPECT_EQ(URLRequestStatus::CANCELED, req->status().status()); |
10111 EXPECT_EQ(0, d.received_redirect_count()); | 10111 EXPECT_EQ(0, d.received_redirect_count()); |
10112 } | 10112 } |
10113 | 10113 |
10114 } // namespace net | 10114 } // namespace net |
OLD | NEW |