OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef NET_CERT_MOCK_CLIENT_CERT_VERIFIER_H_ |
| 6 #define NET_CERT_MOCK_CLIENT_CERT_VERIFIER_H_ |
| 7 |
| 8 #include <list> |
| 9 |
| 10 #include "net/cert/client_cert_verifier.h" |
| 11 |
| 12 namespace net { |
| 13 |
| 14 class MockClientCertVerifier : public ClientCertVerifier { |
| 15 public: |
| 16 // Creates a new MockClientCertVerifier. By default, any call to Verify() will |
| 17 // result in the cert status being flagged as CERT_STATUS_INVALID and return |
| 18 // an ERR_CERT_INVALID network error code. This behaviour can be overridden |
| 19 // by calling set_default_result() to change the default return value for |
| 20 // Verify() or by calling one of the AddResult*() methods to specifically |
| 21 // handle a certificate or certificate and host. |
| 22 MockClientCertVerifier(); |
| 23 |
| 24 ~MockClientCertVerifier() override; |
| 25 |
| 26 // ClientCertVerifier implementation |
| 27 int Verify(X509Certificate* cert, |
| 28 const CompletionCallback& callback, |
| 29 scoped_ptr<Request>* out_req) override; |
| 30 |
| 31 // Sets the default return value for Verify() for certificates/hosts that do |
| 32 // not have explicit results added via the AddResult*() methods. |
| 33 void set_default_result(int default_result) { |
| 34 default_result_ = default_result; |
| 35 } |
| 36 |
| 37 // Adds a rule that will cause any call to Verify() for |cert| to return rv. |
| 38 // Note: Only the primary certificate of |cert| is checked. Any intermediate |
| 39 // certificates will be ignored. |
| 40 void AddResultForCert(X509Certificate* cert, int rv); |
| 41 |
| 42 private: |
| 43 struct Rule; |
| 44 typedef std::list<Rule> RuleList; |
| 45 |
| 46 int default_result_; |
| 47 RuleList rules_; |
| 48 }; |
| 49 |
| 50 } // namespace net |
| 51 |
| 52 #endif // NET_CERT_MOCK_CLIENT_CERT_VERIFIER_H_ |
OLD | NEW |