WiFiServiceImpl (Windows): Fixed wrong authentication type with WEP-PSK.
[chromium-blink-merge.git] / net / cert / mock_cert_verifier.h
blob6486d2ca6a3e0a2cab45d138f86c6c84c1a8f267
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
3 // found in the LICENSE file.
5 #ifndef NET_CERT_MOCK_CERT_VERIFIER_H_
6 #define NET_CERT_MOCK_CERT_VERIFIER_H_
8 #include <list>
10 #include "net/cert/cert_verifier.h"
11 #include "net/cert/cert_verify_result.h"
13 namespace net {
15 class MockCertVerifier : public CertVerifier {
16 public:
17 // Creates a new MockCertVerifier. By default, any call to Verify() will
18 // result in the cert status being flagged as CERT_STATUS_INVALID and return
19 // an ERR_CERT_INVALID network error code. This behaviour can be overridden
20 // by calling set_default_result() to change the default return value for
21 // Verify() or by calling one of the AddResult*() methods to specifically
22 // handle a certificate or certificate and host.
23 MockCertVerifier();
25 ~MockCertVerifier() override;
27 // CertVerifier implementation
28 int Verify(X509Certificate* cert,
29 const std::string& hostname,
30 const std::string& ocsp_response,
31 int flags,
32 CRLSet* crl_set,
33 CertVerifyResult* verify_result,
34 const CompletionCallback& callback,
35 scoped_ptr<Request>* out_req,
36 const BoundNetLog& net_log) override;
38 // Sets the default return value for Verify() for certificates/hosts that do
39 // not have explicit results added via the AddResult*() methods.
40 void set_default_result(int default_result) {
41 default_result_ = default_result;
44 // Adds a rule that will cause any call to Verify() for |cert| to return rv,
45 // copying |verify_result| into the verified result.
46 // Note: Only the primary certificate of |cert| is checked. Any intermediate
47 // certificates will be ignored.
48 void AddResultForCert(X509Certificate* cert,
49 const CertVerifyResult& verify_result,
50 int rv);
52 // Same as AddResultForCert(), but further restricts it to only return for
53 // hostnames that match |host_pattern|.
54 void AddResultForCertAndHost(X509Certificate* cert,
55 const std::string& host_pattern,
56 const CertVerifyResult& verify_result,
57 int rv);
59 private:
60 struct Rule;
61 typedef std::list<Rule> RuleList;
63 int default_result_;
64 RuleList rules_;
67 } // namespace net
69 #endif // NET_CERT_MOCK_CERT_VERIFIER_H_