Skip to content

Add E2E test for the TLSAdherence openshift/api field#31309

Open
richardsonnick wants to merge 1 commit into
openshift:mainfrom
richardsonnick:tls-adherence-e2e
Open

Add E2E test for the TLSAdherence openshift/api field#31309
richardsonnick wants to merge 1 commit into
openshift:mainfrom
richardsonnick:tls-adherence-e2e

Conversation

@richardsonnick

@richardsonnick richardsonnick commented Jun 16, 2026

Copy link
Copy Markdown

Adds E2E tests for the TLSAdherence openshift/api field. This is a requirement for GA.

Summary by CodeRabbit

  • Tests
    • Added Ginkgo coverage for the TLSAdherence feature gate and API server spec.tlsAdherence validation
    • Verifies the API rejects unrecognized spec.tlsAdherence values and accepts StrictAllComponents and LegacyAdheringComponentsOnly
    • Ensures tests run only when the TLSAdherence gate is enabled
    • Confirms only cluster-admin users can update the API server configuration
    • Fails if any cluster operator reports OperatorDegraded=True during updates

@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: automatic mode

@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown

Walkthrough

New extended apiserver tests add TLSAdherence feature-gate gating, validate spec.tlsAdherence dry-run updates, check update authorization on apiservers/cluster, and fail when any cluster operator is degraded. Existing TLS tests now skip when the feature gate is disabled.

Changes

TLSAdherence Integration Tests

Layer / File(s) Summary
Feature gate helper
test/extended/apiserver/tls_adherence.go
Adds the TLSAdherence gate constant and helper logic that reads featuregate/cluster status to detect whether the gate is enabled.
Suite gating
test/extended/apiserver/tls_adherence.go, test/extended/apiserver/tls.go
Creates the Ginkgo suite with a BeforeEach skip when the gate is disabled, and updates existing TLS tests to skip on the same gate.
Spec validation tests
test/extended/apiserver/tls_adherence.go
Adds dry-run update tests for invalid and valid spec.tlsAdherence values and checks the returned field values.
Authorization and health checks
test/extended/apiserver/tls_adherence.go
Adds SubjectAccessReview coverage for update on apiservers/cluster and checks clusteroperators for any OperatorDegraded=True conditions.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes


Caution

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

  • Ignore

❌ Failed checks (1 error)

