From 843df1a4da9502a48f1d53f96e0f47363cee6df6 Mon Sep 17 00:00:00 2001 From: Filip Skokan Date: Thu, 21 Sep 2023 11:02:11 +0200 Subject: [PATCH] test,crypto: update WebCryptoAPI WPT PR-URL: https://github.com/nodejs/node/pull/49714 Reviewed-By: Yagiz Nizipli Reviewed-By: Luigi Pinca --- test/fixtures/wpt/README.md | 2 +- .../import_export/ec_importKey.https.any.js | 45 +------------------ .../import_export/okp_importKey.https.any.js | 44 +----------------- .../import_export/rsa_importKey.https.any.js | 44 +----------------- .../symmetric_importKey.https.any.js | 42 +---------------- .../fixtures/wpt/WebCryptoAPI/util/helpers.js | 2 +- test/fixtures/wpt/versions.json | 2 +- 7 files changed, 10 insertions(+), 171 deletions(-) diff --git a/test/fixtures/wpt/README.md b/test/fixtures/wpt/README.md index 890c8f9e1dbe3b..c8210edb569c17 100644 --- a/test/fixtures/wpt/README.md +++ b/test/fixtures/wpt/README.md @@ -31,7 +31,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/17b7ca10fd/WebCryptoAPI +- WebCryptoAPI: https://github.com/web-platform-tests/wpt/tree/f4e7e32fd0/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 diff --git a/test/fixtures/wpt/WebCryptoAPI/import_export/ec_importKey.https.any.js b/test/fixtures/wpt/WebCryptoAPI/import_export/ec_importKey.https.any.js index 25defa369c1d31..31f062e313f6fe 100644 --- a/test/fixtures/wpt/WebCryptoAPI/import_export/ec_importKey.https.any.js +++ b/test/fixtures/wpt/WebCryptoAPI/import_export/ec_importKey.https.any.js @@ -71,7 +71,7 @@ [true, false].forEach(function(extractable) { // Test public keys first - [[]].forEach(function(usages) { // Only valid usages argument is empty array + allValidUsages(vector.publicUsages, true).forEach(function(usages) { ['spki', 'spki_compressed', 'jwk', 'raw', 'raw_compressed'].forEach(function(format) { var algorithm = {name: vector.name, namedCurve: curve}; var data = keyData[curve]; @@ -88,7 +88,7 @@ ['pkcs8', 'jwk'].forEach(function(format) { var algorithm = {name: vector.name, namedCurve: curve}; var data = keyData[curve]; - allValidUsages(vector.privateUsages, []).forEach(function(usages) { + allValidUsages(vector.privateUsages).forEach(function(usages) { testFormat(format, algorithm, data, curve, usages, extractable); }); testEmptyUsages(format, algorithm, data, curve, extractable); @@ -219,46 +219,6 @@ return base64String.replace(/=/g, ""); } - // Want to test every valid combination of usages. Start by creating a list - // of all non-empty subsets to possible usages. - function allNonemptySubsetsOf(arr) { - var results = []; - var firstElement; - var remainingElements; - - for(var i=0; i 0) { - allNonemptySubsetsOf(remainingElements).forEach(function(combination) { - combination.push(firstElement); - results.push(combination); - }); - } - } - - return results; - } - - // Return a list of all valid usage combinations, given the possible ones - // and the ones that are required for a particular operation. - function allValidUsages(possibleUsages, requiredUsages) { - var allUsages = []; - - allNonemptySubsetsOf(possibleUsages).forEach(function(usage) { - for (var i=0; i 0) { - allNonemptySubsetsOf(remainingElements).forEach(function(combination) { - combination.push(firstElement); - results.push(combination); - }); - } - } - - return results; - } - - // Return a list of all valid usage combinations, given the possible ones - // and the ones that are required for a particular operation. - function allValidUsages(possibleUsages, requiredUsages) { - var allUsages = []; - - allNonemptySubsetsOf(possibleUsages).forEach(function(usage) { - for (var i=0; i 0) { - allNonemptySubsetsOf(remainingElements).forEach(function(combination) { - combination.push(firstElement); - results.push(combination); - }); - } - } - - return results; - } - - // Return a list of all valid usage combinations, given the possible ones - // and the ones that are required for a particular operation. - function allValidUsages(possibleUsages, requiredUsages) { - var allUsages = []; - - allNonemptySubsetsOf(possibleUsages).forEach(function(usage) { - for (var i=0; i 0) { - allNonemptySubsetsOf(remainingElements).forEach(function(combination) { - combination.push(firstElement); - results.push(combination); - }); - } - } - - return results; - } - - // Return a list of all valid usage combinations, given the possible ones - // and the ones that are required for a particular operation. - function allValidUsages(possibleUsages, requiredUsages) { - var allUsages = []; - - allNonemptySubsetsOf(possibleUsages).forEach(function(usage) { - for (var i=0; i