Skip to content

Feat/oauth2 keyclock cicd setup (WIP) - #8554

Closed
abhishekp-bruno wants to merge 21 commits into
usebruno:mainfrom
abhishekp-bruno:feat/oauth2-keyclock-cicd-setup
Closed

abhishekp-bruno wants to merge 21 commits into
usebruno:mainfrom
abhishekp-bruno:feat/oauth2-keyclock-cicd-setup

Conversation

@abhishekp-bruno

@abhishekp-bruno abhishekp-bruno commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Description

Contribution Checklist:

  • I've used AI significantly to create this pull request
  • The pull request only addresses one issue or adds one feature.
  • The pull request does not introduce any breaking changes
  • I have added screenshots or gifs to help explain the change if applicable.
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.

Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.

Publishing to New Package Managers

Please see here for more information.

Summary by CodeRabbit

  • New Features

    • Added OAuth2 end-to-end authentication coverage for authorization-code and implicit flows, including state validation.
    • Added cross-platform automated test jobs for Linux, macOS, and Windows.
    • Added local identity-provider setup and test fixtures for OAuth2 scenarios.
    • Added Playwright report artifacts for OAuth2 test runs.
  • Bug Fixes

    • User-provided OAuth2 state values are now preserved as supplied; otherwise, a secure random value is generated.

@coderabbitai

coderabbitai Bot commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Adds OAuth2 Playwright E2E coverage for authorization-code and implicit flows, cross-platform Keycloak setup and test actions, reusable OAuth2 fixtures, and Linux, macOS, and Windows workflow jobs.

Changes

OAuth2 E2E Test Infrastructure

Layer / File(s) Summary
OAuth2 project and fixture configuration
package.json, playwright.config.ts, tests/auth/oauth2/...
Adds the dedicated Playwright project and npm script, Bruno OAuth2 flow fixtures, local Keycloak settings, realm data, and test preferences.
Cross-platform Keycloak and E2E actions
.github/actions/auth/oauth2/...
Adds Java detection and setup, Keycloak provisioning, readiness polling, platform-specific OAuth2 test execution, cleanup, and Playwright report uploads.
OAuth2 state validation coverage
tests/auth/oauth2/oauth2-state-validation.spec.ts, packages/bruno-electron/src/utils/oauth2.js
Tests matching, mismatched, and user-supplied state across authorization-code and implicit callbacks, and updates the state-generation comment.
OAuth2 CI job wiring
.github/workflows/tests-linux.yml, .github/workflows/tests-macos.yml, .github/workflows/tests-windows.yml
Adds platform-specific OAuth2 test jobs and invokes the corresponding setup and execution actions.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Playwright as OAuth2 E2E tests
  participant Bruno as Bruno Electron
  participant Keycloak
  Playwright->>Bruno: Start OAuth2 request
  Bruno->>Keycloak: Request authorization with state
  Keycloak-->>Playwright: Return code or access token
  Playwright->>Bruno: Send callback deep link
  Bruno-->>Playwright: Report success or state mismatch
Loading

Possibly related PRs

Suggested reviewers: helloanoop, lohit-bruno, naman-bruno, sid-bruno, utkarsh-bruno, sanish-bruno, bijin-bruno

Poem

Keycloak wakes, the browsers fly,
With OAuth states sent through the sky.
Codes and tokens find their way,
Mismatches stop, successes stay.
Three platforms test the flow anew.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is related to the main change: adding OAuth2/Keycloak CI setup and e2e test support.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
putComment timed out

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (10)
.github/actions/auth/oauth2/macos/setup-keycloak/action.yml (2)

55-56: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Use $RUNNER_TEMP for keycloak.log path.

The log file path also uses /tmp — should be $RUNNER_TEMP for the same consistency reasons.

♻️ Proposed fix
-          > /tmp/keycloak.log 2>&1 &
+          > "$RUNNER_TEMP/keycloak.log" 2>&1 &
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/actions/auth/oauth2/macos/setup-keycloak/action.yml around lines 55
- 56, The Keycloak startup command is writing its log to /tmp instead of the
runner temp directory. Update the nohup invocation in setup-keycloak/action.yml
to use $RUNNER_TEMP for the kc.sh start-dev output redirection, keeping the
logging path consistent with the rest of the action; locate the change in the
startup command that launches kc.sh.