Check name Status Explanation Resolution
No-Weak-Crypto ❌ Error New TLS tests iterate over crypto.ValidCipherSuites(), which includes RC4/3DES/DES entries in vendor crypto.go, so weak ciphers are exercised in the added code. Restrict the test to approved strong cipher suites only, or explicitly exclude RC4/3DES/DES/other weak suites from enumeration and comments.
✅ Passed checks (14 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding E2E coverage for TLSAdherence-related behavior.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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 new Ginkgo titles are static string literals; none embed generated names, timestamps, node/namespace/IP data, or other runtime values.
Test Structure And Quality ✅ Passed The new Ginkgo tests are narrowly scoped, use BeforeEach gating, make no persistent writes, and contain no indefinite waits; assertion style matches nearby tests.
Microshift Test Compatibility ✅ Passed All new It() specs carry [apigroup:config.openshift.io], so MicroShift jobs auto-skip these config.openshift.io tests; no unguarded unsupported APIs found.
Single Node Openshift (Sno) Test Compatibility ✅ Passed The new Ginkgo tests only exercise APIs/operators and service port-forwards; they contain no node-counting, scheduling, drain, or topology-specific SNO assumptions.
Topology-Aware Scheduling Compatibility ✅ Passed Only E2E test files changed; no deployment manifests, operator code, or scheduling constraints were added.
Ote Binary Stdout Contract ✅ Passed No stdout writes or process-level hooks were added; the new code only logs inside It blocks or via Ginkgo/e2e helpers.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed New TLSAdherence Ginkgo tests only use cluster APIs/SARs and contain no IPv4-only assumptions or external connectivity.
Container-Privileges ✅ Passed No container/K8s manifests were added; the touched Go E2E test files contain no privileged/host* /SYS_ADMIN /allowPrivilegeEscalation settings.
No-Sensitive-Data-In-Logs ✅ Passed PASS: The patch adds only diagnostic logs (localhost, resource names, operator status); no passwords, tokens, PII, session IDs, or customer data are logged.
✨ 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 commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: richardsonnick
Once this PR has been reviewed and has the lgtm label, please assign smg247 for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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 requested review from p0lyn0mial and sjenning June 16, 2026 18:08

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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/extended/apiserver/tls_adherence.go`:
- Around line 120-131: The test assertion in the It block does not account for
the optional spec.tlsAdherence field being unset. Since the field is marked as
optional with omitempty and the test comment acknowledges "when set", the
apiServer.Spec.TLSAdherence value may be nil, causing the BeElementOf assertion
to fail even when the state is valid. Either guard the assertion with a nil
check that conditionally validates only when the field is set, or add the
nil/zero value to the validValues slice so that an unset field is considered a
valid state.
🪄 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: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 328d6dfb-fe5e-4dfc-a5f3-811d6c04d0e2

📥 Commits

Reviewing files that changed from the base of the PR and between b3b98a0 and 1f5851c.

📒 Files selected for processing (1)
  • test/extended/apiserver/tls_adherence.go

Comment thread test/extended/apiserver/tls_adherence.go Outdated
Comment thread test/extended/apiserver/tls_adherence.go Outdated
Comment on lines +63 to +81
g.It("[FeatureGate:TLSAdherence] should have TLSAdherence listed as enabled in featuregate/cluster status [apigroup:config.openshift.io]", func(ctx context.Context) {
fg, err := oc.AdminConfigClient().ConfigV1().FeatureGates().Get(ctx, "cluster", metav1.GetOptions{})
o.Expect(err).NotTo(o.HaveOccurred(), "failed to get featuregate/cluster")

found := false
for _, featureGateValues := range fg.Status.FeatureGates {
for _, enabledGate := range featureGateValues.Enabled {
if enabledGate.Name == tlsAdherenceFeatureGateName {
found = true
break
}
}
if found {
break
}
}
o.Expect(found).To(o.BeTrue(),
"TLSAdherence must appear in featuregate/cluster .status.featureGates[].enabled[].name")
})

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.

Can't hurt to verify this, but I don't think this should count toward the 5 tests, the intent of which are more functional rather than verifying assumptions.

Comment on lines +134 to +147
// Test 5 – verify that no cluster operator is degraded when the TLSAdherence feature gate is active.
g.It("[FeatureGate:TLSAdherence] should not have any degraded cluster operators [apigroup:config.openshift.io]", func(ctx context.Context) {
coList, err := oc.AdminConfigClient().ConfigV1().ClusterOperators().List(ctx, metav1.ListOptions{})
o.Expect(err).NotTo(o.HaveOccurred(), "failed to list clusteroperators")

for _, co := range coList.Items {
for _, condition := range co.Status.Conditions {
if condition.Type == configv1.OperatorDegraded && condition.Status == configv1.ConditionTrue {
g.Fail(fmt.Sprintf("cluster operator %q is degraded: %s: %s",
co.Name, condition.Reason, condition.Message))
}
}
}
})

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.

I think there is a different kind of test that we can implement that essentially continuously monitors the cluster to verify an invariant is never violated. The way this test is implemented, you'll only get a point in time verification, which would likely result in false negatives.

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling required tests:
/test e2e-aws-csi
/test e2e-aws-ovn-fips
/test e2e-aws-ovn-microshift
/test e2e-aws-ovn-microshift-serial
/test e2e-aws-ovn-serial-1of2
/test e2e-aws-ovn-serial-2of2
/test e2e-gcp-csi
/test e2e-gcp-ovn
/test e2e-gcp-ovn-upgrade
/test e2e-metal-ipi-ovn-ipv6
/test e2e-vsphere-ovn
/test e2e-vsphere-ovn-upi

Comment thread test/extended/apiserver/tls_adherence.go Outdated
Comment thread test/extended/apiserver/tls_adherence.go
@openshift-ci openshift-ci Bot added the ready-for-human-review Indicates a PR has been reviewed by automated tools and is ready for human review label Jun 21, 2026
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling required tests:
/test e2e-aws-csi
/test e2e-aws-ovn-fips
/test e2e-aws-ovn-microshift
/test e2e-aws-ovn-microshift-serial
/test e2e-aws-ovn-serial-1of2
/test e2e-aws-ovn-serial-2of2
/test e2e-gcp-csi
/test e2e-gcp-ovn
/test e2e-gcp-ovn-upgrade
/test e2e-metal-ipi-ovn-ipv6
/test e2e-vsphere-ovn
/test e2e-vsphere-ovn-upi

Tests that apiservers/cluster spec.tlsAdherence:
- rejects invalid values (422 Invalid via dry-run)
- accepts and reflects all valid values (dry-run)
- is only writable by cluster-admins (SubjectAccessReview)
- does not leave cluster operators degraded

Also labels the existing TestTLSMinimumVersions and TestTLSDefaults
wire-level TLS tests with [FeatureGate:TLSAdherence] so they count
toward the openshift/api verify-feature-promotion Sippy check.

Co-authored-by: Cursor <cursoragent@cursor.com>
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling required tests:
/test e2e-aws-csi
/test e2e-aws-ovn-fips
/test e2e-aws-ovn-microshift
/test e2e-aws-ovn-microshift-serial
/test e2e-aws-ovn-serial-1of2
/test e2e-aws-ovn-serial-2of2
/test e2e-gcp-csi
/test e2e-gcp-ovn
/test e2e-gcp-ovn-upgrade
/test e2e-metal-ipi-ovn-ipv6
/test e2e-vsphere-ovn
/test e2e-vsphere-ovn-upi

@openshift-ci

openshift-ci Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

@richardsonnick: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-aws-ovn-microshift 14d023a link true /test e2e-aws-ovn-microshift
ci/prow/e2e-vsphere-ovn 14d023a link true /test e2e-vsphere-ovn
ci/prow/e2e-aws-csi 14d023a link true /test e2e-aws-csi

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.

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

Labels

ready-for-human-review Indicates a PR has been reviewed by automated tools and is ready for human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants