OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/cert_verifier.h" | 5 #include "net/cert/cert_verifier.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "net/base/test_data_directory.h" | 9 #include "net/base/test_data_directory.h" |
10 #include "net/cert/x509_certificate.h" | 10 #include "net/cert/x509_certificate.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 CertVerifier::RequestParams key2; | 44 CertVerifier::RequestParams key2; |
45 | 45 |
46 // Expectation: | 46 // Expectation: |
47 // -1 means key1 is less than key2 | 47 // -1 means key1 is less than key2 |
48 // 0 means key1 equals key2 | 48 // 0 means key1 equals key2 |
49 // 1 means key1 is greater than key2 | 49 // 1 means key1 is greater than key2 |
50 int expected_result; | 50 int expected_result; |
51 } tests[] = { | 51 } tests[] = { |
52 { | 52 { |
53 // Test for basic equivalence. | 53 // Test for basic equivalence. |
54 CertVerifier::RequestParams(ok_cert.get(), "www.example.test", 0, | 54 CertVerifier::RequestParams(ok_cert, "www.example.test", 0, |
55 std::string(), empty_list), | 55 std::string(), empty_list), |
56 CertVerifier::RequestParams(ok_cert.get(), "www.example.test", 0, | 56 CertVerifier::RequestParams(ok_cert, "www.example.test", 0, |
57 std::string(), empty_list), | 57 std::string(), empty_list), |
58 0, | 58 0, |
59 }, | 59 }, |
60 { | 60 { |
61 // Test that different certificates but with the same CA and for | 61 // Test that different certificates but with the same CA and for |
62 // the same host are different validation keys. | 62 // the same host are different validation keys. |
63 CertVerifier::RequestParams(ok_cert.get(), "www.example.test", 0, | 63 CertVerifier::RequestParams(ok_cert, "www.example.test", 0, |
64 std::string(), empty_list), | 64 std::string(), empty_list), |
65 CertVerifier::RequestParams(expired_cert.get(), "www.example.test", 0, | 65 CertVerifier::RequestParams(expired_cert, "www.example.test", 0, |
66 std::string(), empty_list), | 66 std::string(), empty_list), |
67 -1, | 67 -1, |
68 }, | 68 }, |
69 { | 69 { |
70 // Test that the same EE certificate for the same host, but with | 70 // Test that the same EE certificate for the same host, but with |
71 // different chains are different validation keys. | 71 // different chains are different validation keys. |
72 CertVerifier::RequestParams(ok_cert.get(), "www.example.test", 0, | 72 CertVerifier::RequestParams(ok_cert, "www.example.test", 0, |
73 std::string(), empty_list), | 73 std::string(), empty_list), |
74 CertVerifier::RequestParams(combined_cert.get(), "www.example.test", | 74 CertVerifier::RequestParams(combined_cert, "www.example.test", 0, |
75 0, std::string(), empty_list), | 75 std::string(), empty_list), |
76 1, | 76 1, |
77 }, | 77 }, |
78 { | 78 { |
79 // The same certificate, with the same chain, but for different | 79 // The same certificate, with the same chain, but for different |
80 // hosts are different validation keys. | 80 // hosts are different validation keys. |
81 CertVerifier::RequestParams(ok_cert.get(), "www1.example.test", 0, | 81 CertVerifier::RequestParams(ok_cert, "www1.example.test", 0, |
82 std::string(), empty_list), | 82 std::string(), empty_list), |
83 CertVerifier::RequestParams(ok_cert.get(), "www2.example.test", 0, | 83 CertVerifier::RequestParams(ok_cert, "www2.example.test", 0, |
84 std::string(), empty_list), | 84 std::string(), empty_list), |
85 -1, | 85 -1, |
86 }, | 86 }, |
87 { | 87 { |
88 // The same certificate, chain, and host, but with different flags | 88 // The same certificate, chain, and host, but with different flags |
89 // are different validation keys. | 89 // are different validation keys. |
90 CertVerifier::RequestParams(ok_cert.get(), "www.example.test", | 90 CertVerifier::RequestParams(ok_cert, "www.example.test", |
91 CertVerifier::VERIFY_EV_CERT, | 91 CertVerifier::VERIFY_EV_CERT, |
92 std::string(), empty_list), | 92 std::string(), empty_list), |
93 CertVerifier::RequestParams(ok_cert.get(), "www.example.test", 0, | 93 CertVerifier::RequestParams(ok_cert, "www.example.test", 0, |
94 std::string(), empty_list), | 94 std::string(), empty_list), |
95 1, | 95 1, |
96 }, | 96 }, |
97 { | 97 { |
98 // Different additional_trust_anchors. | 98 // Different additional_trust_anchors. |
99 CertVerifier::RequestParams(ok_cert.get(), "www.example.test", 0, | 99 CertVerifier::RequestParams(ok_cert, "www.example.test", 0, |
100 std::string(), empty_list), | 100 std::string(), empty_list), |
101 CertVerifier::RequestParams(ok_cert.get(), "www.example.test", 0, | 101 CertVerifier::RequestParams(ok_cert, "www.example.test", 0, |
102 std::string(), test_list), | 102 std::string(), test_list), |
103 -1, | 103 -1, |
104 }, | 104 }, |
105 { | 105 { |
106 // Different OCSP responses. | 106 // Different OCSP responses. |
107 CertVerifier::RequestParams(ok_cert.get(), "www.example.test", 0, | 107 CertVerifier::RequestParams(ok_cert, "www.example.test", 0, |
108 "ocsp response", empty_list), | 108 "ocsp response", empty_list), |
109 CertVerifier::RequestParams(ok_cert.get(), "www.example.test", 0, | 109 CertVerifier::RequestParams(ok_cert, "www.example.test", 0, |
110 std::string(), empty_list), | 110 std::string(), empty_list), |
111 -1, | 111 -1, |
112 }, | 112 }, |
113 }; | 113 }; |
114 for (size_t i = 0; i < arraysize(tests); ++i) { | 114 for (size_t i = 0; i < arraysize(tests); ++i) { |
115 SCOPED_TRACE(i); | 115 SCOPED_TRACE(i); |
116 | 116 |
117 const CertVerifier::RequestParams& key1 = tests[i].key1; | 117 const CertVerifier::RequestParams& key1 = tests[i].key1; |
118 const CertVerifier::RequestParams& key2 = tests[i].key2; | 118 const CertVerifier::RequestParams& key2 = tests[i].key2; |
119 | 119 |
(...skipping 13 matching lines...) Expand all Loading... |
133 EXPECT_FALSE(key1 < key2); | 133 EXPECT_FALSE(key1 < key2); |
134 EXPECT_TRUE(key2 < key1); | 134 EXPECT_TRUE(key2 < key1); |
135 break; | 135 break; |
136 default: | 136 default: |
137 FAIL() << "Invalid expectation. Can be only -1, 0, 1"; | 137 FAIL() << "Invalid expectation. Can be only -1, 0, 1"; |
138 } | 138 } |
139 } | 139 } |
140 } | 140 } |
141 | 141 |
142 } // namespace net | 142 } // namespace net |
OLD | NEW |