summaryrefslogtreecommitdiff
path: root/chromium/net/cert/ct_log_response_parser_unittest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/net/cert/ct_log_response_parser_unittest.cc')
-rw-r--r--chromium/net/cert/ct_log_response_parser_unittest.cc30
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));
}