Skip to content

CM-937: Automate e2e tests for Azure DNS01 Service Principal auth#374

Open
lunarwhite wants to merge 2 commits intoopenshift:masterfrom
lunarwhite:e2e-az
Open

CM-937: Automate e2e tests for Azure DNS01 Service Principal auth#374
lunarwhite wants to merge 2 commits intoopenshift:masterfrom
lunarwhite:e2e-az

Conversation

@lunarwhite
Copy link
Member

@lunarwhite lunarwhite commented Mar 4, 2026

First (1/2) part of https://issues.redhat.com/browse/CM-937

Changes

Add new e2e tests to initiate Azure DNS-01 coverage:

  • ACME Issuer DNS01 solver with Azure DNS should obtain a valid certificate using explicit credentials through Service Principal
  • ACME Issuer DNS01 solver with Azure DNS should obtain a valid certificate using explicit credentials provisioned by CCO through Service Principal

Dependency

Summary by CodeRabbit

  • Tests
    • Added Azure DNS support for ACME DNS‑01 e2e tests, covering both explicit client‑credentials and ambient (CCO‑provisioned) credential flows.
    • Added test helpers to manage Azure credentials, copy secrets into test namespaces, and parse Azure DNS zone info.
    • Included a CredentialsRequest test fixture for provisioning Azure DNS credentials.

@openshift-ci-robot
Copy link

openshift-ci-robot commented Mar 4, 2026

@lunarwhite: This pull request references CM-937 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 "4.22.0" version, but no target version was set.

Details

In response to this:

First (1/2) part of https://issues.redhat.com/browse/CM-937

Changes

Add new e2e tests to initiate Azure DNS-01 coverage:

  • ACME Issuer DNS01 solver with Azure DNS should obtain a valid certificate using explicit credentials through Service Principal
  • ACME Issuer DNS01 solver with Azure DNS should obtain a valid certificate using ambient credentials through Service Principal

Dependency

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-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Mar 4, 2026
@coderabbitai
Copy link

coderabbitai bot commented Mar 4, 2026

Walkthrough

Adds Azure DNS-01 support to the ACME e2e tests: helpers to read Azure Service Principal credentials from cluster secrets, parse Azure DNS zone identifiers, copy secrets into test namespaces, and provision ambient credentials via a CredentialsRequest for CCO-driven scenarios; adds explicit and ambient Azure test contexts.

Changes

Cohort / File(s) Summary
Azure DNS E2E Test Support
test/e2e/issuer_acme_dns01_test.go
Adds helpers to fetch Azure Service Principal credentials from kube-system secrets, parse subscription/resourceGroup/zone from PublicZone.ID, copy Azure secrets into test namespaces, and create CredentialsRequest resources. Introduces two Azure DNS-01 test contexts: explicit client-credentials and ambient (CCO-provisioned) credentials.
Azure Credentials Configuration
test/e2e/testdata/credentials/credentialsrequest_azure.yaml
Adds a CredentialsRequest manifest (cert-manager-azure-dns) targeting the openshift-cloud-credential-operator namespace, requesting an AzureProviderSpec with a DNS Zone Contributor role binding and producing a secret named azure-credentials in the cert-manager namespace.

Sequence Diagram(s)

sequenceDiagram
    actor Test as E2E Test Suite
    participant K8s as Kubernetes API
    participant CCO as Cloud Credential Operator
    participant Azure as Azure API
    participant AzureDNS as Azure DNS Solver

    Test->>K8s: Create CredentialsRequest (cert-manager-azure-dns)
    K8s->>CCO: Notify CCO of CredentialsRequest
    CCO->>Azure: Request DNS Zone Contributor credentials
    Azure-->>CCO: Return credentials
    CCO->>K8s: Create Secret (`azure-credentials`) in `cert-manager` namespace
    Test->>K8s: Read Azure creds from `kube-system` Secret
    Test->>K8s: Copy Secret to test namespace
    Test->>K8s: Create ACME Issuer with AzureDNS solver referencing secret
    K8s->>AzureDNS: Provide credentials to solver
    AzureDNS->>Azure: Authenticate and update DNS records for DNS-01 challenge
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and specifically describes the main change: adding automated e2e tests for Azure DNS-01 using Service Principal authentication, which matches the core objectives of the PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Stable And Deterministic Test Names ✅ Passed All test names in the modified test file are static and deterministic. Azure DNS test declarations use fixed descriptive strings, and dynamic values like DNS names and random identifiers are correctly placed in test bodies, not titles.
Test Structure And Quality ✅ Passed Azure DNS DNS-01 test implementation adheres to all specified quality requirements with proper single responsibility, resource cleanup, wait operations, and meaningful assertions.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 4, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lunarwhite

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 Mar 4, 2026
@openshift-ci-robot
Copy link

openshift-ci-robot commented Mar 4, 2026

@lunarwhite: This pull request references CM-937 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 "4.22.0" version, but no target version was set.

Details

In response to this:

First (1/2) part of https://issues.redhat.com/browse/CM-937

Changes

