Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
cc1c797
feat(oauth2): add Keycloak-backed OAuth2 e2e tests and CI setup
abhishekp-bruno Sep 11, 2026
5c8b4e4
ci(oauth2): extract Keycloak zip with unzip, fall back to tar
abhishekp-bruno Sep 11, 2026
4563b94
ci(oauth2): switch from Keycloak zip to tar.gz for extraction
abhishekp-bruno Sep 11, 2026
91a48fd
ci(oauth2): refine Keycloak setup action for tar.gz extraction
abhishekp-bruno Sep 11, 2026
8164293
update comments
abhishekp-bruno Sep 11, 2026
e58f084
update test files from .bru to .yml
abhishekp-bruno Oct 6, 2026
4d100a2
refactor(oauth2): remove outdated comments and streamline state gener…
abhishekp-bruno Oct 6, 2026
b7f37a4
docs(oauth2): update local Keycloak setup instructions for state vali…
abhishekp-bruno Oct 6, 2026
233c52e
Resolve review comments
abhishekp-bruno Oct 15, 2026
cd1b63c
resolve code review suggestions
abhishekp-bruno Oct 15, 2026
4dd10db
refactor(oauth2): modularize OAuth2 flow helpers and clean up test setup
abhishekp-bruno Oct 15, 2026
5390526
refactor(oauth2): clean up action.yml files and enhance documentation
abhishekp-bruno Oct 16, 2026
77cef4d
fix(oauth2): improve state mismatch handling in tests
abhishekp-bruno Oct 16, 2026
92eb022
- Added data-testid attributes to the OAuth2 token viewer for improve…
abhishekp-bruno Oct 16, 2026
33a209f
feat(oauth2): add data-testid for Get Access Token button and update …
abhishekp-bruno Oct 16, 2026
8f40eaa
refactor(oauth2): update variable exports to constants in test helpers
abhishekp-bruno Oct 16, 2026
01b425a
fix(oauth2): change log handling in Keycloak log collection action
abhishekp-bruno Oct 19, 2026
cb7954e
fixed lint error
abhishekp-bruno Nov 3, 2026
98bade1
test(oauth2): drive implicit grant tests through a real Keycloak login
abhishekp-bruno Nov 3, 2026
c4eec29
ci(oauth2): kill the Keycloak process tree on Windows
abhishekp-bruno Nov 3, 2026
579485e
ci(oauth2): drop the unused port input from run-oauth2-e2e-tests
abhishekp-bruno Nov 3, 2026
1d25b48
chore(oauth2): restore the state rationale at the auth-code call site
abhishekp-bruno Nov 3, 2026
9ce5cc3
resolved review comments
abhishekp-bruno Nov 3, 2026
2ced57e
ci(oauth2): tidy the log-staging script and add missing trailing newl…
abhishekp-bruno Nov 3, 2026
7325bb9
moved to e2e folder and fixed imports
abhishekp-bruno Nov 20, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/actions/auth/oauth2/collect-keycloak-logs/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: 'Collect Keycloak Logs'
description: 'Stage and upload the Keycloak server logs from an OAuth2 e2e run (Linux, macOS, Windows)'

inputs:
artifact-suffix:
description: 'Suffix for the uploaded log artifact name (linux, macos, windows)'
required: true
Comment thread
abhishekp-bruno marked this conversation as resolved.
Resolved

