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" |
11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 #include "net/cert/ct_serialization.h" | 14 #include "net/cert/ct_serialization.h" |
15 #include "net/cert/signed_tree_head.h" | 15 #include "net/cert/signed_tree_head.h" |
16 #include "net/test/ct_test_util.h" | 16 #include "net/test/ct_test_util.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
18 | 18 |
19 namespace net { | 19 namespace net { |
20 | 20 |
21 namespace ct { | 21 namespace ct { |
22 | 22 |
23 namespace { | 23 namespace { |
24 scoped_ptr<base::Value> ParseJson(const std::string& json) { | 24 scoped_ptr<base::Value> ParseJson(const std::string& json) { |
25 base::JSONReader json_reader; | 25 base::JSONReader json_reader; |
26 return json_reader.Read(json).Pass(); | 26 return json_reader.Read(json); |
27 } | 27 } |
28 } | 28 } |
29 | 29 |
30 TEST(CTLogResponseParserTest, ParsesValidJsonSTH) { | 30 TEST(CTLogResponseParserTest, ParsesValidJsonSTH) { |
31 scoped_ptr<base::Value> sample_sth_json = ParseJson(GetSampleSTHAsJson()); | 31 scoped_ptr<base::Value> sample_sth_json = ParseJson(GetSampleSTHAsJson()); |
32 SignedTreeHead tree_head; | 32 SignedTreeHead tree_head; |
33 EXPECT_TRUE(FillSignedTreeHead(*sample_sth_json.get(), &tree_head)); | 33 EXPECT_TRUE(FillSignedTreeHead(*sample_sth_json.get(), &tree_head)); |
34 | 34 |
35 SignedTreeHead sample_sth; | 35 SignedTreeHead sample_sth; |
36 GetSampleSignedTreeHead(&sample_sth); | 36 GetSampleSignedTreeHead(&sample_sth); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 std::vector<std::string> output; | 138 std::vector<std::string> output; |
139 | 139 |
140 scoped_ptr<base::Value> badly_encoded = | 140 scoped_ptr<base::Value> badly_encoded = |
141 ParseJson(std::string("{\"consistency\": [], \"somethingelse\": 3}")); | 141 ParseJson(std::string("{\"consistency\": [], \"somethingelse\": 3}")); |
142 EXPECT_TRUE(FillConsistencyProof(*badly_encoded.get(), &output)); | 142 EXPECT_TRUE(FillConsistencyProof(*badly_encoded.get(), &output)); |
143 } | 143 } |
144 | 144 |
145 } // namespace ct | 145 } // namespace ct |
146 | 146 |
147 } // namespace net | 147 } // namespace net |
OLD | NEW |