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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <shlobj.h> | 9 #include <shlobj.h> |
10 #endif | 10 #endif |
(...skipping 8240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8251 | 8251 |
8252 void SetUp() override { | 8252 void SetUp() override { |
8253 SetupContext(&context_); | 8253 SetupContext(&context_); |
8254 context_.Init(); | 8254 context_.Init(); |
8255 | 8255 |
8256 scoped_refptr<X509Certificate> root_cert = | 8256 scoped_refptr<X509Certificate> root_cert = |
8257 ImportCertFromFile(GetTestCertsDirectory(), "ocsp-test-root.pem"); | 8257 ImportCertFromFile(GetTestCertsDirectory(), "ocsp-test-root.pem"); |
8258 CHECK_NE(static_cast<X509Certificate*>(NULL), root_cert.get()); | 8258 CHECK_NE(static_cast<X509Certificate*>(NULL), root_cert.get()); |
8259 test_root_.reset(new ScopedTestRoot(root_cert.get())); | 8259 test_root_.reset(new ScopedTestRoot(root_cert.get())); |
8260 | 8260 |
8261 #if defined(USE_NSS) || defined(OS_IOS) | 8261 #if defined(USE_NSS_CERTS) || defined(OS_IOS) |
8262 SetURLRequestContextForNSSHttpIO(&context_); | 8262 SetURLRequestContextForNSSHttpIO(&context_); |
8263 EnsureNSSHttpIOInit(); | 8263 EnsureNSSHttpIOInit(); |
8264 #endif | 8264 #endif |
8265 } | 8265 } |
8266 | 8266 |
8267 void DoConnection(const SpawnedTestServer::SSLOptions& ssl_options, | 8267 void DoConnection(const SpawnedTestServer::SSLOptions& ssl_options, |
8268 CertStatus* out_cert_status) { | 8268 CertStatus* out_cert_status) { |
8269 // We always overwrite out_cert_status. | 8269 // We always overwrite out_cert_status. |
8270 *out_cert_status = 0; | 8270 *out_cert_status = 0; |
8271 SpawnedTestServer test_server( | 8271 SpawnedTestServer test_server( |
8272 SpawnedTestServer::TYPE_HTTPS, | 8272 SpawnedTestServer::TYPE_HTTPS, |
8273 ssl_options, | 8273 ssl_options, |
8274 base::FilePath(FILE_PATH_LITERAL("net/data/ssl"))); | 8274 base::FilePath(FILE_PATH_LITERAL("net/data/ssl"))); |
8275 ASSERT_TRUE(test_server.Start()); | 8275 ASSERT_TRUE(test_server.Start()); |
8276 | 8276 |
8277 TestDelegate d; | 8277 TestDelegate d; |
8278 d.set_allow_certificate_errors(true); | 8278 d.set_allow_certificate_errors(true); |
8279 scoped_ptr<URLRequest> r(context_.CreateRequest( | 8279 scoped_ptr<URLRequest> r(context_.CreateRequest( |
8280 test_server.GetURL(std::string()), DEFAULT_PRIORITY, &d)); | 8280 test_server.GetURL(std::string()), DEFAULT_PRIORITY, &d)); |
8281 r->Start(); | 8281 r->Start(); |
8282 | 8282 |
8283 base::RunLoop().Run(); | 8283 base::RunLoop().Run(); |
8284 | 8284 |
8285 EXPECT_EQ(1, d.response_started_count()); | 8285 EXPECT_EQ(1, d.response_started_count()); |
8286 *out_cert_status = r->ssl_info().cert_status; | 8286 *out_cert_status = r->ssl_info().cert_status; |
8287 } | 8287 } |
8288 | 8288 |
8289 ~HTTPSOCSPTest() override { | 8289 ~HTTPSOCSPTest() override { |
8290 #if defined(USE_NSS) || defined(OS_IOS) | 8290 #if defined(USE_NSS_CERTS) || defined(OS_IOS) |
8291 ShutdownNSSHttpIO(); | 8291 ShutdownNSSHttpIO(); |
8292 #endif | 8292 #endif |
8293 } | 8293 } |
8294 | 8294 |
8295 protected: | 8295 protected: |
8296 // SetupContext configures the URLRequestContext that will be used for making | 8296 // SetupContext configures the URLRequestContext that will be used for making |
8297 // connetions to testserver. This can be overridden in test subclasses for | 8297 // connetions to testserver. This can be overridden in test subclasses for |
8298 // different behaviour. | 8298 // different behaviour. |
8299 virtual void SetupContext(URLRequestContext* context) { | 8299 virtual void SetupContext(URLRequestContext* context) { |
8300 context->set_ssl_config_service( | 8300 context->set_ssl_config_service( |
(...skipping 19 matching lines...) Expand all Loading... |
8320 } | 8320 } |
8321 | 8321 |
8322 // SystemSupportsHardFailRevocationChecking returns true iff the current | 8322 // SystemSupportsHardFailRevocationChecking returns true iff the current |
8323 // operating system supports revocation checking and can distinguish between | 8323 // operating system supports revocation checking and can distinguish between |
8324 // situations where a given certificate lacks any revocation information (eg: | 8324 // situations where a given certificate lacks any revocation information (eg: |
8325 // no CRLDistributionPoints and no OCSP Responder AuthorityInfoAccess) and when | 8325 // no CRLDistributionPoints and no OCSP Responder AuthorityInfoAccess) and when |
8326 // revocation information cannot be obtained (eg: the CRL was unreachable). | 8326 // revocation information cannot be obtained (eg: the CRL was unreachable). |
8327 // If it does not, then tests which rely on 'hard fail' behaviour should be | 8327 // If it does not, then tests which rely on 'hard fail' behaviour should be |
8328 // skipped. | 8328 // skipped. |
8329 static bool SystemSupportsHardFailRevocationChecking() { | 8329 static bool SystemSupportsHardFailRevocationChecking() { |
8330 #if defined(OS_WIN) || defined(USE_NSS) || defined(OS_IOS) | 8330 #if defined(OS_WIN) || defined(USE_NSS_CERTS) || defined(OS_IOS) |
8331 return true; | 8331 return true; |
8332 #else | 8332 #else |
8333 return false; | 8333 return false; |
8334 #endif | 8334 #endif |
8335 } | 8335 } |
8336 | 8336 |
8337 // SystemUsesChromiumEVMetadata returns true iff the current operating system | 8337 // SystemUsesChromiumEVMetadata returns true iff the current operating system |
8338 // uses Chromium's EV metadata (i.e. EVRootCAMetadata). If it does not, then | 8338 // uses Chromium's EV metadata (i.e. EVRootCAMetadata). If it does not, then |
8339 // several tests are effected because our testing EV certificate won't be | 8339 // several tests are effected because our testing EV certificate won't be |
8340 // recognised as EV. | 8340 // recognised as EV. |
(...skipping 18 matching lines...) Expand all Loading... |
8359 return base::win::GetVersion() >= base::win::VERSION_VISTA; | 8359 return base::win::GetVersion() >= base::win::VERSION_VISTA; |
8360 #elif defined(OS_ANDROID) | 8360 #elif defined(OS_ANDROID) |
8361 // TODO(jnd): http://crbug.com/117478 - EV verification is not yet supported. | 8361 // TODO(jnd): http://crbug.com/117478 - EV verification is not yet supported. |
8362 return false; | 8362 return false; |
8363 #else | 8363 #else |
8364 return true; | 8364 return true; |
8365 #endif | 8365 #endif |
8366 } | 8366 } |
8367 | 8367 |
8368 static bool SystemSupportsOCSPStapling() { | 8368 static bool SystemSupportsOCSPStapling() { |
8369 #if defined(USE_NSS) | 8369 #if defined(USE_NSS_CERTS) |
8370 return true; | 8370 return true; |
8371 #elif defined(OS_WIN) | 8371 #elif defined(OS_WIN) |
8372 return base::win::GetVersion() >= base::win::VERSION_VISTA; | 8372 return base::win::GetVersion() >= base::win::VERSION_VISTA; |
8373 #else | 8373 #else |
8374 return false; | 8374 return false; |
8375 #endif | 8375 #endif |
8376 } | 8376 } |
8377 | 8377 |
8378 TEST_F(HTTPSOCSPTest, Valid) { | 8378 TEST_F(HTTPSOCSPTest, Valid) { |
8379 if (!SystemSupportsOCSP()) { | 8379 if (!SystemSupportsOCSP()) { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8456 | 8456 |
8457 EXPECT_EQ(0u, cert_status & CERT_STATUS_ALL_ERRORS); | 8457 EXPECT_EQ(0u, cert_status & CERT_STATUS_ALL_ERRORS); |
8458 | 8458 |
8459 EXPECT_EQ(SystemUsesChromiumEVMetadata(), | 8459 EXPECT_EQ(SystemUsesChromiumEVMetadata(), |
8460 static_cast<bool>(cert_status & CERT_STATUS_IS_EV)); | 8460 static_cast<bool>(cert_status & CERT_STATUS_IS_EV)); |
8461 | 8461 |
8462 EXPECT_TRUE(cert_status & CERT_STATUS_REV_CHECKING_ENABLED); | 8462 EXPECT_TRUE(cert_status & CERT_STATUS_REV_CHECKING_ENABLED); |
8463 } | 8463 } |
8464 | 8464 |
8465 // Disabled on NSS ports. See https://crbug.com/431716. | 8465 // Disabled on NSS ports. See https://crbug.com/431716. |
8466 #if defined(USE_NSS) | 8466 #if defined(USE_NSS_CERTS) |
8467 #define MAYBE_RevokedStapled DISABLED_RevokedStapled | 8467 #define MAYBE_RevokedStapled DISABLED_RevokedStapled |
8468 #else | 8468 #else |
8469 #define MAYBE_RevokedStapled RevokedStapled | 8469 #define MAYBE_RevokedStapled RevokedStapled |
8470 #endif | 8470 #endif |
8471 TEST_F(HTTPSOCSPTest, MAYBE_RevokedStapled) { | 8471 TEST_F(HTTPSOCSPTest, MAYBE_RevokedStapled) { |
8472 if (!SystemSupportsOCSPStapling()) { | 8472 if (!SystemSupportsOCSPStapling()) { |
8473 LOG(WARNING) | 8473 LOG(WARNING) |
8474 << "Skipping test because system doesn't support OCSP stapling"; | 8474 << "Skipping test because system doesn't support OCSP stapling"; |
8475 return; | 8475 return; |
8476 } | 8476 } |
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9109 | 9109 |
9110 EXPECT_FALSE(r->is_pending()); | 9110 EXPECT_FALSE(r->is_pending()); |
9111 EXPECT_EQ(1, d->response_started_count()); | 9111 EXPECT_EQ(1, d->response_started_count()); |
9112 EXPECT_FALSE(d->received_data_before_response()); | 9112 EXPECT_FALSE(d->received_data_before_response()); |
9113 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); | 9113 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); |
9114 } | 9114 } |
9115 } | 9115 } |
9116 #endif // !defined(DISABLE_FTP_SUPPORT) | 9116 #endif // !defined(DISABLE_FTP_SUPPORT) |
9117 | 9117 |
9118 } // namespace net | 9118 } // namespace net |
OLD | NEW |