Elffuss BraidHub

kikocis/continue public

main · 1.2 KiBRawPermalink
1import {
2 SecretType,
3 decodeSecretLocation,
4 encodeSecretLocation,
5} from "./SecretResult.js";
6import { PackageSlug } from "./slugs.js";
7
8describe("SecretLocation encoding/decoding", () => {
9 it("encodes/decodes organization secret location", () => {
10 const orgSecretLocation = {
11 secretType: SecretType.Organization as const,
12 orgSlug: "test-org",
13 secretName: "secret1",
14 };
15
16 const encoded = encodeSecretLocation(orgSecretLocation);
17 expect(encoded).toBe("organization:test-org/secret1");
18
19 const decoded = decodeSecretLocation(encoded);
20 expect(decoded).toEqual(orgSecretLocation);
21 });
22
23 it("encodes/decodes package secret location", () => {
24 const packageSlug: PackageSlug = {
25 ownerSlug: "test-org",
26 packageSlug: "test-package",
27 };
28
29 const packageSecretLocation = {
30 secretType: SecretType.Package as const,
31 packageSlug,
32 secretName: "secret1",
33 };
34
35 const encoded = encodeSecretLocation(packageSecretLocation);
36 expect(encoded).toBe("package:test-org/test-package/secret1");
37
38 const decoded = decodeSecretLocation(encoded);
39 expect(decoded).toEqual(packageSecretLocation);
40 });
41});