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/merkle_tree_leaf.h" | 5 #include "net/cert/merkle_tree_leaf.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 scoped_refptr<SignedCertificateTimestamp> x509_sct_; | 68 scoped_refptr<SignedCertificateTimestamp> x509_sct_; |
69 scoped_refptr<SignedCertificateTimestamp> precert_sct_; | 69 scoped_refptr<SignedCertificateTimestamp> precert_sct_; |
70 scoped_refptr<X509Certificate> test_cert_; | 70 scoped_refptr<X509Certificate> test_cert_; |
71 scoped_refptr<X509Certificate> test_precert_; | 71 scoped_refptr<X509Certificate> test_precert_; |
72 }; | 72 }; |
73 | 73 |
74 TEST_F(MerkleTreeLeafTest, CreatesForX509Cert) { | 74 TEST_F(MerkleTreeLeafTest, CreatesForX509Cert) { |
75 MerkleTreeLeaf leaf; | 75 MerkleTreeLeaf leaf; |
76 ASSERT_TRUE(GetMerkleTreeLeaf(test_cert_.get(), x509_sct_.get(), &leaf)); | 76 ASSERT_TRUE(GetMerkleTreeLeaf(test_cert_.get(), x509_sct_.get(), &leaf)); |
77 | 77 |
78 EXPECT_EQ(LogEntry::LOG_ENTRY_TYPE_X509, leaf.log_entry.type); | 78 EXPECT_EQ(SignedEntryData::LOG_ENTRY_TYPE_X509, leaf.signed_entry.type); |
79 EXPECT_FALSE(leaf.log_entry.leaf_certificate.empty()); | 79 EXPECT_FALSE(leaf.signed_entry.leaf_certificate.empty()); |
80 EXPECT_TRUE(leaf.log_entry.tbs_certificate.empty()); | 80 EXPECT_TRUE(leaf.signed_entry.tbs_certificate.empty()); |
81 | 81 |
82 EXPECT_EQ(x509_sct_->timestamp, leaf.timestamp); | 82 EXPECT_EQ(x509_sct_->timestamp, leaf.timestamp); |
83 EXPECT_EQ(x509_sct_->extensions, leaf.extensions); | 83 EXPECT_EQ(x509_sct_->extensions, leaf.extensions); |
84 } | 84 } |
85 | 85 |
86 TEST_F(MerkleTreeLeafTest, CreatesForPrecert) { | 86 TEST_F(MerkleTreeLeafTest, CreatesForPrecert) { |
87 MerkleTreeLeaf leaf; | 87 MerkleTreeLeaf leaf; |
88 ASSERT_TRUE( | 88 ASSERT_TRUE( |
89 GetMerkleTreeLeaf(test_precert_.get(), precert_sct_.get(), &leaf)); | 89 GetMerkleTreeLeaf(test_precert_.get(), precert_sct_.get(), &leaf)); |
90 | 90 |
91 EXPECT_EQ(LogEntry::LOG_ENTRY_TYPE_PRECERT, leaf.log_entry.type); | 91 EXPECT_EQ(SignedEntryData::LOG_ENTRY_TYPE_PRECERT, leaf.signed_entry.type); |
92 EXPECT_FALSE(leaf.log_entry.tbs_certificate.empty()); | 92 EXPECT_FALSE(leaf.signed_entry.tbs_certificate.empty()); |
93 EXPECT_TRUE(leaf.log_entry.leaf_certificate.empty()); | 93 EXPECT_TRUE(leaf.signed_entry.leaf_certificate.empty()); |
94 | 94 |
95 EXPECT_EQ(precert_sct_->timestamp, leaf.timestamp); | 95 EXPECT_EQ(precert_sct_->timestamp, leaf.timestamp); |
96 EXPECT_EQ(precert_sct_->extensions, leaf.extensions); | 96 EXPECT_EQ(precert_sct_->extensions, leaf.extensions); |
97 } | 97 } |
98 | 98 |
99 TEST_F(MerkleTreeLeafTest, DoesNotCreateForEmbeddedSCTButNotPrecert) { | 99 TEST_F(MerkleTreeLeafTest, DoesNotCreateForEmbeddedSCTButNotPrecert) { |
100 MerkleTreeLeaf leaf; | 100 MerkleTreeLeaf leaf; |
101 ASSERT_FALSE(GetMerkleTreeLeaf(test_cert_.get(), precert_sct_.get(), &leaf)); | 101 ASSERT_FALSE(GetMerkleTreeLeaf(test_cert_.get(), precert_sct_.get(), &leaf)); |
102 } | 102 } |
103 | 103 |
(...skipping 21 matching lines...) Expand all Loading... |
125 ASSERT_TRUE(HashMerkleTreeLeaf(leaf, &hash)); | 125 ASSERT_TRUE(HashMerkleTreeLeaf(leaf, &hash)); |
126 EXPECT_THAT(hash, HexEq("257ae85f08810445511e35e33f7aee99ee19407971e35e95822b" | 126 EXPECT_THAT(hash, HexEq("257ae85f08810445511e35e33f7aee99ee19407971e35e95822b" |
127 "bf42a74be223")); | 127 "bf42a74be223")); |
128 } | 128 } |
129 | 129 |
130 } // namespace | 130 } // namespace |
131 | 131 |
132 } // namespace ct | 132 } // namespace ct |
133 | 133 |
134 } // namespace net | 134 } // namespace net |
OLD | NEW |