| 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 "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "net/cert/cert_net_fetcher.h" | 9 #include "net/cert/cert_net_fetcher.h" |
| 10 #include "net/cert/internal/cert_errors.h" | 10 #include "net/cert/internal/cert_errors.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 std::vector<uint8_t> CertDataVector(const ParsedCertificate* cert) { | 56 std::vector<uint8_t> CertDataVector(const ParsedCertificate* cert) { |
| 57 std::vector<uint8_t> data( | 57 std::vector<uint8_t> data( |
| 58 cert->der_cert().UnsafeData(), | 58 cert->der_cert().UnsafeData(), |
| 59 cert->der_cert().UnsafeData() + cert->der_cert().Length()); | 59 cert->der_cert().UnsafeData() + cert->der_cert().Length()); |
| 60 return data; | 60 return data; |
| 61 } | 61 } |
| 62 | 62 |
| 63 // MockCertNetFetcher is an implementation of CertNetFetcher for testing. | 63 // MockCertNetFetcher is an implementation of CertNetFetcher for testing. |
| 64 class MockCertNetFetcher : public CertNetFetcher { | 64 class MockCertNetFetcher : public CertNetFetcher { |
| 65 public: | 65 public: |
| 66 MockCertNetFetcher() {} |
| 67 MOCK_METHOD0(Shutdown, void()); |
| 66 MOCK_METHOD3(FetchCaIssuers, | 68 MOCK_METHOD3(FetchCaIssuers, |
| 67 std::unique_ptr<Request>(const GURL& url, | 69 std::unique_ptr<Request>(const GURL& url, |
| 68 int timeout_milliseconds, | 70 int timeout_milliseconds, |
| 69 int max_response_bytes)); | 71 int max_response_bytes)); |
| 70 MOCK_METHOD3(FetchCrl, | 72 MOCK_METHOD3(FetchCrl, |
| 71 std::unique_ptr<Request>(const GURL& url, | 73 std::unique_ptr<Request>(const GURL& url, |
| 72 int timeout_milliseconds, | 74 int timeout_milliseconds, |
| 73 int max_response_bytes)); | 75 int max_response_bytes)); |
| 74 | 76 |
| 75 MOCK_METHOD3(FetchOcsp, | 77 MOCK_METHOD3(FetchOcsp, |
| 76 std::unique_ptr<Request>(const GURL& url, | 78 std::unique_ptr<Request>(const GURL& url, |
| 77 int timeout_milliseconds, | 79 int timeout_milliseconds, |
| 78 int max_response_bytes)); | 80 int max_response_bytes)); |
| 81 |
| 82 protected: |
| 83 ~MockCertNetFetcher() override {} |
| 79 }; | 84 }; |
| 80 | 85 |
| 81 // MockCertNetFetcherRequest gives back the indicated error and bytes. | 86 // MockCertNetFetcherRequest gives back the indicated error and bytes. |
| 82 class MockCertNetFetcherRequest : public CertNetFetcher::Request { | 87 class MockCertNetFetcherRequest : public CertNetFetcher::Request { |
| 83 public: | 88 public: |
| 84 MockCertNetFetcherRequest(Error error, std::vector<uint8_t> bytes) | 89 MockCertNetFetcherRequest(Error error, std::vector<uint8_t> bytes) |
| 85 : error_(error), bytes_(std::move(bytes)) {} | 90 : error_(error), bytes_(std::move(bytes)) {} |
| 86 | 91 |
| 87 void WaitForResult(Error* error, std::vector<uint8_t>* bytes) override { | 92 void WaitForResult(Error* error, std::vector<uint8_t>* bytes) override { |
| 88 DCHECK(!did_consume_result_); | 93 DCHECK(!did_consume_result_); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 109 const std::vector<uint8_t>& bytes) { | 114 const std::vector<uint8_t>& bytes) { |
| 110 return base::MakeUnique<MockCertNetFetcherRequest>(OK, bytes); | 115 return base::MakeUnique<MockCertNetFetcherRequest>(OK, bytes); |
| 111 } | 116 } |
| 112 | 117 |
| 113 // CertIssuerSourceAia does not return results for SyncGetIssuersOf. | 118 // CertIssuerSourceAia does not return results for SyncGetIssuersOf. |
| 114 TEST(CertIssuerSourceAiaTest, NoSyncResults) { | 119 TEST(CertIssuerSourceAiaTest, NoSyncResults) { |
| 115 scoped_refptr<ParsedCertificate> cert; | 120 scoped_refptr<ParsedCertificate> cert; |
| 116 ASSERT_TRUE(ReadTestCert("target_two_aia.pem", &cert)); | 121 ASSERT_TRUE(ReadTestCert("target_two_aia.pem", &cert)); |
| 117 | 122 |
| 118 // No methods on |mock_fetcher| should be called. | 123 // No methods on |mock_fetcher| should be called. |
| 119 StrictMock<MockCertNetFetcher> mock_fetcher; | 124 auto mock_fetcher = make_scoped_refptr(new StrictMock<MockCertNetFetcher>()); |
| 120 CertIssuerSourceAia aia_source(&mock_fetcher); | 125 CertIssuerSourceAia aia_source(mock_fetcher); |
| 121 ParsedCertificateList issuers; | 126 ParsedCertificateList issuers; |
| 122 aia_source.SyncGetIssuersOf(cert.get(), &issuers); | 127 aia_source.SyncGetIssuersOf(cert.get(), &issuers); |
| 123 EXPECT_EQ(0U, issuers.size()); | 128 EXPECT_EQ(0U, issuers.size()); |
| 124 } | 129 } |
| 125 | 130 |
| 126 // If the AuthorityInfoAccess extension is not present, AsyncGetIssuersOf should | 131 // If the AuthorityInfoAccess extension is not present, AsyncGetIssuersOf should |
| 127 // synchronously indicate no results. | 132 // synchronously indicate no results. |
| 128 TEST(CertIssuerSourceAiaTest, NoAia) { | 133 TEST(CertIssuerSourceAiaTest, NoAia) { |
| 129 scoped_refptr<ParsedCertificate> cert; | 134 scoped_refptr<ParsedCertificate> cert; |
| 130 ASSERT_TRUE(ReadTestCert("target_no_aia.pem", &cert)); | 135 ASSERT_TRUE(ReadTestCert("target_no_aia.pem", &cert)); |
| 131 | 136 |
| 132 // No methods on |mock_fetcher| should be called. | 137 // No methods on |mock_fetcher| should be called. |
| 133 StrictMock<MockCertNetFetcher> mock_fetcher; | 138 auto mock_fetcher = make_scoped_refptr(new StrictMock<MockCertNetFetcher>()); |
| 134 CertIssuerSourceAia aia_source(&mock_fetcher); | 139 CertIssuerSourceAia aia_source(mock_fetcher); |
| 135 std::unique_ptr<CertIssuerSource::Request> request; | 140 std::unique_ptr<CertIssuerSource::Request> request; |
| 136 aia_source.AsyncGetIssuersOf(cert.get(), &request); | 141 aia_source.AsyncGetIssuersOf(cert.get(), &request); |
| 137 EXPECT_EQ(nullptr, request); | 142 EXPECT_EQ(nullptr, request); |
| 138 } | 143 } |
| 139 | 144 |
| 140 // If the AuthorityInfoAccess extension only contains non-HTTP URIs, | 145 // If the AuthorityInfoAccess extension only contains non-HTTP URIs, |
| 141 // AsyncGetIssuersOf should create a Request object. The URL scheme check is | 146 // AsyncGetIssuersOf should create a Request object. The URL scheme check is |
| 142 // part of the specific CertNetFetcher implementation, this tests that we handle | 147 // part of the specific CertNetFetcher implementation, this tests that we handle |
| 143 // ERR_DISALLOWED_URL_SCHEME properly. If FetchCaIssuers is modified to fail | 148 // ERR_DISALLOWED_URL_SCHEME properly. If FetchCaIssuers is modified to fail |
| 144 // synchronously in that case, this test will be more interesting. | 149 // synchronously in that case, this test will be more interesting. |
| 145 TEST(CertIssuerSourceAiaTest, FileAia) { | 150 TEST(CertIssuerSourceAiaTest, FileAia) { |
| 146 scoped_refptr<ParsedCertificate> cert; | 151 scoped_refptr<ParsedCertificate> cert; |
| 147 ASSERT_TRUE(ReadTestCert("target_file_aia.pem", &cert)); | 152 ASSERT_TRUE(ReadTestCert("target_file_aia.pem", &cert)); |
| 148 | 153 |
| 149 StrictMock<MockCertNetFetcher> mock_fetcher; | 154 auto mock_fetcher = make_scoped_refptr(new StrictMock<MockCertNetFetcher>()); |
| 150 EXPECT_CALL(mock_fetcher, FetchCaIssuers(GURL("file:///dev/null"), _, _)) | 155 EXPECT_CALL(*mock_fetcher, FetchCaIssuers(GURL("file:///dev/null"), _, _)) |
| 151 .WillOnce(Return(ByMove(CreateMockRequest(ERR_DISALLOWED_URL_SCHEME)))); | 156 .WillOnce(Return(ByMove(CreateMockRequest(ERR_DISALLOWED_URL_SCHEME)))); |
| 152 | 157 |
| 153 CertIssuerSourceAia aia_source(&mock_fetcher); | 158 CertIssuerSourceAia aia_source(mock_fetcher); |
| 154 std::unique_ptr<CertIssuerSource::Request> cert_source_request; | 159 std::unique_ptr<CertIssuerSource::Request> cert_source_request; |
| 155 aia_source.AsyncGetIssuersOf(cert.get(), &cert_source_request); | 160 aia_source.AsyncGetIssuersOf(cert.get(), &cert_source_request); |
| 156 ASSERT_NE(nullptr, cert_source_request); | 161 ASSERT_NE(nullptr, cert_source_request); |
| 157 | 162 |
| 158 // No results. | 163 // No results. |
| 159 ParsedCertificateList result_certs; | 164 ParsedCertificateList result_certs; |
| 160 cert_source_request->GetNext(&result_certs); | 165 cert_source_request->GetNext(&result_certs); |
| 161 EXPECT_TRUE(result_certs.empty()); | 166 EXPECT_TRUE(result_certs.empty()); |
| 162 } | 167 } |
| 163 | 168 |
| 164 // If the AuthorityInfoAccess extension contains an invalid URL, | 169 // If the AuthorityInfoAccess extension contains an invalid URL, |
| 165 // AsyncGetIssuersOf should synchronously indicate no results. | 170 // AsyncGetIssuersOf should synchronously indicate no results. |
| 166 TEST(CertIssuerSourceAiaTest, OneInvalidURL) { | 171 TEST(CertIssuerSourceAiaTest, OneInvalidURL) { |
| 167 scoped_refptr<ParsedCertificate> cert; | 172 scoped_refptr<ParsedCertificate> cert; |
| 168 ASSERT_TRUE(ReadTestCert("target_invalid_url_aia.pem", &cert)); | 173 ASSERT_TRUE(ReadTestCert("target_invalid_url_aia.pem", &cert)); |
| 169 | 174 |
| 170 StrictMock<MockCertNetFetcher> mock_fetcher; | 175 auto mock_fetcher = make_scoped_refptr(new StrictMock<MockCertNetFetcher>()); |
| 171 CertIssuerSourceAia aia_source(&mock_fetcher); | 176 CertIssuerSourceAia aia_source(mock_fetcher); |
| 172 std::unique_ptr<CertIssuerSource::Request> request; | 177 std::unique_ptr<CertIssuerSource::Request> request; |
| 173 aia_source.AsyncGetIssuersOf(cert.get(), &request); | 178 aia_source.AsyncGetIssuersOf(cert.get(), &request); |
| 174 EXPECT_EQ(nullptr, request); | 179 EXPECT_EQ(nullptr, request); |
| 175 } | 180 } |
| 176 | 181 |
| 177 // AuthorityInfoAccess with a single HTTP url pointing to a single DER cert. | 182 // AuthorityInfoAccess with a single HTTP url pointing to a single DER cert. |
| 178 TEST(CertIssuerSourceAiaTest, OneAia) { | 183 TEST(CertIssuerSourceAiaTest, OneAia) { |
| 179 scoped_refptr<ParsedCertificate> cert; | 184 scoped_refptr<ParsedCertificate> cert; |
| 180 ASSERT_TRUE(ReadTestCert("target_one_aia.pem", &cert)); | 185 ASSERT_TRUE(ReadTestCert("target_one_aia.pem", &cert)); |
| 181 scoped_refptr<ParsedCertificate> intermediate_cert; | 186 scoped_refptr<ParsedCertificate> intermediate_cert; |
| 182 ASSERT_TRUE(ReadTestCert("i.pem", &intermediate_cert)); | 187 ASSERT_TRUE(ReadTestCert("i.pem", &intermediate_cert)); |
| 183 | 188 |
| 184 StrictMock<MockCertNetFetcher> mock_fetcher; | 189 auto mock_fetcher = make_scoped_refptr(new StrictMock<MockCertNetFetcher>()); |
| 185 | 190 |
| 186 EXPECT_CALL(mock_fetcher, | 191 EXPECT_CALL(*mock_fetcher, |
| 187 FetchCaIssuers(GURL("http://url-for-aia/I.cer"), _, _)) | 192 FetchCaIssuers(GURL("http://url-for-aia/I.cer"), _, _)) |
| 188 .WillOnce(Return( | 193 .WillOnce(Return( |
| 189 ByMove(CreateMockRequest(CertDataVector(intermediate_cert.get()))))); | 194 ByMove(CreateMockRequest(CertDataVector(intermediate_cert.get()))))); |
| 190 | 195 |
| 191 CertIssuerSourceAia aia_source(&mock_fetcher); | 196 CertIssuerSourceAia aia_source(mock_fetcher); |
| 192 std::unique_ptr<CertIssuerSource::Request> cert_source_request; | 197 std::unique_ptr<CertIssuerSource::Request> cert_source_request; |
| 193 aia_source.AsyncGetIssuersOf(cert.get(), &cert_source_request); | 198 aia_source.AsyncGetIssuersOf(cert.get(), &cert_source_request); |
| 194 ASSERT_NE(nullptr, cert_source_request); | 199 ASSERT_NE(nullptr, cert_source_request); |
| 195 | 200 |
| 196 ParsedCertificateList result_certs; | 201 ParsedCertificateList result_certs; |
| 197 cert_source_request->GetNext(&result_certs); | 202 cert_source_request->GetNext(&result_certs); |
| 198 ASSERT_EQ(1u, result_certs.size()); | 203 ASSERT_EQ(1u, result_certs.size()); |
| 199 ASSERT_EQ(result_certs.front()->der_cert(), intermediate_cert->der_cert()); | 204 ASSERT_EQ(result_certs.front()->der_cert(), intermediate_cert->der_cert()); |
| 200 | 205 |
| 201 result_certs.clear(); | 206 result_certs.clear(); |
| 202 cert_source_request->GetNext(&result_certs); | 207 cert_source_request->GetNext(&result_certs); |
| 203 EXPECT_TRUE(result_certs.empty()); | 208 EXPECT_TRUE(result_certs.empty()); |
| 204 } | 209 } |
| 205 | 210 |
| 206 // AuthorityInfoAccess with two URIs, one a FILE, the other a HTTP. | 211 // AuthorityInfoAccess with two URIs, one a FILE, the other a HTTP. |
| 207 // Simulate a ERR_DISALLOWED_URL_SCHEME for the file URL. If FetchCaIssuers is | 212 // Simulate a ERR_DISALLOWED_URL_SCHEME for the file URL. If FetchCaIssuers is |
| 208 // modified to synchronously reject disallowed schemes, this test will be more | 213 // modified to synchronously reject disallowed schemes, this test will be more |
| 209 // interesting. | 214 // interesting. |
| 210 TEST(CertIssuerSourceAiaTest, OneFileOneHttpAia) { | 215 TEST(CertIssuerSourceAiaTest, OneFileOneHttpAia) { |
| 211 scoped_refptr<ParsedCertificate> cert; | 216 scoped_refptr<ParsedCertificate> cert; |
| 212 ASSERT_TRUE(ReadTestCert("target_file_and_http_aia.pem", &cert)); | 217 ASSERT_TRUE(ReadTestCert("target_file_and_http_aia.pem", &cert)); |
| 213 scoped_refptr<ParsedCertificate> intermediate_cert; | 218 scoped_refptr<ParsedCertificate> intermediate_cert; |
| 214 ASSERT_TRUE(ReadTestCert("i2.pem", &intermediate_cert)); | 219 ASSERT_TRUE(ReadTestCert("i2.pem", &intermediate_cert)); |
| 215 | 220 |
| 216 StrictMock<MockCertNetFetcher> mock_fetcher; | 221 auto mock_fetcher = make_scoped_refptr(new StrictMock<MockCertNetFetcher>()); |
| 217 | 222 |
| 218 EXPECT_CALL(mock_fetcher, FetchCaIssuers(GURL("file:///dev/null"), _, _)) | 223 EXPECT_CALL(*mock_fetcher, FetchCaIssuers(GURL("file:///dev/null"), _, _)) |
| 219 .WillOnce(Return(ByMove(CreateMockRequest(ERR_DISALLOWED_URL_SCHEME)))); | 224 .WillOnce(Return(ByMove(CreateMockRequest(ERR_DISALLOWED_URL_SCHEME)))); |
| 220 | 225 |
| 221 EXPECT_CALL(mock_fetcher, | 226 EXPECT_CALL(*mock_fetcher, |
| 222 FetchCaIssuers(GURL("http://url-for-aia2/I2.foo"), _, _)) | 227 FetchCaIssuers(GURL("http://url-for-aia2/I2.foo"), _, _)) |
| 223 .WillOnce(Return( | 228 .WillOnce(Return( |
| 224 ByMove(CreateMockRequest(CertDataVector(intermediate_cert.get()))))); | 229 ByMove(CreateMockRequest(CertDataVector(intermediate_cert.get()))))); |
| 225 | 230 |
| 226 CertIssuerSourceAia aia_source(&mock_fetcher); | 231 CertIssuerSourceAia aia_source(mock_fetcher); |
| 227 std::unique_ptr<CertIssuerSource::Request> cert_source_request; | 232 std::unique_ptr<CertIssuerSource::Request> cert_source_request; |
| 228 aia_source.AsyncGetIssuersOf(cert.get(), &cert_source_request); | 233 aia_source.AsyncGetIssuersOf(cert.get(), &cert_source_request); |
| 229 ASSERT_NE(nullptr, cert_source_request); | 234 ASSERT_NE(nullptr, cert_source_request); |
| 230 | 235 |
| 231 ParsedCertificateList result_certs; | 236 ParsedCertificateList result_certs; |
| 232 cert_source_request->GetNext(&result_certs); | 237 cert_source_request->GetNext(&result_certs); |
| 233 ASSERT_EQ(1u, result_certs.size()); | 238 ASSERT_EQ(1u, result_certs.size()); |
| 234 ASSERT_EQ(result_certs.front()->der_cert(), intermediate_cert->der_cert()); | 239 ASSERT_EQ(result_certs.front()->der_cert(), intermediate_cert->der_cert()); |
| 235 | 240 |
| 236 cert_source_request->GetNext(&result_certs); | 241 cert_source_request->GetNext(&result_certs); |
| 237 EXPECT_EQ(1u, result_certs.size()); | 242 EXPECT_EQ(1u, result_certs.size()); |
| 238 } | 243 } |
| 239 | 244 |
| 240 // TODO(eroman): Re-enable these tests! | 245 // TODO(eroman): Re-enable these tests! |
| 241 #if 0 | 246 #if 0 |
| 242 // AuthorityInfoAccess with two URIs, one is invalid, the other HTTP. | 247 // AuthorityInfoAccess with two URIs, one is invalid, the other HTTP. |
| 243 TEST(CertIssuerSourceAiaTest, OneInvalidOneHttpAia) { | 248 TEST(CertIssuerSourceAiaTest, OneInvalidOneHttpAia) { |
| 244 scoped_refptr<ParsedCertificate> cert; | 249 scoped_refptr<ParsedCertificate> cert; |
| 245 ASSERT_TRUE(ReadTestCert("target_invalid_and_http_aia.pem", &cert)); | 250 ASSERT_TRUE(ReadTestCert("target_invalid_and_http_aia.pem", &cert)); |
| 246 scoped_refptr<ParsedCertificate> intermediate_cert; | 251 scoped_refptr<ParsedCertificate> intermediate_cert; |
| 247 ASSERT_TRUE(ReadTestCert("i2.pem", &intermediate_cert)); | 252 ASSERT_TRUE(ReadTestCert("i2.pem", &intermediate_cert)); |
| 248 | 253 |
| 249 StrictMock<MockIssuerCallback> mock_callback; | 254 StrictMock<MockIssuerCallback> mock_callback; |
| 250 StrictMock<MockCertNetFetcherImpl> mock_fetcher; | 255 scoped_refptr<StrictMock<MockCertNetFetcherImpl>> mock_fetcher( |
| 251 CertIssuerSourceAia aia_source(&mock_fetcher); | 256 new StrictMock<MockCertNetFetcherImpl>()); |
| 257 CertIssuerSourceAia aia_source(mock_fetcher); |
| 252 std::unique_ptr<CertIssuerSource::Request> cert_source_request; | 258 std::unique_ptr<CertIssuerSource::Request> cert_source_request; |
| 253 aia_source.AsyncGetIssuersOf(cert.get(), | 259 aia_source.AsyncGetIssuersOf(cert.get(), |
| 254 base::Bind(&MockIssuerCallback::Callback, | 260 base::Bind(&MockIssuerCallback::Callback, |
| 255 base::Unretained(&mock_callback)), | 261 base::Unretained(&mock_callback)), |
| 256 &cert_source_request); | 262 &cert_source_request); |
| 257 ASSERT_NE(nullptr, cert_source_request); | 263 ASSERT_NE(nullptr, cert_source_request); |
| 258 | 264 |
| 259 RequestManager* req_manager = | 265 RequestManager* req_manager = |
| 260 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia2/I2.foo")); | 266 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia2/I2.foo")); |
| 261 ASSERT_TRUE(req_manager); | 267 ASSERT_TRUE(req_manager); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 285 // and the results are retrieved. | 291 // and the results are retrieved. |
| 286 TEST(CertIssuerSourceAiaTest, TwoAiaCompletedInSeries) { | 292 TEST(CertIssuerSourceAiaTest, TwoAiaCompletedInSeries) { |
| 287 scoped_refptr<ParsedCertificate> cert; | 293 scoped_refptr<ParsedCertificate> cert; |
| 288 ASSERT_TRUE(ReadTestCert("target_two_aia.pem", &cert)); | 294 ASSERT_TRUE(ReadTestCert("target_two_aia.pem", &cert)); |
| 289 scoped_refptr<ParsedCertificate> intermediate_cert; | 295 scoped_refptr<ParsedCertificate> intermediate_cert; |
| 290 ASSERT_TRUE(ReadTestCert("i.pem", &intermediate_cert)); | 296 ASSERT_TRUE(ReadTestCert("i.pem", &intermediate_cert)); |
| 291 scoped_refptr<ParsedCertificate> intermediate_cert2; | 297 scoped_refptr<ParsedCertificate> intermediate_cert2; |
| 292 ASSERT_TRUE(ReadTestCert("i2.pem", &intermediate_cert2)); | 298 ASSERT_TRUE(ReadTestCert("i2.pem", &intermediate_cert2)); |
| 293 | 299 |
| 294 StrictMock<MockIssuerCallback> mock_callback; | 300 StrictMock<MockIssuerCallback> mock_callback; |
| 295 StrictMock<MockCertNetFetcherImpl> mock_fetcher; | 301 scoped_refptr<StrictMock<MockCertNetFetcherImpl>> mock_fetcher( |
| 296 CertIssuerSourceAia aia_source(&mock_fetcher); | 302 new StrictMock<MockCertNetFetcherImpl>()); |
| 303 CertIssuerSourceAia aia_source(mock_fetcher); |
| 297 std::unique_ptr<CertIssuerSource::Request> cert_source_request; | 304 std::unique_ptr<CertIssuerSource::Request> cert_source_request; |
| 298 aia_source.AsyncGetIssuersOf(cert.get(), | 305 aia_source.AsyncGetIssuersOf(cert.get(), |
| 299 base::Bind(&MockIssuerCallback::Callback, | 306 base::Bind(&MockIssuerCallback::Callback, |
| 300 base::Unretained(&mock_callback)), | 307 base::Unretained(&mock_callback)), |
| 301 &cert_source_request); | 308 &cert_source_request); |
| 302 ASSERT_NE(nullptr, cert_source_request); | 309 ASSERT_NE(nullptr, cert_source_request); |
| 303 | 310 |
| 304 RequestManager* req_manager = | 311 RequestManager* req_manager = |
| 305 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia/I.cer")); | 312 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia/I.cer")); |
| 306 ASSERT_TRUE(req_manager); | 313 ASSERT_TRUE(req_manager); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 // supplied to the caller in the same batch. | 368 // supplied to the caller in the same batch. |
| 362 TEST(CertIssuerSourceAiaTest, TwoAiaCompletedBeforeGetNext) { | 369 TEST(CertIssuerSourceAiaTest, TwoAiaCompletedBeforeGetNext) { |
| 363 scoped_refptr<ParsedCertificate> cert; | 370 scoped_refptr<ParsedCertificate> cert; |
| 364 ASSERT_TRUE(ReadTestCert("target_two_aia.pem", &cert)); | 371 ASSERT_TRUE(ReadTestCert("target_two_aia.pem", &cert)); |
| 365 scoped_refptr<ParsedCertificate> intermediate_cert; | 372 scoped_refptr<ParsedCertificate> intermediate_cert; |
| 366 ASSERT_TRUE(ReadTestCert("i.pem", &intermediate_cert)); | 373 ASSERT_TRUE(ReadTestCert("i.pem", &intermediate_cert)); |
| 367 scoped_refptr<ParsedCertificate> intermediate_cert2; | 374 scoped_refptr<ParsedCertificate> intermediate_cert2; |
| 368 ASSERT_TRUE(ReadTestCert("i2.pem", &intermediate_cert2)); | 375 ASSERT_TRUE(ReadTestCert("i2.pem", &intermediate_cert2)); |
| 369 | 376 |
| 370 StrictMock<MockIssuerCallback> mock_callback; | 377 StrictMock<MockIssuerCallback> mock_callback; |
| 371 StrictMock<MockCertNetFetcherImpl> mock_fetcher; | 378 scoped_refptr<StrictMock<MockCertNetFetcherImpl>> mock_fetcher( |
| 372 CertIssuerSourceAia aia_source(&mock_fetcher); | 379 new StrictMock<MockCertNetFetcherImpl>()); |
| 380 CertIssuerSourceAia aia_source(mock_fetcher); |
| 373 std::unique_ptr<CertIssuerSource::Request> cert_source_request; | 381 std::unique_ptr<CertIssuerSource::Request> cert_source_request; |
| 374 aia_source.AsyncGetIssuersOf(cert.get(), | 382 aia_source.AsyncGetIssuersOf(cert.get(), |
| 375 base::Bind(&MockIssuerCallback::Callback, | 383 base::Bind(&MockIssuerCallback::Callback, |
| 376 base::Unretained(&mock_callback)), | 384 base::Unretained(&mock_callback)), |
| 377 &cert_source_request); | 385 &cert_source_request); |
| 378 ASSERT_NE(nullptr, cert_source_request); | 386 ASSERT_NE(nullptr, cert_source_request); |
| 379 | 387 |
| 380 RequestManager* req_manager = | 388 RequestManager* req_manager = |
| 381 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia/I.cer")); | 389 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia/I.cer")); |
| 382 ASSERT_TRUE(req_manager); | 390 ASSERT_TRUE(req_manager); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 scoped_refptr<ParsedCertificate> cert; | 441 scoped_refptr<ParsedCertificate> cert; |
| 434 ASSERT_TRUE(ReadTestCert("target_three_aia.pem", &cert)); | 442 ASSERT_TRUE(ReadTestCert("target_three_aia.pem", &cert)); |
| 435 scoped_refptr<ParsedCertificate> intermediate_cert; | 443 scoped_refptr<ParsedCertificate> intermediate_cert; |
| 436 ASSERT_TRUE(ReadTestCert("i.pem", &intermediate_cert)); | 444 ASSERT_TRUE(ReadTestCert("i.pem", &intermediate_cert)); |
| 437 scoped_refptr<ParsedCertificate> intermediate_cert2; | 445 scoped_refptr<ParsedCertificate> intermediate_cert2; |
| 438 ASSERT_TRUE(ReadTestCert("i2.pem", &intermediate_cert2)); | 446 ASSERT_TRUE(ReadTestCert("i2.pem", &intermediate_cert2)); |
| 439 scoped_refptr<ParsedCertificate> intermediate_cert3; | 447 scoped_refptr<ParsedCertificate> intermediate_cert3; |
| 440 ASSERT_TRUE(ReadTestCert("i3.pem", &intermediate_cert3)); | 448 ASSERT_TRUE(ReadTestCert("i3.pem", &intermediate_cert3)); |
| 441 | 449 |
| 442 StrictMock<MockIssuerCallback> mock_callback; | 450 StrictMock<MockIssuerCallback> mock_callback; |
| 443 StrictMock<MockCertNetFetcherImpl> mock_fetcher; | 451 scoped_refptr<StrictMock<MockCertNetFetcherImpl>> mock_fetcher( |
| 444 CertIssuerSourceAia aia_source(&mock_fetcher); | 452 new StrictMock<MockCertNetFetcherImpl>()); |
| 453 CertIssuerSourceAia aia_source(mock_fetcher); |
| 445 std::unique_ptr<CertIssuerSource::Request> cert_source_request; | 454 std::unique_ptr<CertIssuerSource::Request> cert_source_request; |
| 446 aia_source.AsyncGetIssuersOf(cert.get(), | 455 aia_source.AsyncGetIssuersOf(cert.get(), |
| 447 base::Bind(&MockIssuerCallback::Callback, | 456 base::Bind(&MockIssuerCallback::Callback, |
| 448 base::Unretained(&mock_callback)), | 457 base::Unretained(&mock_callback)), |
| 449 &cert_source_request); | 458 &cert_source_request); |
| 450 ASSERT_NE(nullptr, cert_source_request); | 459 ASSERT_NE(nullptr, cert_source_request); |
| 451 | 460 |
| 452 RequestManager* req_manager = | 461 RequestManager* req_manager = |
| 453 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia/I.cer")); | 462 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia/I.cer")); |
| 454 ASSERT_TRUE(req_manager); | 463 ASSERT_TRUE(req_manager); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 } | 518 } |
| 510 | 519 |
| 511 // AuthorityInfoAccess with a single HTTP url pointing to a single DER cert, | 520 // AuthorityInfoAccess with a single HTTP url pointing to a single DER cert, |
| 512 // CertNetFetcher request fails. The callback should be called to indicate the | 521 // CertNetFetcher request fails. The callback should be called to indicate the |
| 513 // request is complete, but no results should be provided. | 522 // request is complete, but no results should be provided. |
| 514 TEST(CertIssuerSourceAiaTest, OneAiaHttpError) { | 523 TEST(CertIssuerSourceAiaTest, OneAiaHttpError) { |
| 515 scoped_refptr<ParsedCertificate> cert; | 524 scoped_refptr<ParsedCertificate> cert; |
| 516 ASSERT_TRUE(ReadTestCert("target_one_aia.pem", &cert)); | 525 ASSERT_TRUE(ReadTestCert("target_one_aia.pem", &cert)); |
| 517 | 526 |
| 518 StrictMock<MockIssuerCallback> mock_callback; | 527 StrictMock<MockIssuerCallback> mock_callback; |
| 519 StrictMock<MockCertNetFetcherImpl> mock_fetcher; | 528 scoped_refptr<StrictMock<MockCertNetFetcherImpl>> mock_fetcher( |
| 520 CertIssuerSourceAia aia_source(&mock_fetcher); | 529 new StrictMock<MockCertNetFetcherImpl>()); |
| 530 CertIssuerSourceAia aia_source(mock_fetcher); |
| 521 std::unique_ptr<CertIssuerSource::Request> cert_source_request; | 531 std::unique_ptr<CertIssuerSource::Request> cert_source_request; |
| 522 aia_source.AsyncGetIssuersOf(cert.get(), | 532 aia_source.AsyncGetIssuersOf(cert.get(), |
| 523 base::Bind(&MockIssuerCallback::Callback, | 533 base::Bind(&MockIssuerCallback::Callback, |
| 524 base::Unretained(&mock_callback)), | 534 base::Unretained(&mock_callback)), |
| 525 &cert_source_request); | 535 &cert_source_request); |
| 526 ASSERT_NE(nullptr, cert_source_request); | 536 ASSERT_NE(nullptr, cert_source_request); |
| 527 | 537 |
| 528 RequestManager* req_manager = | 538 RequestManager* req_manager = |
| 529 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia/I.cer")); | 539 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia/I.cer")); |
| 530 ASSERT_TRUE(req_manager); | 540 ASSERT_TRUE(req_manager); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 543 | 553 |
| 544 // AuthorityInfoAccess with a single HTTP url pointing to a single DER cert, | 554 // AuthorityInfoAccess with a single HTTP url pointing to a single DER cert, |
| 545 // CertNetFetcher request completes, but the DER cert fails to parse. The | 555 // CertNetFetcher request completes, but the DER cert fails to parse. The |
| 546 // callback should be called to indicate the request is complete, but no results | 556 // callback should be called to indicate the request is complete, but no results |
| 547 // should be provided. | 557 // should be provided. |
| 548 TEST(CertIssuerSourceAiaTest, OneAiaParseError) { | 558 TEST(CertIssuerSourceAiaTest, OneAiaParseError) { |
| 549 scoped_refptr<ParsedCertificate> cert; | 559 scoped_refptr<ParsedCertificate> cert; |
| 550 ASSERT_TRUE(ReadTestCert("target_one_aia.pem", &cert)); | 560 ASSERT_TRUE(ReadTestCert("target_one_aia.pem", &cert)); |
| 551 | 561 |
| 552 StrictMock<MockIssuerCallback> mock_callback; | 562 StrictMock<MockIssuerCallback> mock_callback; |
| 553 StrictMock<MockCertNetFetcherImpl> mock_fetcher; | 563 scoped_refptr<StrictMock<MockCertNetFetcherImpl>> mock_fetcher( |
| 554 CertIssuerSourceAia aia_source(&mock_fetcher); | 564 new StrictMock<MockCertNetFetcherImpl>()); |
| 565 CertIssuerSourceAia aia_source(mock_fetcher); |
| 555 std::unique_ptr<CertIssuerSource::Request> cert_source_request; | 566 std::unique_ptr<CertIssuerSource::Request> cert_source_request; |
| 556 aia_source.AsyncGetIssuersOf(cert.get(), | 567 aia_source.AsyncGetIssuersOf(cert.get(), |
| 557 base::Bind(&MockIssuerCallback::Callback, | 568 base::Bind(&MockIssuerCallback::Callback, |
| 558 base::Unretained(&mock_callback)), | 569 base::Unretained(&mock_callback)), |
| 559 &cert_source_request); | 570 &cert_source_request); |
| 560 ASSERT_NE(nullptr, cert_source_request); | 571 ASSERT_NE(nullptr, cert_source_request); |
| 561 | 572 |
| 562 RequestManager* req_manager = | 573 RequestManager* req_manager = |
| 563 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia/I.cer")); | 574 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia/I.cer")); |
| 564 ASSERT_TRUE(req_manager); | 575 ASSERT_TRUE(req_manager); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 578 // AuthorityInfoAccess with two HTTP urls, each pointing to a single DER cert. | 589 // AuthorityInfoAccess with two HTTP urls, each pointing to a single DER cert. |
| 579 // One request fails. No callback should be generated yet. Once the second | 590 // One request fails. No callback should be generated yet. Once the second |
| 580 // request completes, the callback should occur. | 591 // request completes, the callback should occur. |
| 581 TEST(CertIssuerSourceAiaTest, TwoAiaCompletedInSeriesFirstFails) { | 592 TEST(CertIssuerSourceAiaTest, TwoAiaCompletedInSeriesFirstFails) { |
| 582 scoped_refptr<ParsedCertificate> cert; | 593 scoped_refptr<ParsedCertificate> cert; |
| 583 ASSERT_TRUE(ReadTestCert("target_two_aia.pem", &cert)); | 594 ASSERT_TRUE(ReadTestCert("target_two_aia.pem", &cert)); |
| 584 scoped_refptr<ParsedCertificate> intermediate_cert2; | 595 scoped_refptr<ParsedCertificate> intermediate_cert2; |
| 585 ASSERT_TRUE(ReadTestCert("i2.pem", &intermediate_cert2)); | 596 ASSERT_TRUE(ReadTestCert("i2.pem", &intermediate_cert2)); |
| 586 | 597 |
| 587 StrictMock<MockIssuerCallback> mock_callback; | 598 StrictMock<MockIssuerCallback> mock_callback; |
| 588 StrictMock<MockCertNetFetcherImpl> mock_fetcher; | 599 scoped_refptr<StrictMock<MockCertNetFetcherImpl>> mock_fetcher( |
| 589 CertIssuerSourceAia aia_source(&mock_fetcher); | 600 new StrictMock<MockCertNetFetcherImpl>()); |
| 601 CertIssuerSourceAia aia_source(mock_fetcher); |
| 590 std::unique_ptr<CertIssuerSource::Request> cert_source_request; | 602 std::unique_ptr<CertIssuerSource::Request> cert_source_request; |
| 591 aia_source.AsyncGetIssuersOf(cert.get(), | 603 aia_source.AsyncGetIssuersOf(cert.get(), |
| 592 base::Bind(&MockIssuerCallback::Callback, | 604 base::Bind(&MockIssuerCallback::Callback, |
| 593 base::Unretained(&mock_callback)), | 605 base::Unretained(&mock_callback)), |
| 594 &cert_source_request); | 606 &cert_source_request); |
| 595 ASSERT_NE(nullptr, cert_source_request); | 607 ASSERT_NE(nullptr, cert_source_request); |
| 596 | 608 |
| 597 RequestManager* req_manager = | 609 RequestManager* req_manager = |
| 598 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia/I.cer")); | 610 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia/I.cer")); |
| 599 ASSERT_TRUE(req_manager); | 611 ASSERT_TRUE(req_manager); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 // First request completes, result is retrieved, then the second request fails. | 644 // First request completes, result is retrieved, then the second request fails. |
| 633 // The second callback should occur to indicate that the results are exhausted, | 645 // The second callback should occur to indicate that the results are exhausted, |
| 634 // even though no more results are available. | 646 // even though no more results are available. |
| 635 TEST(CertIssuerSourceAiaTest, TwoAiaCompletedInSeriesSecondFails) { | 647 TEST(CertIssuerSourceAiaTest, TwoAiaCompletedInSeriesSecondFails) { |
| 636 scoped_refptr<ParsedCertificate> cert; | 648 scoped_refptr<ParsedCertificate> cert; |
| 637 ASSERT_TRUE(ReadTestCert("target_two_aia.pem", &cert)); | 649 ASSERT_TRUE(ReadTestCert("target_two_aia.pem", &cert)); |
| 638 scoped_refptr<ParsedCertificate> intermediate_cert; | 650 scoped_refptr<ParsedCertificate> intermediate_cert; |
| 639 ASSERT_TRUE(ReadTestCert("i.pem", &intermediate_cert)); | 651 ASSERT_TRUE(ReadTestCert("i.pem", &intermediate_cert)); |
| 640 | 652 |
| 641 StrictMock<MockIssuerCallback> mock_callback; | 653 StrictMock<MockIssuerCallback> mock_callback; |
| 642 StrictMock<MockCertNetFetcherImpl> mock_fetcher; | 654 scoped_refptr<StrictMock<MockCertNetFetcherImpl>> mock_fetcher( |
| 643 CertIssuerSourceAia aia_source(&mock_fetcher); | 655 new StrictMock<MockCertNetFetcherImpl>()); |
| 656 CertIssuerSourceAia aia_source(mock_fetcher); |
| 644 std::unique_ptr<CertIssuerSource::Request> cert_source_request; | 657 std::unique_ptr<CertIssuerSource::Request> cert_source_request; |
| 645 aia_source.AsyncGetIssuersOf(cert.get(), | 658 aia_source.AsyncGetIssuersOf(cert.get(), |
| 646 base::Bind(&MockIssuerCallback::Callback, | 659 base::Bind(&MockIssuerCallback::Callback, |
| 647 base::Unretained(&mock_callback)), | 660 base::Unretained(&mock_callback)), |
| 648 &cert_source_request); | 661 &cert_source_request); |
| 649 ASSERT_NE(nullptr, cert_source_request); | 662 ASSERT_NE(nullptr, cert_source_request); |
| 650 | 663 |
| 651 RequestManager* req_manager = | 664 RequestManager* req_manager = |
| 652 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia/I.cer")); | 665 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia/I.cer")); |
| 653 ASSERT_TRUE(req_manager); | 666 ASSERT_TRUE(req_manager); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 EXPECT_FALSE(result_cert.get()); | 703 EXPECT_FALSE(result_cert.get()); |
| 691 } | 704 } |
| 692 | 705 |
| 693 // AuthorityInfoAccess with two HTTP urls. Request is cancelled before any HTTP | 706 // AuthorityInfoAccess with two HTTP urls. Request is cancelled before any HTTP |
| 694 // requests finish. | 707 // requests finish. |
| 695 TEST(CertIssuerSourceAiaTest, CertSourceRequestCancelled) { | 708 TEST(CertIssuerSourceAiaTest, CertSourceRequestCancelled) { |
| 696 scoped_refptr<ParsedCertificate> cert; | 709 scoped_refptr<ParsedCertificate> cert; |
| 697 ASSERT_TRUE(ReadTestCert("target_two_aia.pem", &cert)); | 710 ASSERT_TRUE(ReadTestCert("target_two_aia.pem", &cert)); |
| 698 | 711 |
| 699 StrictMock<MockIssuerCallback> mock_callback; | 712 StrictMock<MockIssuerCallback> mock_callback; |
| 700 StrictMock<MockCertNetFetcherImpl> mock_fetcher; | 713 scoped_refptr<StrictMock<MockCertNetFetcherImpl>> mock_fetcher( |
| 701 CertIssuerSourceAia aia_source(&mock_fetcher); | 714 new StrictMock<MockCertNetFetcherImpl>()); |
| 715 CertIssuerSourceAia aia_source(mock_fetcher); |
| 702 std::unique_ptr<CertIssuerSource::Request> cert_source_request; | 716 std::unique_ptr<CertIssuerSource::Request> cert_source_request; |
| 703 aia_source.AsyncGetIssuersOf(cert.get(), | 717 aia_source.AsyncGetIssuersOf(cert.get(), |
| 704 base::Bind(&MockIssuerCallback::Callback, | 718 base::Bind(&MockIssuerCallback::Callback, |
| 705 base::Unretained(&mock_callback)), | 719 base::Unretained(&mock_callback)), |
| 706 &cert_source_request); | 720 &cert_source_request); |
| 707 ASSERT_NE(nullptr, cert_source_request); | 721 ASSERT_NE(nullptr, cert_source_request); |
| 708 | 722 |
| 709 RequestManager* req_manager = | 723 RequestManager* req_manager = |
| 710 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia/I.cer")); | 724 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia/I.cer")); |
| 711 ASSERT_TRUE(req_manager); | 725 ASSERT_TRUE(req_manager); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 726 // AuthorityInfoAccess with two HTTP urls, each pointing to a single DER cert. | 740 // AuthorityInfoAccess with two HTTP urls, each pointing to a single DER cert. |
| 727 // One request completes, results are retrieved, then request is cancelled | 741 // One request completes, results are retrieved, then request is cancelled |
| 728 // before the second HTTP request completes. | 742 // before the second HTTP request completes. |
| 729 TEST(CertIssuerSourceAiaTest, TwoAiaOneCompletedThenRequestCancelled) { | 743 TEST(CertIssuerSourceAiaTest, TwoAiaOneCompletedThenRequestCancelled) { |
| 730 scoped_refptr<ParsedCertificate> cert; | 744 scoped_refptr<ParsedCertificate> cert; |
| 731 ASSERT_TRUE(ReadTestCert("target_two_aia.pem", &cert)); | 745 ASSERT_TRUE(ReadTestCert("target_two_aia.pem", &cert)); |
| 732 scoped_refptr<ParsedCertificate> intermediate_cert; | 746 scoped_refptr<ParsedCertificate> intermediate_cert; |
| 733 ASSERT_TRUE(ReadTestCert("i.pem", &intermediate_cert)); | 747 ASSERT_TRUE(ReadTestCert("i.pem", &intermediate_cert)); |
| 734 | 748 |
| 735 StrictMock<MockIssuerCallback> mock_callback; | 749 StrictMock<MockIssuerCallback> mock_callback; |
| 736 StrictMock<MockCertNetFetcherImpl> mock_fetcher; | 750 scoped_refptr<StrictMock<MockCertNetFetcherImpl>> mock_fetcher( |
| 737 CertIssuerSourceAia aia_source(&mock_fetcher); | 751 new StrictMock<MockCertNetFetcherImpl>()); |
| 752 CertIssuerSourceAia aia_source(mock_fetcher); |
| 738 std::unique_ptr<CertIssuerSource::Request> cert_source_request; | 753 std::unique_ptr<CertIssuerSource::Request> cert_source_request; |
| 739 aia_source.AsyncGetIssuersOf(cert.get(), | 754 aia_source.AsyncGetIssuersOf(cert.get(), |
| 740 base::Bind(&MockIssuerCallback::Callback, | 755 base::Bind(&MockIssuerCallback::Callback, |
| 741 base::Unretained(&mock_callback)), | 756 base::Unretained(&mock_callback)), |
| 742 &cert_source_request); | 757 &cert_source_request); |
| 743 ASSERT_NE(nullptr, cert_source_request); | 758 ASSERT_NE(nullptr, cert_source_request); |
| 744 | 759 |
| 745 RequestManager* req_manager = | 760 RequestManager* req_manager = |
| 746 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia/I.cer")); | 761 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia/I.cer")); |
| 747 ASSERT_TRUE(req_manager); | 762 ASSERT_TRUE(req_manager); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 777 EXPECT_FALSE(req_manager2->is_request_alive()); | 792 EXPECT_FALSE(req_manager2->is_request_alive()); |
| 778 } | 793 } |
| 779 | 794 |
| 780 // AuthorityInfoAccess with six HTTP URLs. kMaxFetchesPerCert is 5, so the | 795 // AuthorityInfoAccess with six HTTP URLs. kMaxFetchesPerCert is 5, so the |
| 781 // sixth URL should be ignored. | 796 // sixth URL should be ignored. |
| 782 TEST(CertIssuerSourceAiaTest, MaxFetchesPerCert) { | 797 TEST(CertIssuerSourceAiaTest, MaxFetchesPerCert) { |
| 783 scoped_refptr<ParsedCertificate> cert; | 798 scoped_refptr<ParsedCertificate> cert; |
| 784 ASSERT_TRUE(ReadTestCert("target_six_aia.pem", &cert)); | 799 ASSERT_TRUE(ReadTestCert("target_six_aia.pem", &cert)); |
| 785 | 800 |
| 786 StrictMock<MockIssuerCallback> mock_callback; | 801 StrictMock<MockIssuerCallback> mock_callback; |
| 787 StrictMock<MockCertNetFetcherImpl> mock_fetcher; | 802 scoped_refptr<StrictMock<MockCertNetFetcherImpl>> mock_fetcher( |
| 788 CertIssuerSourceAia aia_source(&mock_fetcher); | 803 new StrictMock<MockCertNetFetcherImpl>()); |
| 804 CertIssuerSourceAia aia_source(mock_fetcher); |
| 789 std::unique_ptr<CertIssuerSource::Request> cert_source_request; | 805 std::unique_ptr<CertIssuerSource::Request> cert_source_request; |
| 790 aia_source.AsyncGetIssuersOf(cert.get(), | 806 aia_source.AsyncGetIssuersOf(cert.get(), |
| 791 base::Bind(&MockIssuerCallback::Callback, | 807 base::Bind(&MockIssuerCallback::Callback, |
| 792 base::Unretained(&mock_callback)), | 808 base::Unretained(&mock_callback)), |
| 793 &cert_source_request); | 809 &cert_source_request); |
| 794 ASSERT_NE(nullptr, cert_source_request); | 810 ASSERT_NE(nullptr, cert_source_request); |
| 795 | 811 |
| 796 RequestManager* req_manager = | 812 RequestManager* req_manager = |
| 797 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia/I.cer")); | 813 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia/I.cer")); |
| 798 ASSERT_TRUE(req_manager); | 814 ASSERT_TRUE(req_manager); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 821 // Sixth URL should not have created a request. | 837 // Sixth URL should not have created a request. |
| 822 EXPECT_FALSE( | 838 EXPECT_FALSE( |
| 823 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia6/I6.foo"))); | 839 mock_fetcher.GetRequestManagerForURL(GURL("http://url-for-aia6/I6.foo"))); |
| 824 } | 840 } |
| 825 | 841 |
| 826 #endif | 842 #endif |
| 827 | 843 |
| 828 } // namespace | 844 } // namespace |
| 829 | 845 |
| 830 } // namespace net | 846 } // namespace net |
| OLD | NEW |