46-49: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use $RUNNER_TEMP instead of hardcoded /tmp.

Same as the Linux action — prefer $RUNNER_TEMP for consistency with the Windows action and GitHub Actions conventions.

♻️ Proposed fix
-        curl -fsSL -o /tmp/keycloak.zip \
+        curl -fsSL -o "$RUNNER_TEMP/keycloak.zip" \
           "https://github.com/keycloak/keycloak/releases/download/${KEYCLOAK_VERSION}/keycloak-${KEYCLOAK_VERSION}.zip"
-        unzip -q /tmp/keycloak.zip -d /tmp
-        KC_HOME="/tmp/keycloak-${KEYCLOAK_VERSION}"
+        unzip -q "$RUNNER_TEMP/keycloak.zip" -d "$RUNNER_TEMP"
+        KC_HOME="$RUNNER_TEMP/keycloak-${KEYCLOAK_VERSION}"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/actions/auth/oauth2/macos/setup-keycloak/action.yml around lines 46
- 49, The Keycloak setup steps in the macOS action currently write to hardcoded
/tmp paths, which should be replaced with $RUNNER_TEMP for consistency with the
other actions and GitHub Actions conventions. Update the download, unzip, and
KC_HOME assignment in the setup flow so the temporary archive and extracted
directory are placed under $RUNNER_TEMP, using the same approach as the Linux
and Windows setup logic.
.github/actions/auth/oauth2/linux/setup-keycloak/action.yml (2)

46-49: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use $RUNNER_TEMP instead of hardcoded /tmp.

The Windows action correctly uses $env:RUNNER_TEMP, but Linux and macOS hardcode /tmp. While they typically resolve to the same path on GitHub runners, $RUNNER_TEMP is the documented temp directory and ensures consistency across platforms.

♻️ Proposed fix
-        curl -fsSL -o /tmp/keycloak.zip \
+        curl -fsSL -o "$RUNNER_TEMP/keycloak.zip" \
           "https://github.com/keycloak/keycloak/releases/download/${KEYCLOAK_VERSION}/keycloak-${KEYCLOAK_VERSION}.zip"
-        unzip -q /tmp/keycloak.zip -d /tmp
-        KC_HOME="/tmp/keycloak-${KEYCLOAK_VERSION}"
+        unzip -q "$RUNNER_TEMP/keycloak.zip" -d "$RUNNER_TEMP"
+        KC_HOME="$RUNNER_TEMP/keycloak-${KEYCLOAK_VERSION}"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/actions/auth/oauth2/linux/setup-keycloak/action.yml around lines 46
- 49, The Keycloak setup step still hardcodes the temporary directory with /tmp
instead of using the runner-provided temp location. Update the Linux/macOS
action logic in the Keycloak download/extract flow to use RUNNER_TEMP
consistently, matching the Windows setup and keeping the temp zip, unzip target,
and KC_HOME construction based on that variable.

37-68: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚖️ Poor tradeoff

Linux and macOS setup-keycloak actions are identical — consolidate.

This file is byte-for-byte identical to .github/actions/auth/oauth2/macos/setup-keycloak/action.yml. Any fix or update must be applied to both, risking drift. Consider extracting the shared logic into a common composite action invoked by both platform-specific wrappers.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/actions/auth/oauth2/linux/setup-keycloak/action.yml around lines 37
- 68, The Linux setup-keycloak workflow duplicates the macOS version
byte-for-byte, so updates must be made in two places and can drift. Extract the
shared Keycloak setup logic from the “Download and start Keycloak” step into a
common composite action, then have both platform-specific wrappers invoke that
shared action. Keep the wrapper-specific files minimal and ensure any future
changes to the Keycloak download/start/wait flow happen only in the shared
action.
.github/actions/auth/oauth2/macos/run-oauth2-e2e-tests/action.yml (1)

6-9: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Add set -euo pipefail for consistency with Linux.

The Linux run step includes set -euo pipefail but the macOS step does not. While npm run propagates exit codes, adding it ensures consistent error handling across all platform actions.

♻️ Proposed fix
       run: |
