Skip to content

Commit b46a47e

Browse files
committed
fix(integration): keep LXD login out of IdP input detection
1 parent 6fe3432 commit b46a47e

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

tests/integration/assertions/browser.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
bodyContainsHttpErrorText,
77
browserScreenshotPath,
88
formatDeniedTargetRouteFailure,
9+
isIdentityLoginInputPage,
910
isRetryableBlankNavigationError,
1011
isLoginOrOauthCallbackPlumbingPath,
1112
isTargetApplicationPage,
@@ -41,6 +42,11 @@ describe("browser assertion helpers", () => {
4142
expect(isTargetLoginOrOauthPlumbingPage("https://app.example.test/oidc/login", "app.example.test")).toBe(true);
4243
expect(isTargetLoginOrOauthPlumbingPage("https://app.example.test/protected", "app.example.test")).toBe(false);
4344
expect(isTargetLoginOrOauthPlumbingPage("https://auth.example.test/ui/v2/login/password", "app.example.test")).toBe(false);
45+
46+
expect(isIdentityLoginInputPage("https://app.example.test/ui/login", "app.example.test")).toBe(false);
47+
expect(isIdentityLoginInputPage("https://app.example.test/oidc/login", "app.example.test")).toBe(false);
48+
expect(isIdentityLoginInputPage("https://auth.example.test/ui/v2/login/loginname?requestId=oidc_123", "app.example.test")).toBe(true);
49+
expect(isIdentityLoginInputPage("https://app.example.test/protected", "app.example.test")).toBe(true);
4450
});
4551

4652
test("makes browser artifact names distinct by URL, expectation, user, and outcome", () => {

tests/integration/assertions/browser.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ async function clickOidcStartIfNeeded(page: Page, targetHost: string): Promise<v
164164
let lastStartClick = 0;
165165

166166
while (Date.now() < deadline) {
167-
if (await inputVisible(page, USERNAME_INPUT_SELECTORS)) {
167+
if ((await inputVisible(page, USERNAME_INPUT_SELECTORS)) && isIdentityLoginInputPage(page.url(), targetHost)) {
168168
return;
169169
}
170170
const parsed = parseBrowserUrl(page.url());
@@ -232,7 +232,7 @@ async function clickOidcStartIfNeeded(page: Page, targetHost: string): Promise<v
232232
async function waitForOidcStartHandoff(page: Page, targetHost: string): Promise<void> {
233233
const deadline = Date.now() + BROWSER_OIDC_HANDOFF_TIMEOUT_MS;
234234
while (Date.now() < deadline) {
235-
if (await inputVisible(page, USERNAME_INPUT_SELECTORS)) {
235+
if ((await inputVisible(page, USERNAME_INPUT_SELECTORS)) && isIdentityLoginInputPage(page.url(), targetHost)) {
236236
return;
237237
}
238238

@@ -258,7 +258,7 @@ async function waitForIdentityLoginDocument(page: Page, targetHost: string): Pro
258258
}
259259

260260
await maybeWithTimeout(page.waitForLoadState("domcontentloaded", { timeout: 3000 }).catch(() => undefined), 4000);
261-
if (await inputVisible(page, USERNAME_INPUT_SELECTORS)) {
261+
if ((await inputVisible(page, USERNAME_INPUT_SELECTORS)) && isIdentityLoginInputPage(currentUrl, targetHost)) {
262262
return;
263263
}
264264

@@ -1175,6 +1175,11 @@ export function isTargetLoginOrOauthPlumbingPage(currentUrl: string, targetHost:
11751175
return Boolean(parsed && parsed.host === targetHost && isLoginOrOauthCallbackPlumbingPath(parsed.pathname));
11761176
}
11771177

1178+
export function isIdentityLoginInputPage(currentUrl: string, targetHost: string): boolean {
1179+
const parsed = parseBrowserUrl(currentUrl);
1180+
return Boolean(parsed && !(parsed.host === targetHost && isLoginOrOauthCallbackPlumbingPath(parsed.pathname)));
1181+
}
1182+
11781183
export function formatDeniedTargetRouteFailure(finalUrl: string, body: string): string {
11791184
return [
11801185
"expected denied protected route to show a denial page, but the browser reached the target host without denial text",

0 commit comments

Comments
 (0)