Repository navigation
🏰 test: Cover Back-Channel Logout With Real Keycloak - #18586
AtefBellaaj wants to merge 6 commits into
Conversation
d23bc69 to
2f8df3f
Compare
danny-avila
left a comment
There was a problem hiding this comment.
Findings inline. I checked that no application code changed, that the test gate is not reachable from production, and that no secrets are committed.
| - '.nvmrc' | ||
| - '.github/workflows/openid.yml' | ||
| - '!**.md' | ||
| merge_group: |
There was a problem hiding this comment.
This runs on every merge queue entry, but openid.yml is not in SUITES in .github/scripts/merge-gate.mjs. So it costs about 15 runner minutes per entry and blocks nothing.
Either add it to the gate, or drop merge_group and keep it advisory on PRs.
There was a problem hiding this comment.
Agreed. The workflow ran on merge_group, but the gate's SUITES list doesn't include it, so it only cost time there. Removed in 7c1be5a.
| cache: npm | ||
| - run: npm ci | ||
| - run: npx tsc -p e2e/openid/tsconfig.json | ||
| - run: npx playwright install --with-deps chromium |
There was a problem hiding this comment.
playwright-mock.yml made the font install best effort with a time bound, and put continue-on-error on the artifact upload, after outages turned passing runs red. Same here please, for this step and the upload below.
There was a problem hiding this comment.
Partly. The browser suite can't run without chromium (browser.spec.ts:43), so that install stays required. Fixed in 6e9636f, following lighthouse.yml: a required --no-shell chromium install, a best-effort font install (continue-on-error, 4-minute timeout), and continue-on-error with a 3-minute timeout on the artifact upload.
| expect(Boolean(row.providerSession)).toBe(false); | ||
| const receiver = await legacy.context.request | ||
| .post(`${harness.baseURL}/oauth/openid/backchannel-logout`, { | ||
| form: { logout_token: 'invalid' }, |
There was a problem hiding this comment.
This is the only invalid token sent to the real route, and it runs in off mode, so it gets 404 before any validation.
Please add a case that sends a tampered signature in enforce and expects 400 with nothing revoked. A wrong audience and a stale token would be good too.
There was a problem hiding this comment.
Agreed. The only invalid token was sent in off mode and expected a 404, so the signature check was never tested. Fixed in ca0f9d4: a new case in enforce mode sends a token with a tampered signature, expects a 400, and checks that nothing is revoked.
| 'mongo:8.0.20', | ||
| '--bind_ip_all', | ||
| ); | ||
| const mongoURI = `mongodb://127.0.0.1:${mongoPort}/${database}?serverSelectionTimeoutMS=2000&socketTimeoutMS=2000`; |
There was a problem hiding this comment.
The 2 second socket timeout applies to the whole app under test, not just the outage cases. Any query slower than 2 seconds on a busy runner fails.
There was a problem hiding this comment.
Agreed. socketTimeoutMS=2000 reached the app through the shared URI and could cut off slow but valid queries. Removed in 77e29ce. serverSelectionTimeoutMS=2000 stays, so a missing MongoDB still fails fast.
2f8df3f to
b7422b7
Compare
b7422b7 to
c35b23d
Compare
|
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
c35b23d to
77e29ce
Compare
77e29ce to
1a26949
Compare
The merge gate does not list openid.yml in SUITES, so a merge-group run was never required and only spent runner time.
…ailures Install the lockfile-pinned Chromium with --no-shell as a required step, install the optional font packages on a best-effort basis, and cap the artifact upload so it cannot fail or stall the job. The Keycloak Playwright config selects the chromium channel because the headless shell is no longer installed.
…e mode Capture a real Keycloak logout token while the app is down, flip one signature byte, and check that the receiver answers 400 and leaves the session refreshable. The untampered token is then accepted, so the rejection comes from the signature alone. replay() takes an optional token edit for this.
The app shares this URI, and a two-second socket timeout can cut off slow valid queries. Server selection keeps its two-second limit so outage tests still fail fast.
1a26949 to
f4dc2aa
Compare
Summary
The existing recovery tests mock provider grants in several paths. They cannot check how real Keycloak token rotation interacts with browser login and admin refresh retries. This PR adds browser and HTTP tests against real Keycloak and MongoDB. It also tests session logout, races, outages, and mode changes. Application behavior is unchanged.
Stack: the OpenID back-channel logout stack #18434 → #18435 → #18633 → #18436 → #18437 → #18438 → #18439 → #18583 → this PR. This PR targets
atef/ai-2415-bcl-07-logout-login-reason(#18583). Related to AI-2415 (ClickHouse/ai#4540) and AI-2656 (ClickHouse/ai#5057).How it works
Each run creates its own containers, ports, database, and keys. LibreChat runs with
NODE_ENV=production. A test gate pauses real database operations to control callback and refresh races. The proxy holds signed logout messages in memory for replay checks.Tests run headlessly by default. The background case switches real tabs and checks that the app tab is hidden. Request errors omit credential headers, and authentication traces are disabled.
Type of change
Testing
Tested environments/configuration: macOS ARM64, Node 24.22.3, Playwright 1.62.1, Keycloak 26.1.5, and MongoDB 8.0.20. Tests cover local and reused provider tokens, plus off, record, and enforce modes.
Automated tests: all 24 tests passed headlessly, with no skips or retries. A 25th case, a logout token with a tampered signature in
enforcemode, was added after that run; CI runs it.The app build, scoped Prettier and ESLint checks, and strict E2E TypeScript checks passed. The admin regression checks real refresh and verification HTTP endpoints with browser-issued credentials. Admin panel UI and authorization-code exchange are outside that test.
Eight admin renewals with
LOGIN_MAX=7still allow another real browser login. When Keycloak is stopped, admin renewal returns503 AUTH_SESSION_CHECK_UNAVAILABLE. The same credential works after the failed grant's existing lease expires and the provider restarts. With local session checks off, Keycloak rejects the grant and admin renewal returns401 REFRESH_FAILED. An early local-token MongoDB lookup failure also returns 503 and preserves cookies.Screenshots / recordings
No user-facing change.
Risk / compatibility
CI needs Docker and Chromium. It installs Chromium with
--no-shell; the system font install and the report upload do not fail the job. The workflow runs both test groups for PRs targeting the parent branch.The delivery test kept the capture proxy running while LibreChat was down. Keycloak made one attempt and received HTTP 502 during the 120-second observation. The session stayed valid until a successful redelivery. The logout guide now states this measured limit; the test does not establish a general retry policy.
Checklist