Add new e2e tests to initiate Azure DNS-01 coverage:

  • ACME Issuer DNS01 solver with Azure DNS should obtain a valid certificate using explicit credentials through Service Principal
  • ACME Issuer DNS01 solver with Azure DNS should obtain a valid certificate using ambient credentials through Service Principal

Dependency

Summary by CodeRabbit

  • Tests
  • Added Azure DNS support tests for ACME DNS-01 validation, covering explicit and ambient credentials authentication approaches.
  • Introduced test utilities and configuration files for Azure DNS certificate issuance validation scenarios.

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.

Copy link

@coderabbitai coderabbitai bot left a comment

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 (1)
test/e2e/issuer_acme_dns01_test.go (1)

465-470: Harden Azure resource ID parsing to avoid silent mis-parsing.

Line 465–470 assumes fixed indexes after strings.Split. If the ID shape changes slightly, values can shift without validating segment names.

♻️ Proposed refactor
-		parts := strings.Split(zoneID, "/")
-		// parts: [0]="" [1]="subscriptions" [2]=<sub> [3]="resourceGroups" [4]=<rg> [5]="providers" [6]="Microsoft.Network" [7]="dnszones" [8]=<zone>
-		Expect(len(parts)).To(BeNumerically(">=", 9), "unexpected Azure resource ID format: %s", zoneID)
-		subscriptionID = parts[2]
-		resourceGroupName = parts[4]
-		hostedZoneName = parts[8]
+		parts := strings.Split(strings.Trim(zoneID, "/"), "/")
+		// expected:
+		// [0]="subscriptions" [1]=<sub> [2]="resourceGroups" [3]=<rg> [4]="providers" [5]="Microsoft.Network" [6]="dnszones" [7]=<zone>
+		Expect(len(parts)).To(BeNumerically(">=", 8), "unexpected Azure resource ID format: %s", zoneID)
+		Expect(parts[0]).To(Equal("subscriptions"), "unexpected Azure resource ID format: %s", zoneID)
+		Expect(parts[2]).To(Equal("resourceGroups"), "unexpected Azure resource ID format: %s", zoneID)
+		Expect(strings.EqualFold(parts[6], "dnszones")).To(BeTrue(), "unexpected Azure resource ID format: %s", zoneID)
+		subscriptionID = parts[1]
+		resourceGroupName = parts[3]
+		hostedZoneName = parts[7]
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/e2e/issuer_acme_dns01_test.go` around lines 465 - 470, The current
parsing of zoneID via fixed indexes after strings.Split can mis-parse; update
the test to validate segment names and bounds before assigning
subscriptionID/resourceGroupName/hostedZoneName: split zoneID into parts, check
that parts length is sufficient and that parts[1]=="subscriptions",
parts[3]=="resourceGroups", parts[5]=="providers" and parts[7]=="dnszones" (or
locate those segment names dynamically), then extract the following elements
into subscriptionID, resourceGroupName, and hostedZoneName; if any check fails,
call Expect(...).To(HaveOccurred()/Fail) or similar with a clear error including
the full zoneID so the test fails loudly rather than silently mis-parsing.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@test/e2e/issuer_acme_dns01_test.go`:
- Around line 479-485: The test claims "ambient Azure credentials" but still
wires explicit TenantID/ClientID/ClientSecret in setupAmbientAzureCredentials
and the Issuer creation; either convert this to real ambient behavior when Azure
support is added to withCloudCredentials in credentials_request.go (remove
explicit TenantID/ClientID/ClientSecret usage in setupAmbientAzureCredentials
and the Issuer construction so the test relies on the operator-mapped ambient
secret) or change the test scope/naming and comments to reflect explicit
credential wiring (rename setupAmbientAzureCredentials and the test case, and
update the comment to say this is an explicit credential wiring test rather than
ambient); apply the chosen change consistently to the
setupAmbientAzureCredentials function, the Issuer construction that sets
TenantID/ClientID/ClientSecret, and the top comment describing the test.

---

Nitpick comments:
In `@test/e2e/issuer_acme_dns01_test.go`:
- Around line 465-470: The current parsing of zoneID via fixed indexes after
strings.Split can mis-parse; update the test to validate segment names and
bounds before assigning subscriptionID/resourceGroupName/hostedZoneName: split
zoneID into parts, check that parts length is sufficient and that
parts[1]=="subscriptions", parts[3]=="resourceGroups", parts[5]=="providers" and
parts[7]=="dnszones" (or locate those segment names dynamically), then extract
the following elements into subscriptionID, resourceGroupName, and
hostedZoneName; if any check fails, call Expect(...).To(HaveOccurred()/Fail) or
similar with a clear error including the full zoneID so the test fails loudly
rather than silently mis-parsing.

ℹ️ Review info
Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 2fd43aa9-f49f-4568-bf4a-fa1d10b88cff

📥 Commits

Reviewing files that changed from the base of the PR and between b45974d and 12a2535.

📒 Files selected for processing (2)
  • test/e2e/issuer_acme_dns01_test.go
  • test/e2e/testdata/credentials/credentialsrequest_azure.yaml

