| 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 <memory> | 5 #include <memory> |
| 6 #include <utility> | 6 #include <utility> |
| 7 | 7 |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 | 10 |
| (...skipping 9217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9228 | 9228 |
| 9229 void SetUp() override { | 9229 void SetUp() override { |
| 9230 SetupContext(&context_); | 9230 SetupContext(&context_); |
| 9231 context_.Init(); | 9231 context_.Init(); |
| 9232 | 9232 |
| 9233 scoped_refptr<X509Certificate> root_cert = | 9233 scoped_refptr<X509Certificate> root_cert = |
| 9234 ImportCertFromFile(GetTestCertsDirectory(), "ocsp-test-root.pem"); | 9234 ImportCertFromFile(GetTestCertsDirectory(), "ocsp-test-root.pem"); |
| 9235 CHECK_NE(static_cast<X509Certificate*>(NULL), root_cert.get()); | 9235 CHECK_NE(static_cast<X509Certificate*>(NULL), root_cert.get()); |
| 9236 test_root_.reset(new ScopedTestRoot(root_cert.get())); | 9236 test_root_.reset(new ScopedTestRoot(root_cert.get())); |
| 9237 | 9237 |
| 9238 #if defined(USE_NSS_VERIFIER) | 9238 #if defined(USE_NSS_CERTS) |
| 9239 SetURLRequestContextForNSSHttpIO(&context_); | 9239 SetURLRequestContextForNSSHttpIO(&context_); |
| 9240 EnsureNSSHttpIOInit(); | 9240 EnsureNSSHttpIOInit(); |
| 9241 #endif | 9241 #endif |
| 9242 } | 9242 } |
| 9243 | 9243 |
| 9244 void DoConnection(const SpawnedTestServer::SSLOptions& ssl_options, | 9244 void DoConnection(const SpawnedTestServer::SSLOptions& ssl_options, |
| 9245 CertStatus* out_cert_status) { | 9245 CertStatus* out_cert_status) { |
| 9246 // We always overwrite out_cert_status. | 9246 // We always overwrite out_cert_status. |
| 9247 *out_cert_status = 0; | 9247 *out_cert_status = 0; |
| 9248 SpawnedTestServer test_server( | 9248 SpawnedTestServer test_server( |
| 9249 SpawnedTestServer::TYPE_HTTPS, | 9249 SpawnedTestServer::TYPE_HTTPS, |
| 9250 ssl_options, | 9250 ssl_options, |
| 9251 base::FilePath(FILE_PATH_LITERAL("net/data/ssl"))); | 9251 base::FilePath(FILE_PATH_LITERAL("net/data/ssl"))); |
| 9252 ASSERT_TRUE(test_server.Start()); | 9252 ASSERT_TRUE(test_server.Start()); |
| 9253 | 9253 |
| 9254 TestDelegate d; | 9254 TestDelegate d; |
| 9255 d.set_allow_certificate_errors(true); | 9255 d.set_allow_certificate_errors(true); |
| 9256 std::unique_ptr<URLRequest> r( | 9256 std::unique_ptr<URLRequest> r( |
| 9257 context_.CreateRequest(test_server.GetURL("/"), DEFAULT_PRIORITY, &d)); | 9257 context_.CreateRequest(test_server.GetURL("/"), DEFAULT_PRIORITY, &d)); |
| 9258 r->Start(); | 9258 r->Start(); |
| 9259 | 9259 |
| 9260 base::RunLoop().Run(); | 9260 base::RunLoop().Run(); |
| 9261 | 9261 |
| 9262 EXPECT_EQ(1, d.response_started_count()); | 9262 EXPECT_EQ(1, d.response_started_count()); |
| 9263 *out_cert_status = r->ssl_info().cert_status; | 9263 *out_cert_status = r->ssl_info().cert_status; |
| 9264 } | 9264 } |
| 9265 | 9265 |
| 9266 ~HTTPSOCSPTest() override { | 9266 ~HTTPSOCSPTest() override { |
| 9267 #if defined(USE_NSS_VERIFIER) | 9267 #if defined(USE_NSS_CERTS) |
| 9268 ShutdownNSSHttpIO(); | 9268 ShutdownNSSHttpIO(); |
| 9269 #endif | 9269 #endif |
| 9270 } | 9270 } |
| 9271 | 9271 |
| 9272 protected: | 9272 protected: |
| 9273 // SetupContext configures the URLRequestContext that will be used for making | 9273 // SetupContext configures the URLRequestContext that will be used for making |
| 9274 // connetions to testserver. This can be overridden in test subclasses for | 9274 // connetions to testserver. This can be overridden in test subclasses for |
| 9275 // different behaviour. | 9275 // different behaviour. |
| 9276 virtual void SetupContext(URLRequestContext* context) { | 9276 virtual void SetupContext(URLRequestContext* context) { |
| 9277 context->set_ssl_config_service(new TestSSLConfigService( | 9277 context->set_ssl_config_service(new TestSSLConfigService( |
| (...skipping 19 matching lines...) Expand all Loading... |
| 9297 } | 9297 } |
| 9298 | 9298 |
| 9299 // SystemSupportsHardFailRevocationChecking returns true iff the current | 9299 // SystemSupportsHardFailRevocationChecking returns true iff the current |
| 9300 // operating system supports revocation checking and can distinguish between | 9300 // operating system supports revocation checking and can distinguish between |
| 9301 // situations where a given certificate lacks any revocation information (eg: | 9301 // situations where a given certificate lacks any revocation information (eg: |
| 9302 // no CRLDistributionPoints and no OCSP Responder AuthorityInfoAccess) and when | 9302 // no CRLDistributionPoints and no OCSP Responder AuthorityInfoAccess) and when |
| 9303 // revocation information cannot be obtained (eg: the CRL was unreachable). | 9303 // revocation information cannot be obtained (eg: the CRL was unreachable). |
| 9304 // If it does not, then tests which rely on 'hard fail' behaviour should be | 9304 // If it does not, then tests which rely on 'hard fail' behaviour should be |
| 9305 // skipped. | 9305 // skipped. |
| 9306 static bool SystemSupportsHardFailRevocationChecking() { | 9306 static bool SystemSupportsHardFailRevocationChecking() { |
| 9307 #if defined(OS_WIN) || defined(USE_NSS_VERIFIER) | 9307 #if defined(OS_WIN) || defined(USE_NSS_CERTS) |
| 9308 return true; | 9308 return true; |
| 9309 #else | 9309 #else |
| 9310 return false; | 9310 return false; |
| 9311 #endif | 9311 #endif |
| 9312 } | 9312 } |
| 9313 | 9313 |
| 9314 // SystemUsesChromiumEVMetadata returns true iff the current operating system | 9314 // SystemUsesChromiumEVMetadata returns true iff the current operating system |
| 9315 // uses Chromium's EV metadata (i.e. EVRootCAMetadata). If it does not, then | 9315 // uses Chromium's EV metadata (i.e. EVRootCAMetadata). If it does not, then |
| 9316 // several tests are effected because our testing EV certificate won't be | 9316 // several tests are effected because our testing EV certificate won't be |
| 9317 // recognised as EV. | 9317 // recognised as EV. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 9336 return base::win::GetVersion() >= base::win::VERSION_VISTA; | 9336 return base::win::GetVersion() >= base::win::VERSION_VISTA; |
| 9337 #elif defined(OS_ANDROID) | 9337 #elif defined(OS_ANDROID) |
| 9338 // TODO(jnd): http://crbug.com/117478 - EV verification is not yet supported. | 9338 // TODO(jnd): http://crbug.com/117478 - EV verification is not yet supported. |
| 9339 return false; | 9339 return false; |
| 9340 #else | 9340 #else |
| 9341 return true; | 9341 return true; |
| 9342 #endif | 9342 #endif |
| 9343 } | 9343 } |
| 9344 | 9344 |
| 9345 static bool SystemSupportsOCSPStapling() { | 9345 static bool SystemSupportsOCSPStapling() { |
| 9346 #if defined(USE_NSS_VERIFIER) | 9346 #if defined(USE_NSS_CERTS) |
| 9347 return true; | 9347 return true; |
| 9348 #elif defined(OS_WIN) | 9348 #elif defined(OS_WIN) |
| 9349 return base::win::GetVersion() >= base::win::VERSION_VISTA; | 9349 return base::win::GetVersion() >= base::win::VERSION_VISTA; |
| 9350 #else | 9350 #else |
| 9351 return false; | 9351 return false; |
| 9352 #endif | 9352 #endif |
| 9353 } | 9353 } |
| 9354 | 9354 |
| 9355 TEST_F(HTTPSOCSPTest, Valid) { | 9355 TEST_F(HTTPSOCSPTest, Valid) { |
| 9356 if (!SystemSupportsOCSP()) { | 9356 if (!SystemSupportsOCSP()) { |
| (...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10116 AddTestInterceptor()->set_main_intercept_job(std::move(job)); | 10116 AddTestInterceptor()->set_main_intercept_job(std::move(job)); |
| 10117 | 10117 |
| 10118 req->Start(); | 10118 req->Start(); |
| 10119 req->Cancel(); | 10119 req->Cancel(); |
| 10120 base::RunLoop().RunUntilIdle(); | 10120 base::RunLoop().RunUntilIdle(); |
| 10121 EXPECT_EQ(URLRequestStatus::CANCELED, req->status().status()); | 10121 EXPECT_EQ(URLRequestStatus::CANCELED, req->status().status()); |
| 10122 EXPECT_EQ(0, d.received_redirect_count()); | 10122 EXPECT_EQ(0, d.received_redirect_count()); |
| 10123 } | 10123 } |
| 10124 | 10124 |
| 10125 } // namespace net | 10125 } // namespace net |
| OLD | NEW |