Skip to content

test(e2e): cover PROXY_LOGOUT_URL redirect on Logout - #29080

Merged
ryan-crabbe-berri merged 4 commits into
litellm_internal_stagingfrom
litellm_e2e_proxy_logout_url
May 31, 2026
Merged

ryan-crabbe-berri merged 4 commits into
litellm_internal_stagingfrom
litellm_e2e_proxy_logout_url

Conversation

@ryan-crabbe-berri

@ryan-crabbe-berri ryan-crabbe-berri commented May 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds an e2e test for the previously-uncovered manual-QA item "Set PROXY_LOGOUT_URL, click Logout, confirm redirect to that URL".

Both run_e2e.sh and the CircleCI e2e_ui_testing job now boot the proxy with PROXY_LOGOUT_URL=https://www.example.com and export the same value to the Playwright process, so this spec runs as part of the standard suite. It self-skips if PROXY_LOGOUT_URL is empty (e.g. an ad-hoc npx playwright test against a default proxy), so the contract is only asserted when there is a logout target to check.

What the test verifies:

  • Starts authenticated (admin storage state carries a token cookie).
  • Waits for the /sso/get/ui_settings fetch so the navbar logout target is populated before clicking (avoids a same-origin reload from an empty window.location.href).
  • Clicks Logout via stable role-based selectors (account menu button + Logout menuitem), not Ant Design CSS internals.
  • Asserts the browser lands on exactly the configured PROXY_LOGOUT_URL via a normalized href comparison — pins scheme, host, port, path, query and hash (not just origin), while tolerating the browser's trailing-slash/default-port normalization.
  • Asserts the JS-managed token cookie is cleared on logout.

The external logout destination is stubbed via page.route so the assertion does not depend on that host being reachable from CI — we only care that the browser is sent there.

Test plan

  • e2e_tests/tests/auth/proxyLogoutUrl.spec.ts::Logout clears the session and redirects to PROXY_LOGOUT_URL runs in the standard suite when PROXY_LOGOUT_URL is set; self-skips otherwise.

Refs LIT-3093

Env-gated spec mirroring the existing serverRootPathRedirect pattern:
when the proxy is booted with PROXY_LOGOUT_URL set, clicking Logout in
the navbar must navigate to that external URL. The standard run_e2e.sh
exports an empty value so the rest of the suite is unaffected; this
spec self-skips unless the env var is populated.
@codecov

codecov Bot commented May 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@greptile-apps

greptile-apps Bot commented May 27, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds an env-gated Playwright e2e test covering the PROXY_LOGOUT_URL redirect on logout, updating run_e2e.sh and the CircleCI job to boot the proxy with PROXY_LOGOUT_URL=https://www.example.com so the spec runs unconditionally in standard CI.

  • New spec (proxyLogoutUrl.spec.ts): gates the logout click on the /sso/get/ui_settings response (addressing the previous timing-race comment), uses role-based locators instead of Ant Design internals (addressing the previous fragile-selector comment), stubs the external host via page.route to avoid real network dependency, and asserts both the redirect URL and client-side cookie teardown.
  • run_e2e.sh: changes PROXY_LOGOUT_URL from "" to "https://www.example.com"; this is a suite-wide behavioral change (any accidental logout in another test now hits an external redirect instead of staying in-app), explicitly acknowledged in the added comment.
  • CircleCI: promotes PROXY_LOGOUT_URL to job-level environment and removes the conflicting step-level "" override so the proxy and Playwright process agree on the logout target.

Confidence Score: 5/5

Pure test infrastructure change — no production code touched; the new spec is well-guarded and the environment changes are correctly scoped.

All three changed files are test/CI infrastructure. The spec correctly addresses the two issues raised in the previous review cycle (async timing and Ant Design selector fragility). No production logic is modified.

No files require special attention.

Important Files Changed