@lunarwhite lunarwhite force-pushed the e2e-az branch 2 times, most recently from 6f04605 to 2b05a73 Compare March 4, 2026 05:10
@openshift-ci-robot
Copy link

openshift-ci-robot commented Mar 4, 2026

@lunarwhite: This pull request references CM-937 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 "4.22.0" version, but no target version was set.

Details

In response to this:

First (1/2) part of https://issues.redhat.com/browse/CM-937

Changes

Add new e2e tests to initiate Azure DNS-01 coverage:

  • ACME Issuer DNS01 solver with Azure DNS should obtain a valid certificate using explicit credentials through Service Principal
  • ACME Issuer DNS01 solver with Azure DNS should obtain a valid certificate using explicit credentials provisioned by CCO through Service Principal

should obtain a valid certificate using C

Dependency

Summary by CodeRabbit

  • Tests
  • Added Azure DNS support tests for ACME DNS-01 validation, covering explicit and ambient credentials authentication approaches.
  • Introduced test utilities and configuration files for Azure DNS certificate issuance validation scenarios.

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-robot
Copy link

openshift-ci-robot commented Mar 4, 2026

@lunarwhite: This pull request references CM-937 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 "4.22.0" version, but no target version was set.

Details

In response to this:

First (1/2) part of https://issues.redhat.com/browse/CM-937

Changes

Add new e2e tests to initiate Azure DNS-01 coverage:

  • ACME Issuer DNS01 solver with Azure DNS should obtain a valid certificate using explicit credentials through Service Principal
  • ACME Issuer DNS01 solver with Azure DNS should obtain a valid certificate using explicit credentials provisioned by CCO through Service Principal

Dependency

Summary by CodeRabbit

  • Tests
  • Added Azure DNS support tests for ACME DNS-01 validation, covering explicit and ambient credentials authentication approaches.
  • Introduced test utilities and configuration files for Azure DNS certificate issuance validation scenarios.

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-robot
Copy link

openshift-ci-robot commented Mar 4, 2026

@lunarwhite: This pull request references CM-937 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 "4.22.0" version, but no target version was set.

Details

In response to this:

First (1/2) part of https://issues.redhat.com/browse/CM-937

Changes

Add new e2e tests to initiate Azure DNS-01 coverage:

  • ACME Issuer DNS01 solver with Azure DNS should obtain a valid certificate using explicit credentials through Service Principal
  • ACME Issuer DNS01 solver with Azure DNS should obtain a valid certificate using explicit credentials provisioned by CCO through Service Principal

Dependency

Summary by CodeRabbit

  • Tests
  • Added Azure DNS support tests for ACME DNS-01 validation, covering explicit credentials authentication approaches.
  • Introduced test utilities and configuration files for Azure DNS certificate issuance validation scenarios.

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-robot
Copy link

openshift-ci-robot commented Mar 4, 2026

@lunarwhite: This pull request references CM-937 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 "4.22.0" version, but no target version was set.

Details

In response to this:

First (1/2) part of https://issues.redhat.com/browse/CM-937

Changes

Add new e2e tests to initiate Azure DNS-01 coverage:

  • ACME Issuer DNS01 solver with Azure DNS should obtain a valid certificate using explicit credentials through Service Principal
  • ACME Issuer DNS01 solver with Azure DNS should obtain a valid certificate using explicit credentials provisioned by CCO through Service Principal

Dependency

Summary by CodeRabbit

  • Tests
  • Added Azure DNS support for ACME DNS‑01 e2e tests, covering both explicit client‑credentials and ambient (CCO‑provisioned) credential flows.
  • Added test helpers to manage Azure credentials, copy secrets into test namespaces, and parse Azure DNS zone info.
  • Included a CredentialsRequest test fixture for provisioning Azure DNS credentials.

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
Copy link
Contributor

openshift-ci bot commented Mar 4, 2026

@lunarwhite: 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-ci-robot
Copy link

openshift-ci-robot commented Mar 5, 2026

@lunarwhite: This pull request references CM-937 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 "4.22.0" version, but no target version was set.

Details

In response to this:

First (1/2) part of https://issues.redhat.com/browse/CM-937

Changes

Add new e2e tests to initiate Azure DNS-01 coverage:

  • ACME Issuer DNS01 solver with Azure DNS should obtain a valid certificate using explicit credentials through Service Principal
  • ACME Issuer DNS01 solver with Azure DNS should obtain a valid certificate using explicit credentials provisioned by CCO through Service Principal

Dependency

Summary by CodeRabbit

  • Tests
  • Added Azure DNS support for ACME DNS‑01 e2e tests, covering both explicit client‑credentials and ambient (CCO‑provisioned) credential flows.
  • Added test helpers to manage Azure credentials, copy secrets into test namespaces, and parse Azure DNS zone info.
  • Included a CredentialsRequest test fixture for provisioning Azure DNS credentials.

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.

@lunarwhite
Copy link
Member Author

/test ?

@lunarwhite
Copy link
Member Author

/test e2e-operator-azure-ovn

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. 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.

2 participants