Skip to content

Commit 28362f1

Browse files
committed
Creating vault specific tests
1 parent 3c268a1 commit 28362f1

File tree

5 files changed

+202
-1
lines changed

5 files changed

+202
-1
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
fail-fast: false
1515
matrix:
1616
vault: [1password, aws-sm, azure-kv]
17-
task: [check, lint, fmt]
17+
task: [check, lint, fmt, test]
1818
defaults:
1919
run:
2020
working-directory: vault/${{ matrix.vault }}
@@ -29,6 +29,8 @@ jobs:
2929
deno fmt --check extensions/vaults/
3030
elif [ "${{ matrix.task }}" = "lint" ]; then
3131
deno lint extensions/vaults/
32+
elif [ "${{ matrix.task }}" = "test" ]; then
33+
deno test extensions/vaults/
3234
else
3335
deno check extensions/vaults/*.ts
3436
fi

vault/1password/deno.lock

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// Swamp, an Automation Framework
2+
// Copyright (C) 2026 System Initiative, Inc.
3+
//
4+
// This file is part of Swamp.
5+
//
6+
// Swamp is free software: you can redistribute it and/or modify
7+
// it under the terms of the GNU Affero General Public License version 3
8+
// as published by the Free Software Foundation, with the Swamp
9+
// Extension and Definition Exception (found in the "COPYING-EXCEPTION"
10+
// file).
11+
//
12+
// Swamp is distributed in the hope that it will be useful,
13+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
// GNU Affero General Public License for more details.
16+
//
17+
// You should have received a copy of the GNU Affero General Public License
18+
// along with Swamp. If not, see <https://www.gnu.org/licenses/>.
19+
20+
import { assertEquals, assertExists, assertThrows } from "jsr:@std/assert";
21+
import { vault } from "./onepassword.ts";
22+
23+
Deno.test("vault export has correct metadata", () => {
24+
assertEquals(vault.type, "@swamp/1password");
25+
assertEquals(vault.name, "1Password");
26+
assertExists(vault.description);
27+
assertExists(vault.configSchema);
28+
assertEquals(typeof vault.createProvider, "function");
29+
});
30+
31+
Deno.test("configSchema validates valid config", () => {
32+
const result = vault.configSchema.safeParse({ op_vault: "Engineering" });
33+
assertEquals(result.success, true);
34+
});
35+
36+
Deno.test("configSchema validates config with op_account", () => {
37+
const result = vault.configSchema.safeParse({
38+
op_vault: "Engineering",
39+
op_account: "my-team.1password.com",
40+
});
41+
assertEquals(result.success, true);
42+
});
43+
44+
Deno.test("configSchema rejects empty op_vault", () => {
45+
const result = vault.configSchema.safeParse({ op_vault: "" });
46+
assertEquals(result.success, false);
47+
});
48+
49+
Deno.test("configSchema rejects missing op_vault", () => {
50+
const result = vault.configSchema.safeParse({});
51+
assertEquals(result.success, false);
52+
});
53+
54+
Deno.test("createProvider returns a provider with getName", () => {
55+
const provider = vault.createProvider("my-vault", {
56+
op_vault: "Engineering",
57+
});
58+
assertEquals(provider.getName(), "my-vault");
59+
});
60+
61+
Deno.test("createProvider accepts op_account", () => {
62+
const provider = vault.createProvider("my-vault", {
63+
op_vault: "Engineering",
64+
op_account: "my-team.1password.com",
65+
});
66+
assertEquals(provider.getName(), "my-vault");
67+
});
68+
69+
Deno.test("createProvider throws on invalid config", () => {
70+
assertThrows(
71+
() => vault.createProvider("bad-vault", {}),
72+
Error,
73+
);
74+
});
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Swamp, an Automation Framework
2+
// Copyright (C) 2026 System Initiative, Inc.
3+
//
4+
// This file is part of Swamp.
5+
//
6+
// Swamp is free software: you can redistribute it and/or modify
7+
// it under the terms of the GNU Affero General Public License version 3
8+
// as published by the Free Software Foundation, with the Swamp
9+
// Extension and Definition Exception (found in the "COPYING-EXCEPTION"
10+
// file).
11+
//
12+
// Swamp is distributed in the hope that it will be useful,
13+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
// GNU Affero General Public License for more details.
16+
//
17+
// You should have received a copy of the GNU Affero General Public License
18+
// along with Swamp. If not, see <https://www.gnu.org/licenses/>.
19+
20+
import { assertEquals, assertExists, assertThrows } from "jsr:@std/assert";
21+
import { vault } from "./aws_sm.ts";
22+
23+
Deno.test("vault export has correct metadata", () => {
24+
assertEquals(vault.type, "@swamp/aws-sm");
25+
assertEquals(vault.name, "AWS Secrets Manager");
26+
assertExists(vault.description);
27+
assertExists(vault.configSchema);
28+
assertEquals(typeof vault.createProvider, "function");
29+
});
30+
31+
Deno.test("configSchema validates valid config", () => {
32+
const result = vault.configSchema.safeParse({ region: "us-east-1" });
33+
assertEquals(result.success, true);
34+
});
35+
36+
Deno.test("configSchema rejects empty region", () => {
37+
const result = vault.configSchema.safeParse({ region: "" });
38+
assertEquals(result.success, false);
39+
});
40+
41+
Deno.test("configSchema rejects missing region", () => {
42+
const result = vault.configSchema.safeParse({});
43+
assertEquals(result.success, false);
44+
});
45+
46+
Deno.test("createProvider throws on invalid config", () => {
47+
assertThrows(
48+
() => vault.createProvider("bad-vault", {}),
49+
Error,
50+
);
51+
});
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Swamp, an Automation Framework
2+
// Copyright (C) 2026 System Initiative, Inc.
3+
//
4+
// This file is part of Swamp.
5+
//
6+
// Swamp is free software: you can redistribute it and/or modify
7+
// it under the terms of the GNU Affero General Public License version 3
8+
// as published by the Free Software Foundation, with the Swamp
9+
// Extension and Definition Exception (found in the "COPYING-EXCEPTION"
10+
// file).
11+
//
12+
// Swamp is distributed in the hope that it will be useful,
13+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
// GNU Affero General Public License for more details.
16+
//
17+
// You should have received a copy of the GNU Affero General Public License
18+
// along with Swamp. If not, see <https://www.gnu.org/licenses/>.
19+
20+
import { assertEquals, assertExists, assertThrows } from "jsr:@std/assert";
21+
import { vault } from "./azure_kv.ts";
22+
23+
Deno.test("vault export has correct metadata", () => {
24+
assertEquals(vault.type, "@swamp/azure-kv");
25+
assertEquals(vault.name, "Azure Key Vault");
26+
assertExists(vault.description);
27+
assertExists(vault.configSchema);
28+
assertEquals(typeof vault.createProvider, "function");
29+
});
30+
31+
Deno.test("configSchema validates valid config", () => {
32+
const result = vault.configSchema.safeParse({
33+
vault_url: "https://myvault.vault.azure.net/",
34+
});
35+
assertEquals(result.success, true);
36+
});
37+
38+
Deno.test("configSchema validates config with secret_prefix", () => {
39+
const result = vault.configSchema.safeParse({
40+
vault_url: "https://myvault.vault.azure.net/",
41+
secret_prefix: "swamp/",
42+
});
43+
assertEquals(result.success, true);
44+
});
45+
46+
Deno.test("configSchema rejects invalid vault_url", () => {
47+
const result = vault.configSchema.safeParse({ vault_url: "not-a-url" });
48+
assertEquals(result.success, false);
49+
});
50+
51+
Deno.test("configSchema rejects missing vault_url", () => {
52+
const result = vault.configSchema.safeParse({});
53+
assertEquals(result.success, false);
54+
});
55+
56+
Deno.test("createProvider throws on invalid config", () => {
57+
assertThrows(
58+
() => vault.createProvider("bad-vault", {}),
59+
Error,
60+
);
61+
});

0 commit comments

Comments
 (0)