|
1 | 1 | import { describe, it, expect } from "vitest"; |
2 | 2 | import type { EnvironmentVariable } from "../app/v3/environmentVariables/repository"; |
3 | | -import { removeBlacklistedVariables } from "~/v3/environmentVariableRules.server"; |
| 3 | +import { |
| 4 | + isBlacklistedVariable, |
| 5 | + isReservedForExternalSync, |
| 6 | + removeBlacklistedVariables, |
| 7 | +} from "~/v3/environmentVariableRules.server"; |
4 | 8 |
|
5 | 9 | describe("removeBlacklistedVariables", () => { |
6 | 10 | it("should remove exact match blacklisted variables", () => { |
@@ -68,3 +72,32 @@ describe("removeBlacklistedVariables", () => { |
68 | 72 | ]); |
69 | 73 | }); |
70 | 74 | }); |
| 75 | + |
| 76 | +describe("isBlacklistedVariable", () => { |
| 77 | + it("blacklists the platform-managed keys", () => { |
| 78 | + expect(isBlacklistedVariable("TRIGGER_SECRET_KEY")).toBe(true); |
| 79 | + expect(isBlacklistedVariable("TRIGGER_API_URL")).toBe(true); |
| 80 | + }); |
| 81 | + |
| 82 | + it("allows ordinary user keys", () => { |
| 83 | + expect(isBlacklistedVariable("DATABASE_URL")).toBe(false); |
| 84 | + expect(isBlacklistedVariable("MY_API_KEY")).toBe(false); |
| 85 | + }); |
| 86 | +}); |
| 87 | + |
| 88 | +describe("isReservedForExternalSync", () => { |
| 89 | + it("reserves every key the repository would reject", () => { |
| 90 | + expect(isReservedForExternalSync("TRIGGER_SECRET_KEY")).toBe(true); |
| 91 | + expect(isReservedForExternalSync("TRIGGER_API_URL")).toBe(true); |
| 92 | + }); |
| 93 | + |
| 94 | + it("reserves deploy-managed keys that are not blacklisted", () => { |
| 95 | + expect(isReservedForExternalSync("TRIGGER_VERSION")).toBe(true); |
| 96 | + expect(isReservedForExternalSync("TRIGGER_PREVIEW_BRANCH")).toBe(true); |
| 97 | + }); |
| 98 | + |
| 99 | + it("does not reserve ordinary user keys", () => { |
| 100 | + expect(isReservedForExternalSync("DATABASE_URL")).toBe(false); |
| 101 | + expect(isReservedForExternalSync("MY_API_KEY")).toBe(false); |
| 102 | + }); |
| 103 | +}); |
0 commit comments