Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(243)

Side by Side Diff: net/cert/mock_cert_verifier.h

Issue 1994353002: Update CertVerifier::Verify to use RequestParams instead (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@request_params
Patch Set: Rebased Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #ifndef NET_CERT_MOCK_CERT_VERIFIER_H_ 5 #ifndef NET_CERT_MOCK_CERT_VERIFIER_H_
6 #define NET_CERT_MOCK_CERT_VERIFIER_H_ 6 #define NET_CERT_MOCK_CERT_VERIFIER_H_
7 7
8 #include <list> 8 #include <list>
9 #include <memory> 9 #include <memory>
10 10
11 #include "net/cert/cert_verifier.h" 11 #include "net/cert/cert_verifier.h"
12 #include "net/cert/cert_verify_result.h" 12 #include "net/cert/cert_verify_result.h"
13 13
14 namespace net { 14 namespace net {
15 15
16 class MockCertVerifier : public CertVerifier { 16 class MockCertVerifier : public CertVerifier {
17 public: 17 public:
18 // Creates a new MockCertVerifier. By default, any call to Verify() will 18 // Creates a new MockCertVerifier. By default, any call to Verify() will
19 // result in the cert status being flagged as CERT_STATUS_INVALID and return 19 // result in the cert status being flagged as CERT_STATUS_INVALID and return
20 // an ERR_CERT_INVALID network error code. This behaviour can be overridden 20 // an ERR_CERT_INVALID network error code. This behaviour can be overridden
21 // by calling set_default_result() to change the default return value for 21 // by calling set_default_result() to change the default return value for
22 // Verify() or by calling one of the AddResult*() methods to specifically 22 // Verify() or by calling one of the AddResult*() methods to specifically
23 // handle a certificate or certificate and host. 23 // handle a certificate or certificate and host.
24 MockCertVerifier(); 24 MockCertVerifier();
25 25
26 ~MockCertVerifier() override; 26 ~MockCertVerifier() override;
27 27
28 // CertVerifier implementation 28 // CertVerifier implementation
29 int Verify(X509Certificate* cert, 29 int Verify(const CertVerifier::RequestParams& params,
30 const std::string& hostname,
31 const std::string& ocsp_response,
32 int flags,
33 CRLSet* crl_set, 30 CRLSet* crl_set,
34 CertVerifyResult* verify_result, 31 CertVerifyResult* verify_result,
35 const CompletionCallback& callback, 32 const CompletionCallback& callback,
36 std::unique_ptr<Request>* out_req, 33 std::unique_ptr<Request>* out_req,
37 const BoundNetLog& net_log) override; 34 const BoundNetLog& net_log) override;
38 35
39 // Sets the default return value for Verify() for certificates/hosts that do 36 // Sets the default return value for Verify() for certificates/hosts that do
40 // not have explicit results added via the AddResult*() methods. 37 // not have explicit results added via the AddResult*() methods.
41 void set_default_result(int default_result) { 38 void set_default_result(int default_result) {
42 default_result_ = default_result; 39 default_result_ = default_result;
43 } 40 }
44 41
45 // Adds a rule that will cause any call to Verify() for |cert| to return rv, 42 // Adds a rule that will cause any call to Verify() for |cert| to return rv,
46 // copying |verify_result| into the verified result. 43 // copying |verify_result| into the verified result.
47 // Note: Only the primary certificate of |cert| is checked. Any intermediate 44 // Note: Only the primary certificate of |cert| is checked. Any intermediate
48 // certificates will be ignored. 45 // certificates will be ignored.
49 void AddResultForCert(X509Certificate* cert, 46 void AddResultForCert(scoped_refptr<X509Certificate> cert,
50 const CertVerifyResult& verify_result, 47 const CertVerifyResult& verify_result,
51 int rv); 48 int rv);
52 49
53 // Same as AddResultForCert(), but further restricts it to only return for 50 // Same as AddResultForCert(), but further restricts it to only return for
54 // hostnames that match |host_pattern|. 51 // hostnames that match |host_pattern|.
55 void AddResultForCertAndHost(X509Certificate* cert, 52 void AddResultForCertAndHost(scoped_refptr<X509Certificate> cert,
56 const std::string& host_pattern, 53 const std::string& host_pattern,
57 const CertVerifyResult& verify_result, 54 const CertVerifyResult& verify_result,
58 int rv); 55 int rv);
59 56
60 private: 57 private:
61 struct Rule; 58 struct Rule;
62 typedef std::list<Rule> RuleList; 59 typedef std::list<Rule> RuleList;
63 60
64 int default_result_; 61 int default_result_;
65 RuleList rules_; 62 RuleList rules_;
66 }; 63 };
67 64
68 } // namespace net 65 } // namespace net
69 66
70 #endif // NET_CERT_MOCK_CERT_VERIFIER_H_ 67 #endif // NET_CERT_MOCK_CERT_VERIFIER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698