Skip to content

CNTRLPLANE-3375: test(e2e): remove oc dependency in external oidc e2e tests - #9208

Merged
openshift-merge-bot[bot] merged 2 commits into
openshift:mainfrom
everettraven:fix/oidc-e2e-oc
Aug 6, 2026
Merged

CNTRLPLANE-3375: test(e2e): remove oc dependency in external oidc e2e tests#9208
openshift-merge-bot[bot] merged 2 commits into
openshift:mainfrom
everettraven:fix/oidc-e2e-oc

Conversation

@everettraven

@everettraven everettraven commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

Removes oc as a dependency for testing the external OIDC behavior of the hosted cluster. While oc is typically the tooling that end-users will use, it causes unnecessary fragility in the e2e tests by putting a reliance on no changes to the token caching behavior being made.

We encountered this issue when openshift/oc@51c1921 merged and started seeing permafailures for our hypershift tests that use oc.

Which issue(s) this PR fixes:

Fixes permafailures in hypershift OIDC e2e tests due to changes in oc token caching logic made in openshift/oc@51c1921

Special notes for your reviewer:

Checklist:

  • Subject and description added to both, commit and PR.
  • Relevant issues have been referenced.
  • This change includes docs.
  • This change includes unit tests.

Summary by CodeRabbit

  • Bug Fixes
    • Improved OIDC-based authentication reliability by using identity tokens directly during authentication flows.
    • Removed reliance on local token caches and external credential-provider configuration, reducing setup complexity and potential authentication failures.
    • Improved error handling when authenticated test accounts are created, providing clearer feedback when administrator authentication cannot be completed.
    • Added validation to ensure test accounts are created successfully before authentication scenarios continue.

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: LGTM mode

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

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

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 0454be47-c994-4aed-8a14-48c88799d794

📥 Commits

Reviewing files that changed from the base of the PR and between 8317d4c and 48fbf42.

📒 Files selected for processing (2)
  • test/e2e/external_oidc_test.go
  • test/e2e/util/external_oidc.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • test/e2e/external_oidc_test.go
  • test/e2e/util/external_oidc.go

📝 Walkthrough

Walkthrough

The Keycloak OIDC test utility now uses the fetched ID token directly as the bearer token in a copied anonymous REST configuration. It removes refresh-token extraction, filesystem token-cache setup, exec-provider configuration, related imports, and the exported GetClientConfigForKeycloakOIDCUser helper. Test-user setup now refreshes the admin token and validates user creation before claim checks.

Sequence Diagram(s)

sequenceDiagram
  participant OIDC_Test
  participant Keycloak
  participant REST_Config
  OIDC_Test->>Keycloak: fetch ID token
  OIDC_Test->>REST_Config: copy anonymous REST configuration
  OIDC_Test->>REST_Config: set ID token as bearer token
  OIDC_Test->>Keycloak: refresh admin token and create test user
  OIDC_Test->>OIDC_Test: validate test-user creation
Loading

Suggested reviewers: clebs

