| 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 9116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9127 | 9127 |
| 9128 void SetUp() override { | 9128 void SetUp() override { |
| 9129 SetupContext(&context_); | 9129 SetupContext(&context_); |
| 9130 context_.Init(); | 9130 context_.Init(); |
| 9131 | 9131 |
| 9132 scoped_refptr<X509Certificate> root_cert = | 9132 scoped_refptr<X509Certificate> root_cert = |
| 9133 ImportCertFromFile(GetTestCertsDirectory(), "ocsp-test-root.pem"); | 9133 ImportCertFromFile(GetTestCertsDirectory(), "ocsp-test-root.pem"); |
| 9134 CHECK_NE(static_cast<X509Certificate*>(NULL), root_cert.get()); | 9134 CHECK_NE(static_cast<X509Certificate*>(NULL), root_cert.get()); |
| 9135 test_root_.reset(new ScopedTestRoot(root_cert.get())); | 9135 test_root_.reset(new ScopedTestRoot(root_cert.get())); |
| 9136 | 9136 |
| 9137 #if defined(USE_NSS_CERTS) || defined(OS_IOS) | 9137 #if defined(USE_NSS_VERIFIER) |
| 9138 SetURLRequestContextForNSSHttpIO(&context_); | 9138 SetURLRequestContextForNSSHttpIO(&context_); |
| 9139 EnsureNSSHttpIOInit(); | 9139 EnsureNSSHttpIOInit(); |
| 9140 #endif | 9140 #endif |
| 9141 } | 9141 } |
| 9142 | 9142 |
| 9143 void DoConnection(const SpawnedTestServer::SSLOptions& ssl_options, | 9143 void DoConnection(const SpawnedTestServer::SSLOptions& ssl_options, |
| 9144 CertStatus* out_cert_status) { | 9144 CertStatus* out_cert_status) { |
| 9145 // We always overwrite out_cert_status. | 9145 // We always overwrite out_cert_status. |
| 9146 *out_cert_status = 0; | 9146 *out_cert_status = 0; |
| 9147 SpawnedTestServer test_server( | 9147 SpawnedTestServer test_server( |
| 9148 SpawnedTestServer::TYPE_HTTPS, | 9148 SpawnedTestServer::TYPE_HTTPS, |
| 9149 ssl_options, | 9149 ssl_options, |
| 9150 base::FilePath(FILE_PATH_LITERAL("net/data/ssl"))); | 9150 base::FilePath(FILE_PATH_LITERAL("net/data/ssl"))); |
| 9151 ASSERT_TRUE(test_server.Start()); | 9151 ASSERT_TRUE(test_server.Start()); |
| 9152 | 9152 |
| 9153 TestDelegate d; | 9153 TestDelegate d; |
| 9154 d.set_allow_certificate_errors(true); | 9154 d.set_allow_certificate_errors(true); |
| 9155 scoped_ptr<URLRequest> r( | 9155 scoped_ptr<URLRequest> r( |
| 9156 context_.CreateRequest(test_server.GetURL("/"), DEFAULT_PRIORITY, &d)); | 9156 context_.CreateRequest(test_server.GetURL("/"), DEFAULT_PRIORITY, &d)); |
| 9157 r->Start(); | 9157 r->Start(); |
| 9158 | 9158 |
| 9159 base::RunLoop().Run(); | 9159 base::RunLoop().Run(); |
| 9160 | 9160 |
| 9161 EXPECT_EQ(1, d.response_started_count()); | 9161 EXPECT_EQ(1, d.response_started_count()); |
| 9162 *out_cert_status = r->ssl_info().cert_status; | 9162 *out_cert_status = r->ssl_info().cert_status; |
| 9163 } | 9163 } |
| 9164 | 9164 |
| 9165 ~HTTPSOCSPTest() override { | 9165 ~HTTPSOCSPTest() override { |
| 9166 #if defined(USE_NSS_CERTS) || defined(OS_IOS) | 9166 #if defined(USE_NSS_VERIFIER) |
| 9167 ShutdownNSSHttpIO(); | 9167 ShutdownNSSHttpIO(); |
| 9168 #endif | 9168 #endif |
| 9169 } | 9169 } |
| 9170 | 9170 |
| 9171 protected: | 9171 protected: |
| 9172 // SetupContext configures the URLRequestContext that will be used for making | 9172 // SetupContext configures the URLRequestContext that will be used for making |
| 9173 // connetions to testserver. This can be overridden in test subclasses for | 9173 // connetions to testserver. This can be overridden in test subclasses for |
| 9174 // different behaviour. | 9174 // different behaviour. |
| 9175 virtual void SetupContext(URLRequestContext* context) { | 9175 virtual void SetupContext(URLRequestContext* context) { |
| 9176 context->set_ssl_config_service(new TestSSLConfigService( | 9176 context->set_ssl_config_service(new TestSSLConfigService( |
| (...skipping 19 matching lines...) Expand all Loading... |
| 9196 } | 9196 } |
| 9197 | 9197 |
| 9198 // SystemSupportsHardFailRevocationChecking returns true iff the current | 9198 // SystemSupportsHardFailRevocationChecking returns true iff the current |
| 9199 // operating system supports revocation checking and can distinguish between | 9199 // operating system supports revocation checking and can distinguish between |
| 9200 // situations where a given certificate lacks any revocation information (eg: | 9200 // situations where a given certificate lacks any revocation information (eg: |
| 9201 // no CRLDistributionPoints and no OCSP Responder AuthorityInfoAccess) and when | 9201 // no CRLDistributionPoints and no OCSP Responder AuthorityInfoAccess) and when |
| 9202 // revocation information cannot be obtained (eg: the CRL was unreachable). | 9202 // revocation information cannot be obtained (eg: the CRL was unreachable). |
| 9203 // If it does not, then tests which rely on 'hard fail' behaviour should be | 9203 // If it does not, then tests which rely on 'hard fail' behaviour should be |
| 9204 // skipped. | 9204 // skipped. |
| 9205 static bool SystemSupportsHardFailRevocationChecking() { | 9205 static bool SystemSupportsHardFailRevocationChecking() { |
| 9206 #if defined(OS_WIN) || defined(USE_NSS_CERTS) || defined(OS_IOS) | 9206 #if defined(OS_WIN) || defined(USE_NSS_VERIFIER) |
| 9207 return true; | 9207 return true; |
| 9208 #else | 9208 #else |
| 9209 return false; | 9209 return false; |
| 9210 #endif | 9210 #endif |
| 9211 } | 9211 } |
| 9212 | 9212 |
| 9213 // SystemUsesChromiumEVMetadata returns true iff the current operating system | 9213 // SystemUsesChromiumEVMetadata returns true iff the current operating system |
| 9214 // uses Chromium's EV metadata (i.e. EVRootCAMetadata). If it does not, then | 9214 // uses Chromium's EV metadata (i.e. EVRootCAMetadata). If it does not, then |
| 9215 // several tests are effected because our testing EV certificate won't be | 9215 // several tests are effected because our testing EV certificate won't be |
| 9216 // recognised as EV. | 9216 // recognised as EV. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 9235 return base::win::GetVersion() >= base::win::VERSION_VISTA; | 9235 return base::win::GetVersion() >= base::win::VERSION_VISTA; |
| 9236 #elif defined(OS_ANDROID) | 9236 #elif defined(OS_ANDROID) |
| 9237 // TODO(jnd): http://crbug.com/117478 - EV verification is not yet supported. | 9237 // TODO(jnd): http://crbug.com/117478 - EV verification is not yet supported. |
| 9238 return false; | 9238 return false; |
| 9239 #else | 9239 #else |
| 9240 return true; | 9240 return true; |
| 9241 #endif | 9241 #endif |
| 9242 } | 9242 } |
| 9243 | 9243 |
| 9244 static bool SystemSupportsOCSPStapling() { | 9244 static bool SystemSupportsOCSPStapling() { |
| 9245 #if defined(USE_NSS_CERTS) || defined(OS_IOS) | 9245 #if defined(USE_NSS_VERIFIER) |
| 9246 return true; | 9246 return true; |
| 9247 #elif defined(OS_WIN) | 9247 #elif defined(OS_WIN) |
| 9248 return base::win::GetVersion() >= base::win::VERSION_VISTA; | 9248 return base::win::GetVersion() >= base::win::VERSION_VISTA; |
| 9249 #else | 9249 #else |
| 9250 return false; | 9250 return false; |
| 9251 #endif | 9251 #endif |
| 9252 } | 9252 } |
| 9253 | 9253 |
| 9254 TEST_F(HTTPSOCSPTest, Valid) { | 9254 TEST_F(HTTPSOCSPTest, Valid) { |
| 9255 if (!SystemSupportsOCSP()) { | 9255 if (!SystemSupportsOCSP()) { |
| (...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10015 AddTestInterceptor()->set_main_intercept_job(std::move(job)); | 10015 AddTestInterceptor()->set_main_intercept_job(std::move(job)); |
| 10016 | 10016 |
| 10017 req->Start(); | 10017 req->Start(); |
| 10018 req->Cancel(); | 10018 req->Cancel(); |
| 10019 base::RunLoop().RunUntilIdle(); | 10019 base::RunLoop().RunUntilIdle(); |
| 10020 EXPECT_EQ(URLRequestStatus::CANCELED, req->status().status()); | 10020 EXPECT_EQ(URLRequestStatus::CANCELED, req->status().status()); |
| 10021 EXPECT_EQ(0, d.received_redirect_count()); | 10021 EXPECT_EQ(0, d.received_redirect_count()); |
| 10022 } | 10022 } |
| 10023 | 10023 |
| 10024 } // namespace net | 10024 } // namespace net |
| OLD | NEW |