src/net/cert/multi_threaded_cert_verifier_unittest.cc
TEST_F(MultiThreadedCertVerifierTest, CancelRequest) {
  base::FilePath certs_dir = GetTestCertsDirectory();
  scoped_refptr<X509Certificate> test_cert(
      ImportCertFromFile(certs_dir, "ok_cert.pem"));
  ASSERT_NE(static_cast<X509Certificate*>(nullptr), test_cert.get());

  int error;
  CertVerifyResult verify_result;
  std::unique_ptr<CertVerifier::Request> request;

  error = verifier_->Verify(
      CertVerifier::RequestParams(test_cert, "www.example.com", 0,
                                  /*ocsp_response=*/std::string(),
                                  /*sct_list=*/std::string()),
      &verify_result, base::BindOnce(&FailTest), &request, NetLogWithSource());
  ASSERT_THAT(error, IsError(ERR_IO_PENDING));
  ASSERT_TRUE(request);
  request.reset();

  // Issue a few more requests to the worker pool and wait for their
  // completion, so that the task of the canceled request (which runs on a
  // worker thread) is likely to complete by the end of this test.
  TestCompletionCallback callback;
  for (int i = 0; i < 5; ++i) {
    error = verifier_->Verify(
        CertVerifier::RequestParams(test_cert, "www2.example.com", 0,
                                    /*ocsp_response=*/std::string(),
                                    /*sct_list=*/std::string()),
        &verify_result, callback.callback(), &request, NetLogWithSource());
    ASSERT_THAT(error, IsError(ERR_IO_PENDING));
    EXPECT_TRUE(request);
    error = callback.WaitForResult();
  }
}
// Tests that the callback of a canceled request is never made.
Tests that the callback of a canceled request is never made.
Tests that the callback of a canceled request is never made .
TEST_F(MultiThreadedCertVerifierTest, CancelRequest) {
  base::FilePath certs_dir = GetTestCertsDirectory();
  scoped_refptr<X509Certificate> test_cert(
      ImportCertFromFile(certs_dir, "ok_cert.pem"));
  ASSERT_NE(static_cast<X509Certificate*>(nullptr), test_cert.get());
  int error;
  CertVerifyResult verify_result;
  std::unique_ptr<CertVerifier::Request> request;
  error = verifier_->Verify(
      CertVerifier::RequestParams(test_cert, "www.example.com", 0,
                                  std::string(),
                                  std::string()),
      &verify_result, base::BindOnce(&FailTest), &request, NetLogWithSource());
  ASSERT_THAT(error, IsError(ERR_IO_PENDING));
  ASSERT_TRUE(request);
  request.reset();
  TestCompletionCallback callback;
  for (int i = 0; i < 5; ++i) {
    error = verifier_->Verify(
        CertVerifier::RequestParams(test_cert, "www2.example.com", 0,
                                    std::string(),
                                    std::string()),
        &verify_result, callback.callback(), &request, NetLogWithSource());
    ASSERT_THAT(error, IsError(ERR_IO_PENDING));
    EXPECT_TRUE(request);
    error = callback.WaitForResult();
  }
}
TEST_F ( MultiThreadedCertVerifierTest , CancelRequest ) { base :: FilePath certs_dir = GetTestCertsDirectory ( ) ; scoped_refptr < X509Certificate > test_cert ( ImportCertFromFile ( certs_dir , " " ) ) ; ASSERT_NE ( static_cast < X509Certificate * > ( nullptr ) , test_cert . get ( ) ) ; int error ; CertVerifyResult verify_result ; std :: unique_ptr < CertVerifier :: Request > request ; error = verifier_ -> Verify ( CertVerifier :: RequestParams ( test_cert , " " , 0 , std :: string ( ) , std :: string ( ) ) , & verify_result , base :: BindOnce ( & FailTest ) , & request , NetLogWithSource ( ) ) ; ASSERT_THAT ( error , IsError ( ERR_IO_PENDING ) ) ; ASSERT_TRUE ( request ) ; request . reset ( ) ; TestCompletionCallback callback ; for ( int i = 0 ; i < 5 ; ++ i ) { error = verifier_ -> Verify ( CertVerifier :: RequestParams ( test_cert , " " , 0 , std :: string ( ) , std :: string ( ) ) , & verify_result , callback . callback ( ) , & request , NetLogWithSource ( ) ) ; ASSERT_THAT ( error , IsError ( ERR_IO_PENDING ) ) ; EXPECT_TRUE ( request ) ; error = callback . WaitForResult ( ) ; } }
Tests that the callback of a canceled request is never made.
Tests that the callback of a canceled request is never made .
/*ocsp_response=*/ /*sct_list=*/ // Issue a few more requests to the worker pool and wait for their // completion, so that the task of the canceled request (which runs on a // worker thread) is likely to complete by the end of this test. /*ocsp_response=*/ /*sct_list=*/