Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Side by Side Diff: net/cert/internal/trust_store_collection_unittest.cc

Issue 2801813004: Refactor VerifyCertificateChain test data to include a key purpose (Closed)
Patch Set: Address mattm's comment Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/cert/internal/test_helpers.cc ('k') | net/cert/internal/trust_store_nss_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « net/cert/internal/test_helpers.cc ('k') | net/cert/internal/trust_store_nss_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698