Filename Overview
ui/litellm-dashboard/e2e_tests/tests/auth/proxyLogoutUrl.spec.ts New Playwright e2e test for PROXY_LOGOUT_URL redirect; correctly addresses both previous review issues (timing race and fragile Ant Design selector). Uses waitForResponse to gate logout click on settings fetch, role-based locators, route interception to stub external host, and parallel waitForURL+click to capture the redirect.
ui/litellm-dashboard/e2e_tests/run_e2e.sh Changes PROXY_LOGOUT_URL from "" to "https://www.example.com" so local suite runs proxyLogoutUrl.spec.ts by default; the comment explicitly acknowledges the suite-wide behavioral change.
.circleci/config.yml Promotes PROXY_LOGOUT_URL to job-level environment and removes the conflicting step-level override so the proxy boot step and Playwright step both see the same value.

Reviews (2): Last reviewed commit: "test(e2e): run PROXY_LOGOUT_URL spec in ..." | Re-trigger Greptile

…ertions

Boot the e2e proxy with PROXY_LOGOUT_URL set (job-level env in CircleCI and
run_e2e.sh) so proxyLogoutUrl.spec.ts actually runs instead of self-skipping.
Nothing else in the suite performs a logout, so this only affects the behavior
under test.

Harden the spec to verify the logout flow rather than a URL substring:
- wait for /sso/get/ui_settings before clicking so logoutUrl is populated
  (otherwise window.location.href = "" silently reloads same-origin)
- assert a token cookie exists first, and is cleared after logout
- locate the dropdown via getByRole instead of internal antd CSS classes
- stub the external destination and assert on URL origin + path prefix
@ryan-crabbe-berri
ryan-crabbe-berri requested a review from a team May 30, 2026 07:48
@ryan-crabbe-berri

Copy link
Copy Markdown
Contributor Author

@greptileai rereview

Replace the origin + startsWith(pathname) checks with a single normalized
href comparison. With PROXY_LOGOUT_URL=https://www.example.com the path was
"/", so startsWith("/") matched any path and left path/query/hash
unchecked. Comparing normalized hrefs pins scheme, host, port, path, query
and hash while still tolerating the browser's trailing-slash/default-port
normalization.
@ryan-crabbe-berri
ryan-crabbe-berri enabled auto-merge (squash) May 31, 2026 01:18
@ryan-crabbe-berri
ryan-crabbe-berri merged commit a9cc6ed into litellm_internal_staging May 31, 2026
119 checks passed
fzowl pushed a commit to fzowl/litellm that referenced this pull request Jun 24, 2026
* test(e2e): cover PROXY_LOGOUT_URL redirect on Logout

Env-gated spec mirroring the existing serverRootPathRedirect pattern:
when the proxy is booted with PROXY_LOGOUT_URL set, clicking Logout in
the navbar must navigate to that external URL. The standard run_e2e.sh
exports an empty value so the rest of the suite is unaffected; this
spec self-skips unless the env var is populated.

* test(e2e): run PROXY_LOGOUT_URL spec in the suite + harden logout assertions

Boot the e2e proxy with PROXY_LOGOUT_URL set (job-level env in CircleCI and
run_e2e.sh) so proxyLogoutUrl.spec.ts actually runs instead of self-skipping.
Nothing else in the suite performs a logout, so this only affects the behavior
under test.

Harden the spec to verify the logout flow rather than a URL substring:
- wait for /sso/get/ui_settings before clicking so logoutUrl is populated
  (otherwise window.location.href = "" silently reloads same-origin)
- assert a token cookie exists first, and is cleared after logout
- locate the dropdown via getByRole instead of internal antd CSS classes
- stub the external destination and assert on URL origin + path prefix

* test(e2e): assert exact PROXY_LOGOUT_URL on logout redirect

Replace the origin + startsWith(pathname) checks with a single normalized
href comparison. With PROXY_LOGOUT_URL=https://www.example.com the path was
"/", so startsWith("/") matched any path and left path/query/hash
unchecked. Comparing normalized hrefs pins scheme, host, port, path, query
and hash while still tolerating the browser's trailing-slash/default-port
normalization.
@devin-ai-integration
devin-ai-integration Bot deleted the litellm_e2e_proxy_logout_url branch September 10, 2026 03:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants