Skip to content

CM-1223: Add extensive e2e automation for TLS profile test - #449

Open
chiragkyal wants to merge 1 commit into
openshift:masterfrom
chiragkyal:tls-profile-e2e
Open

CM-1223: Add extensive e2e automation for TLS profile test#449
chiragkyal wants to merge 1 commit into
openshift:masterfrom
chiragkyal:tls-profile-e2e

Conversation

@chiragkyal

@chiragkyal chiragkyal commented Jun 26, 2026

Copy link
Copy Markdown
Member

Summary

The cert-manager operator propagates the cluster-wide TLS security profile and adherence policy to cert-manager operand deployments. Existing e2e coverage only validated a single happy-path case, leaving profile types, adherence transitions, rollback, and override behavior untested.

Change

Rework the TLS profile e2e suite to add broad coverage across:

  • All TLS profile types (Modern, Intermediate, Old, Custom) under strict adherence

  • Legacy adherence behavior (no args injected)

  • Rollback from strict to legacy adherence

  • unsupportedConfigOverrides precedence over cluster-enforced TLS settings

  • Live profile switching between profiles

Summary by CodeRabbit

  • New Features

    • Expanded end-to-end coverage for cluster TLS profile handling across multiple scenarios.
    • Added checks for profile changes, including switching between older TLS settings and modern settings.
  • Bug Fixes

    • Improved validation that TLS settings are applied consistently across key components.
    • Added safeguards to confirm rollback and temporary override behavior work as expected.
  • Tests

    • Reworked the TLS profile e2e suite to cover more real-world certificate and cipher suite combinations.

Signed-off-by: chiragkyal <ckyal@redhat.com>
@openshift-ci
openshift-ci Bot requested review from TrilokGeer and mytreya-rh June 26, 2026 08:36
@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Walkthrough

The TLS profile e2e test now saves and restores cluster apiserver TLS state, covers legacy and strict adherence paths across cert-manager operands, checks webhook override precedence, and verifies live transitions from Intermediate to Modern.

Changes

TLS profile e2e coverage

Layer / File(s) Summary
Fixtures and hooks
test/e2e/tls_profile_test.go
Adds reusable TLS profile objects, the touched deployments list, and shared setup and teardown that save, verify, restore, and clean cluster apiserver TLS state while checking operator health.
Adherence and overrides
test/e2e/tls_profile_test.go
Adds S1–S8 checks for legacy and strict TLS adherence, operand and webhook arg expectations across Modern, Intermediate, and Old profiles, rollback from Strict to Legacy, and a retrying helper for updating or clearing webhook unsupported args.
Live profile switch
test/e2e/tls_profile_test.go
Adds S9 coverage for switching the cluster profile from Intermediate to Modern and asserts removal of cipher-suite args plus Modern effective-spec alignment across the webhook and operands.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

