diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2016-07-14 17:41:05 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2016-08-04 12:37:36 +0000 |
commit | 399c965b6064c440ddcf4015f5f8e9d131c7a0a6 (patch) | |
tree | 6b06b60ff365abef0e13b3503d593a0df48d20e8 /chromium/net/cert/ct_log_response_parser_unittest.cc | |
parent | 7366110654eec46f21b6824f302356426f48cd74 (diff) | |
download | qtwebengine-chromium-399c965b6064c440ddcf4015f5f8e9d131c7a0a6.tar.gz |
BASELINE: Update Chromium to 52.0.2743.76 and Ninja to 1.7.1
Change-Id: I382f51b959689505a60f8b707255ecb344f7d8b4
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/net/cert/ct_log_response_parser_unittest.cc')
-rw-r--r-- | chromium/net/cert/ct_log_response_parser_unittest.cc | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/chromium/net/cert/ct_log_response_parser_unittest.cc b/chromium/net/cert/ct_log_response_parser_unittest.cc index 8084a283e64..110a432aaa4 100644 --- a/chromium/net/cert/ct_log_response_parser_unittest.cc +++ b/chromium/net/cert/ct_log_response_parser_unittest.cc @@ -4,11 +4,11 @@ #include "net/cert/ct_log_response_parser.h" +#include <memory> #include <string> #include "base/base64.h" #include "base/json/json_reader.h" -#include "base/memory/scoped_ptr.h" #include "base/strings/stringprintf.h" #include "base/time/time.h" #include "base/values.h" @@ -22,14 +22,15 @@ namespace net { namespace ct { namespace { -scoped_ptr<base::Value> ParseJson(const std::string& json) { +std::unique_ptr<base::Value> ParseJson(const std::string& json) { base::JSONReader json_reader; return json_reader.Read(json); } } TEST(CTLogResponseParserTest, ParsesValidJsonSTH) { - scoped_ptr<base::Value> sample_sth_json = ParseJson(GetSampleSTHAsJson()); + std::unique_ptr<base::Value> sample_sth_json = + ParseJson(GetSampleSTHAsJson()); SignedTreeHead tree_head; EXPECT_TRUE(FillSignedTreeHead(*sample_sth_json.get(), &tree_head)); @@ -59,14 +60,14 @@ TEST(CTLogResponseParserTest, ParsesValidJsonSTH) { } TEST(CTLogResponseParserTest, FailsToParseMissingFields) { - scoped_ptr<base::Value> missing_signature_sth = ParseJson( + std::unique_ptr<base::Value> missing_signature_sth = ParseJson( CreateSignedTreeHeadJsonString(1 /* tree_size */, 123456u /* timestamp */, GetSampleSTHSHA256RootHash(), "")); SignedTreeHead tree_head; ASSERT_FALSE(FillSignedTreeHead(*missing_signature_sth.get(), &tree_head)); - scoped_ptr<base::Value> missing_root_hash_sth = ParseJson( + std::unique_ptr<base::Value> missing_root_hash_sth = ParseJson( CreateSignedTreeHeadJsonString(1 /* tree_size */, 123456u /* timestamp */, "", GetSampleSTHTreeHeadSignature())); ASSERT_FALSE(FillSignedTreeHead(*missing_root_hash_sth.get(), &tree_head)); @@ -79,7 +80,7 @@ TEST(CTLogResponseParserTest, FailsToParseIncorrectLengthRootHash) { base::Base64Decode( base::StringPiece("/WHFMgXtI/umKKuACJIN0Bb73TcILm9WkeU6qszvoArK\n"), &too_long_hash); - scoped_ptr<base::Value> too_long_hash_json = + std::unique_ptr<base::Value> too_long_hash_json = ParseJson(CreateSignedTreeHeadJsonString( 1 /* tree_size */, 123456u /* timestamp */, GetSampleSTHSHA256RootHash(), too_long_hash)); @@ -89,7 +90,7 @@ TEST(CTLogResponseParserTest, FailsToParseIncorrectLengthRootHash) { base::Base64Decode( base::StringPiece("/WHFMgXtI/umKKuACJIN0Bb73TcILm9WkeU6qszvoA==\n"), &too_short_hash); - scoped_ptr<base::Value> too_short_hash_json = + std::unique_ptr<base::Value> too_short_hash_json = ParseJson(CreateSignedTreeHeadJsonString( 1 /* tree_size */, 123456u /* timestamp */, GetSampleSTHSHA256RootHash(), too_short_hash)); @@ -99,7 +100,7 @@ TEST(CTLogResponseParserTest, FailsToParseIncorrectLengthRootHash) { TEST(CTLogResponseParserTest, ParsesJsonSTHWithLargeTimestamp) { SignedTreeHead tree_head; - scoped_ptr<base::Value> large_timestamp_json = + std::unique_ptr<base::Value> large_timestamp_json = ParseJson(CreateSignedTreeHeadJsonString( 100, INT64_C(1) << 34, GetSampleSTHSHA256RootHash(), GetSampleSTHTreeHeadSignature())); @@ -122,7 +123,7 @@ TEST(CTLogResponseParserTest, ParsesConsistencyProofSuccessfully) { raw_nodes.push_back(first); raw_nodes.push_back(second); raw_nodes.push_back(third); - scoped_ptr<base::Value> sample_consistency_proof = + std::unique_ptr<base::Value> sample_consistency_proof = ParseJson(CreateConsistencyProofJsonString(raw_nodes)); std::vector<std::string> output; @@ -137,25 +138,26 @@ TEST(CTLogResponseParserTest, ParsesConsistencyProofSuccessfully) { TEST(CTLogResponseParserTest, FailsOnInvalidProofJson) { std::vector<std::string> output; - scoped_ptr<base::Value> badly_encoded = + std::unique_ptr<base::Value> badly_encoded = ParseJson(std::string("{\"consistency\": [\"notbase64\"]}")); EXPECT_FALSE(FillConsistencyProof(*badly_encoded.get(), &output)); - scoped_ptr<base::Value> not_a_string = + std::unique_ptr<base::Value> not_a_string = ParseJson(std::string("{\"consistency\": [42, 16]}")); EXPECT_FALSE(FillConsistencyProof(*badly_encoded.get(), &output)); - scoped_ptr<base::Value> missing_consistency = ParseJson(std::string("{}")); + std::unique_ptr<base::Value> missing_consistency = + ParseJson(std::string("{}")); EXPECT_FALSE(FillConsistencyProof(*missing_consistency.get(), &output)); - scoped_ptr<base::Value> not_a_dict = ParseJson(std::string("[]")); + std::unique_ptr<base::Value> not_a_dict = ParseJson(std::string("[]")); EXPECT_FALSE(FillConsistencyProof(*not_a_dict.get(), &output)); } TEST(CTLogResponseParserTest, ParsesProofJsonWithExtraFields) { std::vector<std::string> output; - scoped_ptr<base::Value> badly_encoded = + std::unique_ptr<base::Value> badly_encoded = ParseJson(std::string("{\"consistency\": [], \"somethingelse\": 3}")); EXPECT_TRUE(FillConsistencyProof(*badly_encoded.get(), &output)); } |