🚥 Pre-merge checks | ✅ 10 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Test Structure And Quality ⚠️ Warning 21 error assertions and 15 other assertions lack meaningful failure messages; e.g., lines 117, 123, 142 check errors without context messages needed to diagnose failures when tests fail. Add meaningful failure messages to all assertions: wrap assertions like g.Expect(err).NotTo(HaveOccurred()) with messages like g.Expect(err).NotTo(HaveOccurred(), "failed to create test user") to help diagnose failures.
✅ Passed checks (10 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: removing the oc dependency from external OIDC end-to-end tests.
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.
Stable And Deterministic Test Names ✅ Passed All test titles in the changed e2e file are static string literals; dynamic usernames, namespaces, and cluster names occur only in setup or logs.
Topology-Aware Scheduling Compatibility ✅ Passed The PR changes only external OIDC e2e utility and test code; it adds no deployment manifests, operator/controller logic, or scheduling constraints.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed The PR adds no Ginkgo test declarations. Added lines contain no IPv4 literals or public-network commands, and the removed oc callback eliminated the 127.0.0.1 assumption.
No-Weak-Crypto ✅ Passed The PR adds no weak algorithms or custom crypto; it removes SHA-256 cache code. Current changed files only use crypto/tls and assign the ID token without secret comparisons.
Container-Privileges ✅ Passed The PR modifies only test code (test/e2e/external_oidc_test.go) and contains no container or Kubernetes manifests with privileged configurations.
No-Sensitive-Data-In-Logs ✅ Passed The PR logs only synthetic usernames and generic status/errors; it does not log passwords, ID/bearer tokens, API keys, emails, or credential values.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@openshift-ci openshift-ci Bot added area/testing Indicates the PR includes changes for e2e testing and removed do-not-merge/needs-area labels Aug 3, 2026
@everettraven

Copy link
Copy Markdown
Contributor Author

/test e2e-azure-aks-external-oidc-techpreview
/test e2e-aws-external-oidc-techpreview

@openshift-ci
openshift-ci Bot requested review from bryan-cox and clebs August 3, 2026 17:08
@codecov

codecov Bot commented Aug 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 44.96%. Comparing base (923aba2) to head (48fbf42).
⚠️ Report is 57 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9208      +/-   ##
==========================================
+ Coverage   44.94%   44.96%   +0.01%     
==========================================
  Files         778      778              
  Lines       97427    97452      +25     
==========================================
+ Hits        43790    43820      +30     
+ Misses      50616    50607       -9     
- Partials     3021     3025       +4     

see 5 files with indirect coverage changes

Flag Coverage Δ
cmd-support 38.62% <ø> (ø)
cpo-hostedcontrolplane 47.28% <ø> (ø)
cpo-other 45.67% <ø> (ø)
hypershift-operator 55.00% <ø> (+0.07%) ⬆️
other 34.30% <ø> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bryan-cox

Copy link
Copy Markdown
Member

Did any of the v2 e2e things need updated here as well?

@everettraven

Copy link
Copy Markdown
Contributor Author

Did any of the v2 e2e things need updated here as well?

Not sure. I'll do some additional digging on this as it looks like I'll have some additional work to troubleshoot based on the new failures I'm seeing. It looks like it might have something to do with Keycloak admin token timeouts causing issues.

@everettraven

Copy link
Copy Markdown
Contributor Author

/test e2e-azure-aks-external-oidc-techpreview
/test e2e-aws-external-oidc-techpreview

@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

🤖 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 `@test/e2e/external_oidc_test.go`:
- Around line 60-65: The err variable is declared on the first line when calling
kc.GetAdminToken, then on line 65 the code attempts to redeclare err using :=
with the kc.CreateGroup call. Since the underscore (_) does not introduce a new
variable, the := operator fails with "no new variables on left side of :=".
Change the := to = for the kc.CreateGroup call to reassign the existing err
variable instead of attempting to redeclare it.
🪄 Autofix

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: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: f7ac328e-4ae6-4c55-88f9-75f44c010db8

📥 Commits

Reviewing files that changed from the base of the PR and between 6b5039e and a4d4773.

📒 Files selected for processing (1)
  • test/e2e/external_oidc_test.go

Comment thread test/e2e/external_oidc_test.go Outdated
@everettraven

Copy link
Copy Markdown
Contributor Author

/test e2e-azure-aks-external-oidc-techpreview
/test e2e-aws-external-oidc-techpreview

@everettraven

Copy link
Copy Markdown
Contributor Author

Did any of the v2 e2e things need updated here as well?

Following up on this - it doesn't look like it. It looks the external oidc tests in the v2 e2e already directly uses the token instead of relying on oc.

@everettraven everettraven changed the title test(e2e): remove oc dependency in external oidc e2e tests CNTRLPLANE-3375: test(e2e): remove oc dependency in external oidc e2e tests Aug 4, 2026
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Aug 4, 2026
@openshift-ci-robot

openshift-ci-robot commented Aug 4, 2026

Copy link
Copy Markdown

@everettraven: This pull request references CNTRLPLANE-3375 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "5.0.0" version, but no target version was set.

Details

In response to this:

What this PR does / why we need it:

Removes oc as a dependency for testing the external OIDC behavior of the hosted cluster. While oc is typically the tooling that end-users will use, it causes unnecessary fragility in the e2e tests by putting a reliance on no changes to the token caching behavior being made.

We encountered this issue when openshift/oc@51c1921 merged and started seeing permafailures for our hypershift tests that use oc.

Which issue(s) this PR fixes:

Fixes permafailures in hypershift OIDC e2e tests due to changes in oc token caching logic made in openshift/oc@51c1921

Special notes for your reviewer:

Checklist:

  • Subject and description added to both, commit and PR.
  • Relevant issues have been referenced.
  • This change includes docs.
  • This change includes unit tests.

Summary by CodeRabbit

  • Bug Fixes
  • Improved OIDC-based authentication reliability by using identity tokens directly during authentication flows.
  • Removed dependence on local token caches and external credential-provider configuration, reducing setup complexity and potential authentication failures.
  • Improved error handling when creating authenticated test accounts, providing clearer feedback when administrator authentication cannot be completed.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@everettraven

Copy link
Copy Markdown
Contributor Author

/test e2e-azure-aks-external-oidc-techpreview
/test e2e-aws-external-oidc-techpreview

@everettraven

Copy link
Copy Markdown
Contributor Author

/test verify

@bryan-cox bryan-cox left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Review: CNTRLPLANE-3375

Nice simplification — removing the oc exec-provider machinery in favor of a direct bearer token is a clean fix for the permafailure. A few notes:

Standards

  1. Commit message bodies: Both commits have good subjects but are missing "Why" and "How" in the body (CONTRIBUTING.md rule 4.2). The PR description has the context — would be good to squash or amend the body to include it before merge, since commit messages outlive the PR.

Spec

  1. Token refresh removed: The old path cached both id_token and refresh_token, letting oc get-token transparently refresh. The new BearerToken approach has no refresh mechanism. This is probably fine given short e2e durations and configurable Keycloak token lifetimes — can you confirm the CI token TTL is long enough that no single test subcase would hit a 401?

Overall this looks good. The token lifetime question is the main thing I'd want confirmed.

}
userCfg := rest.AnonymousClientConfig(rest.CopyConfig(clientCfg))
userCfg.BearerToken = idToken

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The old code had a refresh_token path via oc's exec credential plugin. With BearerToken set directly, there's no automatic refresh if the id_token expires mid-test. Worth confirming the Keycloak token lifetime configured in CI is longer than the longest test subcase that uses this path.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copying from slack for posterity:

