Skip to content

Commit 4a74797

Browse files
TeoBonzadonskov
andauthored
chore(oxlint): add import and vitest in plugins, update tests (#521)
Co-authored-by: Dmytro Donskov <donskovdmitriyv@gmail.com>
1 parent 2a59a9d commit 4a74797

17 files changed

Lines changed: 63 additions & 59 deletions

.oxlintrc.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"$schema": "./node_modules/oxlint/configuration_schema.json",
3-
"plugins": ["typescript", "unicorn", "oxc"],
3+
"plugins": ["typescript", "unicorn", "oxc", "import", "vitest"],
44
"categories": {
55
"correctness": "error"
66
},
@@ -30,6 +30,18 @@
3030
"no-unused-vars": "off",
3131
"unicorn/no-empty-file": "off"
3232
}
33+
},
34+
{
35+
"files": ["test/NISTPKITS.spec.ts", "test/functionalTest.spec.ts"],
36+
"rules": {
37+
"vitest/expect-expect": "off"
38+
}
39+
},
40+
{
41+
"files": ["test/NISTPKITS.spec.ts", "test/nodePKCS12Example.spec.ts"],
42+
"rules": {
43+
"vitest/no-disabled-tests": "off"
44+
}
3345
}
3446
],
3547
"env": {

test/NISTPKITS.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1895,7 +1895,7 @@ describe("PKITS's certificates parsing test", () => {
18951895
};
18961896
};
18971897

1898-
it(keys[i], runningFunction(pkitsToArrayBuffer(PKITS.certs[keys[i]]), parsingCheck));
1898+
it(`${keys[i]}`, runningFunction(pkitsToArrayBuffer(PKITS.certs[keys[i]]), parsingCheck));
18991899
}
19001900
});
19011901

@@ -1923,7 +1923,7 @@ describe("PKITS's CRL parsing test", () => {
19231923
};
19241924
};
19251925

1926-
it(keys[i], runningFunction(pkitsToArrayBuffer(PKITS.crls[keys[i]]), parsingCheck));
1926+
it(`${keys[i]}`, runningFunction(pkitsToArrayBuffer(PKITS.crls[keys[i]]), parsingCheck));
19271927
}
19281928
});
19291929

@@ -1972,7 +1972,7 @@ describe("PKITS's certificate pairs parsing test", () => {
19721972
};
19731973
};
19741974

1975-
it(keys[i], runningFunction(pkitsToArrayBuffer(PKITS.certpairs[keys[i]]), parsingCheck));
1975+
it(`${keys[i]}`, runningFunction(pkitsToArrayBuffer(PKITS.certpairs[keys[i]]), parsingCheck));
19761976
}
19771977
});
19781978

