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

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

Issue 1082123003: Rename USE_NSS to USE_NSS_CERTS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@use-nss-certs
Patch Set: rebase Created 5 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
« no previous file with comments | « net/url_request/url_fetcher_impl_unittest.cc ('k') | remoting/host/token_validator_base.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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 8244 matching lines...) Expand 10 before | Expand all | Expand 10 after
8255 8255
8256 void SetUp() override { 8256 void SetUp() override {
8257 SetupContext(&context_); 8257 SetupContext(&context_);
8258 context_.Init(); 8258 context_.Init();
8259 8259
8260 scoped_refptr<X509Certificate> root_cert = 8260 scoped_refptr<X509Certificate> root_cert =
8261 ImportCertFromFile(GetTestCertsDirectory(), "ocsp-test-root.pem"); 8261 ImportCertFromFile(GetTestCertsDirectory(), "ocsp-test-root.pem");
8262 CHECK_NE(static_cast<X509Certificate*>(NULL), root_cert.get()); 8262 CHECK_NE(static_cast<X509Certificate*>(NULL), root_cert.get());
8263 test_root_.reset(new ScopedTestRoot(root_cert.get())); 8263 test_root_.reset(new ScopedTestRoot(root_cert.get()));
8264 8264
8265 #if defined(USE_NSS) || defined(OS_IOS) 8265 #if defined(USE_NSS_CERTS) || defined(OS_IOS)
8266 SetURLRequestContextForNSSHttpIO(&context_); 8266 SetURLRequestContextForNSSHttpIO(&context_);
8267 EnsureNSSHttpIOInit(); 8267 EnsureNSSHttpIOInit();
8268 #endif 8268 #endif
8269 } 8269 }
8270 8270
8271 void DoConnection(const SpawnedTestServer::SSLOptions& ssl_options, 8271 void DoConnection(const SpawnedTestServer::SSLOptions& ssl_options,
8272 CertStatus* out_cert_status) { 8272 CertStatus* out_cert_status) {
8273 // We always overwrite out_cert_status. 8273 // We always overwrite out_cert_status.
8274 *out_cert_status = 0; 8274 *out_cert_status = 0;
8275 SpawnedTestServer test_server( 8275 SpawnedTestServer test_server(
8276 SpawnedTestServer::TYPE_HTTPS, 8276 SpawnedTestServer::TYPE_HTTPS,
8277 ssl_options, 8277 ssl_options,
8278 base::FilePath(FILE_PATH_LITERAL("net/data/ssl"))); 8278 base::FilePath(FILE_PATH_LITERAL("net/data/ssl")));
8279 ASSERT_TRUE(test_server.Start()); 8279 ASSERT_TRUE(test_server.Start());
8280 8280
8281 TestDelegate d; 8281 TestDelegate d;
8282 d.set_allow_certificate_errors(true); 8282 d.set_allow_certificate_errors(true);
8283 scoped_ptr<URLRequest> r(context_.CreateRequest( 8283 scoped_ptr<URLRequest> r(context_.CreateRequest(
8284 test_server.GetURL(std::string()), DEFAULT_PRIORITY, &d)); 8284 test_server.GetURL(std::string()), DEFAULT_PRIORITY, &d));
8285 r->Start(); 8285 r->Start();
8286 8286
8287 base::RunLoop().Run(); 8287 base::RunLoop().Run();
8288 8288
8289 EXPECT_EQ(1, d.response_started_count()); 8289 EXPECT_EQ(1, d.response_started_count());
8290 *out_cert_status = r->ssl_info().cert_status; 8290 *out_cert_status = r->ssl_info().cert_status;
8291 } 8291 }
8292 8292
8293 ~HTTPSOCSPTest() override { 8293 ~HTTPSOCSPTest() override {
8294 #if defined(USE_NSS) || defined(OS_IOS) 8294 #if defined(USE_NSS_CERTS) || defined(OS_IOS)
8295 ShutdownNSSHttpIO(); 8295 ShutdownNSSHttpIO();
8296 #endif 8296 #endif
8297 } 8297 }
8298 8298
8299 protected: 8299 protected:
8300 // SetupContext configures the URLRequestContext that will be used for making 8300 // SetupContext configures the URLRequestContext that will be used for making
8301 // connetions to testserver. This can be overridden in test subclasses for 8301 // connetions to testserver. This can be overridden in test subclasses for
8302 // different behaviour. 8302 // different behaviour.
8303 virtual void SetupContext(URLRequestContext* context) { 8303 virtual void SetupContext(URLRequestContext* context) {
8304 context->set_ssl_config_service( 8304 context->set_ssl_config_service(
(...skipping 19 matching lines...) Expand all
8324 } 8324 }
8325 8325
8326 // SystemSupportsHardFailRevocationChecking returns true iff the current 8326 // SystemSupportsHardFailRevocationChecking returns true iff the current
8327 // operating system supports revocation checking and can distinguish between 8327 // operating system supports revocation checking and can distinguish between
8328 // situations where a given certificate lacks any revocation information (eg: 8328 // situations where a given certificate lacks any revocation information (eg:
8329 // no CRLDistributionPoints and no OCSP Responder AuthorityInfoAccess) and when 8329 // no CRLDistributionPoints and no OCSP Responder AuthorityInfoAccess) and when
8330 // revocation information cannot be obtained (eg: the CRL was unreachable). 8330 // revocation information cannot be obtained (eg: the CRL was unreachable).
8331 // If it does not, then tests which rely on 'hard fail' behaviour should be 8331 // If it does not, then tests which rely on 'hard fail' behaviour should be
8332 // skipped. 8332 // skipped.
8333 static bool SystemSupportsHardFailRevocationChecking() { 8333 static bool SystemSupportsHardFailRevocationChecking() {
8334 #if defined(OS_WIN) || defined(USE_NSS) || defined(OS_IOS) 8334 #if defined(OS_WIN) || defined(USE_NSS_CERTS) || defined(OS_IOS)
8335 return true; 8335 return true;
8336 #else 8336 #else
8337 return false; 8337 return false;
8338 #endif 8338 #endif
8339 } 8339 }
8340 8340
8341 // SystemUsesChromiumEVMetadata returns true iff the current operating system 8341 // SystemUsesChromiumEVMetadata returns true iff the current operating system
8342 // uses Chromium's EV metadata (i.e. EVRootCAMetadata). If it does not, then 8342 // uses Chromium's EV metadata (i.e. EVRootCAMetadata). If it does not, then
8343 // several tests are effected because our testing EV certificate won't be 8343 // several tests are effected because our testing EV certificate won't be
8344 // recognised as EV. 8344 // recognised as EV.
(...skipping 18 matching lines...) Expand all
8363 return base::win::GetVersion() >= base::win::VERSION_VISTA; 8363 return base::win::GetVersion() >= base::win::VERSION_VISTA;
8364 #elif defined(OS_ANDROID) 8364 #elif defined(OS_ANDROID)
8365 // TODO(jnd): http://crbug.com/117478 - EV verification is not yet supported. 8365 // TODO(jnd): http://crbug.com/117478 - EV verification is not yet supported.
8366 return false; 8366 return false;
8367 #else 8367 #else
8368 return true; 8368 return true;
8369 #endif 8369 #endif
8370 } 8370 }
8371 8371
8372 static bool SystemSupportsOCSPStapling() { 8372 static bool SystemSupportsOCSPStapling() {
8373 #if defined(USE_NSS) 8373 #if defined(USE_NSS_CERTS)
8374 return true; 8374 return true;
8375 #elif defined(OS_WIN) 8375 #elif defined(OS_WIN)
8376 return base::win::GetVersion() >= base::win::VERSION_VISTA; 8376 return base::win::GetVersion() >= base::win::VERSION_VISTA;
8377 #else 8377 #else
8378 return false; 8378 return false;
8379 #endif 8379 #endif
8380 } 8380 }
8381 8381
8382 TEST_F(HTTPSOCSPTest, Valid) { 8382 TEST_F(HTTPSOCSPTest, Valid) {
8383 if (!SystemSupportsOCSP()) { 8383 if (!SystemSupportsOCSP()) {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
8460 8460
8461 EXPECT_EQ(0u, cert_status & CERT_STATUS_ALL_ERRORS); 8461 EXPECT_EQ(0u, cert_status & CERT_STATUS_ALL_ERRORS);
8462 8462
8463 EXPECT_EQ(SystemUsesChromiumEVMetadata(), 8463 EXPECT_EQ(SystemUsesChromiumEVMetadata(),
8464 static_cast<bool>(cert_status & CERT_STATUS_IS_EV)); 8464 static_cast<bool>(cert_status & CERT_STATUS_IS_EV));
8465 8465
8466 EXPECT_TRUE(cert_status & CERT_STATUS_REV_CHECKING_ENABLED); 8466 EXPECT_TRUE(cert_status & CERT_STATUS_REV_CHECKING_ENABLED);
8467 } 8467 }
8468 8468
8469 // Disabled on NSS ports. See https://crbug.com/431716. 8469 // Disabled on NSS ports. See https://crbug.com/431716.
8470 #if defined(USE_NSS) 8470 #if defined(USE_NSS_CERTS)
8471 #define MAYBE_RevokedStapled DISABLED_RevokedStapled 8471 #define MAYBE_RevokedStapled DISABLED_RevokedStapled
8472 #else 8472 #else
8473 #define MAYBE_RevokedStapled RevokedStapled 8473 #define MAYBE_RevokedStapled RevokedStapled
8474 #endif 8474 #endif
8475 TEST_F(HTTPSOCSPTest, MAYBE_RevokedStapled) { 8475 TEST_F(HTTPSOCSPTest, MAYBE_RevokedStapled) {
8476 if (!SystemSupportsOCSPStapling()) { 8476 if (!SystemSupportsOCSPStapling()) {
8477 LOG(WARNING) 8477 LOG(WARNING)
8478 << "Skipping test because system doesn't support OCSP stapling"; 8478 << "Skipping test because system doesn't support OCSP stapling";
8479 return; 8479 return;
8480 } 8480 }
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
9113 9113
9114 EXPECT_FALSE(r->is_pending()); 9114 EXPECT_FALSE(r->is_pending());
9115 EXPECT_EQ(1, d->response_started_count()); 9115 EXPECT_EQ(1, d->response_started_count());
9116 EXPECT_FALSE(d->received_data_before_response()); 9116 EXPECT_FALSE(d->received_data_before_response());
9117 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); 9117 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size));
9118 } 9118 }
9119 } 9119 }
9120 #endif // !defined(DISABLE_FTP_SUPPORT) 9120 #endif // !defined(DISABLE_FTP_SUPPORT)
9121 9121
9122 } // namespace net 9122 } // namespace net
OLDNEW
« no previous file with comments | « net/url_request/url_fetcher_impl_unittest.cc ('k') | remoting/host/token_validator_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698