mirror of
https://github.com/Drop-OSS/droplet.git
synced 2025-11-17 02:01:19 +10:00
add tests and ci rules
This commit is contained in:
42
__test__/trust.spec.ts
Normal file
42
__test__/trust.spec.ts
Normal file
@ -0,0 +1,42 @@
|
||||
import test from "ava";
|
||||
|
||||
import {
|
||||
generateRootCa,
|
||||
generateClientCertificate,
|
||||
verifyClientCertificate,
|
||||
} from "../index.js";
|
||||
|
||||
test("generate ca", (t) => {
|
||||
const [pub, priv] = generateRootCa();
|
||||
t.pass();
|
||||
});
|
||||
|
||||
test("generate ca & client certs", (t) => {
|
||||
const [pub, priv] = generateRootCa();
|
||||
|
||||
const clientName = "My Test Client";
|
||||
const [clientPub, clientPriv] = generateClientCertificate(
|
||||
clientName,
|
||||
clientName,
|
||||
pub,
|
||||
priv
|
||||
);
|
||||
|
||||
t.pass();
|
||||
});
|
||||
|
||||
test("trust chain", (t) => {
|
||||
const [pub, priv] = generateRootCa();
|
||||
|
||||
const clientName = "My Test Client";
|
||||
const [clientPub, clientPriv] = generateClientCertificate(
|
||||
clientName,
|
||||
clientName,
|
||||
pub,
|
||||
priv
|
||||
);
|
||||
|
||||
const valid = verifyClientCertificate(clientPub, pub);
|
||||
if (valid) return t.pass();
|
||||
return t.fail();
|
||||
});
|
||||
Reference in New Issue
Block a user