runs:
using: 'composite'
steps:
- name: Stage Keycloak logs
shell: bash
run: |
set -euo pipefail
mkdir -p keycloak-logs
shopt -s nullglob
logs=("$RUNNER_TEMP"/keycloak*.log)
if (( ${#logs[@]} )); then
cp "${logs[@]}" keycloak-logs/
else
# Keycloak is started by run-oauth2-e2e-tests, so a missing log usually means
# setup-keycloak failed first; that failure is the one worth surfacing.
echo "::warning::No Keycloak logs found in $RUNNER_TEMP."
fi
- name: Upload Keycloak logs
uses: actions/upload-artifact@v4
with:
name: keycloak-logs-oauth2-${{ inputs.artifact-suffix }}
path: keycloak-logs/
retention-days: 30
76 changes: 76 additions & 0 deletions .github/actions/auth/oauth2/run-oauth2-e2e-tests/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: 'Run OAuth2 E2E Tests'
description: 'Start Keycloak and run the OAuth2 (Keycloak) E2E tests on Linux, macOS and Windows'

inputs:
artifact-suffix:
description: 'Suffix for the uploaded Playwright report artifact name (linux, macos, windows)'
required: true

runs:
using: 'composite'
steps:
# Keycloak is started and the tests run in the same step because GitHub Actions kills
# background processes when a step ends. KC_HOME comes from the setup-keycloak step.
- name: Start Keycloak and run OAuth2 E2E tests
shell: bash
env:
KEYCLOAK_PORT: '8090'
run: |
set -euo pipefail
if [ -z "${KC_HOME:-}" ]; then
echo "::error::KC_HOME is not set; setup-keycloak must run first"
exit 1
fi
if [ "${RUNNER_OS}" = "Windows" ]; then
kc_bin="${KC_HOME}/bin/kc.bat"
else
kc_bin="${KC_HOME}/bin/kc.sh"
fi
log="${RUNNER_TEMP}/keycloak.log"
"${kc_bin}" start-dev --http-port="${KEYCLOAK_PORT}" --import-realm > "${log}" 2>&1 &
kc_pid=$!
# On Windows, kc_pid belongs to the kc.bat wrapper (cmd.exe), not to Java.
# `kill` would stop only the wrapper and leave Keycloak running, so use
# taskkill /T to kill the whole tree.
if [ "${RUNNER_OS}" = "Windows" ]; then
kc_winpid="$(cat "/proc/${kc_pid}/winpid")"
trap 'taskkill //PID "${kc_winpid}" //T //F > /dev/null 2>&1 || true' EXIT
else
trap 'kill "${kc_pid}" 2>/dev/null || true' EXIT
fi
echo "Waiting for Keycloak (realm bruno) on :${KEYCLOAK_PORT} ..."
ready=false
for i in $(seq 1 60); do
if curl -fsS "http://127.0.0.1:${KEYCLOAK_PORT}/realms/bruno/.well-known/openid-configuration" > /dev/null 2>&1; then
ready=true
break
fi
sleep 2
done
if [ "${ready}" != "true" ]; then
echo "::error::Keycloak did not become ready in time"
tail -n 100 "${log}" || true
exit 1
fi
echo "Keycloak is ready."
# Linux runners are headless, so Electron needs a virtual display.
if [ "${RUNNER_OS}" = "Linux" ]; then
xvfb-run npm run test:e2e:auth:oauth2
else
npm run test:e2e:auth:oauth2
fi
- name: Upload Playwright Report
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v4
with:
name: playwright-report-oauth2-${{ inputs.artifact-suffix }}
path: |
playwright-report/
test-results/
retention-days: 30
36 changes: 36 additions & 0 deletions .github/actions/auth/oauth2/setup-keycloak/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: 'Setup Keycloak'
description: 'Provision Keycloak (download + realm import prep) for the OAuth2 e2e tests on Linux, macOS and Windows'

inputs:
keycloak-version:
description: 'Keycloak release to download'
required: false
default: '26.3.3'

runs:
using: 'composite'
steps:
- name: Setup Java 21 (Temurin)
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '21'
- name: Download and prepare Keycloak
shell: bash
working-directory: ${{ runner.temp }}
env:
KEYCLOAK_VERSION: ${{ inputs.keycloak-version }}
run: |
Comment thread
abhishekp-bruno marked this conversation as resolved.
Resolved
set -euo pipefail
curl -fsSL -o keycloak.tar.gz \
"https://github.com/keycloak/keycloak/releases/download/${KEYCLOAK_VERSION}/keycloak-${KEYCLOAK_VERSION}.tar.gz"
tar -xzf keycloak.tar.gz
KC_HOME="${RUNNER_TEMP}/keycloak-${KEYCLOAK_VERSION}"
mkdir -p "${KC_HOME}/data/import"
cp "${GITHUB_WORKSPACE}/e2e/tests/auth/oauth2/fixtures/keycloak/realm-export.json" \
"${KC_HOME}/data/import/realm-export.json"
echo "KC_HOME=${KC_HOME}" >> "${GITHUB_ENV}"
echo "Keycloak prepared at ${KC_HOME}"
32 changes: 31 additions & 1 deletion .github/workflows/tests-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -230,4 +230,34 @@ jobs:
uses: ./.github/actions/auth/oauth1/linux/start-test-server

- name: Run OAuth1 CLI Tests
uses: ./.github/actions/auth/oauth1/linux/run-oauth1-cli-tests
uses: ./.github/actions/auth/oauth1/linux/run-oauth1-cli-tests

oauth2-tests:
name: OAuth 2.0 Auth Tests (Linux)
timeout-minutes: 60
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v6

- name: Setup Node Dependencies
uses: ./.github/actions/common/setup-node-deps

- name: Setup Feature Dependencies
uses: ./.github/actions/auth/oauth1/linux/setup-feature-specific-deps

- name: Setup Keycloak
uses: ./.github/actions/auth/oauth2/setup-keycloak

- name: Run OAuth2 E2E Tests
uses: ./.github/actions/auth/oauth2/run-oauth2-e2e-tests
with:
artifact-suffix: linux

# Runs even when setup-keycloak or the test step failed, so a broken IdP is debuggable.
- name: Collect Keycloak Logs
if: ${{ !cancelled() }}
uses: ./.github/actions/auth/oauth2/collect-keycloak-logs
with:
artifact-suffix: linux
29 changes: 28 additions & 1 deletion .github/workflows/tests-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,31 @@ jobs:
uses: ./.github/actions/auth/oauth1/macos/start-test-server

- name: Run OAuth1 CLI Tests
uses: ./.github/actions/auth/oauth1/macos/run-oauth1-cli-tests
uses: ./.github/actions/auth/oauth1/macos/run-oauth1-cli-tests

oauth2-tests:
name: OAuth 2.0 Auth Tests (macOS)
timeout-minutes: 60
runs-on: macos-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v6

- name: Setup Node Dependencies
uses: ./.github/actions/common/setup-node-deps

- name: Setup Keycloak
uses: ./.github/actions/auth/oauth2/setup-keycloak

- name: Run OAuth2 E2E Tests
uses: ./.github/actions/auth/oauth2/run-oauth2-e2e-tests
with:
artifact-suffix: macos

# Runs even when setup-keycloak or the test step failed, so a broken IdP is debuggable.
- name: Collect Keycloak Logs
if: ${{ !cancelled() }}
uses: ./.github/actions/auth/oauth2/collect-keycloak-logs
with:
artifact-suffix: macos
27 changes: 27 additions & 0 deletions .github/workflows/tests-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,30 @@ jobs:

- name: Run OAuth1 CLI Tests
uses: ./.github/actions/auth/oauth1/windows/run-oauth1-cli-tests

oauth2-tests:
name: OAuth 2.0 Auth Tests (Windows)
timeout-minutes: 60
runs-on: windows-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v6

- name: Setup Node Dependencies
uses: ./.github/actions/common/setup-node-deps

- name: Setup Keycloak
uses: ./.github/actions/auth/oauth2/setup-keycloak

- name: Run OAuth2 E2E Tests
uses: ./.github/actions/auth/oauth2/run-oauth2-e2e-tests
with:
artifact-suffix: windows

# Runs even when setup-keycloak or the test step failed, so a broken IdP is debuggable.
- name: Collect Keycloak Logs
if: ${{ !cancelled() }}
uses: ./.github/actions/auth/oauth2/collect-keycloak-logs
with:
artifact-suffix: windows
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ yarn-error.log*
/test-results/
/playwright-report/
/playwright/.cache/
/keycloak-logs/

#dev editor
bruno.iml
Expand Down
7 changes: 7 additions & 0 deletions docs/playwright-testing-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,13 @@ npx playwright test e2e/tests/common/home-screen.spec.ts
npx playwright test e2e/tests/folder-a/
```

### Projects That Need External Services

Most projects run self-contained. Two need a service started by hand first; each suite's readme has the steps:

- `oauth2` (`npm run test:e2e:auth:oauth2`) — a local Keycloak instance, see [`tests/auth/oauth2/README.md`](../tests/auth/oauth2/README.md)
- `ssl` (`npm run test:e2e:ssl`) — generated certificates and a local HTTPS server, see [`tests/ssl/custom-ca-certs/server/readme.md`](../tests/ssl/custom-ca-certs/server/readme.md)

### Advanced Options

```bash
Expand Down
9 changes: 7 additions & 2 deletions e2e/pages/request/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ export const buildAuthLocators = (page: Page) => ({
signatureMethodDropdown: () => page.getByTestId('oauth1-signature-method-dropdown'),
signatureMethodMenu: () => page.getByTestId('oauth1-signature-method-dropdown-dropdown'),
placementDropdown: () => page.getByTestId('oauth1-placement-dropdown'),
placementMenu: () => page.getByTestId('oauth1-placement-dropdown-dropdown')
placementMenu: () => page.getByTestId('oauth1-placement-dropdown-dropdown'),
placementSelector: () => page.getByTestId('auth-placement-selector'),
placementLabel: () => page.getByTestId('auth-placement-label')
},
oauth2: {
grantTypeDropdown: () => page.getByTestId('grant-type-dropdown'),
Expand All @@ -46,7 +48,10 @@ export const buildAuthLocators = (page: Page) => ({
getAccessTokenButton: () => page.getByRole('button', { name: 'Get Access Token' }),
clearCacheButton: () => page.getByRole('button', { name: 'Clear Cache' }),
tokenSection: (title: string) => page.getByRole('heading', { name: title, exact: true }),
copyTokenButton: () => page.getByRole('button', { name: 'Copy token' })
copyTokenButton: () => page.getByRole('button', { name: 'Copy token' }),
noToken: () => page.getByTestId('oauth2-no-token'),
tokenValue: (tokenKey: 'access-token' | 'refresh-token' | 'id-token') => page.getByTestId(`oauth2-token-value-${tokenKey}`),
getAccessTokenBtn: () => page.getByTestId('oauth2-get-access-token')
},
modeSelector: () => page.getByTestId('auth-mode-selector'),
modeLabel: () => page.getByTestId('auth-mode-label'),
Expand Down
34 changes: 34 additions & 0 deletions e2e/tests/auth/oauth2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# OAuth2 e2e tests

The `oauth2` Playwright project drives real OAuth2 flows against a local Keycloak instance,
so Keycloak must be running before the specs start.

## What the specs expect

- Keycloak reachable at `http://127.0.0.1:8090`
- The `bruno` realm imported from `fixtures/keycloak/realm-export.json`

CI provisions this through `.github/actions/auth/oauth2/setup-keycloak` and
`.github/actions/auth/oauth2/run-oauth2-e2e-tests`; keep the local setup below in step with them.

## Running locally

Start Keycloak with the fixture realm imported:

```bash
docker run -d --name bruno-keycloak -p 8090:8080 \
-v "$PWD/e2e/tests/auth/oauth2/fixtures/keycloak/realm-export.json:/opt/keycloak/data/import/realm-export.json:ro" \
quay.io/keycloak/keycloak:26.3.3 start-dev --http-port=8080 --import-realm
```

Wait until `http://127.0.0.1:8090/realms/bruno` responds, then run the suite:

```bash
npm run test:e2e:auth:oauth2
```

Stop and remove the container when you are done:

```bash
docker rm -f bruno-keycloak
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
info:
name: AuthCodeUserSuppliedState
type: http
seq: 3

http:
method: GET
url: "{{userinfo_url}}"
auth:
type: oauth2
flow: authorization_code
authorizationUrl: "{{host}}/realms/{{realm}}/protocol/openid-connect/auth"
accessTokenUrl: "{{host}}/realms/{{realm}}/protocol/openid-connect/token"
callbackUrl: bruno://app/oauth2/callback
credentials:
clientId: bruno
clientSecret: "{{client_secret}}"
placement: body
scope: openid
state: brunoUserState
pkce:
disabled: true
tokenConfig:
id: credentials
placement:
header: Bearer
source: access_token
settings:
autoFetchToken: true
autoRefreshToken: false

settings:
encodeUrl: true
timeout: 0
followRedirects: true
maxRedirects: 5
forwardAuthorizationHeader: true
Loading
Loading