Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(240)

Side by Side Diff: net/url_request/url_request_unittest.cc

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

Powered by Google App Engine
This is Rietveld 408576698