Skip to content

Commit

Permalink
test,crypto: update WebCryptoAPI WPT
Browse files Browse the repository at this point in the history
PR-URL: nodejs#55997
Reviewed-By: Jason Zhang <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Yagiz Nizipli <[email protected]>
  • Loading branch information
panva authored and nodejs-github-bot committed Dec 4, 2024
1 parent 18e910e commit 0b8484d
Show file tree
Hide file tree
Showing 7 changed files with 420 additions and 268 deletions.
2 changes: 1 addition & 1 deletion test/fixtures/wpt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Last update:
- user-timing: https://github.com/web-platform-tests/wpt/tree/5ae85bf826/user-timing
- wasm/jsapi: https://github.com/web-platform-tests/wpt/tree/cde25e7e3c/wasm/jsapi
- wasm/webapi: https://github.com/web-platform-tests/wpt/tree/fd1b23eeaa/wasm/webapi
- WebCryptoAPI: https://github.com/web-platform-tests/wpt/tree/b81831169b/WebCryptoAPI
- WebCryptoAPI: https://github.com/web-platform-tests/wpt/tree/ecf39b605f/WebCryptoAPI
- webidl/ecmascript-binding/es-exceptions: https://github.com/web-platform-tests/wpt/tree/a370aad338/webidl/ecmascript-binding/es-exceptions
- webmessaging/broadcastchannel: https://github.com/web-platform-tests/wpt/tree/6495c91853/webmessaging/broadcastchannel
- webstorage: https://github.com/web-platform-tests/wpt/tree/9dafa89214/webstorage
Expand Down
14 changes: 14 additions & 0 deletions test/fixtures/wpt/WebCryptoAPI/digest/digest.https.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,20 @@
});
});

// Call digest() with empty algorithm object
Object.keys(sourceData).forEach(function(size) {
promise_test(function(test) {
var promise = subtle.digest({}, sourceData[size])
.then(function(result) {
assert_unreached("digest() with missing algorithm name should have thrown a TypeError");
}, function(err) {
assert_equals(err.name, "TypeError", "Missing algorithm name should cause TypeError")
});

return promise;
}, "empty algorithm object with " + size);
});


done();

Expand Down
8 changes: 8 additions & 0 deletions test/fixtures/wpt/WebCryptoAPI/generateKey/failures.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,14 @@ function run_test(algorithmNames) {
});
});

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


// Algorithms normalize okay, but usages bad (though not empty).
// It shouldn't matter what other extractable is. Should fail
Expand Down
15 changes: 15 additions & 0 deletions test/fixtures/wpt/WebCryptoAPI/import_export/importKey_failures.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,19 @@ function run_test(algorithmNames) {
});
});
});

// Missing mandatory "name" field on algorithm
testVectors.forEach(function(vector) {
var name = vector.name;
// We just need *some* valid keydata, so pick the first available algorithm.
var algorithm = allAlgorithmSpecifiersFor(name)[0];
getValidKeyData(algorithm).forEach(function(test) {
validUsages(vector, test.format, test.data).forEach(function(usages) {
[true, false].forEach(function(extractable) {
testError(test.format, {}, test.data, name, usages, extractable, "TypeError", "Missing algorithm name");
});
});
});
});

}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion test/fixtures/wpt/versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
"path": "wasm/webapi"
},
"WebCryptoAPI": {
"commit": "b81831169b8527a6c569a4ad92cf8a1baf4a7118",
"commit": "ecf39b605f4d2b5d7ef4fe344063c2856c9f105c",
"path": "WebCryptoAPI"
},
"webidl/ecmascript-binding/es-exceptions": {
Expand Down

0 comments on commit 0b8484d

Please sign in to comment.