Index: content/child/webcrypto/test/ecdh_unittest.cc |
diff --git a/content/child/webcrypto/test/ecdh_unittest.cc b/content/child/webcrypto/test/ecdh_unittest.cc |
index 822013f6cc5058755f5d1c7e73bfbadfa6c3f8d6..c1883917baa2c7ffa0df4b230dc5352fffc6685a 100644 |
--- a/content/child/webcrypto/test/ecdh_unittest.cc |
+++ b/content/child/webcrypto/test/ecdh_unittest.cc |
@@ -126,19 +126,30 @@ TEST(WebCryptoEcdhTest, DeriveBitsKnownAnswer) { |
// Loads up a test ECDH public and private key for P-521. The keys |
// come from different key pairs, and can be used for key derivation of up to |
// 528 bits. |
-void LoadTestKeys(blink::WebCryptoKey* public_key, |
+::testing::AssertionResult LoadTestKeys(blink::WebCryptoKey* public_key, |
blink::WebCryptoKey* private_key) { |
eroman
2014/12/29 18:01:04
run "git cl format" to fix these sorts of formatti
Habib Virji
2014/12/30 17:22:48
It do not remember, but will keep an eye on runnin
|
- // Assume that the 7th key in the test data is for P-521. |
scoped_ptr<base::ListValue> tests; |
- ASSERT_TRUE(ReadJsonTestFileToList("ecdh.json", &tests)); |
+ EXPECT_TRUE(ReadJsonTestFileToList("ecdh.json", &tests)); |
eroman
2014/12/29 18:01:04
Please change to:
if (!ReadJsonTestFileToList(...
Habib Virji
2014/12/30 17:22:48
Done.
|
const base::DictionaryValue* test; |
- ASSERT_TRUE(tests->GetDictionary(6, &test)); |
+ bool valid_p521_keys = false; |
+ for (size_t test_index = 0; test_index < tests->GetSize(); ++test_index) { |
+ SCOPED_TRACE(test_index); |
+ EXPECT_TRUE(tests->GetDictionary(test_index, &test)); |
+ test->GetBoolean("valid_p521_keys", &valid_p521_keys); |
+ if (valid_p521_keys) |
+ break; |
+ else if (!valid_p521_keys && tests->GetSize() == test_index + 1) |
eroman
2014/12/29 18:01:04
use curly braces around this:
else if (...) {
.
Habib Virji
2014/12/30 17:22:48
Done.
|
+ return ::testing::AssertionFailure() << |
+ "The P-521 test are missing in ecdh.json"; |
+ } |
ImportKeysFromTest(test, public_key, private_key); |
- ASSERT_EQ(blink::WebCryptoNamedCurveP521, |
+ EXPECT_EQ(blink::WebCryptoNamedCurveP521, |
public_key->algorithm().ecParams()->namedCurve()); |
+ |
+ return ::testing::AssertionSuccess(); |
} |
// Try deriving an AES key of length 129 bits. |
@@ -148,7 +159,7 @@ TEST(WebCryptoEcdhTest, DeriveKeyBadAesLength) { |
blink::WebCryptoKey public_key; |
blink::WebCryptoKey base_key; |
- LoadTestKeys(&public_key, &base_key); |
+ ASSERT_TRUE(LoadTestKeys(&public_key, &base_key)); |
blink::WebCryptoKey derived_key; |
@@ -166,7 +177,7 @@ TEST(WebCryptoEcdhTest, DeriveKeyUnsupportedAesLength) { |
blink::WebCryptoKey public_key; |
blink::WebCryptoKey base_key; |
- LoadTestKeys(&public_key, &base_key); |
+ ASSERT_TRUE(LoadTestKeys(&public_key, &base_key)); |
blink::WebCryptoKey derived_key; |
@@ -184,7 +195,7 @@ TEST(WebCryptoEcdhTest, DeriveKeyZeroLengthHmac) { |
blink::WebCryptoKey public_key; |
blink::WebCryptoKey base_key; |
- LoadTestKeys(&public_key, &base_key); |
+ ASSERT_TRUE(LoadTestKeys(&public_key, &base_key)); |
blink::WebCryptoKey derived_key; |
@@ -204,7 +215,7 @@ TEST(WebCryptoEcdhTest, DeriveKeyHmac19Bits) { |
blink::WebCryptoKey public_key; |
blink::WebCryptoKey base_key; |
- LoadTestKeys(&public_key, &base_key); |
+ ASSERT_TRUE(LoadTestKeys(&public_key, &base_key)); |
blink::WebCryptoKey derived_key; |
@@ -237,7 +248,7 @@ TEST(WebCryptoEcdhTest, DeriveKeyHmacSha256NoLength) { |
blink::WebCryptoKey public_key; |
blink::WebCryptoKey base_key; |
- LoadTestKeys(&public_key, &base_key); |
+ ASSERT_TRUE(LoadTestKeys(&public_key, &base_key)); |
blink::WebCryptoKey derived_key; |
@@ -276,7 +287,7 @@ TEST(WebCryptoEcdhTest, DeriveKeyHmacSha512NoLength) { |
blink::WebCryptoKey public_key; |
blink::WebCryptoKey base_key; |
- LoadTestKeys(&public_key, &base_key); |
+ ASSERT_TRUE(LoadTestKeys(&public_key, &base_key)); |
blink::WebCryptoKey derived_key; |
@@ -296,7 +307,7 @@ TEST(WebCryptoEcdhTest, DeriveKeyAes128) { |
blink::WebCryptoKey public_key; |
blink::WebCryptoKey base_key; |
- LoadTestKeys(&public_key, &base_key); |
+ ASSERT_TRUE(LoadTestKeys(&public_key, &base_key)); |
blink::WebCryptoKey derived_key; |