| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_net/nss_ocsp.h" | 5 #include "net/cert_net/nss_ocsp.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "net/base/net_errors.h" | 15 #include "net/base/net_errors.h" |
| 16 #include "net/base/test_completion_callback.h" | 16 #include "net/base/test_completion_callback.h" |
| 17 #include "net/cert/cert_status_flags.h" | 17 #include "net/cert/cert_status_flags.h" |
| 18 #include "net/cert/cert_verifier.h" | 18 #include "net/cert/cert_verifier.h" |
| 19 #include "net/cert/cert_verify_proc.h" | 19 #include "net/cert/cert_verify_proc.h" |
| 20 #include "net/cert/cert_verify_proc_nss.h" | 20 #include "net/cert/cert_verify_proc_nss.h" |
| 21 #include "net/cert/cert_verify_result.h" | 21 #include "net/cert/cert_verify_result.h" |
| 22 #include "net/cert/multi_threaded_cert_verifier.h" | 22 #include "net/cert/multi_threaded_cert_verifier.h" |
| 23 #include "net/cert/test_root_certs.h" | 23 #include "net/cert/test_root_certs.h" |
| 24 #include "net/cert/x509_certificate.h" | 24 #include "net/cert/x509_certificate.h" |
| 25 #include "net/test/cert_test_util.h" | 25 #include "net/test/cert_test_util.h" |
| 26 #include "net/test/gtest_util.h" |
| 26 #include "net/test/test_data_directory.h" | 27 #include "net/test/test_data_directory.h" |
| 27 #include "net/url_request/url_request_filter.h" | 28 #include "net/url_request/url_request_filter.h" |
| 28 #include "net/url_request/url_request_interceptor.h" | 29 #include "net/url_request/url_request_interceptor.h" |
| 29 #include "net/url_request/url_request_test_job.h" | 30 #include "net/url_request/url_request_test_job.h" |
| 30 #include "net/url_request/url_request_test_util.h" | 31 #include "net/url_request/url_request_test_util.h" |
| 32 #include "testing/gmock/include/gmock/gmock.h" |
| 31 #include "testing/gtest/include/gtest/gtest.h" | 33 #include "testing/gtest/include/gtest/gtest.h" |
| 32 | 34 |
| 35 using net::test::IsError; |
| 36 using net::test::IsOk; |
| 37 |
| 33 namespace net { | 38 namespace net { |
| 34 | 39 |
| 35 namespace { | 40 namespace { |
| 36 | 41 |
| 37 // Matches the caIssuers hostname from the generated certificate. | 42 // Matches the caIssuers hostname from the generated certificate. |
| 38 const char kAiaHost[] = "aia-test.invalid"; | 43 const char kAiaHost[] = "aia-test.invalid"; |
| 39 // Returning a single DER-encoded cert, so the mime-type must be | 44 // Returning a single DER-encoded cert, so the mime-type must be |
| 40 // application/pkix-cert per RFC 5280. | 45 // application/pkix-cert per RFC 5280. |
| 41 const char kAiaHeaders[] = "HTTP/1.1 200 OK\0" | 46 const char kAiaHeaders[] = "HTTP/1.1 200 OK\0" |
| 42 "Content-type: application/pkix-cert\0" | 47 "Content-type: application/pkix-cert\0" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 CertVerifyResult verify_result; | 146 CertVerifyResult verify_result; |
| 142 TestCompletionCallback test_callback; | 147 TestCompletionCallback test_callback; |
| 143 std::unique_ptr<CertVerifier::Request> request; | 148 std::unique_ptr<CertVerifier::Request> request; |
| 144 | 149 |
| 145 int flags = CertVerifier::VERIFY_CERT_IO_ENABLED; | 150 int flags = CertVerifier::VERIFY_CERT_IO_ENABLED; |
| 146 int error = verifier()->Verify( | 151 int error = verifier()->Verify( |
| 147 CertVerifier::RequestParams(test_cert, "aia-host.invalid", flags, | 152 CertVerifier::RequestParams(test_cert, "aia-host.invalid", flags, |
| 148 std::string(), CertificateList()), | 153 std::string(), CertificateList()), |
| 149 nullptr, &verify_result, test_callback.callback(), &request, | 154 nullptr, &verify_result, test_callback.callback(), &request, |
| 150 BoundNetLog()); | 155 BoundNetLog()); |
| 151 ASSERT_EQ(ERR_IO_PENDING, error); | 156 ASSERT_THAT(error, IsError(ERR_IO_PENDING)); |
| 152 | 157 |
| 153 error = test_callback.WaitForResult(); | 158 error = test_callback.WaitForResult(); |
| 154 | 159 |
| 155 EXPECT_EQ(OK, error); | 160 EXPECT_THAT(error, IsOk()); |
| 156 | 161 |
| 157 // Ensure that NSS made an AIA request for the missing intermediate. | 162 // Ensure that NSS made an AIA request for the missing intermediate. |
| 158 EXPECT_LT(0, request_count()); | 163 EXPECT_LT(0, request_count()); |
| 159 } | 164 } |
| 160 | 165 |
| 161 } // namespace net | 166 } // namespace net |
| OLD | NEW |