test/certificateComplexExample.spec.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,8 @@ describe("Certificate Complex Example", () => {
2727

2828
signAlgs.forEach(signAlg => {
2929
hashAlgs.forEach(hashAlg => {
30-
const testName = `${hashAlg} + ${signAlg}`;
31-
32-
it(testName, async () => {
30+
it(`${hashAlg} + ${signAlg}`, async () => {
31+
const testName = `${hashAlg} + ${signAlg}`;
3332
const cert = await example.createCertificate(hashAlg, signAlg);
3433

3534
const certificate = pkijs.Certificate.fromBER(cert.certificateBuffer);

test/cmsSignedComplexExample.spec.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ describe("CMS Signed Complex Example", () => {
1717
hashAlgs.forEach(hashAlg => {
1818
addExts.forEach(addExt => {
1919
detachedSignatures.forEach(detachedSignature => {
20-
const testName = `${hashAlg} + ${signAlg}, add ext: ${addExt}, detached signature: ${detachedSignature}`;
21-
22-
it(testName, async () => {
20+
it(`${hashAlg} + ${signAlg}, add ext: ${addExt}, detached signature: ${detachedSignature}`, async () => {
2321
const cms = await example.createCMSSigned(
2422
hashAlg,
2523
signAlg,

test/crlComplexExample.spec.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,8 @@ describe("CRL Complex Example", () => {
2727

2828
signAlgs.forEach(signAlg => {
2929
hashAlgs.forEach(hashAlg => {
30-
const testName = `${hashAlg} + ${signAlg}`;
31-
32-
it(testName, async () => {
30+
it(`${hashAlg} + ${signAlg}`, async () => {
31+
const testName = `${hashAlg} + ${signAlg}`;
3332
const crlWithKey = await example.createCRL(hashAlg, signAlg);
3433
const crl = pkijs.CertificateRevocationList.fromBER(crlWithKey.crlBuffer);
3534

test/functionalTest.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ describe("PKIjs functional testing", () => {
329329
const crypto = new Crypto();
330330

331331
for (const t of tests) {
332-
it(t.name, async () => {
332+
it(`${t.name}`, async () => {
333333
const data = new Uint8Array(10).buffer;
334334
const certData = await createCertificate("SHA-256", "RSASSA-PKCS1-v1_5");
335335

@@ -768,7 +768,7 @@ describe("PKIjs functional testing", () => {
768768
});
769769

770770
for (const t of tests) {
771-
it(t.name, () => {
771+
it(`${t.name}`, () => {
772772
if (t.browser) {
773773
(global as any).self = (global as any).window = { crypto };
774774
}

test/howToEncryptCMSviaCertificate.spec.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ describe("How To Encrypt CMS via Certificate", () => {
1919
signAlgs.forEach(signAlg => {
2020
hashAlgs.forEach(hashAlg => {
2121
oaepHashAlgs.forEach(oaepHashAlg => {
22-
const testName = `${encAlg} with ${encLen}, ${hashAlg} + ${signAlg}, OAEP hash: ${oaepHashAlg}`;
23-
24-
it(testName, async () => {
22+
it(`${encAlg} with ${encLen}, ${hashAlg} + ${signAlg}, OAEP hash: ${oaepHashAlg}`, async () => {
2523
const certWithKey = await utils.createSelfSignedCertificate(hashAlg, signAlg);
2624
const certRaw = certWithKey.certificate.toSchema().toBER();
2725
const cmsEnvelopedBuffer = await example.envelopedEncrypt(

test/howToEncryptCMSviaKey.spec.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ describe("How To Encrypt CMS via Key Identifier", () => {
1616
encLens.forEach(encLen => {
1717
curveNames.forEach(curveName => {
1818
kdfHashAlgs.forEach(kdfHashAlg => {
19-
const testName = `${encAlg} with ${encLen} + ${curveName}, OAEP hash: ${kdfHashAlg}`;
20-
21-
it(testName, async () => {
19+
it(`${encAlg} with ${encLen} + ${curveName}, OAEP hash: ${kdfHashAlg}`, async () => {
2220
const encryptionAlgorithm = {
2321
name: encAlg,
2422
length: encLen,

test/howToEncryptCMSviaPassword.spec.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ describe("How To Encrypt CMS via Password", () => {
1717
encAlgs.forEach(encAlg => {
1818
encLens.forEach(encLen => {
1919
encryptionVariants.forEach(encryptionVariant => {
20-
const testName = `${encAlg} with ${encLen}, ${encryptionVariant === 2 ? "Password-based encryption" : "Pre-defined KEK"}`;
21-
22-
it(testName, async () => {
20+
it(`${encAlg} with ${encLen}, ${encryptionVariant === 2 ? "Password-based encryption" : "Pre-defined KEK"}`, async () => {
2321
const encryptionAlgorithm = {
2422
name: encAlg,
2523
length: encLen

test/nodePKCS12Example.spec.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, it, beforeAll, afterAll } from "vitest";
1+
import { describe, it, beforeAll, afterAll, expect } from "vitest";
22
import * as asn1js from "asn1js";
33
import * as pvtsutils from "pvtsutils";
44
import * as pvutils from "pvutils";
@@ -281,7 +281,9 @@ describe("Node.js PKCS#12 Example", () => {
281281
it("Forge 3DES", async () => {
282282
const windowsP12 =
283283
"MIIGgAIBAzCCBkYGCSqGSIb3DQEHAaCCBjcEggYzMIIGLzCCAxUGCSqGSIb3DQEHAaCCAwYEggMCMIIC/jCCAvoGCyqGSIb3DQEMCgEDoIICqTCCAqUGCiqGSIb3DQEJFgGgggKVBIICkTCCAo0wggH2oAMCAQICAQEwDQYJKoZIhvcNAQEFBQAwaTEUMBIGA1UEAxMLZXhhbXBsZS5vcmcxCzAJBgNVBAYTAlVTMREwDwYDVQQIEwhWaXJnaW5pYTETMBEGA1UEBxMKQmxhY2tzYnVyZzENMAsGA1UEChMEVGVzdDENMAsGA1UECxMEVGVzdDAeFw0xODAyMDMxMjI2NDlaFw0xOTAyMDMxMjI2NDlaMGk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4IZeS9mcmViqwilOXm0RiZvxZ0J4svCnwceknfKZjRgxhxxVZKrg6LVIt6QR4IS724bbHBtAhc3+2Fb63RlgYJgLofq/UYB/DaySH7zepVQZAwZRCJjscR8pFaPRHnXNr8/KxruJHKXSHxa/Re+jK4YZPTrsAO25BYnnsGA5KPxQU/OkeoZZElt7X01FMKKK+V3bS4X/e2fB7Iv4qacEmP8CHRtEy0rh0XepsCMjw7+jbFKSE/8ULkWi+9zVJJEp+8mKf1JmWTR4luvefp4/ua8kFsQEhwSAFy4QNKKaB26w+++hWNK51FWi8Y1psqqv06ToWn8co5cpu3Z0l9TnTuzoDwlw3JrTmhY6D25FyrsYEFVCaGu8LdDBf33kqt3swmsnJDk4fZa6bggRC0NqRgs8jqO7TJ7/syOwN78ClnTPso+mpxZ3n4MZNmraErq408eaemIkKm5deWdzA7oPvj+Fwf2yUwFu2bxsYiolYuLz93q/+auXdgfmT6sNcjVhJkOB9ODZeO+9CmwtVzUOb0BhxXcdtE5NmBYowhpALJMjmc2fAL39IGORNwLLGJcthua1RblEKPsBevKPBVECCG1z0usj/3mDh3HVyzSppyQCyLyD0jUxPjAjBgkqhkiG9w0BCRUxFgQUdiizccsrR5qWhb4DSyDvp+AIWzcwFwYJKoZIhvcNAQkUMQoeCAB0AGUAcwB0MDEwITAJBgUrDgMCGgUABBR6Jj6s4TaUiDXuwVOS0LXnHYTI7QQIivzKaUTP0Y8CAggA";
284-
return parsePKCS12(pvutils.stringToArrayBuffer(pvutils.fromBase64(windowsP12)), "password");
284+
await expect(
285+
parsePKCS12(pvutils.stringToArrayBuffer(pvutils.fromBase64(windowsP12)), "password")
286+
).resolves.toBeInstanceOf(pkijs.PFX);
285287
});
286288
});
287289

@@ -305,22 +307,22 @@ describe("Node.js PKCS#12 Example", () => {
305307

306308
describe("DES-EDE3-CBC algorithm", () => {
307309
["SHA-1", "SHA-256", "SHA-384", "SHA-512"].forEach(hashAlg => {
308-
it(hashAlg, async () => {
310+
it(`${hashAlg}`, async () => {
309311
const pkcs12Raw = await openSSLLike(
310312
pkcs8Simpl,
311313
certSimpl,
312314
password,
313315
"DES-EDE3-CBC",
314316
hashAlg
315317
);
316-
await parsePKCS12(pkcs12Raw, password);
318+
await expect(parsePKCS12(pkcs12Raw, password)).resolves.toBeInstanceOf(pkijs.PFX);
317319
});
318320
});
319321
});
320322

321323
it("AES-256-CBC algorithm", async () => {
322324
const pkcs12Raw = await openSSLLike(pkcs8Simpl, certSimpl, password, "AES-256-CBC");
323-
await parsePKCS12(pkcs12Raw, password);
325+
await expect(parsePKCS12(pkcs12Raw, password)).resolves.toBeInstanceOf(pkijs.PFX);
324326
});
325327
});
326328

@@ -341,7 +343,7 @@ describe("Node.js PKCS#12 Example", () => {
341343
["DES-EDE3-CBC", "AES-256-CBC"].forEach(encAlg => {
342344
it(`${encAlg} algorithm`, async () => {
343345
const pkcs12Raw = await openSSLLike(pkcs8Simpl, attrCertSimpl, password, encAlg);
344-
await parsePKCS12(pkcs12Raw, password);
346+
await expect(parsePKCS12(pkcs12Raw, password)).resolves.toBeInstanceOf(pkijs.PFX);
345347
});
346348
});
347349
});

0 commit comments

Comments
 (0)