+        set -euo pipefail
+
         npm run test:e2e:auth:oauth2
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/actions/auth/oauth2/macos/run-oauth2-e2e-tests/action.yml around
lines 6 - 9, The macOS OAuth2 E2E test step in the action’s run block is missing
the same strict shell settings used by the Linux step. Update the Run OAuth2 E2E
tests step in the oauth2 macOS action to include set -euo pipefail before npm
run test:e2e:auth:oauth2 so error handling matches across platforms and the
shell behavior is consistent.
.github/workflows/tests-linux.yml (1)

157-157: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win

Set persist-credentials: false on checkout for security hardening

The actions/checkout@v6 step defaults to persist-credentials: true, leaving the GitHub token in .git/config. Since these jobs only run tests, add persist-credentials: false to reduce credential exposure risk. This matches the existing pattern across other jobs, so consider applying it repo-wide.

🔒 Suggested fix
     steps:
-      - uses: actions/checkout@v6
+      - uses: actions/checkout@v6
+        with:
+          persist-credentials: false
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/tests-linux.yml at line 157, Add security hardening to the
existing actions/checkout@v6 step by setting persist-credentials to false so the
GitHub token is not left in .git/config. Update the checkout step in the
tests-linux workflow, and apply the same change anywhere else in the repo where
checkout is used for test-only jobs to keep the pattern consistent.

Source: Linters/SAST tools

.github/workflows/tests-windows.yml (1)

149-149: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win

Set persist-credentials: false on checkout for security hardening

Same as the Linux and macOS recommendations — add persist-credentials: false to reduce credential exposure.

🔒 Suggested fix
     steps:
-      - uses: actions/checkout@v6
+      - uses: actions/checkout@v6
+        with:
+          persist-credentials: false
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/tests-windows.yml at line 149, The checkout step in the
Windows workflow should be hardened by disabling credential persistence. Update
the existing actions/checkout usage in the workflow to include
persist-credentials: false, matching the security setup already used in the
Linux and macOS workflows. Ensure the change is applied to the checkout step
itself so credentials are not retained after the job runs.

Source: Linters/SAST tools

.github/workflows/tests-macos.yml (1)

141-141: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win

Set persist-credentials: false on checkout for security hardening

Same as the Linux recommendation — add persist-credentials: false to reduce credential exposure.

🔒 Suggested fix
     steps:
-      - uses: actions/checkout@v6
+      - uses: actions/checkout@v6
+        with:
+          persist-credentials: false
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/tests-macos.yml at line 141, The checkout step in the
macOS workflow is missing the security hardening setting, so update the existing
actions/checkout usage to disable credential persistence. Adjust the checkout
configuration in the tests-macos workflow by setting persist-credentials to
false on the same checkout step, matching the Linux workflow’s hardening
approach.

Source: Linters/SAST tools

tests/auth/oauth2/oauth2-state-validation.spec.ts (2)

263-268: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Uncomment or remove the commented-out test.step wrapper.

The test.step('start the authorization code flow', ...) wrapper is commented out in test 3 (lines 263-268) but active in all other tests. This reduces report readability and creates an inconsistency. Either wrap the steps in a test.step like the other tests do, or remove the commented-out lines.

