1
0
forked from baron/baron-sso

Align RP auto login launch behavior

This commit is contained in:
2026-04-30 16:36:40 +09:00
parent 28a440734c
commit d16f6cdcb4
7 changed files with 76 additions and 21 deletions

View File

@@ -1,8 +1,6 @@
import { expect, test } from "@playwright/test";
import { expect, test, type Page } from "@playwright/test";
test("orgfront login auto parameter starts OIDC authorization", async ({
page,
}) => {
async function stubOidcAuthorization(page: Page) {
let authorizationURL = "";
await page.route(
@@ -32,11 +30,19 @@ test("orgfront login auto parameter starts OIDC authorization", async ({
},
);
await page.goto("/login?auto=1&returnTo=%2Fpicker");
return {
authorizationURL: () => authorizationURL,
};
}
await expect.poll(() => authorizationURL).toContain("/oauth2/auth");
test("orgfront login defaults to OIDC authorization", async ({ page }) => {
const oidc = await stubOidcAuthorization(page);
const parsed = new URL(authorizationURL);
await page.goto("/login");
await expect.poll(oidc.authorizationURL).toContain("/oauth2/auth");
const parsed = new URL(oidc.authorizationURL());
expect(parsed.searchParams.get("client_id")).toBe("orgfront");
expect(parsed.searchParams.get("redirect_uri")).toBe(
"http://localhost:5175/auth/callback",
@@ -44,3 +50,32 @@ test("orgfront login auto parameter starts OIDC authorization", async ({
expect(parsed.searchParams.get("response_type")).toBe("code");
expect(parsed.searchParams.get("scope") ?? "").toContain("openid");
});
test("orgfront login auto parameter starts OIDC authorization", async ({
page,
}) => {
const oidc = await stubOidcAuthorization(page);
await page.goto("/login?auto=1&returnTo=%2Fpicker");
await expect.poll(oidc.authorizationURL).toContain("/oauth2/auth");
const parsed = new URL(oidc.authorizationURL());
expect(parsed.searchParams.get("client_id")).toBe("orgfront");
expect(parsed.searchParams.get("redirect_uri")).toBe(
"http://localhost:5175/auth/callback",
);
expect(parsed.searchParams.get("response_type")).toBe("code");
expect(parsed.searchParams.get("scope") ?? "").toContain("openid");
});
test("orgfront login can opt out of default OIDC authorization", async ({
page,
}) => {
const oidc = await stubOidcAuthorization(page);
await page.goto("/login?auto=0");
await page.waitForTimeout(500);
expect(oidc.authorizationURL()).toBe("");
});