Skip to content

Commit f8848ba

Browse files
author
Mert Can Altin
committed
lint
1 parent eebdd92 commit f8848ba

17 files changed

+233
-123
lines changed

test/parallel/test-async-wrap-pop-id-during-load.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ test('async function stack overflow test', async (t) => {
1111
fn();
1212
throw new Error();
1313
}
14-
await (async function () { await fn(); })();
14+
await (async function() { await fn(); })();
1515
}
1616

1717
const ret = spawnSync(

test/parallel/test-c-ares.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
'use strict';
2323

24+
require('../common');
25+
2426
const { test } = require('node:test');
2527
const assert = require('node:assert');
2628
const dns = require('node:dns');

test/parallel/test-fs-promises-file-handle-aggregate-errors.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ async function checkAggregateError(op) {
2323
try {
2424
const filePath = await createFile();
2525
Object.defineProperty(FileHandle.prototype, 'fd', {
26-
get: function () {
26+
get: function() {
2727
// Close is set by using a setter,
2828
// so it needs to be set on the instance.
2929
const originalClose = this.close;

test/parallel/test-fs-promises-file-handle-close-errors.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ async function checkCloseError(op) {
2323
try {
2424
const filePath = await createFile();
2525
Object.defineProperty(FileHandle.prototype, 'fd', {
26-
get: function () {
26+
get: function() {
2727
// Close is set by using a setter,
2828
// so it needs to be set on the instance.
2929
const originalClose = this.close;

test/parallel/test-webcrypto-cryptokey-workers.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
// This test ensures that CryptoKey instances can be correctly
44
// sent to a Worker via postMessage.
55

6-
const { test } = require('node:test');
6+
const common = require('../common');
77
const assert = require('node:assert');
8+
const { test } = require('node:test');
89
const { subtle } = globalThis.crypto;
910
const { once } = require('node:events');
1011
const { Worker, parentPort } = require('node:worker_threads');
11-
const common = require('../common');
12+
1213

1314
// Skip the test if crypto is not available
1415
if (!common.hasCrypto) common.skip('missing crypto');

test/parallel/test-webcrypto-export-import-rsa.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
'use strict';
22

3+
require('../common');
4+
35
const assert = require('assert');
4-
const crypto = require('crypto');
56
const { subtle } = globalThis.crypto;
67

78
const sizes = [1024, 2048, 4096];
@@ -365,7 +366,7 @@ async function testImportJwk({ name, publicUsages, privateUsages }, size, hash,
365366

366367
const [
367368
publicKey,
368-
privateKey
369+
privateKey,
369370
] = await Promise.all([
370371
subtle.importKey(
371372
'jwk',

test/parallel/test-webcrypto-sign-verify-ecdsa.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
'use strict';
22

3+
const common = require('../common');
4+
35
const { test } = require('node:test');
4-
const assert = require('node:assert');
56
const { subtle } = globalThis.crypto;
7+
const assert = require('node:assert');
68

7-
const common = require('../common');
89
if (!common.hasCrypto) common.skip('missing crypto');
910

1011
const vectors = require('../fixtures/crypto/ecdsa')();
Lines changed: 121 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,42 @@
11
'use strict';
22

3+
const common = require('../common');
4+
const assert = require('node:assert');
35
const { test } = require('node:test');
4-
const assert = require('assert');
56
const { subtle } = globalThis.crypto;
67

7-
const common = require('../common');
88
if (!common.hasCrypto) common.skip('missing crypto');
99

1010
const vectors = require('../fixtures/crypto/eddsa')();
1111

1212
// Test function for verification
13-
async function testVerify({ name, publicKeyBuffer, privateKeyBuffer, signature, data }) {
14-
const [
15-
publicKey,
16-
noVerifyPublicKey,
17-
privateKey,
18-
hmacKey,
19-
rsaKeys,
20-
ecKeys,
21-
] = await Promise.all([
22-
subtle.importKey('spki', publicKeyBuffer, { name }, false, ['verify']),
23-
subtle.importKey('spki', publicKeyBuffer, { name }, false, []), // No usages for this key
24-
subtle.importKey('pkcs8', privateKeyBuffer, { name }, false, ['sign']),
25-
subtle.generateKey({ name: 'HMAC', hash: 'SHA-256' }, false, ['sign']),
26-
subtle.generateKey({ name: 'RSA-PSS', modulusLength: 1024, publicExponent: new Uint8Array([1, 0, 1]), hash: 'SHA-256' }, false, ['sign']),
27-
subtle.generateKey({ name: 'ECDSA', namedCurve: 'P-256' }, false, ['sign']),
28-
]);
13+
async function testVerify({
14+
name,
15+
publicKeyBuffer,
16+
privateKeyBuffer,
17+
signature,
18+
data,
19+
}) {
20+
const [publicKey, noVerifyPublicKey, privateKey, hmacKey, rsaKeys, ecKeys] =
21+
await Promise.all([
22+
subtle.importKey('spki', publicKeyBuffer, { name }, false, ['verify']),
23+
subtle.importKey('spki', publicKeyBuffer, { name }, false, []), // No usages for this key
24+
subtle.importKey('pkcs8', privateKeyBuffer, { name }, false, ['sign']),
25+
subtle.generateKey({ name: 'HMAC', hash: 'SHA-256' }, false, ['sign']),
26+
subtle.generateKey(
27+
{
28+
name: 'RSA-PSS',
29+
modulusLength: 1024,
30+
publicExponent: new Uint8Array([1, 0, 1]),
31+
hash: 'SHA-256',
32+
},
33+
false,
34+
['sign'],
35+
),
36+
subtle.generateKey({ name: 'ECDSA', namedCurve: 'P-256' }, false, [
37+
'sign',
38+
]),
39+
]);
2940

3041
// Test valid verification
3142
assert(await subtle.verify({ name }, publicKey, signature, data));
@@ -40,49 +51,69 @@ async function testVerify({ name, publicKeyBuffer, privateKeyBuffer, signature,
4051

4152
// Test failure with wrong key or algorithm
4253
await assert.rejects(subtle.verify({ name }, privateKey, signature, data), {
43-
message: /Unable to use this key to verify/
54+
message: /Unable to use this key to verify/,
4455
});
4556

46-
await assert.rejects(subtle.verify({ name }, noVerifyPublicKey, signature, data), {
47-
message: /Unable to use this key to verify/
48-
});
57+
await assert.rejects(
58+
subtle.verify({ name }, noVerifyPublicKey, signature, data),
59+
{
60+
message: /Unable to use this key to verify/,
61+
},
62+
);
4963

5064
await assert.rejects(subtle.verify({ name }, hmacKey, signature, data), {
51-
message: /Unable to use this key to verify/
65+
message: /Unable to use this key to verify/,
5266
});
5367

54-
await assert.rejects(subtle.verify({ name }, rsaKeys.publicKey, signature, data), {
55-
message: /Unable to use this key to verify/
56-
});
68+
await assert.rejects(
69+
subtle.verify({ name }, rsaKeys.publicKey, signature, data),
70+
{
71+
message: /Unable to use this key to verify/,
72+
},
73+
);
5774

58-
await assert.rejects(subtle.verify({ name }, ecKeys.publicKey, signature, data), {
59-
message: /Unable to use this key to verify/
60-
});
75+
await assert.rejects(
76+
subtle.verify({ name }, ecKeys.publicKey, signature, data),
77+
{
78+
message: /Unable to use this key to verify/,
79+
},
80+
);
6181

6282
// Test failure when signature or data is altered
6383
const alteredSig = Buffer.from(signature);
6484
alteredSig[0] = 255 - alteredSig[0];
6585
assert(!(await subtle.verify({ name }, publicKey, alteredSig, data)));
66-
assert(!(await subtle.verify({ name }, publicKey, alteredSig.slice(1), data)));
86+
assert(
87+
!(await subtle.verify({ name }, publicKey, alteredSig.slice(1), data)),
88+
);
6789

6890
const alteredData = Buffer.from(data);
6991
alteredData[0] = 255 - alteredData[0];
7092
assert(!(await subtle.verify({ name }, publicKey, signature, alteredData)));
7193
}
7294

7395
// Test function for signing
74-
async function testSign({ name, publicKeyBuffer, privateKeyBuffer, signature, data }) {
75-
const [
76-
publicKey,
77-
privateKey,
78-
hmacKey,
79-
rsaKeys,
80-
ecKeys,
81-
] = await Promise.all([
96+
async function testSign({
97+
name,
98+
publicKeyBuffer,
99+
privateKeyBuffer,
100+
signature,
101+
data,
102+
}) {
103+
const [publicKey, privateKey, hmacKey, rsaKeys, ecKeys] = await Promise.all([
82104
subtle.importKey('spki', publicKeyBuffer, { name }, false, ['verify']),
83105
subtle.importKey('pkcs8', privateKeyBuffer, { name }, false, ['sign']),
84106
subtle.generateKey({ name: 'HMAC', hash: 'SHA-256' }, false, ['sign']),
85-
subtle.generateKey({ name: 'RSA-PSS', modulusLength: 1024, publicExponent: new Uint8Array([1, 0, 1]), hash: 'SHA-256' }, false, ['sign']),
107+
subtle.generateKey(
108+
{
109+
name: 'RSA-PSS',
110+
modulusLength: 1024,
111+
publicExponent: new Uint8Array([1, 0, 1]),
112+
hash: 'SHA-256',
113+
},
114+
false,
115+
['sign'],
116+
),
86117
subtle.generateKey({ name: 'ECDSA', namedCurve: 'P-256' }, false, ['sign']),
87118
]);
88119

@@ -98,19 +129,19 @@ async function testSign({ name, publicKeyBuffer, privateKeyBuffer, signature, da
98129

99130
// Test failure with wrong key or algorithm
100131
await assert.rejects(subtle.sign({ name }, publicKey, data), {
101-
message: /Unable to use this key to sign/
132+
message: /Unable to use this key to sign/,
102133
});
103134

104135
await assert.rejects(subtle.sign({ name }, hmacKey, data), {
105-
message: /Unable to use this key to sign/
136+
message: /Unable to use this key to sign/,
106137
});
107138

108139
await assert.rejects(subtle.sign({ name }, rsaKeys.privateKey, data), {
109-
message: /Unable to use this key to sign/
140+
message: /Unable to use this key to sign/,
110141
});
111142

112143
await assert.rejects(subtle.sign({ name }, ecKeys.privateKey, data), {
113-
message: /Unable to use this key to sign/
144+
message: /Unable to use this key to sign/,
114145
});
115146
}
116147

@@ -128,19 +159,54 @@ vectors.forEach((vector) => {
128159
test('Ed448 context', async () => {
129160
const vector = vectors.find(({ name }) => name === 'Ed448');
130161
const [privateKey, publicKey] = await Promise.all([
131-
subtle.importKey('pkcs8', vector.privateKeyBuffer, { name: 'Ed448' }, false, ['sign']),
132-
subtle.importKey('spki', vector.publicKeyBuffer, { name: 'Ed448' }, false, ['verify']),
162+
subtle.importKey(
163+
'pkcs8',
164+
vector.privateKeyBuffer,
165+
{ name: 'Ed448' },
166+
false,
167+
['sign'],
168+
),
169+
subtle.importKey('spki', vector.publicKeyBuffer, { name: 'Ed448' }, false, [
170+
'verify',
171+
]),
133172
]);
134173

135-
const sig = await subtle.sign({ name: 'Ed448', context: Buffer.alloc(0) }, privateKey, vector.data);
174+
const sig = await subtle.sign(
175+
{ name: 'Ed448', context: Buffer.alloc(0) },
176+
privateKey,
177+
vector.data,
178+
);
136179
assert.deepStrictEqual(Buffer.from(sig), vector.signature);
137-
assert.strictEqual(await subtle.verify({ name: 'Ed448', context: Buffer.alloc(0) }, publicKey, sig, vector.data), true);
138-
139-
await assert.rejects(subtle.sign({ name: 'Ed448', context: Buffer.alloc(1) }, privateKey, vector.data), {
140-
message: /Non zero-length context is not yet supported/
141-
});
142-
143-
await assert.rejects(subtle.verify({ name: 'Ed448', context: Buffer.alloc(1) }, publicKey, sig, vector.data), {
144-
message: /Non zero-length context is not yet supported/
145-
});
180+
assert.strictEqual(
181+
await subtle.verify(
182+
{ name: 'Ed448', context: Buffer.alloc(0) },
183+
publicKey,
184+
sig,
185+
vector.data,
186+
),
187+
true,
188+
);
189+
190+
await assert.rejects(
191+
subtle.sign(
192+
{ name: 'Ed448', context: Buffer.alloc(1) },
193+
privateKey,
194+
vector.data,
195+
),
196+
{
197+
message: /Non zero-length context is not yet supported/,
198+
},
199+
);
200+
201+
await assert.rejects(
202+
subtle.verify(
203+
{ name: 'Ed448', context: Buffer.alloc(1) },
204+
publicKey,
205+
sig,
206+
vector.data,
207+
),
208+
{
209+
message: /Non zero-length context is not yet supported/,
210+
},
211+
);
146212
});

test/parallel/test-worker-heapdump-failure.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
'use strict';
2+
3+
const common = require('../common');
4+
25
const { test } = require('node:test');
3-
const assert = require('node:assert');
46
const { Worker } = require('node:worker_threads');
57
const { once } = require('node:events');
6-
const common = require('../common');
8+
const assert = require('node:assert');
79

810
// Test for ERR_WORKER_NOT_RUNNING when calling getHeapSnapshot on a worker that's not running
911
test('Worker heap snapshot tests', async (t) => {

0 commit comments

Comments
 (0)