kaneo (minimalist kanban) fork to experiment adding a tangled integration github.com/usekaneo/kaneo
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at 9a620ba2f31238f03cd28f1da5ef3838d67e4e8a 75 lines 2.2 kB view raw
1import { afterEach, beforeEach, describe, expect, it } from "vitest"; 2import { 3 getGithubSsoOAuthCredentials, 4 isGithubSsoConfigured, 5} from "../../../apps/api/src/utils/github-sso-env"; 6 7const keys = [ 8 "GITHUB_OAUTH_CLIENT_ID", 9 "GITHUB_OAUTH_CLIENT_SECRET", 10 "GITHUB_CLIENT_ID", 11 "GITHUB_CLIENT_SECRET", 12] as const; 13 14describe("github-sso-env", () => { 15 const original: Partial<Record<(typeof keys)[number], string | undefined>> = 16 {}; 17 18 beforeEach(() => { 19 for (const key of keys) { 20 original[key] = process.env[key]; 21 delete process.env[key]; 22 } 23 }); 24 25 afterEach(() => { 26 for (const key of keys) { 27 const value = original[key]; 28 if (value === undefined) { 29 delete process.env[key]; 30 } else { 31 process.env[key] = value; 32 } 33 } 34 }); 35 36 it("prefers GITHUB_OAUTH_* when both are set", () => { 37 process.env.GITHUB_OAUTH_CLIENT_ID = "oauth-id"; 38 process.env.GITHUB_OAUTH_CLIENT_SECRET = "oauth-secret"; 39 process.env.GITHUB_CLIENT_ID = "legacy-id"; 40 process.env.GITHUB_CLIENT_SECRET = "legacy-secret"; 41 expect(getGithubSsoOAuthCredentials()).toEqual({ 42 clientId: "oauth-id", 43 clientSecret: "oauth-secret", 44 }); 45 expect(isGithubSsoConfigured()).toBe(true); 46 }); 47 48 it("falls back to legacy GITHUB_CLIENT_* when OAuth vars are unset", () => { 49 process.env.GITHUB_CLIENT_ID = "legacy-id"; 50 process.env.GITHUB_CLIENT_SECRET = "legacy-secret"; 51 expect(getGithubSsoOAuthCredentials()).toEqual({ 52 clientId: "legacy-id", 53 clientSecret: "legacy-secret", 54 }); 55 expect(isGithubSsoConfigured()).toBe(true); 56 }); 57 58 it("returns empty credentials when nothing is configured", () => { 59 expect(getGithubSsoOAuthCredentials()).toEqual({ 60 clientId: "", 61 clientSecret: "", 62 }); 63 expect(isGithubSsoConfigured()).toBe(false); 64 }); 65 66 it("treats partial OAuth pair as absent and falls back to legacy", () => { 67 process.env.GITHUB_OAUTH_CLIENT_ID = "only-id"; 68 process.env.GITHUB_CLIENT_ID = "legacy-id"; 69 process.env.GITHUB_CLIENT_SECRET = "legacy-secret"; 70 expect(getGithubSsoOAuthCredentials()).toEqual({ 71 clientId: "legacy-id", 72 clientSecret: "legacy-secret", 73 }); 74 }); 75});