🚥 Pre-merge checks | ✅ 13 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Test Structure And Quality ⚠️ Warning Several Expect(err).NotTo(HaveOccurred()) assertions lack diagnostic messages (e.g. lines 87, 135, 164, 190, 210, 330). Add contextual failure messages to the bare error assertions, or wrap them in helper assertions that report which scenario/step failed.
Microshift Test Compatibility ⚠️ Warning The new S1–S9 e2e tests read/update apiserver.config.openshift.io/cluster via config.openshift.io APIs, but the suite has no MicroShift skip tag or runtime MicroShift guard. Add [apigroup:config.openshift.io] or [Skipped:MicroShift], or gate the suite with exutil.IsMicroShiftCluster() and g.Skip().
✅ Passed checks (13 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
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 Ginkgo titles in tls_profile_test.go are static, descriptive strings; no fmt.Sprintf, generated IDs, dates, or runtime values appear in test names.
Single Node Openshift (Sno) Test Compatibility ✅ Passed The new suite only patches cluster TLS config and checks deployment args; it has no node-count, rescheduling, topology-spread, or SNO-specific assumptions.
Topology-Aware Scheduling Compatibility ✅ Passed Only an e2e TLS profile test changed; no manifests, controllers, affinity, nodeSelector, spread, or replica logic were added.
Ote Binary Stdout Contract ✅ Passed Changed e2e file has no main/init/TestMain/BeforeSuite stdout writes; it only uses Ginkgo By/Skip and fmt for errors.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed tls_profile_test.go only patches cluster TLS config and checks deployment args; no IPv4 literals, host/IP URL building, or external network calls found.
No-Weak-Crypto ✅ Passed The changed test file only uses OpenShift TLS profile objects and modern AES-GCM/TLS version args; no MD5/SHA1/DES/RC4/3DES/ECB, custom crypto, or secret comparisons found.
Container-Privileges ✅ Passed The PR only rewrites an e2e test helper; no container/K8s manifests or privilege-related fields (privileged, hostPID/Network/IPC, SYS_ADMIN, allowPrivilegeEscalation) are added.
No-Sensitive-Data-In-Logs ✅ Passed New test logs only TLS/profile steps and operand names; no passwords, tokens, PII, hostnames, or secrets appear in the code or diff.
Title check ✅ Passed The title accurately summarizes the main change: expanded e2e TLS profile test automation.
✨ 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 26, 2026

Copy link
Copy Markdown
Contributor

@chiragkyal: 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.

@chiragkyal

Copy link
Copy Markdown
Member Author

/cc @arun717 @bharath-b-rh @mytreya-rh

@openshift-ci
openshift-ci Bot requested review from arun717 and bharath-b-rh June 26, 2026 13:08
@openshift-ci

openshift-ci Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: anandkuma77, chiragkyal
Once this PR has been reviewed and has the lgtm label, please assign mytreya-rh 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

@chiragkyal chiragkyal changed the title Add extensive e2e automation for TLS profile test CM-1223: Add extensive e2e automation for TLS profile test Jul 29, 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 Jul 29, 2026
@openshift-ci-robot

openshift-ci-robot commented Jul 29, 2026

Copy link
Copy Markdown

@chiragkyal: This pull request references CM-1223 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:

Summary by CodeRabbit

  • New Features

  • Expanded end-to-end coverage for cluster TLS profile handling across multiple scenarios.

  • Added checks for profile changes, including switching between older TLS settings and modern settings.

  • Bug Fixes

  • Improved validation that TLS settings are applied consistently across key components.

  • Added safeguards to confirm rollback and temporary override behavior work as expected.

  • Tests

  • Reworked the TLS profile e2e suite to cover more real-world certificate and cipher suite combinations.

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.

@chiragkyal

Copy link
Copy Markdown
Member Author

/cc @bharath-b-rh @mytreya-rh
for labels

// ─────────────────────────────────────────────────────────────────────────
// Scenario 1: LegacyAdheringComponentsOnly — operands must be untouched
// ─────────────────────────────────────────────────────────────────────────
It("S1: should not inject TLS args when tlsAdherence is LegacyAdheringComponentsOnly", func() {

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.

I was just comparing scenario 1 and scenario 6. And looks like S6 is a superset of S1.
So if S6 passes (no args injected with Modern + Legacy), S1 should always pass too.
S1 only adds the nil profile case, which does not exercise a different branch today.
I think even if we drop scenario 1 in this case, we should be good. Let me know what do you think.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks for the review. I see the logic, but I think S1 is worth keeping for a few reasons:

They test different API-level guarantees, not just different code paths.

S1 asserts: "when no TLS profile has ever been set, cert-manager operands are untouched." This is the day-0 / fresh-install state of any cluster.

S6 asserts: "when a profile is explicitly set to Modern but adherence is Legacy, operands are still untouched."
Both pass through the same early-return today, but they protect against independently plausible regression e.g:

  • A future change that adds "apply a default profile when tlsSecurityProfile is nil" — this would break S1 but leave S6 green, because S6 has an explicit non-nil profile.

There is also a subtle documentation value: S1 makes it explicit that cert-manager's TLS hook is opt-in — zero configuration means zero injection. S6 alone doesn't communicate that; it looks like the adherence policy is the only gate, whereas S1 shows the nil profile is also a valid no-op state.

Also since it's the first test in the Ordered suite, it also serves as a clean-slate baseline before all the mutation tests that follow. Happy to discuss further, but I'd prefer to keep both.

@bharath-b-rh bharath-b-rh 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.

return restoreClusterAPIServerTLSConfig(ctx, original)
}, lowTimeout, fastPollInterval).Should(Succeed())

By("clearing any unsupportedConfigOverrides left by scenario 8")

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.

Suggested change
By("clearing any unsupportedConfigOverrides left by scenario 8")
By("clearing unsupportedConfigOverrides left by any test scenarios")

updated := cm.DeepCopy()
if args == nil {
// Clear the whole unsupportedConfigOverrides field
updated.Spec.OperatorSpec.UnsupportedConfigOverrides = runtime.RawExtension{}

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.

nit: This method is specifically for webhook, but cleanup is done for all components.


By("verifying all operands match the Modern profile")
expectedSpec, err := tlsprofile.EffectiveSpec(tlsProfileModernProfile)
Expect(err).NotTo(HaveOccurred())

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.

Could we add some message here to make debugging easier. Same at other places too.

@chiragkyal

Copy link
Copy Markdown
Member Author

All the tests added here are getting skipped. Please check https://gcsweb-ci.apps.ci.l2s4.p1.openshiftapps.com/gcs/test-platform-results/pr-logs/pull/openshift_cert-manager-operator/449/pull-ci-openshift-cert-manager-operator-master-e2e-operator-tech-preview/2070425619958599680/artifacts/e2e-operator-tech-preview/test/artifacts/junit.xml for the reason.

I see the issue. The techpreview jobs are running in a HyperShift Cluster, where the apiserver.config.openshift.io/cluster object is immutable from inside the guest cluster.

apiserver tlsAdherence field not available on this cluster: apiservers.config.openshift.io &#34;cluster&#34; is forbidden: ValidatingAdmissionPolicy &#39;config&#39; with binding &#39;config-binding&#39; denied request: This resource cannot be created, updated, or deleted. Please ask your administrator to modify the resource in the HostedCluster object

So to run these tests need would need a standalone OCP cluster with TechPreviewNoUpgrade FeatureSet enabled.

@bharath-b-rh, should we migrate the job to a standalone OCP instead of HyperShift, or do we have some alternative approach here?

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

Labels

jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants