forked from farhoodlabs/paperclip
fix(plugin): align kubernetes config validation
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import manifest from "../../src/manifest.js";
|
||||
|
||||
describe("manifest", () => {
|
||||
const configSchema = manifest.environmentDrivers[0]?.configSchema as {
|
||||
properties: Record<string, { const?: unknown; maxLength?: number; pattern?: string }>;
|
||||
anyOf: Array<{
|
||||
properties?: Record<string, { const?: unknown }>;
|
||||
required?: string[];
|
||||
}>;
|
||||
};
|
||||
|
||||
it("keeps namespace inputs within the Kubernetes DNS label length limit", () => {
|
||||
expect(configSchema.properties.namespacePrefix.maxLength).toBe(20);
|
||||
expect(configSchema.properties.companySlug.maxLength).toBe(43);
|
||||
});
|
||||
|
||||
it("requires real Kubernetes credentials instead of only inCluster key presence", () => {
|
||||
expect(configSchema.properties.kubeconfig.pattern).toBe("\\S");
|
||||
expect(configSchema.anyOf).toContainEqual({
|
||||
properties: { inCluster: { const: true } },
|
||||
required: ["inCluster"],
|
||||
});
|
||||
expect(configSchema.anyOf).toContainEqual({ required: ["kubeconfig"] });
|
||||
});
|
||||
});
|
||||
@@ -31,6 +31,21 @@ describe("kubernetesProviderConfigSchema", () => {
|
||||
).toThrow();
|
||||
});
|
||||
|
||||
it("bounds namespacePrefix and companySlug so their combination fits a Kubernetes namespace", () => {
|
||||
expect(() =>
|
||||
parseKubernetesProviderConfig({ inCluster: true, namespacePrefix: "a".repeat(21) }),
|
||||
).toThrow();
|
||||
expect(() =>
|
||||
parseKubernetesProviderConfig({ inCluster: true, companySlug: "a".repeat(44) }),
|
||||
).toThrow();
|
||||
});
|
||||
|
||||
it("rejects whitespace-only kubeconfig", () => {
|
||||
expect(() =>
|
||||
parseKubernetesProviderConfig({ inCluster: false, kubeconfig: " " }),
|
||||
).toThrow(/requires one of `inCluster` or `kubeconfig`/);
|
||||
});
|
||||
|
||||
it("rejects egressAllowCidrs entries that are not valid CIDR", () => {
|
||||
expect(() =>
|
||||
parseKubernetesProviderConfig({ inCluster: true, egressAllowCidrs: ["not-a-cidr"] }),
|
||||
|
||||
Reference in New Issue
Block a user