Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Unified Diff: LayoutTests/crypto/unwrapKey-badParameters.html

Issue 214263002: [refactor] Split wrap-unwrap.html into smaller files, and directly check the error result. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | LayoutTests/crypto/unwrapKey-badParameters-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/crypto/unwrapKey-badParameters.html
diff --git a/LayoutTests/crypto/wrap-unwrap.html b/LayoutTests/crypto/unwrapKey-badParameters.html
similarity index 38%
rename from LayoutTests/crypto/wrap-unwrap.html
rename to LayoutTests/crypto/unwrapKey-badParameters.html
index d72992e6245b87d99c6a789e2bfbfeebe0d02a8d..6090982bcf7d6af20d433af386a4bedb022668eb 100644
--- a/LayoutTests/crypto/wrap-unwrap.html
+++ b/LayoutTests/crypto/unwrapKey-badParameters.html
@@ -3,81 +3,39 @@
<head>
<script src="../resources/js-test.js"></script>
<script src="resources/common.js"></script>
-<script src="resources/keys.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script>
-description("Tests cypto.subtle.sign and crypto.subtle.verify");
-
-// FIXME: This is only testing invalid parameters right now. Once the
-// chromium-side implements the algorithms more interesting tests should be
-// added.
+description("Tests calls to unwrapKey() with bad inputs.");
jsTestIsAsync = true;
-importTestKeys().then(function(result) {
- keys = result;
- key = keys.hmacSha1;
- wrappingKey = keys.aesCbc;
-
- wrapAlgorithm = {name: 'aes-cbc', iv: new Uint8Array(16)};
-
- // --------------------------------
- // wrapKey invalid parameters
- // --------------------------------
-
- // Invalid format.
- shouldRejectPromiseWithNull("crypto.subtle.wrapKey('bad-format', key, wrappingKey, wrapAlgorithm)");
-
- // Invalid key
- shouldThrow("crypto.subtle.wrapKey('raw', 1, wrappingKey, wrapAlgorithm)");
-
- // Invalid wrappingKey
- shouldThrow("crypto.subtle.wrapKey('raw', key, '', wrapAlgorithm)");
-
- // Invalid wrapAlgorithm
- shouldThrow("crypto.subtle.wrapKey('raw', key, wrappingKey, undefined)");
-
- // Key is not extractable.
- shouldRejectPromiseWithNull("crypto.subtle.wrapKey('raw', keys.aesCbcJustDecrypt, wrappingKey, wrapAlgorithm)");
-
- // wrappingKey's usage does not include wrapKey.
- shouldRejectPromiseWithNull("crypto.subtle.wrapKey('raw', key, keys.aesCbcJustDecrypt, wrapAlgorithm)");
-
- // SHA-1 isn't a valid wrapKey algorithm.
- shouldRejectPromiseWithNull("crypto.subtle.wrapKey('raw', key, wrappingKey, {name: 'SHA-1'})");
+function importUnwrappingKey()
+{
+ var data = new Uint8Array(16);
+ var extractable = true;
+ var keyUsages = ['unwrapKey'];
- // Wrap algorithm doesn't match the wrapping key's algorithm (AES-CBC key
- // with AES-CTR wrap algorithm)
- aesCtrAlgorithm = {name: 'AES-CTR', counter: new Uint8Array(16), length: 0};
- shouldRejectPromiseWithNull("crypto.subtle.wrapKey('raw', key, wrappingKey, aesCtrAlgorithm)");
-
- // --------------------------------
- // unwrapKey invalid parameters
- // --------------------------------
+ return crypto.subtle.importKey('raw', data, {name: 'AES-CBC'}, extractable, keyUsages);
+}
+importUnwrappingKey().then(function(result) {
wrappedKey = new Uint8Array(100);
- unwrappingKey = keys.aesCbc;
+ unwrappingKey = result;
unwrapAlgorithm = {name: 'aes-cbc', iv: new Uint8Array(16)};
unwrappedKeyAlgorithm = unwrapAlgorithm;
extractable = true;
keyUsages = ['encrypt'];
- // Invalid format
- shouldRejectPromiseWithNull("crypto.subtle.unwrapKey('bad-format', wrappedKey, unwrappingKey, unwrapAlgorithm, unwrappedKeyAlgorithm, extractable, keyUsages)");
-
// Invalid wrappedKey
shouldThrow("crypto.subtle.unwrapKey('raw', null, unwrappingKey, unwrapAlgorithm, unwrappedKeyAlgorithm, extractable, keyUsages)");
// Invalid unwrappingKey
shouldThrow("crypto.subtle.unwrapKey('raw', wrappedKey, 'hi', unwrapAlgorithm, unwrappedKeyAlgorithm, extractable, keyUsages)");
- // unwrappingKey does not include unwrapKey usage.
- shouldRejectPromiseWithNull("crypto.subtle.unwrapKey('raw', wrappedKey, keys.aesCbcJustDecrypt, unwrapAlgorithm, unwrappedKeyAlgorithm, extractable, keyUsages)");
-
// Invalid keyUsages (also, unwrappedKeyAlgorithm is set to null).
shouldThrow("crypto.subtle.unwrapKey('raw', wrappedKey, 'hi', unwrapAlgorithm, null, extractable, 9)");
@@ -87,15 +45,27 @@ importTestKeys().then(function(result) {
// Invalid unwrappedKeyAlgorithm (specified but bad).
shouldThrow("crypto.subtle.unwrapKey('raw', wrappedKey, unwrappingKey, unwrapAlgorithm, 3, extractable, keyUsages)");
+ // Invalid format
+ return crypto.subtle.unwrapKey('bad-format', wrappedKey, unwrappingKey, unwrapAlgorithm, unwrappedKeyAlgorithm, extractable, keyUsages);
+}).then(failAndFinishJSTest, function(result) {
+ error = result;
+ shouldBeNull("error");
+
// SHA-1 isn't a valid unwrapKey algorithm.
- shouldRejectPromiseWithNull("crypto.subtle.unwrapKey('raw', wrappedKey, unwrappingKey, {name: 'SHA-1'}, unwrappedKeyAlgorithm, extractable, keyUsages)");
+ return crypto.subtle.unwrapKey('raw', wrappedKey, unwrappingKey, {name: 'SHA-1'}, unwrappedKeyAlgorithm, extractable, keyUsages);
+}).then(failAndFinishJSTest, function(result) {
+ error = result;
+ shouldBeNull("error");
// Mismatch between the unwrappingKey's algorithm and unwrapAlgorithm.
- shouldRejectPromiseWithNull("crypto.subtle.unwrapKey('raw', wrappedKey, unwrappingKey, aesCtrAlgorithm, unwrappedKeyAlgorithm, extractable, keyUsages)");
-
+ aesCtrAlgorithm = {name: 'AES-CTR', counter: new Uint8Array(16), length: 0};
+ return crypto.subtle.unwrapKey('raw', wrappedKey, unwrappingKey, aesCtrAlgorithm, unwrappedKeyAlgorithm, extractable, keyUsages);
+}).then(failAndFinishJSTest, function(result) {
+ error = result;
+ shouldBeNull("error");
}).then(finishJSTest, failAndFinishJSTest);
-
</script>
</body>
+</html>
« no previous file with comments | « no previous file | LayoutTests/crypto/unwrapKey-badParameters-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698