MCPcopy Create free account
hub / github.com/nodejs/node / invalidUsages

Function invalidUsages

test/fixtures/wpt/WebCryptoAPI/generateKey/failures.js:125–145  ·  view source on GitHub ↗
(validUsages, mandatoryUsages)

Source from the content-addressed store, hash-verified

123 // of an illegal usage, and "poison" every valid usage
124 // with an illegal one.
125 function invalidUsages(validUsages, mandatoryUsages) {
126 var results = [];
127
128 var illegalUsages = [];
129 ["encrypt", "decrypt", "sign", "verify", "wrapKey", "unwrapKey", "deriveKey", "deriveBits"].forEach(function(usage) {
130 if (!validUsages.includes(usage)) {
131 illegalUsages.push(usage);
132 }
133 });
134
135 var goodUsageCombinations = allValidUsages(validUsages, false, mandatoryUsages);
136
137 illegalUsages.forEach(function(illegalUsage) {
138 results.push([illegalUsage]);
139 goodUsageCombinations.forEach(function(usageCombination) {
140 results.push(usageCombination.concat([illegalUsage]));
141 });
142 });
143
144 return results;
145 }
146
147
148// Now test for properly handling errors

Callers 1

run_testFunction · 0.70

Calls 5

allValidUsagesFunction · 0.85
includesMethod · 0.80
concatMethod · 0.80
forEachMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected