summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreroman <eroman@chromium.org>2014-11-07 19:05:10 -0800
committerCommit bot <commit-bot@chromium.org>2014-11-08 03:05:34 +0000
commit398e7e1ecb130cc82e16612767b827c57dc4b277 (patch)
tree0553087194381e9309075badd198762f983f90b8
parent344435e974a2f4322735f04a0a3118aa262a6910 (diff)
downloadchromium_src-398e7e1ecb130cc82e16612767b827c57dc4b277.zip
chromium_src-398e7e1ecb130cc82e16612767b827c57dc4b277.tar.gz
chromium_src-398e7e1ecb130cc82e16612767b827c57dc4b277.tar.bz2
Refactor: Rename "property" --> "member" for JWK error function.
BUG=428949 Review URL: https://codereview.chromium.org/703343002 Cr-Commit-Position: refs/heads/master@{#303368}
-rw-r--r--content/child/webcrypto/jwk.cc10
-rw-r--r--content/child/webcrypto/status.cc30
-rw-r--r--content/child/webcrypto/status.h25
-rw-r--r--content/child/webcrypto/test/aes_cbc_unittest.cc14
-rw-r--r--content/child/webcrypto/test/status_unittest.cc8
-rw-r--r--content/child/webcrypto/webcrypto_util.cc2
6 files changed, 48 insertions, 41 deletions
diff --git a/content/child/webcrypto/jwk.cc b/content/child/webcrypto/jwk.cc
index b0073cc..d6729ca 100644
--- a/content/child/webcrypto/jwk.cc
+++ b/content/child/webcrypto/jwk.cc
@@ -345,9 +345,9 @@ Status JwkReader::GetString(const std::string& member_name,
std::string* result) const {
base::Value* value = NULL;
if (!dict_->Get(member_name, &value))
- return Status::ErrorJwkPropertyMissing(member_name);
+ return Status::ErrorJwkMemberMissing(member_name);
if (!value->GetAsString(result))
- return Status::ErrorJwkPropertyWrongType(member_name, "string");
+ return Status::ErrorJwkMemberWrongType(member_name, "string");
return Status::Success();
}
@@ -360,7 +360,7 @@ Status JwkReader::GetOptionalString(const std::string& member_name,
return Status::Success();
if (!value->GetAsString(result))
- return Status::ErrorJwkPropertyWrongType(member_name, "string");
+ return Status::ErrorJwkMemberWrongType(member_name, "string");
*member_exists = true;
return Status::Success();
@@ -375,7 +375,7 @@ Status JwkReader::GetOptionalList(const std::string& member_name,
return Status::Success();
if (!value->GetAsList(result))
- return Status::ErrorJwkPropertyWrongType(member_name, "list");
+ return Status::ErrorJwkMemberWrongType(member_name, "list");
*member_exists = true;
return Status::Success();
@@ -421,7 +421,7 @@ Status JwkReader::GetOptionalBool(const std::string& member_name,
return Status::Success();
if (!value->GetAsBoolean(result))
- return Status::ErrorJwkPropertyWrongType(member_name, "boolean");
+ return Status::ErrorJwkMemberWrongType(member_name, "boolean");
*member_exists = true;
return Status::Success();
diff --git a/content/child/webcrypto/status.cc b/content/child/webcrypto/status.cc
index a7afdb3..9910cff 100644
--- a/content/child/webcrypto/status.cc
+++ b/content/child/webcrypto/status.cc
@@ -6,6 +6,10 @@
namespace content {
+// TODO(eroman): The error text for JWK uses the terminology "property" however
+// it should instead call it a "member". Changing this needs to coordinate with
+// the Blink LayoutTests as they depend on the old names.
+
namespace webcrypto {
bool Status::IsError() const {
@@ -33,22 +37,23 @@ Status Status::ErrorJwkNotDictionary() {
"JWK input could not be parsed to a JSON dictionary");
}
-Status Status::ErrorJwkPropertyMissing(const std::string& property) {
- return Status(blink::WebCryptoErrorTypeData,
- "The required JWK property \"" + property + "\" was missing");
+Status Status::ErrorJwkMemberMissing(const std::string& member_name) {
+ return Status(
+ blink::WebCryptoErrorTypeData,
+ "The required JWK property \"" + member_name + "\" was missing");
}
-Status Status::ErrorJwkPropertyWrongType(const std::string& property,
- const std::string& expected_type) {
+Status Status::ErrorJwkMemberWrongType(const std::string& member_name,
+ const std::string& expected_type) {
return Status(
blink::WebCryptoErrorTypeData,
- "The JWK property \"" + property + "\" must be a " + expected_type);
+ "The JWK property \"" + member_name + "\" must be a " + expected_type);
}
-Status Status::ErrorJwkBase64Decode(const std::string& property) {
+Status Status::ErrorJwkBase64Decode(const std::string& member_name) {
return Status(
blink::WebCryptoErrorTypeData,
- "The JWK property \"" + property + "\" could not be base64 decoded");
+ "The JWK property \"" + member_name + "\" could not be base64 decoded");
}
Status Status::ErrorJwkExtInconsistent() {
@@ -105,15 +110,16 @@ Status Status::ErrorJwkIncorrectKeyLength() {
"of key data for the given algorithm.");
}
-Status Status::ErrorJwkEmptyBigInteger(const std::string& property) {
+Status Status::ErrorJwkEmptyBigInteger(const std::string& member_name) {
return Status(blink::WebCryptoErrorTypeData,
- "The JWK \"" + property + "\" property was empty.");
+ "The JWK \"" + member_name + "\" property was empty.");
}
-Status Status::ErrorJwkBigIntegerHasLeadingZero(const std::string& property) {
+Status Status::ErrorJwkBigIntegerHasLeadingZero(
+ const std::string& member_name) {
return Status(
blink::WebCryptoErrorTypeData,
- "The JWK \"" + property + "\" property contained a leading zero.");
+ "The JWK \"" + member_name + "\" property contained a leading zero.");
}
Status Status::ErrorJwkDuplicateKeyOps() {
diff --git a/content/child/webcrypto/status.h b/content/child/webcrypto/status.h
index 4c1aae6..17735c3 100644
--- a/content/child/webcrypto/status.h
+++ b/content/child/webcrypto/status.h
@@ -54,16 +54,16 @@ class CONTENT_EXPORT Status {
// convertable to a dictionary.
static Status ErrorJwkNotDictionary();
- // The required property |property| was missing.
- static Status ErrorJwkPropertyMissing(const std::string& property);
+ // The required JWK member |member_name| was missing.
+ static Status ErrorJwkMemberMissing(const std::string& member_name);
- // The property |property| was not of type |expected_type|.
- static Status ErrorJwkPropertyWrongType(const std::string& property,
- const std::string& expected_type);
+ // The JWK member |member_name| was not of type |expected_type|.
+ static Status ErrorJwkMemberWrongType(const std::string& member_name,
+ const std::string& expected_type);
- // The property |property| was a string, however could not be successfully
- // base64 decoded.
- static Status ErrorJwkBase64Decode(const std::string& property);
+ // The JWK member |member_name| was a string, however could not be
+ // successfully base64 decoded.
+ static Status ErrorJwkBase64Decode(const std::string& member_name);
// The "ext" parameter was specified but was
// incompatible with the value requested by the Web Crypto call.
@@ -103,13 +103,14 @@ class CONTENT_EXPORT Status {
// given that is an error.
static Status ErrorJwkIncorrectKeyLength();
- // The JWK property |property| is supposed to represent a big-endian unsigned
+ // The JWK member |member_name| is supposed to represent a big-endian unsigned
// integer, however was the empty string.
- static Status ErrorJwkEmptyBigInteger(const std::string& property);
+ static Status ErrorJwkEmptyBigInteger(const std::string& member_name);
- // The big-endian unsigned integer |property| contained leading zeros. This
+ // The big-endian unsigned integer |member_name| contained leading zeros. This
// violates the JWA requirement that such octet strings be minimal.
- static Status ErrorJwkBigIntegerHasLeadingZero(const std::string& property);
+ static Status ErrorJwkBigIntegerHasLeadingZero(
+ const std::string& member_name);
// The key_ops lists a usage more than once.
static Status ErrorJwkDuplicateKeyOps();
diff --git a/content/child/webcrypto/test/aes_cbc_unittest.cc b/content/child/webcrypto/test/aes_cbc_unittest.cc
index 95a6d2c..c6fe95d 100644
--- a/content/child/webcrypto/test/aes_cbc_unittest.cc
+++ b/content/child/webcrypto/test/aes_cbc_unittest.cc
@@ -557,7 +557,7 @@ TEST(WebCryptoAesCbcTest, ImportJwkMissingKty) {
base::DictionaryValue dict;
dict.SetString("k", "GADWrMRHwQfoNaXU5fZvTg==");
EXPECT_EQ(
- Status::ErrorJwkPropertyMissing("kty"),
+ Status::ErrorJwkMemberMissing("kty"),
ImportKeyJwkFromDict(dict,
CreateAlgorithm(blink::WebCryptoAlgorithmIdAesCbc),
false,
@@ -574,7 +574,7 @@ TEST(WebCryptoAesCbcTest, ImportJwkKtyWrongType) {
dict.SetString("k", "GADWrMRHwQfoNaXU5fZvTg==");
EXPECT_EQ(
- Status::ErrorJwkPropertyWrongType("kty", "string"),
+ Status::ErrorJwkMemberWrongType("kty", "string"),
ImportKeyJwkFromDict(dict,
CreateAlgorithm(blink::WebCryptoAlgorithmIdAesCbc),
false,
@@ -610,7 +610,7 @@ TEST(WebCryptoAesCbcTest, ImportJwkUseWrongType) {
dict.SetString("k", "GADWrMRHwQfoNaXU5fZvTg==");
EXPECT_EQ(
- Status::ErrorJwkPropertyWrongType("use", "string"),
+ Status::ErrorJwkMemberWrongType("use", "string"),
ImportKeyJwkFromDict(dict,
CreateAlgorithm(blink::WebCryptoAlgorithmIdAesCbc),
false,
@@ -628,7 +628,7 @@ TEST(WebCryptoAesCbcTest, ImportJwkExtWrongType) {
dict.SetString("k", "GADWrMRHwQfoNaXU5fZvTg==");
EXPECT_EQ(
- Status::ErrorJwkPropertyWrongType("ext", "boolean"),
+ Status::ErrorJwkMemberWrongType("ext", "boolean"),
ImportKeyJwkFromDict(dict,
CreateAlgorithm(blink::WebCryptoAlgorithmIdAesCbc),
false,
@@ -646,7 +646,7 @@ TEST(WebCryptoAesCbcTest, ImportJwkKeyOpsWrongType) {
dict.SetBoolean("key_ops", true);
EXPECT_EQ(
- Status::ErrorJwkPropertyWrongType("key_ops", "list"),
+ Status::ErrorJwkMemberWrongType("key_ops", "list"),
ImportKeyJwkFromDict(dict,
CreateAlgorithm(blink::WebCryptoAlgorithmIdAesCbc),
false,
@@ -718,7 +718,7 @@ TEST(WebCryptoAesCbcTest, ImportJwkNonStringKeyOp) {
dict.Set("key_ops", key_ops);
key_ops->AppendString("encrypt");
key_ops->AppendInteger(3);
- EXPECT_EQ(Status::ErrorJwkPropertyWrongType("key_ops[1]", "string"),
+ EXPECT_EQ(Status::ErrorJwkMemberWrongType("key_ops[1]", "string"),
ImportKeyJwkFromDict(dict, algorithm, false, usages, &key));
}
@@ -730,7 +730,7 @@ TEST(WebCryptoAesCbcTest, ImportJwkMissingK) {
dict.SetString("kty", "oct");
EXPECT_EQ(
- Status::ErrorJwkPropertyMissing("k"),
+ Status::ErrorJwkMemberMissing("k"),
ImportKeyJwkFromDict(dict,
CreateAlgorithm(blink::WebCryptoAlgorithmIdAesCbc),
false,
diff --git a/content/child/webcrypto/test/status_unittest.cc b/content/child/webcrypto/test/status_unittest.cc
index 11d014e..93b4369 100644
--- a/content/child/webcrypto/test/status_unittest.cc
+++ b/content/child/webcrypto/test/status_unittest.cc
@@ -29,8 +29,8 @@ TEST(WebCryptoStatusTest, Basic) {
EXPECT_NE(Status::Success(), Status::OperationError());
EXPECT_EQ(Status::Success(), Status::Success());
- EXPECT_EQ(Status::ErrorJwkPropertyWrongType("kty", "string"),
- Status::ErrorJwkPropertyWrongType("kty", "string"));
+ EXPECT_EQ(Status::ErrorJwkMemberWrongType("kty", "string"),
+ Status::ErrorJwkMemberWrongType("kty", "string"));
Status status = Status::Success();
@@ -52,13 +52,13 @@ TEST(WebCryptoStatusTest, Basic) {
EXPECT_EQ("The requested operation is unsupported", status.error_details());
EXPECT_EQ(blink::WebCryptoErrorTypeNotSupported, status.error_type());
- status = Status::ErrorJwkPropertyMissing("kty");
+ status = Status::ErrorJwkMemberMissing("kty");
EXPECT_TRUE(status.IsError());
EXPECT_EQ("The required JWK property \"kty\" was missing",
status.error_details());
EXPECT_EQ(blink::WebCryptoErrorTypeData, status.error_type());
- status = Status::ErrorJwkPropertyWrongType("kty", "string");
+ status = Status::ErrorJwkMemberWrongType("kty", "string");
EXPECT_TRUE(status.IsError());
EXPECT_EQ("The JWK property \"kty\" must be a string",
status.error_details());
diff --git a/content/child/webcrypto/webcrypto_util.cc b/content/child/webcrypto/webcrypto_util.cc
index 410acdd..bb4cbb9 100644
--- a/content/child/webcrypto/webcrypto_util.cc
+++ b/content/child/webcrypto/webcrypto_util.cc
@@ -84,7 +84,7 @@ Status GetWebCryptoUsagesFromJwkKeyOps(const base::ListValue* key_ops,
for (size_t i = 0; i < key_ops->GetSize(); ++i) {
std::string key_op;
if (!key_ops->GetString(i, &key_op)) {
- return Status::ErrorJwkPropertyWrongType(
+ return Status::ErrorJwkMemberWrongType(
base::StringPrintf("key_ops[%d]", static_cast<int>(i)), "string");
}