| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "net/cert/internal/cert_issuer_source_aia.h" | 5 #include "net/cert/internal/cert_issuer_source_aia.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "net/cert/cert_net_fetcher.h" | 8 #include "net/cert/cert_net_fetcher.h" |
| 9 #include "net/cert/internal/cert_issuer_source_test_helpers.h" |
| 9 #include "net/cert/internal/parsed_certificate.h" | 10 #include "net/cert/internal/parsed_certificate.h" |
| 10 #include "net/cert/internal/test_helpers.h" | 11 #include "net/cert/internal/test_helpers.h" |
| 11 #include "testing/gmock/include/gmock/gmock.h" | 12 #include "testing/gmock/include/gmock/gmock.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 13 #include "url/gurl.h" | 14 #include "url/gurl.h" |
| 14 | 15 |
| 15 namespace net { | 16 namespace net { |
| 16 | 17 |
| 17 namespace { | 18 namespace { |
| 18 | 19 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 NOTREACHED(); | 144 NOTREACHED(); |
| 144 return nullptr; | 145 return nullptr; |
| 145 } | 146 } |
| 146 | 147 |
| 147 private: | 148 private: |
| 148 std::map<GURL, std::unique_ptr<RequestManager>> request_map_; | 149 std::map<GURL, std::unique_ptr<RequestManager>> request_map_; |
| 149 | 150 |
| 150 DISALLOW_COPY_AND_ASSIGN(MockCertNetFetcherImpl); | 151 DISALLOW_COPY_AND_ASSIGN(MockCertNetFetcherImpl); |
| 151 }; | 152 }; |
| 152 | 153 |
| 153 class MockIssuerCallback { | |
| 154 public: | |
| 155 MOCK_METHOD1(Callback, void(CertIssuerSource::Request*)); | |
| 156 }; | |
| 157 | |
| 158 void NotCalled(CertIssuerSource::Request* request) { | 154 void NotCalled(CertIssuerSource::Request* request) { |
| 159 ADD_FAILURE() << "NotCalled was called"; | 155 ADD_FAILURE() << "NotCalled was called"; |
| 160 } | 156 } |
| 161 | 157 |
| 162 // CertIssuerSourceAia does not return results for SyncGetIssuersOf. | 158 // CertIssuerSourceAia does not return results for SyncGetIssuersOf. |
| 163 TEST(CertIssuerSourceAiaTest, NoSyncResults) { | 159 TEST(CertIssuerSourceAiaTest, NoSyncResults) { |
| 164 scoped_refptr<ParsedCertificate> cert; | 160 scoped_refptr<ParsedCertificate> cert; |
| 165 ASSERT_TRUE(ReadTestCert("target_two_aia.pem", &cert)); | 161 ASSERT_TRUE(ReadTestCert("target_two_aia.pem", &cert)); |
| 166 | 162 |
| 167 StrictMock<MockCertNetFetcherImpl> mock_fetcher; | 163 StrictMock<MockCertNetFetcherImpl> mock_fetcher; |
| 168 CertIssuerSourceAia aia_source(&mock_fetcher); | 164 CertIssuerSourceAia aia_source(&mock_fetcher); |
| 169 ParsedCertificateList issuers; | 165 ParsedCertificateList issuers; |
| 170 aia_source.SyncGetIssuersOf(cert.get(), &issuers); | 166 aia_source.SyncGetIssuersOf(cert.get(), &issuers); |
| 171 EXPECT_EQ(0U, issuers.size()); | 167 EXPECT_EQ(0U, issuers.size()); |
| 172 } | 168 } |
| 173 | 169 |
| 174 // If the AuthorityInfoAccess extension is not present, AsyncGetIssuersOf should | 170 // If the AuthorityInfoAccess extension is not present, AsyncGetIssuersOf should |
| 175 // synchronously indicate no results. | 171 // synchronously indicate no results. |
| 176 TEST(CertIssuerSourceAiaTest, NoAia) { | 172 TEST(CertIssuerSourceAiaTest, NoAia) { |
| 177 scoped_refptr<ParsedCertificate> cert; | 173 scoped_refptr<ParsedCertificate> cert; |
| 178 ASSERT_TRUE(ReadTestCert("target_no_aia.pem", &cert)); | 174 ASSERT_TRUE(ReadTestCert("target_no_aia.pem", &cert)); |
| 179 | 175 |
| 180 StrictMock<MockCertNetFetcherImpl> mock_fetcher; | 176 StrictMock<MockCertNetFetcherImpl> mock_fetcher; |
| 181 CertIssuerSourceAia aia_source(&mock_fetcher); | 177 CertIssuerSourceAia aia_source(&mock_fetcher); |
| 182 std::unique_ptr<CertIssuerSource::Request> request; | 178 std::unique_ptr<CertIssuerSource::Request> request; |
| 183 aia_source.AsyncGetIssuersOf(cert.get(), base::Bind(&NotCalled), &request); | 179 aia_source.AsyncGetIssuersOf(cert, base::Bind(&NotCalled), &request); |
| 184 EXPECT_EQ(nullptr, request); | 180 EXPECT_EQ(nullptr, request); |
| 185 } | 181 } |
| 186 | 182 |
| 187 // If the AuthorityInfoAccess extension only contains non-HTTP URIs, | 183 // If the AuthorityInfoAccess extension only contains non-HTTP URIs, |
| 188 // AsyncGetIssuersOf should create a Request object. The URL scheme check is | 184 // AsyncGetIssuersOf should create a Request object. The URL scheme check is |
| 189 // part of the specific CertNetFetcher implementation, this tests that we handle | 185 // part of the specific CertNetFetcher implementation, this tests that we handle |
| 190 // ERR_DISALLOWED_URL_SCHEME properly. If FetchCaIssuers is modified to fail | 186 // ERR_DISALLOWED_URL_SCHEME properly. If FetchCaIssuers is modified to fail |
| 191 // synchronously in that case, this test will be more interesting. | 187 // synchronously in that case, this test will be more interesting. |
| 192 TEST(CertIssuerSourceAiaTest, FileAia) { | 188 TEST(CertIssuerSourceAiaTest, FileAia) { |
| 193 scoped_refptr<ParsedCertificate> cert; | 189 scoped_refptr<ParsedCertificate> cert; |
| 194 ASSERT_TRUE(ReadTestCert("target_file_aia.pem", &cert)); | 190 ASSERT_TRUE(ReadTestCert("target_file_aia.pem", &cert)); |
| 195 | 191 |
| 196 StrictMock<MockIssuerCallback> mock_callback; | 192 StrictMock<MockIssuerCallback> mock_callback; |
| 197 StrictMock<MockCertNetFetcherImpl> mock_fetcher; | 193 StrictMock<MockCertNetFetcherImpl> mock_fetcher; |
| 198 CertIssuerSourceAia aia_source(&mock_fetcher); | 194 CertIssuerSourceAia aia_source(&mock_fetcher); |
| 199 std::unique_ptr<CertIssuerSource::Request> cert_source_request; | 195 std::unique_ptr<CertIssuerSource::Request> cert_source_request; |
| 200 aia_source.AsyncGetIssuersOf(cert.get(), | 196 aia_source.AsyncGetIssuersOf(cert, |
| 201 base::Bind(&MockIssuerCallback::Callback, | 197 base::Bind(&MockIssuerCallback::Callback, |
| 202 base::Unretained(&mock_callback)), | 198 base::Unretained(&mock_callback)), |
| 203 &cert_source_request); | 199 &cert_source_request); |
| 204 ASSERT_NE(nullptr, cert_source_request); | 200 ASSERT_NE(nullptr, cert_source_request); |
| 205 | 201 |
| 206 RequestManager* req_manager = | 202 RequestManager* req_manager = |
| 207 mock_fetcher.GetRequestManagerForURL(GURL("file:///dev/null")); | 203 mock_fetcher.GetRequestManagerForURL(GURL("file:///dev/null")); |
| 208 ASSERT_TRUE(req_manager); | 204 ASSERT_TRUE(req_manager); |
| 209 ASSERT_TRUE(req_manager->is_request_alive()); | 205 ASSERT_TRUE(req_manager->is_request_alive()); |
| 210 | 206 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 223 | 219 |
| 224 // If the AuthorityInfoAccess extension contains an invalid URL, | 220 // If the AuthorityInfoAccess extension contains an invalid URL, |
| 225 // AsyncGetIssuersOf should synchronously indicate no results. | 221 // AsyncGetIssuersOf should synchronously indicate no results. |
| 226 TEST(CertIssuerSourceAiaTest, OneInvalidURL) { | 222 TEST(CertIssuerSourceAiaTest, OneInvalidURL) { |
| 227 scoped_refptr<ParsedCertificate> cert; | 223 scoped_refptr<ParsedCertificate> cert; |
| 228 ASSERT_TRUE(ReadTestCert("target_invalid_url_aia.pem", &cert)); | 224 ASSERT_TRUE(ReadTestCert("target_invalid_url_aia.pem", &cert)); |
| 229 | 225 |
| 230 StrictMock<MockCertNetFetcherImpl> mock_fetcher; | 226 StrictMock<MockCertNetFetcherImpl> mock_fetcher; |
| 231 CertIssuerSourceAia aia_source(&mock_fetcher); | 227 CertIssuerSourceAia aia_source(&mock_fetcher); |
| 232 std::unique_ptr<CertIssuerSource::Request> request; | 228 std::unique_ptr<CertIssuerSource::Request> request; |
| 233 aia_source.AsyncGetIssuersOf(cert.get(), base::Bind(&NotCalled), &request); | 229 aia_source.AsyncGetIssuersOf(cert, base::Bind(&NotCalled), &request); |
| 234 EXPECT_EQ(nullptr, request); | 230 EXPECT_EQ(nullptr, request); |
| 235 } | 231 } |
| 236 | 232 |
| 237 // AuthorityInfoAccess with a single HTTP url pointing to a single DER cert. | 233 // AuthorityInfoAccess with a single HTTP url pointing to a single DER cert. |
| 238 TEST(CertIssuerSourceAiaTest, OneAia) { | 234 TEST(CertIssuerSourceAiaTest, OneAia) { |
| 239 scoped_refptr<ParsedCertificate> cert; | 235 scoped_refptr<ParsedCertificate> cert; |
| 240 ASSERT_TRUE(ReadTestCert("target_one_aia.pem", &cert)); | 236 ASSERT_TRUE(ReadTestCert("target_one_aia.pem", &cert)); |
| 241 scoped_refptr<ParsedCertificate> intermediate_cert; | 237 scoped_refptr<ParsedCertificate> intermediate_cert; |
| 242 ASSERT_TRUE(ReadTestCert("i.pem", &intermediate_cert)); | 238 ASSERT_TRUE(ReadTestCert("i.pem", &intermediate_cert)); |
| 243 | 239 |
| 244 StrictMock<MockIssuerCallback> mock_callback; | 240 StrictMock<MockIssuerCallback> mock_callback; |
| 245 StrictMock<MockCertNetFetcherImpl> mock_fetcher; | 241 StrictMock<MockCertNetFetcherImpl> mock_fetcher; |
| 246 CertIssuerSourceAia aia_source(&mock_fetcher); | 242 CertIssuerSourceAia aia_source(&mock_fetcher); |
| 247 std::unique_ptr<CertIssuerSource::Request> cert_source_request; | 243 std::unique_ptr<CertIssuerSource::Request> cert_source_request; |
| 248 aia_source.AsyncGetIssuersOf(cert.get(), | 244 aia_source.AsyncGetIssuersOf(cert, |
| 249 base::Bind(&MockIssuerCallback::Callback, | 245 base::Bind(&MockIssuerCallback::Callback, |
| 250 base::Unretained(&mock_callback)), | 246 base::Unretained(&mock_callback)), |
| 251 &cert_source_request); | 247 &cert_source_request); |
| 252 ASSERT_NE(nullptr, cert_source_request); | 248 ASSERT_NE(nullptr, cert_source_request); |
| 253 | 249 |
| 254 RequestManager* req_manager = | 250 RequestManager* req_manager = |
| 255 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia/I.cer")); | 251 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia/I.cer")); |
| 256 ASSERT_TRUE(req_manager); | 252 ASSERT_TRUE(req_manager); |
| 257 ASSERT_TRUE(req_manager->is_request_alive()); | 253 ASSERT_TRUE(req_manager->is_request_alive()); |
| 258 | 254 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 282 TEST(CertIssuerSourceAiaTest, OneFileOneHttpAia) { | 278 TEST(CertIssuerSourceAiaTest, OneFileOneHttpAia) { |
| 283 scoped_refptr<ParsedCertificate> cert; | 279 scoped_refptr<ParsedCertificate> cert; |
| 284 ASSERT_TRUE(ReadTestCert("target_file_and_http_aia.pem", &cert)); | 280 ASSERT_TRUE(ReadTestCert("target_file_and_http_aia.pem", &cert)); |
| 285 scoped_refptr<ParsedCertificate> intermediate_cert; | 281 scoped_refptr<ParsedCertificate> intermediate_cert; |
| 286 ASSERT_TRUE(ReadTestCert("i2.pem", &intermediate_cert)); | 282 ASSERT_TRUE(ReadTestCert("i2.pem", &intermediate_cert)); |
| 287 | 283 |
| 288 StrictMock<MockIssuerCallback> mock_callback; | 284 StrictMock<MockIssuerCallback> mock_callback; |
| 289 StrictMock<MockCertNetFetcherImpl> mock_fetcher; | 285 StrictMock<MockCertNetFetcherImpl> mock_fetcher; |
| 290 CertIssuerSourceAia aia_source(&mock_fetcher); | 286 CertIssuerSourceAia aia_source(&mock_fetcher); |
| 291 std::unique_ptr<CertIssuerSource::Request> cert_source_request; | 287 std::unique_ptr<CertIssuerSource::Request> cert_source_request; |
| 292 aia_source.AsyncGetIssuersOf(cert.get(), | 288 aia_source.AsyncGetIssuersOf(cert, |
| 293 base::Bind(&MockIssuerCallback::Callback, | 289 base::Bind(&MockIssuerCallback::Callback, |
| 294 base::Unretained(&mock_callback)), | 290 base::Unretained(&mock_callback)), |
| 295 &cert_source_request); | 291 &cert_source_request); |
| 296 ASSERT_NE(nullptr, cert_source_request); | 292 ASSERT_NE(nullptr, cert_source_request); |
| 297 | 293 |
| 298 RequestManager* req_manager = | 294 RequestManager* req_manager = |
| 299 mock_fetcher.GetRequestManagerForURL(GURL("file:///dev/null")); | 295 mock_fetcher.GetRequestManagerForURL(GURL("file:///dev/null")); |
| 300 ASSERT_TRUE(req_manager); | 296 ASSERT_TRUE(req_manager); |
| 301 ASSERT_TRUE(req_manager->is_request_alive()); | 297 ASSERT_TRUE(req_manager->is_request_alive()); |
| 302 | 298 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 TEST(CertIssuerSourceAiaTest, OneInvalidOneHttpAia) { | 331 TEST(CertIssuerSourceAiaTest, OneInvalidOneHttpAia) { |
| 336 scoped_refptr<ParsedCertificate> cert; | 332 scoped_refptr<ParsedCertificate> cert; |
| 337 ASSERT_TRUE(ReadTestCert("target_invalid_and_http_aia.pem", &cert)); | 333 ASSERT_TRUE(ReadTestCert("target_invalid_and_http_aia.pem", &cert)); |
| 338 scoped_refptr<ParsedCertificate> intermediate_cert; | 334 scoped_refptr<ParsedCertificate> intermediate_cert; |
| 339 ASSERT_TRUE(ReadTestCert("i2.pem", &intermediate_cert)); | 335 ASSERT_TRUE(ReadTestCert("i2.pem", &intermediate_cert)); |
| 340 | 336 |
| 341 StrictMock<MockIssuerCallback> mock_callback; | 337 StrictMock<MockIssuerCallback> mock_callback; |
| 342 StrictMock<MockCertNetFetcherImpl> mock_fetcher; | 338 StrictMock<MockCertNetFetcherImpl> mock_fetcher; |
| 343 CertIssuerSourceAia aia_source(&mock_fetcher); | 339 CertIssuerSourceAia aia_source(&mock_fetcher); |
| 344 std::unique_ptr<CertIssuerSource::Request> cert_source_request; | 340 std::unique_ptr<CertIssuerSource::Request> cert_source_request; |
| 345 aia_source.AsyncGetIssuersOf(cert.get(), | 341 aia_source.AsyncGetIssuersOf(cert, |
| 346 base::Bind(&MockIssuerCallback::Callback, | 342 base::Bind(&MockIssuerCallback::Callback, |
| 347 base::Unretained(&mock_callback)), | 343 base::Unretained(&mock_callback)), |
| 348 &cert_source_request); | 344 &cert_source_request); |
| 349 ASSERT_NE(nullptr, cert_source_request); | 345 ASSERT_NE(nullptr, cert_source_request); |
| 350 | 346 |
| 351 RequestManager* req_manager = | 347 RequestManager* req_manager = |
| 352 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia2/I2.foo")); | 348 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia2/I2.foo")); |
| 353 ASSERT_TRUE(req_manager); | 349 ASSERT_TRUE(req_manager); |
| 354 ASSERT_TRUE(req_manager->is_request_alive()); | 350 ASSERT_TRUE(req_manager->is_request_alive()); |
| 355 | 351 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 380 ASSERT_TRUE(ReadTestCert("target_two_aia.pem", &cert)); | 376 ASSERT_TRUE(ReadTestCert("target_two_aia.pem", &cert)); |
| 381 scoped_refptr<ParsedCertificate> intermediate_cert; | 377 scoped_refptr<ParsedCertificate> intermediate_cert; |
| 382 ASSERT_TRUE(ReadTestCert("i.pem", &intermediate_cert)); | 378 ASSERT_TRUE(ReadTestCert("i.pem", &intermediate_cert)); |
| 383 scoped_refptr<ParsedCertificate> intermediate_cert2; | 379 scoped_refptr<ParsedCertificate> intermediate_cert2; |
| 384 ASSERT_TRUE(ReadTestCert("i2.pem", &intermediate_cert2)); | 380 ASSERT_TRUE(ReadTestCert("i2.pem", &intermediate_cert2)); |
| 385 | 381 |
| 386 StrictMock<MockIssuerCallback> mock_callback; | 382 StrictMock<MockIssuerCallback> mock_callback; |
| 387 StrictMock<MockCertNetFetcherImpl> mock_fetcher; | 383 StrictMock<MockCertNetFetcherImpl> mock_fetcher; |
| 388 CertIssuerSourceAia aia_source(&mock_fetcher); | 384 CertIssuerSourceAia aia_source(&mock_fetcher); |
| 389 std::unique_ptr<CertIssuerSource::Request> cert_source_request; | 385 std::unique_ptr<CertIssuerSource::Request> cert_source_request; |
| 390 aia_source.AsyncGetIssuersOf(cert.get(), | 386 aia_source.AsyncGetIssuersOf(cert, |
| 391 base::Bind(&MockIssuerCallback::Callback, | 387 base::Bind(&MockIssuerCallback::Callback, |
| 392 base::Unretained(&mock_callback)), | 388 base::Unretained(&mock_callback)), |
| 393 &cert_source_request); | 389 &cert_source_request); |
| 394 ASSERT_NE(nullptr, cert_source_request); | 390 ASSERT_NE(nullptr, cert_source_request); |
| 395 | 391 |
| 396 RequestManager* req_manager = | 392 RequestManager* req_manager = |
| 397 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia/I.cer")); | 393 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia/I.cer")); |
| 398 ASSERT_TRUE(req_manager); | 394 ASSERT_TRUE(req_manager); |
| 399 ASSERT_TRUE(req_manager->is_request_alive()); | 395 ASSERT_TRUE(req_manager->is_request_alive()); |
| 400 | 396 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 ASSERT_TRUE(ReadTestCert("target_two_aia.pem", &cert)); | 452 ASSERT_TRUE(ReadTestCert("target_two_aia.pem", &cert)); |
| 457 scoped_refptr<ParsedCertificate> intermediate_cert; | 453 scoped_refptr<ParsedCertificate> intermediate_cert; |
| 458 ASSERT_TRUE(ReadTestCert("i.pem", &intermediate_cert)); | 454 ASSERT_TRUE(ReadTestCert("i.pem", &intermediate_cert)); |
| 459 scoped_refptr<ParsedCertificate> intermediate_cert2; | 455 scoped_refptr<ParsedCertificate> intermediate_cert2; |
| 460 ASSERT_TRUE(ReadTestCert("i2.pem", &intermediate_cert2)); | 456 ASSERT_TRUE(ReadTestCert("i2.pem", &intermediate_cert2)); |
| 461 | 457 |
| 462 StrictMock<MockIssuerCallback> mock_callback; | 458 StrictMock<MockIssuerCallback> mock_callback; |
| 463 StrictMock<MockCertNetFetcherImpl> mock_fetcher; | 459 StrictMock<MockCertNetFetcherImpl> mock_fetcher; |
| 464 CertIssuerSourceAia aia_source(&mock_fetcher); | 460 CertIssuerSourceAia aia_source(&mock_fetcher); |
| 465 std::unique_ptr<CertIssuerSource::Request> cert_source_request; | 461 std::unique_ptr<CertIssuerSource::Request> cert_source_request; |
| 466 aia_source.AsyncGetIssuersOf(cert.get(), | 462 aia_source.AsyncGetIssuersOf(cert, |
| 467 base::Bind(&MockIssuerCallback::Callback, | 463 base::Bind(&MockIssuerCallback::Callback, |
| 468 base::Unretained(&mock_callback)), | 464 base::Unretained(&mock_callback)), |
| 469 &cert_source_request); | 465 &cert_source_request); |
| 470 ASSERT_NE(nullptr, cert_source_request); | 466 ASSERT_NE(nullptr, cert_source_request); |
| 471 | 467 |
| 472 RequestManager* req_manager = | 468 RequestManager* req_manager = |
| 473 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia/I.cer")); | 469 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia/I.cer")); |
| 474 ASSERT_TRUE(req_manager); | 470 ASSERT_TRUE(req_manager); |
| 475 ASSERT_TRUE(req_manager->is_request_alive()); | 471 ASSERT_TRUE(req_manager->is_request_alive()); |
| 476 | 472 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 ASSERT_TRUE(ReadTestCert("i.pem", &intermediate_cert)); | 524 ASSERT_TRUE(ReadTestCert("i.pem", &intermediate_cert)); |
| 529 scoped_refptr<ParsedCertificate> intermediate_cert2; | 525 scoped_refptr<ParsedCertificate> intermediate_cert2; |
| 530 ASSERT_TRUE(ReadTestCert("i2.pem", &intermediate_cert2)); | 526 ASSERT_TRUE(ReadTestCert("i2.pem", &intermediate_cert2)); |
| 531 scoped_refptr<ParsedCertificate> intermediate_cert3; | 527 scoped_refptr<ParsedCertificate> intermediate_cert3; |
| 532 ASSERT_TRUE(ReadTestCert("i3.pem", &intermediate_cert3)); | 528 ASSERT_TRUE(ReadTestCert("i3.pem", &intermediate_cert3)); |
| 533 | 529 |
| 534 StrictMock<MockIssuerCallback> mock_callback; | 530 StrictMock<MockIssuerCallback> mock_callback; |
| 535 StrictMock<MockCertNetFetcherImpl> mock_fetcher; | 531 StrictMock<MockCertNetFetcherImpl> mock_fetcher; |
| 536 CertIssuerSourceAia aia_source(&mock_fetcher); | 532 CertIssuerSourceAia aia_source(&mock_fetcher); |
| 537 std::unique_ptr<CertIssuerSource::Request> cert_source_request; | 533 std::unique_ptr<CertIssuerSource::Request> cert_source_request; |
| 538 aia_source.AsyncGetIssuersOf(cert.get(), | 534 aia_source.AsyncGetIssuersOf(cert, |
| 539 base::Bind(&MockIssuerCallback::Callback, | 535 base::Bind(&MockIssuerCallback::Callback, |
| 540 base::Unretained(&mock_callback)), | 536 base::Unretained(&mock_callback)), |
| 541 &cert_source_request); | 537 &cert_source_request); |
| 542 ASSERT_NE(nullptr, cert_source_request); | 538 ASSERT_NE(nullptr, cert_source_request); |
| 543 | 539 |
| 544 RequestManager* req_manager = | 540 RequestManager* req_manager = |
| 545 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia/I.cer")); | 541 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia/I.cer")); |
| 546 ASSERT_TRUE(req_manager); | 542 ASSERT_TRUE(req_manager); |
| 547 ASSERT_TRUE(req_manager->is_request_alive()); | 543 ASSERT_TRUE(req_manager->is_request_alive()); |
| 548 | 544 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 604 // CertNetFetcher request fails. The callback should be called to indicate the | 600 // CertNetFetcher request fails. The callback should be called to indicate the |
| 605 // request is complete, but no results should be provided. | 601 // request is complete, but no results should be provided. |
| 606 TEST(CertIssuerSourceAiaTest, OneAiaHttpError) { | 602 TEST(CertIssuerSourceAiaTest, OneAiaHttpError) { |
| 607 scoped_refptr<ParsedCertificate> cert; | 603 scoped_refptr<ParsedCertificate> cert; |
| 608 ASSERT_TRUE(ReadTestCert("target_one_aia.pem", &cert)); | 604 ASSERT_TRUE(ReadTestCert("target_one_aia.pem", &cert)); |
| 609 | 605 |
| 610 StrictMock<MockIssuerCallback> mock_callback; | 606 StrictMock<MockIssuerCallback> mock_callback; |
| 611 StrictMock<MockCertNetFetcherImpl> mock_fetcher; | 607 StrictMock<MockCertNetFetcherImpl> mock_fetcher; |
| 612 CertIssuerSourceAia aia_source(&mock_fetcher); | 608 CertIssuerSourceAia aia_source(&mock_fetcher); |
| 613 std::unique_ptr<CertIssuerSource::Request> cert_source_request; | 609 std::unique_ptr<CertIssuerSource::Request> cert_source_request; |
| 614 aia_source.AsyncGetIssuersOf(cert.get(), | 610 aia_source.AsyncGetIssuersOf(cert, |
| 615 base::Bind(&MockIssuerCallback::Callback, | 611 base::Bind(&MockIssuerCallback::Callback, |
| 616 base::Unretained(&mock_callback)), | 612 base::Unretained(&mock_callback)), |
| 617 &cert_source_request); | 613 &cert_source_request); |
| 618 ASSERT_NE(nullptr, cert_source_request); | 614 ASSERT_NE(nullptr, cert_source_request); |
| 619 | 615 |
| 620 RequestManager* req_manager = | 616 RequestManager* req_manager = |
| 621 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia/I.cer")); | 617 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia/I.cer")); |
| 622 ASSERT_TRUE(req_manager); | 618 ASSERT_TRUE(req_manager); |
| 623 ASSERT_TRUE(req_manager->is_request_alive()); | 619 ASSERT_TRUE(req_manager->is_request_alive()); |
| 624 | 620 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 638 // callback should be called to indicate the request is complete, but no results | 634 // callback should be called to indicate the request is complete, but no results |
| 639 // should be provided. | 635 // should be provided. |
| 640 TEST(CertIssuerSourceAiaTest, OneAiaParseError) { | 636 TEST(CertIssuerSourceAiaTest, OneAiaParseError) { |
| 641 scoped_refptr<ParsedCertificate> cert; | 637 scoped_refptr<ParsedCertificate> cert; |
| 642 ASSERT_TRUE(ReadTestCert("target_one_aia.pem", &cert)); | 638 ASSERT_TRUE(ReadTestCert("target_one_aia.pem", &cert)); |
| 643 | 639 |
| 644 StrictMock<MockIssuerCallback> mock_callback; | 640 StrictMock<MockIssuerCallback> mock_callback; |
| 645 StrictMock<MockCertNetFetcherImpl> mock_fetcher; | 641 StrictMock<MockCertNetFetcherImpl> mock_fetcher; |
| 646 CertIssuerSourceAia aia_source(&mock_fetcher); | 642 CertIssuerSourceAia aia_source(&mock_fetcher); |
| 647 std::unique_ptr<CertIssuerSource::Request> cert_source_request; | 643 std::unique_ptr<CertIssuerSource::Request> cert_source_request; |
| 648 aia_source.AsyncGetIssuersOf(cert.get(), | 644 aia_source.AsyncGetIssuersOf(cert, |
| 649 base::Bind(&MockIssuerCallback::Callback, | 645 base::Bind(&MockIssuerCallback::Callback, |
| 650 base::Unretained(&mock_callback)), | 646 base::Unretained(&mock_callback)), |
| 651 &cert_source_request); | 647 &cert_source_request); |
| 652 ASSERT_NE(nullptr, cert_source_request); | 648 ASSERT_NE(nullptr, cert_source_request); |
| 653 | 649 |
| 654 RequestManager* req_manager = | 650 RequestManager* req_manager = |
| 655 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia/I.cer")); | 651 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia/I.cer")); |
| 656 ASSERT_TRUE(req_manager); | 652 ASSERT_TRUE(req_manager); |
| 657 ASSERT_TRUE(req_manager->is_request_alive()); | 653 ASSERT_TRUE(req_manager->is_request_alive()); |
| 658 | 654 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 673 TEST(CertIssuerSourceAiaTest, TwoAiaCompletedInSeriesFirstFails) { | 669 TEST(CertIssuerSourceAiaTest, TwoAiaCompletedInSeriesFirstFails) { |
| 674 scoped_refptr<ParsedCertificate> cert; | 670 scoped_refptr<ParsedCertificate> cert; |
| 675 ASSERT_TRUE(ReadTestCert("target_two_aia.pem", &cert)); | 671 ASSERT_TRUE(ReadTestCert("target_two_aia.pem", &cert)); |
| 676 scoped_refptr<ParsedCertificate> intermediate_cert2; | 672 scoped_refptr<ParsedCertificate> intermediate_cert2; |
| 677 ASSERT_TRUE(ReadTestCert("i2.pem", &intermediate_cert2)); | 673 ASSERT_TRUE(ReadTestCert("i2.pem", &intermediate_cert2)); |
| 678 | 674 |
| 679 StrictMock<MockIssuerCallback> mock_callback; | 675 StrictMock<MockIssuerCallback> mock_callback; |
| 680 StrictMock<MockCertNetFetcherImpl> mock_fetcher; | 676 StrictMock<MockCertNetFetcherImpl> mock_fetcher; |
| 681 CertIssuerSourceAia aia_source(&mock_fetcher); | 677 CertIssuerSourceAia aia_source(&mock_fetcher); |
| 682 std::unique_ptr<CertIssuerSource::Request> cert_source_request; | 678 std::unique_ptr<CertIssuerSource::Request> cert_source_request; |
| 683 aia_source.AsyncGetIssuersOf(cert.get(), | 679 aia_source.AsyncGetIssuersOf(cert, |
| 684 base::Bind(&MockIssuerCallback::Callback, | 680 base::Bind(&MockIssuerCallback::Callback, |
| 685 base::Unretained(&mock_callback)), | 681 base::Unretained(&mock_callback)), |
| 686 &cert_source_request); | 682 &cert_source_request); |
| 687 ASSERT_NE(nullptr, cert_source_request); | 683 ASSERT_NE(nullptr, cert_source_request); |
| 688 | 684 |
| 689 RequestManager* req_manager = | 685 RequestManager* req_manager = |
| 690 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia/I.cer")); | 686 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia/I.cer")); |
| 691 ASSERT_TRUE(req_manager); | 687 ASSERT_TRUE(req_manager); |
| 692 ASSERT_TRUE(req_manager->is_request_alive()); | 688 ASSERT_TRUE(req_manager->is_request_alive()); |
| 693 | 689 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 TEST(CertIssuerSourceAiaTest, TwoAiaCompletedInSeriesSecondFails) { | 723 TEST(CertIssuerSourceAiaTest, TwoAiaCompletedInSeriesSecondFails) { |
| 728 scoped_refptr<ParsedCertificate> cert; | 724 scoped_refptr<ParsedCertificate> cert; |
| 729 ASSERT_TRUE(ReadTestCert("target_two_aia.pem", &cert)); | 725 ASSERT_TRUE(ReadTestCert("target_two_aia.pem", &cert)); |
| 730 scoped_refptr<ParsedCertificate> intermediate_cert; | 726 scoped_refptr<ParsedCertificate> intermediate_cert; |
| 731 ASSERT_TRUE(ReadTestCert("i.pem", &intermediate_cert)); | 727 ASSERT_TRUE(ReadTestCert("i.pem", &intermediate_cert)); |
| 732 | 728 |
| 733 StrictMock<MockIssuerCallback> mock_callback; | 729 StrictMock<MockIssuerCallback> mock_callback; |
| 734 StrictMock<MockCertNetFetcherImpl> mock_fetcher; | 730 StrictMock<MockCertNetFetcherImpl> mock_fetcher; |
| 735 CertIssuerSourceAia aia_source(&mock_fetcher); | 731 CertIssuerSourceAia aia_source(&mock_fetcher); |
| 736 std::unique_ptr<CertIssuerSource::Request> cert_source_request; | 732 std::unique_ptr<CertIssuerSource::Request> cert_source_request; |
| 737 aia_source.AsyncGetIssuersOf(cert.get(), | 733 aia_source.AsyncGetIssuersOf(cert, |
| 738 base::Bind(&MockIssuerCallback::Callback, | 734 base::Bind(&MockIssuerCallback::Callback, |
| 739 base::Unretained(&mock_callback)), | 735 base::Unretained(&mock_callback)), |
| 740 &cert_source_request); | 736 &cert_source_request); |
| 741 ASSERT_NE(nullptr, cert_source_request); | 737 ASSERT_NE(nullptr, cert_source_request); |
| 742 | 738 |
| 743 RequestManager* req_manager = | 739 RequestManager* req_manager = |
| 744 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia/I.cer")); | 740 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia/I.cer")); |
| 745 ASSERT_TRUE(req_manager); | 741 ASSERT_TRUE(req_manager); |
| 746 ASSERT_TRUE(req_manager->is_request_alive()); | 742 ASSERT_TRUE(req_manager->is_request_alive()); |
| 747 | 743 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 785 // AuthorityInfoAccess with two HTTP urls. Request is cancelled before any HTTP | 781 // AuthorityInfoAccess with two HTTP urls. Request is cancelled before any HTTP |
| 786 // requests finish. | 782 // requests finish. |
| 787 TEST(CertIssuerSourceAiaTest, CertSourceRequestCancelled) { | 783 TEST(CertIssuerSourceAiaTest, CertSourceRequestCancelled) { |
| 788 scoped_refptr<ParsedCertificate> cert; | 784 scoped_refptr<ParsedCertificate> cert; |
| 789 ASSERT_TRUE(ReadTestCert("target_two_aia.pem", &cert)); | 785 ASSERT_TRUE(ReadTestCert("target_two_aia.pem", &cert)); |
| 790 | 786 |
| 791 StrictMock<MockIssuerCallback> mock_callback; | 787 StrictMock<MockIssuerCallback> mock_callback; |
| 792 StrictMock<MockCertNetFetcherImpl> mock_fetcher; | 788 StrictMock<MockCertNetFetcherImpl> mock_fetcher; |
| 793 CertIssuerSourceAia aia_source(&mock_fetcher); | 789 CertIssuerSourceAia aia_source(&mock_fetcher); |
| 794 std::unique_ptr<CertIssuerSource::Request> cert_source_request; | 790 std::unique_ptr<CertIssuerSource::Request> cert_source_request; |
| 795 aia_source.AsyncGetIssuersOf(cert.get(), | 791 aia_source.AsyncGetIssuersOf(cert, |
| 796 base::Bind(&MockIssuerCallback::Callback, | 792 base::Bind(&MockIssuerCallback::Callback, |
| 797 base::Unretained(&mock_callback)), | 793 base::Unretained(&mock_callback)), |
| 798 &cert_source_request); | 794 &cert_source_request); |
| 799 ASSERT_NE(nullptr, cert_source_request); | 795 ASSERT_NE(nullptr, cert_source_request); |
| 800 | 796 |
| 801 RequestManager* req_manager = | 797 RequestManager* req_manager = |
| 802 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia/I.cer")); | 798 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia/I.cer")); |
| 803 ASSERT_TRUE(req_manager); | 799 ASSERT_TRUE(req_manager); |
| 804 ASSERT_TRUE(req_manager->is_request_alive()); | 800 ASSERT_TRUE(req_manager->is_request_alive()); |
| 805 | 801 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 821 TEST(CertIssuerSourceAiaTest, TwoAiaOneCompletedThenRequestCancelled) { | 817 TEST(CertIssuerSourceAiaTest, TwoAiaOneCompletedThenRequestCancelled) { |
| 822 scoped_refptr<ParsedCertificate> cert; | 818 scoped_refptr<ParsedCertificate> cert; |
| 823 ASSERT_TRUE(ReadTestCert("target_two_aia.pem", &cert)); | 819 ASSERT_TRUE(ReadTestCert("target_two_aia.pem", &cert)); |
| 824 scoped_refptr<ParsedCertificate> intermediate_cert; | 820 scoped_refptr<ParsedCertificate> intermediate_cert; |
| 825 ASSERT_TRUE(ReadTestCert("i.pem", &intermediate_cert)); | 821 ASSERT_TRUE(ReadTestCert("i.pem", &intermediate_cert)); |
| 826 | 822 |
| 827 StrictMock<MockIssuerCallback> mock_callback; | 823 StrictMock<MockIssuerCallback> mock_callback; |
| 828 StrictMock<MockCertNetFetcherImpl> mock_fetcher; | 824 StrictMock<MockCertNetFetcherImpl> mock_fetcher; |
| 829 CertIssuerSourceAia aia_source(&mock_fetcher); | 825 CertIssuerSourceAia aia_source(&mock_fetcher); |
| 830 std::unique_ptr<CertIssuerSource::Request> cert_source_request; | 826 std::unique_ptr<CertIssuerSource::Request> cert_source_request; |
| 831 aia_source.AsyncGetIssuersOf(cert.get(), | 827 aia_source.AsyncGetIssuersOf(cert, |
| 832 base::Bind(&MockIssuerCallback::Callback, | 828 base::Bind(&MockIssuerCallback::Callback, |
| 833 base::Unretained(&mock_callback)), | 829 base::Unretained(&mock_callback)), |
| 834 &cert_source_request); | 830 &cert_source_request); |
| 835 ASSERT_NE(nullptr, cert_source_request); | 831 ASSERT_NE(nullptr, cert_source_request); |
| 836 | 832 |
| 837 RequestManager* req_manager = | 833 RequestManager* req_manager = |
| 838 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia/I.cer")); | 834 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia/I.cer")); |
| 839 ASSERT_TRUE(req_manager); | 835 ASSERT_TRUE(req_manager); |
| 840 ASSERT_TRUE(req_manager->is_request_alive()); | 836 ASSERT_TRUE(req_manager->is_request_alive()); |
| 841 | 837 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 872 // AuthorityInfoAccess with six HTTP URLs. kMaxFetchesPerCert is 5, so the | 868 // AuthorityInfoAccess with six HTTP URLs. kMaxFetchesPerCert is 5, so the |
| 873 // sixth URL should be ignored. | 869 // sixth URL should be ignored. |
| 874 TEST(CertIssuerSourceAiaTest, MaxFetchesPerCert) { | 870 TEST(CertIssuerSourceAiaTest, MaxFetchesPerCert) { |
| 875 scoped_refptr<ParsedCertificate> cert; | 871 scoped_refptr<ParsedCertificate> cert; |
| 876 ASSERT_TRUE(ReadTestCert("target_six_aia.pem", &cert)); | 872 ASSERT_TRUE(ReadTestCert("target_six_aia.pem", &cert)); |
| 877 | 873 |
| 878 StrictMock<MockIssuerCallback> mock_callback; | 874 StrictMock<MockIssuerCallback> mock_callback; |
| 879 StrictMock<MockCertNetFetcherImpl> mock_fetcher; | 875 StrictMock<MockCertNetFetcherImpl> mock_fetcher; |
| 880 CertIssuerSourceAia aia_source(&mock_fetcher); | 876 CertIssuerSourceAia aia_source(&mock_fetcher); |
| 881 std::unique_ptr<CertIssuerSource::Request> cert_source_request; | 877 std::unique_ptr<CertIssuerSource::Request> cert_source_request; |
| 882 aia_source.AsyncGetIssuersOf(cert.get(), | 878 aia_source.AsyncGetIssuersOf(cert, |
| 883 base::Bind(&MockIssuerCallback::Callback, | 879 base::Bind(&MockIssuerCallback::Callback, |
| 884 base::Unretained(&mock_callback)), | 880 base::Unretained(&mock_callback)), |
| 885 &cert_source_request); | 881 &cert_source_request); |
| 886 ASSERT_NE(nullptr, cert_source_request); | 882 ASSERT_NE(nullptr, cert_source_request); |
| 887 | 883 |
| 888 RequestManager* req_manager = | 884 RequestManager* req_manager = |
| 889 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia/I.cer")); | 885 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia/I.cer")); |
| 890 ASSERT_TRUE(req_manager); | 886 ASSERT_TRUE(req_manager); |
| 891 EXPECT_TRUE(req_manager->is_request_alive()); | 887 EXPECT_TRUE(req_manager->is_request_alive()); |
| 892 | 888 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 911 EXPECT_TRUE(req_manager5->is_request_alive()); | 907 EXPECT_TRUE(req_manager5->is_request_alive()); |
| 912 | 908 |
| 913 // Sixth URL should not have created a request. | 909 // Sixth URL should not have created a request. |
| 914 EXPECT_FALSE( | 910 EXPECT_FALSE( |
| 915 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia6/I6.foo"))); | 911 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia6/I6.foo"))); |
| 916 } | 912 } |
| 917 | 913 |
| 918 } // namespace | 914 } // namespace |
| 919 | 915 |
| 920 } // namespace net | 916 } // namespace net |
| OLD | NEW |