From dabc619b27894d7da395feebb54d37b6ee94cd95 Mon Sep 17 00:00:00 2001 From: Zai Shi Date: Mon, 28 Jul 2025 17:37:06 -0700 Subject: [PATCH] tests --- .../api/v1/internal/config-overrides.test.ts | 115 +++++++++++++++++- 1 file changed, 114 insertions(+), 1 deletion(-) diff --git a/apps/e2e/tests/backend/endpoints/api/v1/internal/config-overrides.test.ts b/apps/e2e/tests/backend/endpoints/api/v1/internal/config-overrides.test.ts index f3090daa7..835f3dc3c 100644 --- a/apps/e2e/tests/backend/endpoints/api/v1/internal/config-overrides.test.ts +++ b/apps/e2e/tests/backend/endpoints/api/v1/internal/config-overrides.test.ts @@ -1,3 +1,4 @@ +import { pick } from "@stackframe/stack-shared/dist/utils/objects"; import { it } from "../../../../../helpers"; import { Project, niceBackendFetch } from "../../../../backend-helpers"; @@ -283,7 +284,119 @@ it("adds, updates, and removes oauth config", async ({ expect }) => { expect(persistedConfig.auth.oauth.providers).toEqual({}); }); -it.todo("misconfigures oauth config"); +it("doesn't allow duplicated oauth ids", async ({ expect }) => { + const { adminAccessToken } = await Project.createAndSwitch({ + config: { + magic_link_enabled: true, + } + }); + + // However, trying to create multiple providers with same OAuth ID in single request should fail + // or at minimum, only the last one should be applied + const multipleWithSameIdResponse = await niceBackendFetch("/api/v1/internal/config-overrides", { + method: "PATCH", + accessType: "admin", + headers: { + 'x-stack-admin-access-token': adminAccessToken, + }, + body: { + config: ` + { + "auth.oauth.providers.duplicate": { + "type":"google", + "isShared":false, + "clientId":"google-client-id", + "clientSecret":"google-client-secret", + "allowSignIn":true, + "allowConnectedAccounts":true + }, + "auth.oauth.providers.duplicate": { + "type":"google", + "isShared":false, + "clientId":"google-client-id", + "clientSecret":"google-client-secret", + "allowSignIn":true, + "allowConnectedAccounts":true + }, + }`, + }, + }); + + expect(multipleWithSameIdResponse).toMatchInlineSnapshot(` + NiceResponse { + "status": 400, + "body": "Invalid config JSON", + "headers": Headers {