AFAIK we fetch a fresh token for each subtest and immediately make a SelfSubjectReview call. The token should be valid long enough for each of those calls and we don't need to make any further calls (we are wanting to make sure identity mapping works correctly - only the SelfSubjectReview call is necessary for that).

If the token expires while that request is in-flight, it should be OK as the initial request would have already gone through the "is token valid?" chunk of the authentication flow. Having run the tests a handful of times with this change, I haven't seen any problems related to token refresh issues here.

…ests

to prevent token fetching issues happening when changes to the oc
caching logic are made. Because the tests only need a valid ID token,
returning a rest.Config that has been anonymized and explicitly setting
the bearer token to one we fetched for the test user is sufficient for
testing the functionality while removing the dependence on oc
client-side token caching behavior.

Signed-off-by: Bryce Palmer <bpalmer@redhat.com>
…g test user

to prevent stale admin API tokens causing failures to create
test user data within Keycloak due to short-lived tokens
being issued by Keycloak.

Signed-off-by: Bryce Palmer <bpalmer@redhat.com>
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@bryan-cox

Copy link
Copy Markdown
Member

/approve

@openshift-ci

openshift-ci Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bryan-cox, everettraven

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 5, 2026
@ironcladlou

Copy link
Copy Markdown
Contributor

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Aug 5, 2026
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling tests matching the pipeline_run_if_changed or not excluded by pipeline_skip_if_only_changed parameters:
/test e2e-aks-4-22
/test e2e-aws-4-22
/test e2e-aks
/test e2e-aws
/test e2e-aws-upgrade-hypershift-operator
/test e2e-kubevirt-aws-ovn-reduced
/test e2e-v2-aws
/test e2e-v2-azure-self-managed
/test e2e-v2-gke

@cwbotbot

cwbotbot commented Aug 5, 2026

Copy link
Copy Markdown

Test Results

e2e-aws

e2e-aks

@bryan-cox

Copy link
Copy Markdown
Member

/retest-required

2 similar comments
@everettraven

Copy link
Copy Markdown
Contributor Author

/retest-required

@everettraven

Copy link
Copy Markdown
Contributor Author

/retest-required

@everettraven

Copy link
Copy Markdown
Contributor Author

/verified by ci

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Aug 6, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@everettraven: This PR has been marked as verified by ci.

Details

In response to this:

/verified by ci

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci

openshift-ci Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

@everettraven: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@openshift-merge-bot
openshift-merge-bot Bot merged commit 3977578 into openshift:main Aug 6, 2026
43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. area/testing Indicates the PR includes changes for e2e testing jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. verified Signifies that the PR passed pre-merge verification criteria

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants