test,crypto: update WebCryptoAPI WPT · nodejs/node@bb4aa7a · GitHub
Skip to content

Commit bb4aa7a

Browse files
panvaruyadorno
authored andcommitted
test,crypto: update WebCryptoAPI WPT
PR-URL: #55997 Reviewed-By: Jason Zhang <xzha4350@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
1 parent 8efa240 commit bb4aa7a

7 files changed

Lines changed: 420 additions & 268 deletions

File tree

test/fixtures/wpt/README.md

Lines changed: 1 addition & 1 deletion

test/fixtures/wpt/WebCryptoAPI/digest/digest.https.any.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,20 @@
118118
});
119119
});
120120

121+
// Call digest() with empty algorithm object
122+
Object.keys(sourceData).forEach(function(size) {
123+
promise_test(function(test) {
124+
var promise = subtle.digest({}, sourceData[size])
125+
.then(function(result) {
126+
assert_unreached("digest() with missing algorithm name should have thrown a TypeError");
127+
}, function(err) {
128+
assert_equals(err.name, "TypeError", "Missing algorithm name should cause TypeError")
129+
});
130+
131+
return promise;
132+
}, "empty algorithm object with " + size);
133+
});
134+
121135

122136
done();
123137

test/fixtures/wpt/WebCryptoAPI/generateKey/failures.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,14 @@ function run_test(algorithmNames) {
166166
});
167167
});
168168

169+
// Empty algorithm should fail with TypeError
170+
allValidUsages(["decrypt", "sign", "deriveBits"], true, []) // Small search space, shouldn't matter because should fail before used
171+
.forEach(function(usages) {
172+
[false, true, "RED", 7].forEach(function(extractable){
173+
testError({}, extractable, usages, "TypeError", "Empty algorithm");
174+
});
175+
});
176+
169177

170178
// Algorithms normalize okay, but usages bad (though not empty).
171179
// It shouldn't matter what other extractable is. Should fail

test/fixtures/wpt/WebCryptoAPI/import_export/importKey_failures.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,4 +192,19 @@ function run_test(algorithmNames) {
192192
});
193193
});
194194
});
195+
196+
// Missing mandatory "name" field on algorithm
197+
testVectors.forEach(function(vector) {
198+
var name = vector.name;
199+
// We just need *some* valid keydata, so pick the first available algorithm.
200+
var algorithm = allAlgorithmSpecifiersFor(name)[0];
201+
getValidKeyData(algorithm).forEach(function(test) {
202+
validUsages(vector, test.format, test.data).forEach(function(usages) {
203+
[true, false].forEach(function(extractable) {
204+
testError(test.format, {}, test.data, name, usages, extractable, "TypeError", "Missing algorithm name");
205+
});
206+
});
207+
});
208+
});
209+
195210
}

test/fixtures/wpt/WebCryptoAPI/wrapKey_unwrapKey/wrapKey_unwrapKey.https.any.js

Lines changed: 267 additions & 266 deletions
Large diffs are not rendered by default.

test/fixtures/wpt/WebCryptoAPI/wrapKey_unwrapKey/wrapKey_unwrapKey_vectors.js

Lines changed: 114 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/fixtures/wpt/versions.json

Lines changed: 1 addition & 1 deletion

0 commit comments

Comments
 (0)