OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chrome/browser/chromeos/policy/policy_cert_verifier.h" | 5 #include "chrome/browser/chromeos/policy/policy_cert_verifier.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 EXPECT_TRUE(request_handle); | 166 EXPECT_TRUE(request_handle); |
167 error = callback.WaitForResult(); | 167 error = callback.WaitForResult(); |
168 EXPECT_EQ(net::OK, error); | 168 EXPECT_EQ(net::OK, error); |
169 | 169 |
170 // The additional trust anchors were not used, since the certificate is | 170 // The additional trust anchors were not used, since the certificate is |
171 // trusted from the database. | 171 // trusted from the database. |
172 EXPECT_FALSE(WasTrustAnchorUsedAndReset()); | 172 EXPECT_FALSE(WasTrustAnchorUsedAndReset()); |
173 } | 173 } |
174 | 174 |
175 TEST_F(PolicyCertVerifierTest, VerifyUsingAdditionalTrustAnchor) { | 175 TEST_F(PolicyCertVerifierTest, VerifyUsingAdditionalTrustAnchor) { |
176 if (!SupportsAdditionalTrustAnchors()) { | 176 ASSERT_TRUE(SupportsAdditionalTrustAnchors()); |
177 LOG(INFO) << "Test skipped on this platform. NSS >= 3.14.2 required."; | |
178 return; | |
179 } | |
180 | 177 |
181 // |test_server_cert_| is untrusted, so Verify() fails. | 178 // |test_server_cert_| is untrusted, so Verify() fails. |
182 { | 179 { |
183 net::CertVerifyResult verify_result; | 180 net::CertVerifyResult verify_result; |
184 net::TestCompletionCallback callback; | 181 net::TestCompletionCallback callback; |
185 net::CertVerifier::RequestHandle request_handle = NULL; | 182 net::CertVerifier::RequestHandle request_handle = NULL; |
186 int error = VerifyTestServerCert(callback, &verify_result, &request_handle); | 183 int error = VerifyTestServerCert(callback, &verify_result, &request_handle); |
187 ASSERT_EQ(net::ERR_IO_PENDING, error); | 184 ASSERT_EQ(net::ERR_IO_PENDING, error); |
188 EXPECT_TRUE(request_handle); | 185 EXPECT_TRUE(request_handle); |
189 error = callback.WaitForResult(); | 186 error = callback.WaitForResult(); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 int error = VerifyTestServerCert(callback, &verify_result, &request_handle); | 222 int error = VerifyTestServerCert(callback, &verify_result, &request_handle); |
226 // Note: this hits the cached result from the first Verify() in this test. | 223 // Note: this hits the cached result from the first Verify() in this test. |
227 EXPECT_EQ(net::ERR_CERT_AUTHORITY_INVALID, error); | 224 EXPECT_EQ(net::ERR_CERT_AUTHORITY_INVALID, error); |
228 } | 225 } |
229 // The additional trust anchors were reset, thus |cert_verifier_| should not | 226 // The additional trust anchors were reset, thus |cert_verifier_| should not |
230 // signal it's usage anymore. | 227 // signal it's usage anymore. |
231 EXPECT_FALSE(WasTrustAnchorUsedAndReset()); | 228 EXPECT_FALSE(WasTrustAnchorUsedAndReset()); |
232 } | 229 } |
233 | 230 |
234 } // namespace policy | 231 } // namespace policy |
OLD | NEW |