MCPcopy Index your code
hub / github.com/nodejs/node / runTests

Function runTests

test/fixtures/wpt/WebCryptoAPI/import_export/ML-DSA_importKey.js:3–44  ·  view source on GitHub ↗
(algorithmName)

Source from the content-addressed store, hash-verified

1var subtle = crypto.subtle;
2
3function runTests(algorithmName) {
4 var algorithm = { name: algorithmName };
5 var data = keyData[algorithmName];
6 var jwkData = {
7 jwk: { kty: data.jwk.kty, alg: data.jwk.alg, pub: data.jwk.pub },
8 };
9
10 [true, false].forEach(function (extractable) {
11 // Test public keys first
12 allValidUsages(data.publicUsages, true).forEach(function (usages) {
13 ['spki', 'jwk', 'raw-public'].forEach(function (format) {
14 if (format === 'jwk') {
15 // Not all fields used for public keys
16 testFormat(
17 format,
18 algorithm,
19 jwkData,
20 algorithmName,
21 usages,
22 extractable
23 );
24 } else {
25 testFormat(
26 format,
27 algorithm,
28 data,
29 algorithmName,
30 usages,
31 extractable
32 );
33 }
34 });
35 });
36
37 // Next, test private keys
38 allValidUsages(data.privateUsages).forEach(function (usages) {
39 ['pkcs8', 'jwk', 'raw-seed'].forEach(function (format) {
40 testFormat(format, algorithm, data, algorithmName, usages, extractable);
41 });
42 });
43 });
44}
45
46// Test importKey with a given key format and other parameters. If
47// extrable is true, export the key and verify that it matches the input.

Callers

nothing calls this directly

Calls 3

allValidUsagesFunction · 0.85
testFormatFunction · 0.70
forEachMethod · 0.65

Tested by

no test coverage detected