Format the TypeScript sources with Oxfmt
This commit is contained in:
+6
-28
@@ -1,9 +1,5 @@
|
||||
import { assertEquals, assertRejects } from "jsr:@std/assert@1";
|
||||
import {
|
||||
decryptCredential,
|
||||
encryptCredential,
|
||||
parseCredentials,
|
||||
} from "./credentials.ts";
|
||||
import { decryptCredential, encryptCredential, parseCredentials } from "./credentials.ts";
|
||||
|
||||
const MASTER_KEY = "AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8";
|
||||
const OTHER_KEY = "AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE";
|
||||
@@ -11,17 +7,11 @@ const NONCE = Uint8Array.from({ length: 12 }, (_, index) => index + 32);
|
||||
const ENCRYPTED = "v1:ICEiIyQlJicoKSor:oV_FAgnsN3p1FyegJxwGVdyjfyPio6qDeSUwbA";
|
||||
|
||||
Deno.test("decrypts a known AES-256-GCM credential", async () => {
|
||||
assertEquals(
|
||||
await decryptCredential(ENCRYPTED, MASTER_KEY),
|
||||
"secret-token",
|
||||
);
|
||||
assertEquals(await decryptCredential(ENCRYPTED, MASTER_KEY), "secret-token");
|
||||
});
|
||||
|
||||
Deno.test("encrypts a credential with a fresh supplied nonce", async () => {
|
||||
assertEquals(
|
||||
await encryptCredential("secret-token", MASTER_KEY, NONCE),
|
||||
ENCRYPTED,
|
||||
);
|
||||
assertEquals(await encryptCredential("secret-token", MASTER_KEY, NONCE), ENCRYPTED);
|
||||
});
|
||||
|
||||
Deno.test("rejects a credential encrypted by another master key", async () => {
|
||||
@@ -30,11 +20,7 @@ Deno.test("rejects a credential encrypted by another master key", async () => {
|
||||
|
||||
Deno.test("rejects a credential with a nonstandard nonce", async () => {
|
||||
await assertRejects(
|
||||
() =>
|
||||
decryptCredential(
|
||||
"v1:AA:oV_FAgnsN3p1FyegJxwGVdyjfyPio6qDeSUwbA",
|
||||
MASTER_KEY,
|
||||
),
|
||||
() => decryptCredential("v1:AA:oV_FAgnsN3p1FyegJxwGVdyjfyPio6qDeSUwbA", MASTER_KEY),
|
||||
Error,
|
||||
"nonce must be 12 bytes",
|
||||
);
|
||||
@@ -75,17 +61,9 @@ profiles:
|
||||
});
|
||||
|
||||
Deno.test("rejects malformed central credentials", async () => {
|
||||
await assertRejects(() => parseCredentials("profiles: []", MASTER_KEY), Error, "reviewer-token");
|
||||
await assertRejects(
|
||||
() => parseCredentials("profiles: []", MASTER_KEY),
|
||||
Error,
|
||||
"reviewer-token",
|
||||
);
|
||||
await assertRejects(
|
||||
() =>
|
||||
parseCredentials(
|
||||
`reviewer-token: ${ENCRYPTED}\nprofiles:\n - type: claude`,
|
||||
MASTER_KEY,
|
||||
),
|
||||
() => parseCredentials(`reviewer-token: ${ENCRYPTED}\nprofiles:\n - type: claude`, MASTER_KEY),
|
||||
Error,
|
||||
"profiles[0].token",
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user