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

  auto mock_fetcher = base::MakeRefCounted<StrictMock<MockCertNetFetcher>>();

  EXPECT_CALL(*mock_fetcher,
              FetchCaIssuers(GURL("http://url-for-aia/I.cer"), _, _))
      .WillOnce(Return(
          ByMove(CreateMockRequest(CertDataVector(intermediate_cert.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());
  ASSERT_EQ(result_certs.front()->der_cert(), intermediate_cert->der_cert());

  result_certs.clear();
  cert_source_request->GetNext(&result_certs);
  EXPECT_TRUE(result_certs.empty());
}
// AuthorityInfoAccess with a single HTTP url pointing to a single DER cert.
AuthorityInfoAccess with a single HTTP url pointing to a single DER cert.
AuthorityInfoAccess with a single HTTP url pointing to a single DER cert .
TEST(CertIssuerSourceAiaTest, OneAia) {
  scoped_refptr<ParsedCertificate> cert;
  ASSERT_TRUE(ReadTestCert("target_one_aia.pem", &cert));
  scoped_refptr<ParsedCertificate> intermediate_cert;
  ASSERT_TRUE(ReadTestCert("i.pem", &intermediate_cert));
  auto mock_fetcher = base::MakeRefCounted<StrictMock<MockCertNetFetcher>>();
  EXPECT_CALL(*mock_fetcher,
              FetchCaIssuers(GURL("http://url-for-aia/I.cer"), _, _))
      .WillOnce(Return(
          ByMove(CreateMockRequest(CertDataVector(intermediate_cert.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());
  ASSERT_EQ(result_certs.front()->der_cert(), intermediate_cert->der_cert());
  result_certs.clear();
  cert_source_request->GetNext(&result_certs);
  EXPECT_TRUE(result_certs.empty());
}
TEST ( CertIssuerSourceAiaTest , OneAia ) { scoped_refptr < ParsedCertificate > cert ; ASSERT_TRUE ( ReadTestCert ( " " , & cert ) ) ; scoped_refptr < ParsedCertificate > intermediate_cert ; ASSERT_TRUE ( ReadTestCert ( " " , & intermediate_cert ) ) ; auto mock_fetcher = base :: MakeRefCounted < StrictMock < MockCertNetFetcher > > ( ) ; EXPECT_CALL ( * mock_fetcher , FetchCaIssuers ( GURL ( " " ) , _ , _ ) ) . WillOnce ( Return ( ByMove ( CreateMockRequest ( CertDataVector ( intermediate_cert . 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 ( ) ) ; ASSERT_EQ ( result_certs . front ( ) -> der_cert ( ) , intermediate_cert -> der_cert ( ) ) ; result_certs . clear ( ) ; cert_source_request -> GetNext ( & result_certs ) ; EXPECT_TRUE ( result_certs . empty ( ) ) ; }
AuthorityInfoAccess with a single HTTP url pointing to a single DER cert.
AuthorityInfoAccess with a single HTTP url pointing to a single DER cert .