From e26f6dae998d3c5521597adebf8ed7f6cc088a44 Mon Sep 17 00:00:00 2001 From: Filip Skokan Date: Sun, 15 Sep 2024 18:28:03 +0200 Subject: [PATCH] test,crypto: update WebCryptoAPI WPT MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/54925 Reviewed-By: Luigi Pinca Reviewed-By: Michaƫl Zasso Reviewed-By: Matteo Collina --- test/fixtures/wpt/README.md | 2 +- .../wpt/WebCryptoAPI/generateKey/successes.js | 30 +++++++++++++++++-- test/fixtures/wpt/versions.json | 2 +- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/test/fixtures/wpt/README.md b/test/fixtures/wpt/README.md index 118bb456a8eecd..836e238bc4bcef 100644 --- a/test/fixtures/wpt/README.md +++ b/test/fixtures/wpt/README.md @@ -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/6748a0a246/WebCryptoAPI +- WebCryptoAPI: https://github.com/web-platform-tests/wpt/tree/272064ebf9/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/e97fac4791/webmessaging/broadcastchannel - webstorage: https://github.com/web-platform-tests/wpt/tree/9dafa89214/webstorage diff --git a/test/fixtures/wpt/WebCryptoAPI/generateKey/successes.js b/test/fixtures/wpt/WebCryptoAPI/generateKey/successes.js index e1c1665b511030..a9a168e1adbf72 100644 --- a/test/fixtures/wpt/WebCryptoAPI/generateKey/successes.js +++ b/test/fixtures/wpt/WebCryptoAPI/generateKey/successes.js @@ -5,7 +5,8 @@ function run_test(algorithmNames, slowTest) { setup({explicit_timeout: true}); // These tests check that generateKey successfully creates keys -// when provided any of a wide set of correct parameters. +// when provided any of a wide set of correct parameters +// and that they can be exported afterwards. // // There are a lot of combinations of possible parameters, // resulting in a very large number of tests @@ -68,9 +69,32 @@ function run_test(algorithmNames, slowTest) { } else { assert_goodCryptoKey(result, algorithm, extractable, usages, "secret"); } + return result; }, function(err) { - assert_unreached("Threw an unexpected error: " + err.toString()); - }); + assert_unreached("generateKey threw an unexpected error: " + err.toString()); + }) + .then(async function (result) { + if (resultType === "CryptoKeyPair") { + await Promise.all([ + subtle.exportKey('jwk', result.publicKey), + subtle.exportKey('spki', result.publicKey), + result.publicKey.algorithm.name.startsWith('RSA') ? undefined : subtle.exportKey('raw', result.publicKey), + ...(extractable ? [ + subtle.exportKey('jwk', result.privateKey), + subtle.exportKey('pkcs8', result.privateKey), + ] : []) + ]); + } else { + if (extractable) { + await Promise.all([ + subtle.exportKey('raw', result), + subtle.exportKey('jwk', result), + ]); + } + } + }, function(err) { + assert_unreached("exportKey threw an unexpected error: " + err.toString()); + }) }, testTag + ": generateKey" + parameterString(algorithm, extractable, usages)); } diff --git a/test/fixtures/wpt/versions.json b/test/fixtures/wpt/versions.json index 43b1f480d1f18c..e55319b60334c7 100644 --- a/test/fixtures/wpt/versions.json +++ b/test/fixtures/wpt/versions.json @@ -88,7 +88,7 @@ "path": "wasm/webapi" }, "WebCryptoAPI": { - "commit": "6748a0a24614b01ce6527493a19ef846738bee3a", + "commit": "272064ebf9a3d313a2d4db8bb9ce2790648aa162", "path": "WebCryptoAPI" }, "webidl/ecmascript-binding/es-exceptions": {