| 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" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 if (!it->cert->Equals(cert)) | 50 if (!it->cert->Equals(cert)) |
| 51 continue; | 51 continue; |
| 52 if (!MatchPattern(hostname, it->hostname)) | 52 if (!MatchPattern(hostname, it->hostname)) |
| 53 continue; | 53 continue; |
| 54 *verify_result = it->result; | 54 *verify_result = it->result; |
| 55 return it->rv; | 55 return it->rv; |
| 56 } | 56 } |
| 57 | 57 |
| 58 // Fall through to the default. | 58 // Fall through to the default. |
| 59 verify_result->verified_cert = cert; | 59 verify_result->verified_cert = cert; |
| 60 verify_result->unverified_server_cert = cert; |
| 60 verify_result->cert_status = MapNetErrorToCertStatus(default_result_); | 61 verify_result->cert_status = MapNetErrorToCertStatus(default_result_); |
| 61 return default_result_; | 62 return default_result_; |
| 62 } | 63 } |
| 63 | 64 |
| 64 void MockCertVerifier::CancelRequest(RequestHandle req) { | 65 void MockCertVerifier::CancelRequest(RequestHandle req) { |
| 65 NOTIMPLEMENTED(); | 66 NOTIMPLEMENTED(); |
| 66 } | 67 } |
| 67 | 68 |
| 68 void MockCertVerifier::AddResultForCert(X509Certificate* cert, | 69 void MockCertVerifier::AddResultForCert(X509Certificate* cert, |
| 69 const CertVerifyResult& verify_result, | 70 const CertVerifyResult& verify_result, |
| 70 int rv) { | 71 int rv) { |
| 71 AddResultForCertAndHost(cert, "*", verify_result, rv); | 72 AddResultForCertAndHost(cert, "*", verify_result, rv); |
| 72 } | 73 } |
| 73 | 74 |
| 74 void MockCertVerifier::AddResultForCertAndHost( | 75 void MockCertVerifier::AddResultForCertAndHost( |
| 75 X509Certificate* cert, | 76 X509Certificate* cert, |
| 76 const std::string& host_pattern, | 77 const std::string& host_pattern, |
| 77 const CertVerifyResult& verify_result, | 78 const CertVerifyResult& verify_result, |
| 78 int rv) { | 79 int rv) { |
| 79 Rule rule(cert, host_pattern, verify_result, rv); | 80 Rule rule(cert, host_pattern, verify_result, rv); |
| 80 rules_.push_back(rule); | 81 rules_.push_back(rule); |
| 81 } | 82 } |
| 82 | 83 |
| 83 } // namespace net | 84 } // namespace net |
| OLD | NEW |