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

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

Issue 2388393002: Add unittests of HTTPS loading that requires AIA fetching. (Closed)
Patch Set: rebase Created 4 years 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/tools/testserver/testserver.py ('k') | no next file » | 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 <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 "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 9222 matching lines...) Expand 10 before | Expand all | Expand 10 after
9233 // insert xyz 9233 // insert xyz
9234 9234
9235 EXPECT_EQ(1, d.response_started_count()); 9235 EXPECT_EQ(1, d.response_started_count());
9236 AssertTwoDistinctSessionsInserted(d.data_received()); 9236 AssertTwoDistinctSessionsInserted(d.data_received());
9237 } 9237 }
9238 } 9238 }
9239 9239
9240 // This the fingerprint of the "Testing CA" certificate used by the testserver. 9240 // This the fingerprint of the "Testing CA" certificate used by the testserver.
9241 // See net/data/ssl/certificates/ocsp-test-root.pem. 9241 // See net/data/ssl/certificates/ocsp-test-root.pem.
9242 static const SHA1HashValue kOCSPTestCertFingerprint = {{ 9242 static const SHA1HashValue kOCSPTestCertFingerprint = {{
9243 0xa7, 0xea, 0x4b, 0x0d, 0x13, 0xc1, 0x63, 0xbf, 0xb8, 0x4e, 9243 0x80, 0x37, 0xe7, 0xee, 0x12, 0x19, 0xeb, 0x10, 0x79, 0x36,
9244 0x9a, 0xaf, 0x33, 0x05, 0xb0, 0x8f, 0x9c, 0xbe, 0x23, 0xe9, 9244 0x00, 0x48, 0x57, 0x5a, 0xa6, 0x1e, 0x2b, 0x24, 0x1a, 0xd7,
9245 }}; 9245 }};
9246 9246
9247 // This is the SHA256, SPKI hash of the "Testing CA" certificate used by the 9247 // This is the SHA256, SPKI hash of the "Testing CA" certificate used by the
9248 // testserver. 9248 // testserver.
9249 static const SHA256HashValue kOCSPTestCertSPKI = { { 9249 static const SHA256HashValue kOCSPTestCertSPKI = {{
9250 0xee, 0xe6, 0x51, 0x2d, 0x4c, 0xfa, 0xf7, 0x3e, 9250 0x05, 0xa8, 0xf6, 0xfd, 0x8e, 0x10, 0xfe, 0x92, 0x2f, 0x22, 0x75,
9251 0x6c, 0xd8, 0xca, 0x67, 0xed, 0xb5, 0x5d, 0x49, 9251 0x46, 0x40, 0xf4, 0xc4, 0x57, 0x06, 0x0d, 0x95, 0xfd, 0x60, 0x31,
9252 0x76, 0xe1, 0x52, 0xa7, 0x6e, 0x0e, 0xa0, 0x74, 9252 0x3b, 0xf3, 0xfc, 0x12, 0x47, 0xe7, 0x66, 0x1a, 0x82, 0xa3,
9253 0x09, 0x75, 0xe6, 0x23, 0x24, 0xbd, 0x1b, 0x28, 9253 }};
9254 } };
9255 9254
9256 // This is the policy OID contained in the certificates that testserver 9255 // This is the policy OID contained in the certificates that testserver
9257 // generates. 9256 // generates.
9258 static const char kOCSPTestCertPolicy[] = "1.3.6.1.4.1.11129.2.4.1"; 9257 static const char kOCSPTestCertPolicy[] = "1.3.6.1.4.1.11129.2.4.1";
9259 9258
9260 class HTTPSOCSPTest : public HTTPSRequestTest { 9259 class HTTPSOCSPTest : public HTTPSRequestTest {
9261 public: 9260 public:
9262 HTTPSOCSPTest() 9261 HTTPSOCSPTest()
9263 : context_(true), 9262 : context_(true),
9264 ev_test_policy_( 9263 ev_test_policy_(
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
9906 EXPECT_EQ(test.response_status, ssl_info.ocsp_result.response_status); 9905 EXPECT_EQ(test.response_status, ssl_info.ocsp_result.response_status);
9907 9906
9908 if (test.has_revocation_status) 9907 if (test.has_revocation_status)
9909 EXPECT_EQ(test.cert_status, ssl_info.ocsp_result.revocation_status); 9908 EXPECT_EQ(test.cert_status, ssl_info.ocsp_result.revocation_status);
9910 } 9909 }
9911 9910
9912 INSTANTIATE_TEST_CASE_P(OCSPVerify, 9911 INSTANTIATE_TEST_CASE_P(OCSPVerify,
9913 HTTPSOCSPVerifyTest, 9912 HTTPSOCSPVerifyTest,
9914 testing::ValuesIn(kOCSPVerifyData)); 9913 testing::ValuesIn(kOCSPVerifyData));
9915 9914
9915 static bool SystemSupportsAIA() {
9916 #if defined(OS_ANDROID)
9917 return false;
9918 #else
9919 return true;
9920 #endif
9921 }
9922
9923 class HTTPSAIATest : public HTTPSOCSPTest {
9924 public:
9925 void SetupContext() override {
9926 context_.set_ssl_config_service(new TestSSLConfigService(
9927 false /* check for EV */, false /* online revocation checking */,
9928 false /* require rev. checking for local anchors */,
9929 false /* token binding enabled */));
9930 }
9931 };
9932
9933 TEST_F(HTTPSAIATest, AIAFetching) {
9934 SpawnedTestServer::SSLOptions ssl_options(
9935 SpawnedTestServer::SSLOptions::CERT_AUTO_AIA_INTERMEDIATE);
9936 SpawnedTestServer test_server(
9937 SpawnedTestServer::TYPE_HTTPS, ssl_options,
9938 base::FilePath(FILE_PATH_LITERAL("net/data/ssl")));
9939 ASSERT_TRUE(test_server.Start());
9940
9941 TestDelegate d;
9942 d.set_allow_certificate_errors(true);
9943 std::unique_ptr<URLRequest> r(context_.CreateRequest(
9944 test_server.GetURL("/defaultresponse"), DEFAULT_PRIORITY, &d));
9945
9946 r->Start();
9947 EXPECT_TRUE(r->is_pending());
9948
9949 base::RunLoop().Run();
9950
9951 EXPECT_EQ(1, d.response_started_count());
9952
9953 CertStatus cert_status = r->ssl_info().cert_status;
9954 if (SystemSupportsAIA()) {
9955 EXPECT_EQ(OK, d.request_status());
9956 EXPECT_EQ(0u, cert_status & CERT_STATUS_ALL_ERRORS);
9957 ASSERT_TRUE(r->ssl_info().cert);
9958 EXPECT_EQ(2u, r->ssl_info().cert->GetIntermediateCertificates().size());
9959 } else {
9960 EXPECT_EQ(CERT_STATUS_AUTHORITY_INVALID,
9961 cert_status & CERT_STATUS_ALL_ERRORS);
9962 }
9963 ASSERT_TRUE(r->ssl_info().unverified_cert);
9964 EXPECT_EQ(
9965 0u, r->ssl_info().unverified_cert->GetIntermediateCertificates().size());
9966 }
9967
9916 class HTTPSHardFailTest : public HTTPSOCSPTest { 9968 class HTTPSHardFailTest : public HTTPSOCSPTest {
9917 protected: 9969 protected:
9918 void SetupContext() override { 9970 void SetupContext() override {
9919 context_.set_ssl_config_service(new TestSSLConfigService( 9971 context_.set_ssl_config_service(new TestSSLConfigService(
9920 false /* check for EV */, false /* online revocation checking */, 9972 false /* check for EV */, false /* online revocation checking */,
9921 true /* require rev. checking for local 9973 true /* require rev. checking for local
9922 anchors */, 9974 anchors */,
9923 false /* token binding enabled */)); 9975 false /* token binding enabled */));
9924 } 9976 }
9925 }; 9977 };
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
10562 AddTestInterceptor()->set_main_intercept_job(std::move(job)); 10614 AddTestInterceptor()->set_main_intercept_job(std::move(job));
10563 10615
10564 req->Start(); 10616 req->Start();
10565 req->Cancel(); 10617 req->Cancel();
10566 base::RunLoop().RunUntilIdle(); 10618 base::RunLoop().RunUntilIdle();
10567 EXPECT_EQ(ERR_ABORTED, d.request_status()); 10619 EXPECT_EQ(ERR_ABORTED, d.request_status());
10568 EXPECT_EQ(0, d.received_redirect_count()); 10620 EXPECT_EQ(0, d.received_redirect_count());
10569 } 10621 }
10570 10622
10571 } // namespace net 10623 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/testserver/testserver.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698