OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/mock_cert_verifier.h" | 5 #include "net/cert/mock_cert_verifier.h" |
6 | 6 |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
10 #include "net/cert/cert_status_flags.h" | 10 #include "net/cert/cert_status_flags.h" |
11 #include "net/cert/cert_verify_result.h" | 11 #include "net/cert/cert_verify_result.h" |
12 #include "net/cert/x509_certificate.h" | 12 #include "net/cert/x509_certificate.h" |
13 | 13 |
14 namespace net { | 14 namespace net { |
15 | 15 |
16 struct MockCertVerifier::Rule { | 16 struct MockCertVerifier::Rule { |
17 Rule(X509Certificate* cert, | 17 Rule(X509Certificate* cert, |
18 const std::string& hostname, | 18 const std::string& hostname, |
19 const CertVerifyResult& result, | 19 const CertVerifyResult& result, |
20 int rv) | 20 int rv) |
21 : cert(cert), | 21 : cert(cert), hostname(hostname), result(result), rv(rv) { |
22 hostname(hostname), | |
23 result(result), | |
24 rv(rv) { | |
25 DCHECK(cert); | 22 DCHECK(cert); |
26 DCHECK(result.verified_cert.get()); | 23 DCHECK(result.verified_cert.get()); |
27 } | 24 } |
28 | 25 |
29 scoped_refptr<X509Certificate> cert; | 26 scoped_refptr<X509Certificate> cert; |
30 std::string hostname; | 27 std::string hostname; |
31 CertVerifyResult result; | 28 CertVerifyResult result; |
32 int rv; | 29 int rv; |
33 }; | 30 }; |
34 | 31 |
35 MockCertVerifier::MockCertVerifier() : default_result_(ERR_CERT_INVALID) {} | 32 MockCertVerifier::MockCertVerifier() : default_result_(ERR_CERT_INVALID) { |
| 33 } |
36 | 34 |
37 MockCertVerifier::~MockCertVerifier() {} | 35 MockCertVerifier::~MockCertVerifier() { |
| 36 } |
38 | 37 |
39 int MockCertVerifier::Verify(X509Certificate* cert, | 38 int MockCertVerifier::Verify(X509Certificate* cert, |
40 const std::string& hostname, | 39 const std::string& hostname, |
41 int flags, | 40 int flags, |
42 CRLSet* crl_set, | 41 CRLSet* crl_set, |
43 CertVerifyResult* verify_result, | 42 CertVerifyResult* verify_result, |
44 const CompletionCallback& callback, | 43 const CompletionCallback& callback, |
45 RequestHandle* out_req, | 44 RequestHandle* out_req, |
46 const BoundNetLog& net_log) { | 45 const BoundNetLog& net_log) { |
47 RuleList::const_iterator it; | 46 RuleList::const_iterator it; |
(...skipping 26 matching lines...) Expand all Loading... |
74 void MockCertVerifier::AddResultForCertAndHost( | 73 void MockCertVerifier::AddResultForCertAndHost( |
75 X509Certificate* cert, | 74 X509Certificate* cert, |
76 const std::string& host_pattern, | 75 const std::string& host_pattern, |
77 const CertVerifyResult& verify_result, | 76 const CertVerifyResult& verify_result, |
78 int rv) { | 77 int rv) { |
79 Rule rule(cert, host_pattern, verify_result, rv); | 78 Rule rule(cert, host_pattern, verify_result, rv); |
80 rules_.push_back(rule); | 79 rules_.push_back(rule); |
81 } | 80 } |
82 | 81 |
83 } // namespace net | 82 } // namespace net |
OLD | NEW |