src/net/cert/internal/cert_issuer_source_aia_unittest.cc
TEST(CertIssuerSourceAiaTest, TwoAiaCompletedInSeries) {
  scoped_refptr<ParsedCertificate> cert;
  ASSERT_TRUE(ReadTestCert("target_two_aia.pem", &cert));
  scoped_refptr<ParsedCertificate> intermediate_cert;
  ASSERT_TRUE(ReadTestCert("i.pem", &intermediate_cert));
  scoped_refptr<ParsedCertificate> intermediate_cert2;
  ASSERT_TRUE(ReadTestCert("i2.pem", &intermediate_cert2));

  scoped_refptr<StrictMock<MockCertNetFetcher>> mock_fetcher(
      new StrictMock<MockCertNetFetcher>());

  EXPECT_CALL(*mock_fetcher,
              FetchCaIssuers(GURL("http://url-for-aia/I.cer"), _, _))
      .WillOnce(Return(
          ByMove(CreateMockRequest(CertDataVector(intermediate_cert.get())))));

  EXPECT_CALL(*mock_fetcher,
              FetchCaIssuers(GURL("http://url-for-aia2/I2.foo"), _, _))
      .WillOnce(Return(
          ByMove(CreateMockRequest(CertDataVector(intermediate_cert2.get())))));

  CertIssuerSourceAia aia_source(mock_fetcher);
  std::unique_ptr<CertIssuerSource::Request> cert_source_request;
  aia_source.AsyncGetIssuersOf(cert.get(), &cert_source_request);
  ASSERT_NE(nullptr, cert_source_request);

  // GetNext() should return intermediate_cert followed by intermediate_cert2.
  // They are returned in two separate batches.
  ParsedCertificateList result_certs;
  cert_source_request->GetNext(&result_certs);
  ASSERT_EQ(1u, result_certs.size());
  EXPECT_EQ(result_certs.front()->der_cert(), intermediate_cert->der_cert());

  result_certs.clear();
  cert_source_request->GetNext(&result_certs);
  ASSERT_EQ(1u, result_certs.size());
  EXPECT_EQ(result_certs.front()->der_cert(), intermediate_cert2->der_cert());

  // No more results.
  result_certs.clear();
  cert_source_request->GetNext(&result_certs);
  EXPECT_EQ(0u, result_certs.size());
}
// AuthorityInfoAccess with two HTTP urls, each pointing to a single DER cert.
// One request completes, results are retrieved, then the next request completes
// and the results are retrieved.
AuthorityInfoAccess with two HTTP urls, each pointing to a single DER cert.
One request completes, results are retrieved, then the next request completes
and the results are retrieved.
AuthorityInfoAccess with two HTTP urls each pointing to a single DER cert . One request completes results are retrieved then the next request completes and the results are retrieved .
TEST(CertIssuerSourceAiaTest, TwoAiaCompletedInSeries) {
  scoped_refptr<ParsedCertificate> cert;
  ASSERT_TRUE(ReadTestCert("target_two_aia.pem", &cert));
  scoped_refptr<ParsedCertificate> intermediate_cert;
  ASSERT_TRUE(ReadTestCert("i.pem", &intermediate_cert));
  scoped_refptr<ParsedCertificate> intermediate_cert2;
  ASSERT_TRUE(ReadTestCert("i2.pem", &intermediate_cert2));
  scoped_refptr<StrictMock<MockCertNetFetcher>> mock_fetcher(
      new StrictMock<MockCertNetFetcher>());
  EXPECT_CALL(*mock_fetcher,
              FetchCaIssuers(GURL("http://url-for-aia/I.cer"), _, _))
      .WillOnce(Return(
          ByMove(CreateMockRequest(CertDataVector(intermediate_cert.get())))));
  EXPECT_CALL(*mock_fetcher,
              FetchCaIssuers(GURL("http://url-for-aia2/I2.foo"), _, _))
      .WillOnce(Return(
          ByMove(CreateMockRequest(CertDataVector(intermediate_cert2.get())))));
  CertIssuerSourceAia aia_source(mock_fetcher);
  std::unique_ptr<CertIssuerSource::Request> cert_source_request;
  aia_source.AsyncGetIssuersOf(cert.get(), &cert_source_request);
  ASSERT_NE(nullptr, cert_source_request);
  ParsedCertificateList result_certs;
  cert_source_request->GetNext(&result_certs);
  ASSERT_EQ(1u, result_certs.size());
  EXPECT_EQ(result_certs.front()->der_cert(), intermediate_cert->der_cert());
  result_certs.clear();
  cert_source_request->GetNext(&result_certs);
  ASSERT_EQ(1u, result_certs.size());
  EXPECT_EQ(result_certs.front()->der_cert(), intermediate_cert2->der_cert());
  result_certs.clear();
  cert_source_request->GetNext(&result_certs);
  EXPECT_EQ(0u, result_certs.size());
}
TEST ( CertIssuerSourceAiaTest , TwoAiaCompletedInSeries ) { scoped_refptr < ParsedCertificate > cert ; ASSERT_TRUE ( ReadTestCert ( " " , & cert ) ) ; scoped_refptr < ParsedCertificate > intermediate_cert ; ASSERT_TRUE ( ReadTestCert ( " " , & intermediate_cert ) ) ; scoped_refptr < ParsedCertificate > intermediate_cert2 ; ASSERT_TRUE ( ReadTestCert ( " " , & intermediate_cert2 ) ) ; scoped_refptr < StrictMock < MockCertNetFetcher > > mock_fetcher ( new StrictMock < MockCertNetFetcher > ( ) ) ; EXPECT_CALL ( * mock_fetcher , FetchCaIssuers ( GURL ( " " ) , _ , _ ) ) . WillOnce ( Return ( ByMove ( CreateMockRequest ( CertDataVector ( intermediate_cert . get ( ) ) ) ) ) ) ; EXPECT_CALL ( * mock_fetcher , FetchCaIssuers ( GURL ( " " ) , _ , _ ) ) . WillOnce ( Return ( ByMove ( CreateMockRequest ( CertDataVector ( intermediate_cert2 . get ( ) ) ) ) ) ) ; CertIssuerSourceAia aia_source ( mock_fetcher ) ; std :: unique_ptr < CertIssuerSource :: Request > cert_source_request ; aia_source . AsyncGetIssuersOf ( cert . get ( ) , & cert_source_request ) ; ASSERT_NE ( nullptr , cert_source_request ) ; ParsedCertificateList result_certs ; cert_source_request -> GetNext ( & result_certs ) ; ASSERT_EQ ( 1u , result_certs . size ( ) ) ; EXPECT_EQ ( result_certs . front ( ) -> der_cert ( ) , intermediate_cert -> der_cert ( ) ) ; result_certs . clear ( ) ; cert_source_request -> GetNext ( & result_certs ) ; ASSERT_EQ ( 1u , result_certs . size ( ) ) ; EXPECT_EQ ( result_certs . front ( ) -> der_cert ( ) , intermediate_cert2 -> der_cert ( ) ) ; result_certs . clear ( ) ; cert_source_request -> GetNext ( & result_certs ) ; EXPECT_EQ ( 0u , result_certs . size ( ) ) ; }
AuthorityInfoAccess with two HTTP urls, each pointing to a single DER cert.
AuthorityInfoAccess with two HTTP urls each pointing to a single DER cert .
// GetNext() should return intermediate_cert followed by intermediate_cert2. // They are returned in two separate batches. // No more results.