♻️ Proposed fix
-    // await test.step('start the authorization code flow', async () => {
+    await test.step('start the authorization code flow', async () => {
     await stubOpenExternal(app);
     await installCallbackCapture(app);
     await clickGetAccessToken(page, 'AuthCodeUserSuppliedState');
     await waitForAuthorizationStarted(app);
-    // });
+    });
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/auth/oauth2/oauth2-state-validation.spec.ts` around lines 263 - 268,
The authorization code flow block in oauth2-state-validation.spec.ts has a
commented-out test.step wrapper, unlike the other tests. Update the test around
the clickGetAccessToken, stubOpenExternal, installCallbackCapture, and
waitForAuthorizationStarted calls to either restore the test.step('start the
authorization code flow', ...) wrapper or remove the commented wrapper entirely
so the structure is consistent.

152-152: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Remove dead code: STATE_NONCE_HEX_LENGTH and the commented-out nonce-length assertion.

STATE_NONCE_HEX_LENGTH (line 152) is only referenced in the commented-out assertion on line 160. If the nonce-length check is intentionally disabled, remove both the constant and the comment to avoid confusion. If the check should be active, uncomment it and remove the contradictory toBe assertions in the user-supplied state tests instead.

♻️ Proposed cleanup
 const STATE_NONCE_HEX_LENGTH = 32;
-
-/** `state` Bruno sent on the authorization URL (stored internally as expectedState). */
-const getIssuedState = async (app: ElectronApplication): Promise<string> => {
-  const authUrl = await getCapturedAuthUrl(app);
-  expect(authUrl, 'authorization URL should have been opened').toBeTruthy();
-  const state = stateFromAuthorizationUrl(authUrl as string);
-  expect(state, 'issued state should be present on the authorization URL').toBeTruthy();
-  // expect((state as string).length).toBeGreaterThanOrEqual(STATE_NONCE_HEX_LENGTH);
-  return state as string;
-};
+// (Remove STATE_NONCE_HEX_LENGTH if the nonce-length check is intentionally disabled)

Also applies to: 160-160

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/auth/oauth2/oauth2-state-validation.spec.ts` at line 152, Remove the
dead nonce-length test code in oauth2-state-validation.spec.ts: the
STATE_NONCE_HEX_LENGTH constant and the commented-out nonce-length assertion are
only used together, so delete both if the check is intentionally disabled. If
nonce validation should remain active, update the state validation test logic in
the oauth2 state spec to re-enable the assertion and make the user-supplied
state tests consistent by removing any contradictory toBe expectations.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/actions/auth/oauth2/windows/setup-keycloak/action.yml:
- Around line 75-79: The failure path in the Keycloak readiness check uses
Write-Error, which stops execution before the log tail is printed because
$ErrorActionPreference is Stop. Update the error handling in the setup-keycloak
action script so the not-ready branch in the readiness check prints the failure
message and the last log lines with Write-Host (or equivalent non-terminating
output), then explicitly exits with code 1. Keep the change localized to the
Keycloak startup wait logic so the log output is always reached when readiness
fails.

---

Nitpick comments:
In @.github/actions/auth/oauth2/linux/setup-keycloak/action.yml:
- Around line 46-49: The Keycloak setup step still hardcodes the temporary
directory with /tmp instead of using the runner-provided temp location. Update
the Linux/macOS action logic in the Keycloak download/extract flow to use
RUNNER_TEMP consistently, matching the Windows setup and keeping the temp zip,
unzip target, and KC_HOME construction based on that variable.
- Around line 37-68: The Linux setup-keycloak workflow duplicates the macOS
version byte-for-byte, so updates must be made in two places and can drift.
Extract the shared Keycloak setup logic from the “Download and start Keycloak”
step into a common composite action, then have both platform-specific wrappers
invoke that shared action. Keep the wrapper-specific files minimal and ensure
any future changes to the Keycloak download/start/wait flow happen only in the
shared action.

In @.github/actions/auth/oauth2/macos/run-oauth2-e2e-tests/action.yml:
- Around line 6-9: The macOS OAuth2 E2E test step in the action’s run block is
missing the same strict shell settings used by the Linux step. Update the Run
OAuth2 E2E tests step in the oauth2 macOS action to include set -euo pipefail
before npm run test:e2e:auth:oauth2 so error handling matches across platforms
and the shell behavior is consistent.

In @.github/actions/auth/oauth2/macos/setup-keycloak/action.yml:
- Around line 55-56: The Keycloak startup command is writing its log to /tmp
instead of the runner temp directory. Update the nohup invocation in
setup-keycloak/action.yml to use $RUNNER_TEMP for the kc.sh start-dev output
redirection, keeping the logging path consistent with the rest of the action;
locate the change in the startup command that launches kc.sh.
- Around line 46-49: The Keycloak setup steps in the macOS action currently
write to hardcoded /tmp paths, which should be replaced with $RUNNER_TEMP for
consistency with the other actions and GitHub Actions conventions. Update the
download, unzip, and KC_HOME assignment in the setup flow so the temporary
archive and extracted directory are placed under $RUNNER_TEMP, using the same
approach as the Linux and Windows setup logic.

