OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ct_log_response_parser.h" | 5 #include "net/cert/ct_log_response_parser.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
88 base::Base64Decode( | 88 base::Base64Decode( |
89 base::StringPiece("/WHFMgXtI/umKKuACJIN0Bb73TcILm9WkeU6qszvoA==\n"), | 89 base::StringPiece("/WHFMgXtI/umKKuACJIN0Bb73TcILm9WkeU6qszvoA==\n"), |
90 &too_short_hash); | 90 &too_short_hash); |
91 scoped_ptr<base::Value> too_short_hash_json = | 91 scoped_ptr<base::Value> too_short_hash_json = |
92 ParseJson(CreateSignedTreeHeadJsonString( | 92 ParseJson(CreateSignedTreeHeadJsonString( |
93 1 /* tree_size */, 123456u /* timestamp */, | 93 1 /* tree_size */, 123456u /* timestamp */, |
94 GetSampleSTHSHA256RootHash(), too_short_hash)); | 94 GetSampleSTHSHA256RootHash(), too_short_hash)); |
95 ASSERT_FALSE(FillSignedTreeHead(*too_short_hash_json.get(), &tree_head)); | 95 ASSERT_FALSE(FillSignedTreeHead(*too_short_hash_json.get(), &tree_head)); |
96 } | 96 } |
97 | 97 |
98 TEST(CTLogResponseParserTest, ParsesJsonSTHWithLargeTimestamp) { | |
99 SignedTreeHead tree_head; | |
100 | |
101 scoped_ptr<base::Value> large_timestamp_json = | |
102 ParseJson(CreateSignedTreeHeadJsonString( | |
103 100, 1L << 34, GetSampleSTHSHA256RootHash(), | |
davidben
2016/03/02 17:30:39
1L -> INT64_C(1) ?
Ryan Sleevi
2016/03/02 19:03:22
Yes, this is needed
Eran Messeri
2016/03/04 11:28:30
Done.
| |
104 GetSampleSTHTreeHeadSignature())); | |
105 | |
106 ASSERT_TRUE(FillSignedTreeHead(*large_timestamp_json.get(), &tree_head)); | |
107 | |
108 base::Time expected_time = | |
109 base::Time::UnixEpoch() + | |
110 base::TimeDelta::FromMilliseconds(INT64_C(1) << 34); | |
111 | |
112 EXPECT_EQ(tree_head.timestamp, expected_time); | |
113 } | |
114 | |
98 TEST(CTLogResponseParserTest, ParsesConsistencyProofSuccessfully) { | 115 TEST(CTLogResponseParserTest, ParsesConsistencyProofSuccessfully) { |
99 std::string first(32, 'a'); | 116 std::string first(32, 'a'); |
100 std::string second(32, 'b'); | 117 std::string second(32, 'b'); |
101 std::string third(32, 'c'); | 118 std::string third(32, 'c'); |
102 | 119 |
103 std::vector<std::string> raw_nodes; | 120 std::vector<std::string> raw_nodes; |
104 raw_nodes.push_back(first); | 121 raw_nodes.push_back(first); |
105 raw_nodes.push_back(second); | 122 raw_nodes.push_back(second); |
106 raw_nodes.push_back(third); | 123 raw_nodes.push_back(third); |
107 scoped_ptr<base::Value> sample_consistency_proof = | 124 scoped_ptr<base::Value> sample_consistency_proof = |
(...skipping 30 matching lines...) Expand all Loading... | |
138 std::vector<std::string> output; | 155 std::vector<std::string> output; |
139 | 156 |
140 scoped_ptr<base::Value> badly_encoded = | 157 scoped_ptr<base::Value> badly_encoded = |
141 ParseJson(std::string("{\"consistency\": [], \"somethingelse\": 3}")); | 158 ParseJson(std::string("{\"consistency\": [], \"somethingelse\": 3}")); |
142 EXPECT_TRUE(FillConsistencyProof(*badly_encoded.get(), &output)); | 159 EXPECT_TRUE(FillConsistencyProof(*badly_encoded.get(), &output)); |
143 } | 160 } |
144 | 161 |
145 } // namespace ct | 162 } // namespace ct |
146 | 163 |
147 } // namespace net | 164 } // namespace net |
OLD | NEW |