| 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, INT64_C(1) << 34, GetSampleSTHSHA256RootHash(), | |
| 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 | |
| 115 TEST(CTLogResponseParserTest, ParsesConsistencyProofSuccessfully) { | 98 TEST(CTLogResponseParserTest, ParsesConsistencyProofSuccessfully) { |
| 116 std::string first(32, 'a'); | 99 std::string first(32, 'a'); |
| 117 std::string second(32, 'b'); | 100 std::string second(32, 'b'); |
| 118 std::string third(32, 'c'); | 101 std::string third(32, 'c'); |
| 119 | 102 |
| 120 std::vector<std::string> raw_nodes; | 103 std::vector<std::string> raw_nodes; |
| 121 raw_nodes.push_back(first); | 104 raw_nodes.push_back(first); |
| 122 raw_nodes.push_back(second); | 105 raw_nodes.push_back(second); |
| 123 raw_nodes.push_back(third); | 106 raw_nodes.push_back(third); |
| 124 scoped_ptr<base::Value> sample_consistency_proof = | 107 scoped_ptr<base::Value> sample_consistency_proof = |
| (...skipping 30 matching lines...) Expand all Loading... |
| 155 std::vector<std::string> output; | 138 std::vector<std::string> output; |
| 156 | 139 |
| 157 scoped_ptr<base::Value> badly_encoded = | 140 scoped_ptr<base::Value> badly_encoded = |
| 158 ParseJson(std::string("{\"consistency\": [], \"somethingelse\": 3}")); | 141 ParseJson(std::string("{\"consistency\": [], \"somethingelse\": 3}")); |
| 159 EXPECT_TRUE(FillConsistencyProof(*badly_encoded.get(), &output)); | 142 EXPECT_TRUE(FillConsistencyProof(*badly_encoded.get(), &output)); |
| 160 } | 143 } |
| 161 | 144 |
| 162 } // namespace ct | 145 } // namespace ct |
| 163 | 146 |
| 164 } // namespace net | 147 } // namespace net |
| OLD | NEW |