In @.github/workflows/tests-linux.yml:
- Line 157: Add security hardening to the existing actions/checkout@v6 step by
setting persist-credentials to false so the GitHub token is not left in
.git/config. Update the checkout step in the tests-linux workflow, and apply the
same change anywhere else in the repo where checkout is used for test-only jobs
to keep the pattern consistent.

In @.github/workflows/tests-macos.yml:
- Line 141: The checkout step in the macOS workflow is missing the security
hardening setting, so update the existing actions/checkout usage to disable
credential persistence. Adjust the checkout configuration in the tests-macos
workflow by setting persist-credentials to false on the same checkout step,
matching the Linux workflow’s hardening approach.

In @.github/workflows/tests-windows.yml:
- Line 149: The checkout step in the Windows workflow should be hardened by
disabling credential persistence. Update the existing actions/checkout usage in
the workflow to include persist-credentials: false, matching the security setup
already used in the Linux and macOS workflows. Ensure the change is applied to
the checkout step itself so credentials are not retained after the job runs.

In `@tests/auth/oauth2/oauth2-state-validation.spec.ts`:
- Around line 263-268: The authorization code flow block in
oauth2-state-validation.spec.ts has a commented-out test.step wrapper, unlike
the other tests. Update the test around the clickGetAccessToken,
stubOpenExternal, installCallbackCapture, and waitForAuthorizationStarted calls
to either restore the test.step('start the authorization code flow', ...)
wrapper or remove the commented wrapper entirely so the structure is consistent.
- Line 152: Remove the dead nonce-length test code in
oauth2-state-validation.spec.ts: the STATE_NONCE_HEX_LENGTH constant and the
commented-out nonce-length assertion are only used together, so delete both if
the check is intentionally disabled. If nonce validation should remain active,
update the state validation test logic in the oauth2 state spec to re-enable the
assertion and make the user-supplied state tests consistent by removing any
contradictory toBe expectations.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7797074f-ef5d-4c86-a993-3f57f6aeb088

📥 Commits

Reviewing files that changed from the base of the PR and between ff2f2d0 and 8ee7295.

📒 Files selected for processing (20)
  • .github/actions/auth/oauth2/linux/run-oauth2-e2e-tests/action.yml
  • .github/actions/auth/oauth2/linux/setup-keycloak/action.yml
  • .github/actions/auth/oauth2/macos/run-oauth2-e2e-tests/action.yml
  • .github/actions/auth/oauth2/macos/setup-keycloak/action.yml
  • .github/actions/auth/oauth2/windows/run-oauth2-e2e-tests/action.yml
  • .github/actions/auth/oauth2/windows/setup-keycloak/action.yml
  • .github/workflows/tests-linux.yml
  • .github/workflows/tests-macos.yml
  • .github/workflows/tests-windows.yml
  • package.json
  • playwright.config.ts
  • tests/auth/oauth2/fixtures/collection/AuthCodeUserSuppliedState.bru
  • tests/auth/oauth2/fixtures/collection/AuthorizationCode.bru
  • tests/auth/oauth2/fixtures/collection/AuthorizationImplicit.bru
  • tests/auth/oauth2/fixtures/collection/ImplicitUserSuppliedState.bru
  • tests/auth/oauth2/fixtures/collection/bruno.json
  • tests/auth/oauth2/fixtures/collection/environments/Local.bru
  • tests/auth/oauth2/fixtures/keycloak/realm-export.json
  • tests/auth/oauth2/init-user-data/preferences.json
  • tests/auth/oauth2/oauth2-state-validation.spec.ts

