| 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/internal/trust_store_collection.h" | 5 #include "net/cert/internal/trust_store_collection.h" |
| 6 | 6 |
| 7 #include "net/cert/internal/test_helpers.h" | 7 #include "net/cert/internal/test_helpers.h" |
| 8 #include "net/cert/internal/trust_store_in_memory.h" | 8 #include "net/cert/internal/trust_store_in_memory.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| 11 namespace net { | 11 namespace net { |
| 12 | 12 |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 class TrustStoreCollectionTest : public testing::Test { | 15 class TrustStoreCollectionTest : public testing::Test { |
| 16 public: | 16 public: |
| 17 void SetUp() override { | 17 void SetUp() override { |
| 18 ParsedCertificateList chain; | 18 ParsedCertificateList chain; |
| 19 bool unused_verify_result; | |
| 20 der::GeneralizedTime unused_time; | |
| 21 std::string unused_errors; | |
| 22 | 19 |
| 20 VerifyCertChainTest test; |
| 23 ReadVerifyCertChainTestFromFile( | 21 ReadVerifyCertChainTestFromFile( |
| 24 "net/data/verify_certificate_chain_unittest/key-rollover-oldchain.pem", | 22 "net/data/verify_certificate_chain_unittest/key-rollover-oldchain.pem", |
| 25 &chain, &oldroot_, &unused_time, &unused_verify_result, &unused_errors); | 23 &test); |
| 24 chain = test.chain; |
| 25 oldroot_ = test.trust_anchor; |
| 26 |
| 26 ASSERT_EQ(2U, chain.size()); | 27 ASSERT_EQ(2U, chain.size()); |
| 27 target_ = chain[0]; | 28 target_ = chain[0]; |
| 28 oldintermediate_ = chain[1]; | 29 oldintermediate_ = chain[1]; |
| 29 ASSERT_TRUE(target_); | 30 ASSERT_TRUE(target_); |
| 30 ASSERT_TRUE(oldintermediate_); | 31 ASSERT_TRUE(oldintermediate_); |
| 31 ASSERT_TRUE(oldroot_); | 32 ASSERT_TRUE(oldroot_); |
| 32 | 33 |
| 33 scoped_refptr<TrustAnchor> unused_root; | |
| 34 ReadVerifyCertChainTestFromFile( | 34 ReadVerifyCertChainTestFromFile( |
| 35 "net/data/verify_certificate_chain_unittest/" | 35 "net/data/verify_certificate_chain_unittest/" |
| 36 "key-rollover-longrolloverchain.pem", | 36 "key-rollover-longrolloverchain.pem", |
| 37 &chain, &unused_root, &unused_time, &unused_verify_result, | 37 &test); |
| 38 &unused_errors); | 38 chain = test.chain; |
| 39 |
| 39 ASSERT_EQ(4U, chain.size()); | 40 ASSERT_EQ(4U, chain.size()); |
| 40 newintermediate_ = chain[1]; | 41 newintermediate_ = chain[1]; |
| 41 newroot_ = TrustAnchor::CreateFromCertificateNoConstraints(chain[2]); | 42 newroot_ = TrustAnchor::CreateFromCertificateNoConstraints(chain[2]); |
| 42 newrootrollover_ = | 43 newrootrollover_ = |
| 43 TrustAnchor::CreateFromCertificateNoConstraints(chain[3]); | 44 TrustAnchor::CreateFromCertificateNoConstraints(chain[3]); |
| 44 ASSERT_TRUE(newintermediate_); | 45 ASSERT_TRUE(newintermediate_); |
| 45 ASSERT_TRUE(newroot_); | 46 ASSERT_TRUE(newroot_); |
| 46 ASSERT_TRUE(newrootrollover_); | 47 ASSERT_TRUE(newrootrollover_); |
| 47 } | 48 } |
| 48 | 49 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 collection.FindTrustAnchorsForCert(newintermediate_, &matches); | 95 collection.FindTrustAnchorsForCert(newintermediate_, &matches); |
| 95 | 96 |
| 96 ASSERT_EQ(2U, matches.size()); | 97 ASSERT_EQ(2U, matches.size()); |
| 97 EXPECT_EQ(newroot_, matches[0]); | 98 EXPECT_EQ(newroot_, matches[0]); |
| 98 EXPECT_EQ(oldroot_, matches[1]); | 99 EXPECT_EQ(oldroot_, matches[1]); |
| 99 } | 100 } |
| 100 | 101 |
| 101 } // namespace | 102 } // namespace |
| 102 | 103 |
| 103 } // namespace net | 104 } // namespace net |
| OLD | NEW |