Comment on lines +75 to +79
if (-not $ready) {
Write-Error "Keycloak did not become ready in time"
if (Test-Path $log) { Get-Content $log -Tail 100 }
exit 1
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Log tail is unreachable when Keycloak fails to start.

With $ErrorActionPreference = 'Stop' set at line 46, Write-Error at line 76 throws immediately, so Get-Content at line 77 and exit 1 at line 78 never execute. The Keycloak log — critical for debugging startup failures — won't be displayed. Use Write-Host for the error message and log output, then exit 1 explicitly.

🐛 Proposed fix
         if (-not $ready) {
-          Write-Error "Keycloak did not become ready in time"
-          if (Test-Path $log) { Get-Content $log -Tail 100 }
+          Write-Host "::error::Keycloak did not become ready in time"
+          if (Test-Path $log) { Get-Content $log -Tail 100 }
+          if (Test-Path "$env:RUNNER_TEMP\keycloak.err.log") { Get-Content "$env:RUNNER_TEMP\keycloak.err.log" -Tail 100 }
           exit 1
         }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (-not $ready) {
Write-Error "Keycloak did not become ready in time"
if (Test-Path $log) { Get-Content $log -Tail 100 }
exit 1
}
if (-not $ready) {
Write-Host "::error::Keycloak did not become ready in time"
if (Test-Path $log) { Get-Content $log -Tail 100 }
if (Test-Path "$env:RUNNER_TEMP\keycloak.err.log") { Get-Content "$env:RUNNER_TEMP\keycloak.err.log" -Tail 100 }
exit 1
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/actions/auth/oauth2/windows/setup-keycloak/action.yml around lines
75 - 79, The failure path in the Keycloak readiness check uses Write-Error,
which stops execution before the log tail is printed because
$ErrorActionPreference is Stop. Update the error handling in the setup-keycloak
action script so the not-ready branch in the readiness check prints the failure
message and the last log lines with Write-Host (or equivalent non-terminating
output), then explicitly exits with code 1. Keep the change localized to the
Keycloak startup wait logic so the log output is always reached when readiness
fails.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (2)
.github/workflows/lint-checks.yml (1)

1-26: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Same anti-pattern as benchmarks.yml — and this one disables lint enforcement in CI.

Commenting out the entire file leaves dead YAML and produces an actionlint "workflow is empty" error. More importantly, this removes automated lint enforcement from CI — the npm run lint script and eslint-plugin-diff config remain active in the repo (confirmed in package.json line 91 and eslint.config.js), so only CI-side enforcement is lost.

Prefer the same alternatives: delete the file, keep only workflow_dispatch, or add if: false to the job. If the intent is to temporarily unblock the WIP PR, a single comment at the top of an otherwise intact file is cleaner than commenting out every line.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/lint-checks.yml around lines 1 - 26, The lint-checks
workflow is effectively disabled by commenting out the entire file, which also
leaves dead YAML that triggers the empty-workflow actionlint error. Update the
workflow by either removing the file, keeping only workflow_dispatch, or marking
the lint job in lint-checks.yml with if: false; if this is only a temporary WIP
unblock, leave the workflow intact and add a brief top-level comment instead of
commenting every step.

Source: Linters/SAST tools

.github/workflows/benchmarks.yml (1)

1-92: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Avoid commenting out entire workflow files — prefer deletion or trigger removal.

Commenting out every line produces an invalid workflow (actionlint reports "workflow is empty") and leaves ~90 lines of dead YAML in the repo. This is hard to maintain and easy to accidentally re-enable.

For a WIP disable, prefer one of:

  1. Delete the file — recoverable via git history when needed.
  2. Keep only workflow_dispatch — removes automatic triggers while preserving manual-run capability:
-# name: Benchmarks
-# on:
-#   workflow_dispatch:
-#     inputs:
-#       update-baseline:
-#         description: 'Update baseline with current results instead of comparing'
-#         type: boolean
-#         default: false
-#   pull_request:
-#     branches: [main, 'release/v*']
+name: Benchmarks
+on:
+  workflow_dispatch:
+    inputs:
+      update-baseline:
+        description: 'Update baseline with current results instead of comparing'
+        type: boolean
+        default: false
  1. Add if: false to the job — keeps the workflow structurally valid while disabling execution.

If this is truly temporary and will be reverted before merge, a comment at the top (# Temporarily disabled for OAuth2 WIP) on an otherwise intact file would be cleaner than commenting out every line.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/benchmarks.yml around lines 1 - 92, The entire benchmarks
workflow is commented out, which leaves an invalid empty workflow and a lot of
dead YAML. In .github/workflows/benchmarks.yml, either remove the file, restore
the workflow and keep only the manual trigger, or disable execution structurally
with an always-false job condition; use the existing Benchmarks workflow/job
definitions and the benchmark job name to locate it. Avoid commenting out every
line so the file remains maintainable and lint-safe.

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/flaky-test-detector.yml:
- Around line 1-123: The flaky-test-detector workflow is inert because all jobs
in the workflow are commented out, leaving GitHub Actions with an empty
workflow. Restore the active workflow structure around detect-flaky-tests and
its related steps, and if this is meant to be temporary, keep the workflow file
valid by gating execution with an on/if condition rather than commenting out the
entire job block. Refer to the detect-flaky-tests job and the Post PR
comment/Upload flaky test artifacts steps when re-enabling it.

In @.github/workflows/npm-bru-cli.yml:
- Around line 1-51: The Bru CLI validation workflow has been effectively
disabled because the entire workflow definition is commented out, leaving no
runnable jobs or triggers. Restore the workflow structure in npm-bru-cli.yml by
uncommenting the actual job definition and only disable it through the trigger
or job conditions if this is meant to be temporary; keep the existing workflow
identity and steps such as the test job and actions/checkout,
actions/setup-node, and dorny/test-reporter intact.

In @.github/workflows/tests-linux.yml:
- Around line 14-146: The Linux workflow currently disables every existing test
job by commenting out unit-test, cli-test, e2e-test, ssl-test, and oauth1-tests,
which removes CI coverage. Restore the existing job definitions in
tests-linux.yml and use a safer temporary disable mechanism like if: false on
individual jobs with a brief note, or leave them intact and add the new
oauth2-tests job separately. Keep the workflow anchored around the existing job
names so the CI intent stays clear and the YAML does not drift.

---

Nitpick comments:
In @.github/workflows/benchmarks.yml:
- Around line 1-92: The entire benchmarks workflow is commented out, which
leaves an invalid empty workflow and a lot of dead YAML. In
.github/workflows/benchmarks.yml, either remove the file, restore the workflow
and keep only the manual trigger, or disable execution structurally with an
always-false job condition; use the existing Benchmarks workflow/job definitions
and the benchmark job name to locate it. Avoid commenting out every line so the
file remains maintainable and lint-safe.

In @.github/workflows/lint-checks.yml:
- Around line 1-26: The lint-checks workflow is effectively disabled by
commenting out the entire file, which also leaves dead YAML that triggers the
empty-workflow actionlint error. Update the workflow by either removing the
file, keeping only workflow_dispatch, or marking the lint job in lint-checks.yml
with if: false; if this is only a temporary WIP unblock, leave the workflow
intact and add a brief top-level comment instead of commenting every step.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: cad6ca3a-ce2e-422c-804b-a40494c64c34

📥 Commits

Reviewing files that changed from the base of the PR and between 8ee7295 and ecc643c.

📒 Files selected for processing (9)
  • .github/workflows/benchmarks.yml
  • .github/workflows/flaky-test-detector.yml
  • .github/workflows/lint-checks.yml
  • .github/workflows/npm-bru-cli.yml
  • .github/workflows/tests-linux.yml
  • .github/workflows/tests-macos.yml
  • .github/workflows/tests-windows.yml
  • tests/auth/oauth2/fixtures/collection/environments/Local.bru
  • tests/auth/oauth2/oauth2-state-validation.spec.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/auth/oauth2/oauth2-state-validation.spec.ts

Comment thread .github/workflows/npm-bru-cli.yml Resolved
Comment thread .github/workflows/tests-linux.yml Resolved
… environment

- Changed the Keycloak setup action to only prepare the environment without starting the server.
- Updated the test execution action to start Keycloak and run OAuth2 E2E tests in the same step, ensuring the server remains active during the tests.
- Improved error handling and logging for Keycloak readiness checks.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
tests/auth/oauth2/oauth2-state-validation.spec.ts (1)

128-133: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Type annotation inconsistency on arg parameter.

The arg parameter is typed as string but uses optional chaining (arg?.startsWith). If arg can be undefined, the type should reflect that; if not, the ?. is unnecessary. As per coding guidelines, avoid optional chaining where it doesn't make sense — fix the type or narrow first.

♻️ Suggested type fix
-      const url = commandLine?.find((arg: string) => arg?.startsWith('bruno://'));
+      const url = commandLine?.find((arg) => arg?.startsWith('bruno://'));

Or, if arg is guaranteed to be a string:

-      const url = commandLine?.find((arg: string) => arg?.startsWith('bruno://'));
+      const url = commandLine?.find((arg: string) => arg.startsWith('bruno://'));
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/auth/oauth2/oauth2-state-validation.spec.ts` around lines 128 - 133,
Resolve the type and optional-chaining mismatch in the second-instance
listener’s commandLine.find callback: either declare arg as possibly undefined
if that reflects the data, or keep it as string and replace arg?.startsWith with
arg.startsWith. Preserve the existing bruno:// URL detection and capture
behavior.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/auth/oauth2/oauth2-state-validation.spec.ts`:
- Around line 272-273: Update both mismatch tests in
oauth2-state-validation.spec.ts, including “authorization code: rejects callback
when returned state does not match issued state” and the other mismatch test, to
call test.setTimeout(60_000) consistently with the success tests before their
asynchronous setup.
- Around line 373-374: Set a 60-second timeout for the implicit-grant
state-mismatch test, alongside the existing test declaration before its
asynchronous setup, so waitForReadyPage can complete within the allowed
duration. Keep the test behavior unchanged.

---

Nitpick comments:
In `@tests/auth/oauth2/oauth2-state-validation.spec.ts`:
- Around line 128-133: Resolve the type and optional-chaining mismatch in the
second-instance listener’s commandLine.find callback: either declare arg as
possibly undefined if that reflects the data, or keep it as string and replace
arg?.startsWith with arg.startsWith. Preserve the existing bruno:// URL
detection and capture behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3b4b4b2d-da5f-4535-b9d9-062dd77d3c21

📥 Commits

Reviewing files that changed from the base of the PR and between ec22139 and 9f5cacb.

📒 Files selected for processing (2)
  • packages/bruno-electron/src/utils/oauth2.js
  • tests/auth/oauth2/oauth2-state-validation.spec.ts
✅ Files skipped from review due to trivial changes (1)
  • packages/bruno-electron/src/utils/oauth2.js

Comment on lines +272 to +273
test('authorization code: rejects callback when returned state does not match issued state', async ({ restartApp }) => {
const app = await restartApp();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Add test.setTimeout(60_000) to mismatch tests for consistency and stability.

The four success tests (lines 198, 238, 306, 343) all set a 60s test timeout, but the two mismatch tests (here and line 373) do not. Since waitForReadyPage can take up to 45s, the default test timeout may be exceeded on slower CI runners, causing flaky failures.

🛡️ Proposed fix
   test('authorization code: rejects callback when returned state does not match issued state', async ({ restartApp }) => {
+    test.setTimeout(60_000);
     const app = await restartApp();
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
test('authorization code: rejects callback when returned state does not match issued state', async ({ restartApp }) => {
const app = await restartApp();
test('authorization code: rejects callback when returned state does not match issued state', async ({ restartApp }) => {
test.setTimeout(60_000);
const app = await restartApp();
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/auth/oauth2/oauth2-state-validation.spec.ts` around lines 272 - 273,
Update both mismatch tests in oauth2-state-validation.spec.ts, including
“authorization code: rejects callback when returned state does not match issued
state” and the other mismatch test, to call test.setTimeout(60_000) consistently
with the success tests before their asynchronous setup.

Comment on lines +373 to +374
test('implicit grant: rejects callback when returned state does not match issued state', async ({ restartApp }) => {
const app = await restartApp();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Add test.setTimeout(60_000) here too.

Same missing timeout as the auth code mismatch test — waitForReadyPage can take up to 45s, risking a default-timeout failure.

🛡️ Proposed fix
   test('implicit grant: rejects callback when returned state does not match issued state', async ({ restartApp }) => {
+    test.setTimeout(60_000);
     const app = await restartApp();
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
test('implicit grant: rejects callback when returned state does not match issued state', async ({ restartApp }) => {
const app = await restartApp();
test('implicit grant: rejects callback when returned state does not match issued state', async ({ restartApp }) => {
test.setTimeout(60_000);
const app = await restartApp();
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/auth/oauth2/oauth2-state-validation.spec.ts` around lines 373 - 374,
Set a 60-second timeout for the implicit-grant state-mismatch test, alongside
the existing test declaration before its asynchronous setup, so waitForReadyPage
can complete within the allowed duration. Keep the test behavior unchanged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant