Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ func verifyInternalReleaseMasterMachineConfig(t *testing.T, mc *mcfgv1.MachineCo

assert.Len(t, ignCfg.Systemd.Units, 1)
assert.Contains(t, *ignCfg.Systemd.Units[0].Contents, "docker-registry-image-pullspec")
assert.Contains(t, *ignCfg.Systemd.Units[0].Contents, "REGISTRY_AUTH_HTPASSWD_REALM")
assert.Contains(t, *ignCfg.Systemd.Units[0].Contents, "REGISTRY_AUTH_HTPASSWD_PATH")
assert.NotContains(t, *ignCfg.Systemd.Units[0].Contents, "REGISTRY_AUTH_HTPASSWD_REALM")
assert.NotContains(t, *ignCfg.Systemd.Units[0].Contents, "REGISTRY_AUTH_HTPASSWD_PATH")

assert.Len(t, ignCfg.Storage.Files, 5, "Found an unexpected file")
verifyIgnitionFile(t, &ignCfg, "/etc/pki/ca-trust/source/anchors/iri-root-ca.crt", "iri-root-ca-data")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ contents: |
-e REGISTRY_HTTP_ADDR=0.0.0.0:22625 \
-e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/tls.crt -e REGISTRY_HTTP_TLS_KEY=/certs/tls.key \
-e 'REGISTRY_STORAGE_MAINTENANCE_READONLY={"enabled":true}' \
{{- /* REGISTRY_AUTH_HTPASSWD_REALM is required by the distribution registry but can be any value. It is sent in WWW-Authenticate headers to identify the protected area to clients. */}}
-e REGISTRY_AUTH_HTPASSWD_REALM=iri-registry -e REGISTRY_AUTH_HTPASSWD_PATH=/etc/registry/auth/htpasswd \
-u 0 --entrypoint=/usr/bin/distribution {{ .DockerRegistryImage }} serve /etc/registry/config.yaml
ExecStop=/usr/bin/podman stop --ignore --cidfile=%t/%n.ctr-id
ExecStopPost=/usr/bin/podman rm -f --ignore --cidfile=%t/%n.ctr-id
Expand Down
64 changes: 8 additions & 56 deletions test/e2e-iri/iri_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"context"
"crypto/tls"
"crypto/x509"
"encoding/base64"
"encoding/pem"
"fmt"
"net/http"
Expand Down Expand Up @@ -276,10 +275,6 @@ func TestIRIController_VerifyIRIRegistryOnAllTheMasterNodes_NoCert(t *testing.T)
skipIfNoBaremetal(t)

cs := framework.NewClientSet("")
authSecret, err := cs.Secrets(ctrlcommon.MCONamespace).Get(context.TODO(), ctrlcommon.InternalReleaseImageAuthSecretName, v1.GetOptions{})
require.NoError(t, err)
password := string(authSecret.Data["password"])

masterNodes, err := cs.CoreV1Interface.Nodes().List(context.TODO(), v1.ListOptions{LabelSelector: "node-role.kubernetes.io/master="})
require.NoError(t, err)

Expand All @@ -301,7 +296,7 @@ func TestIRIController_VerifyIRIRegistryOnAllTheMasterNodes_NoCert(t *testing.T)
},
Timeout: 30 * time.Second,
}
pingIRIRegistry(t, client, nodeAddr, ctrlcommon.IRIRegistryUsername, password)
pingIRIRegistry(t, client, nodeAddr)
}
}

Expand Down Expand Up @@ -359,17 +354,14 @@ func TestIRIController_VerifyIRIRegistryOnApiInt_WithCert(t *testing.T) {
require.NoError(t, err)
require.NotEmpty(t, infra.Status.PlatformStatus.BareMetal.APIServerInternalIPs)

authSecret, err := cs.Secrets(ctrlcommon.MCONamespace).Get(ctx, ctrlcommon.InternalReleaseImageAuthSecretName, v1.GetOptions{})
require.NoError(t, err)
pingIRIRegistry(t, client, infra.Status.PlatformStatus.BareMetal.APIServerInternalIPs[0], ctrlcommon.IRIRegistryUsername, string(authSecret.Data["password"]))
pingIRIRegistry(t, client, infra.Status.PlatformStatus.BareMetal.APIServerInternalIPs[0])
}

func pingIRIRegistry(t *testing.T, client *http.Client, ipAddr, username, password string) {
func pingIRIRegistry(t *testing.T, client *http.Client, ipAddr string) {
iriRegistryUrl := fmt.Sprintf("https://%s:%d/v2/", ipAddr, ctrlcommon.IRIRegistryPort)

req, err := http.NewRequestWithContext(context.Background(), http.MethodGet, iriRegistryUrl, nil)
require.NoError(t, err)
req.SetBasicAuth(username, password)
resp, err := client.Do(req)
require.NoError(t, err)
defer resp.Body.Close()
Expand All @@ -389,56 +381,16 @@ func getBaseDomain(t *testing.T, cs *framework.ClientSet) string {
return cconfig.Spec.DNS.Spec.BaseDomain
}

// curlIRIRegistry runs curl against the IRI registry /v2/ endpoint via
// ExecCmdOnNode, which executes inside the MCD pod on the given master node.
// The MCD pod runs on the host network and can reach api-int:22625, making
// this approach work in CI where the port is not reachable from the test runner.
// Returns the HTTP status code string (e.g. "200", "401").
func curlIRIRegistry(t *testing.T, cs *framework.ClientSet, node corev1.Node, baseDomain string, extraArgs ...string) string {
t.Helper()
url := fmt.Sprintf("https://api-int.%s:%d/v2/", baseDomain, ctrlcommon.IRIRegistryPort)
args := []string{"curl", "-s", "--cacert", iriRootCAPath, "-o", "/dev/null", "-w", "%{http_code}"}
args = append(args, extraArgs...)
args = append(args, url)
return strings.TrimSpace(helpers.ExecCmdOnNode(t, cs, node, args...))
}

func TestIRIAuth_UnauthenticatedRequestReturns401(t *testing.T) {
cs := framework.NewClientSet("")
ctx := context.Background()

_, err := cs.Secrets(ctrlcommon.MCONamespace).Get(ctx, ctrlcommon.InternalReleaseImageAuthSecretName, v1.GetOptions{})
if k8serrors.IsNotFound(err) {
t.Skip("IRI auth secret not found, authentication is not enabled")
}
require.NoError(t, err)

baseDomain := getBaseDomain(t, cs)
node := helpers.GetRandomNode(t, cs, "master")

statusCode := curlIRIRegistry(t, cs, node, baseDomain)
require.Equal(t, "401", statusCode, "unauthenticated request should return 401")
}

func TestIRIAuth_AuthenticatedRequestSucceeds(t *testing.T) {
func TestIRIRegistry_UnauthenticatedReadSucceeds(t *testing.T) {
cs := framework.NewClientSet("")
ctx := context.Background()

authSecret, err := cs.Secrets(ctrlcommon.MCONamespace).Get(ctx, ctrlcommon.InternalReleaseImageAuthSecretName, v1.GetOptions{})
if k8serrors.IsNotFound(err) {
t.Skip("IRI auth secret not found, authentication is not enabled")
}
require.NoError(t, err)

password := string(authSecret.Data["password"])
require.NotEmpty(t, password)

baseDomain := getBaseDomain(t, cs)
node := helpers.GetRandomNode(t, cs, "master")
authHeader := "Basic " + base64.StdEncoding.EncodeToString([]byte(ctrlcommon.IRIRegistryUsername+":"+password))

statusCode := curlIRIRegistry(t, cs, node, baseDomain, "-H", "Authorization: "+authHeader)
require.Equal(t, "200", statusCode, "authenticated request should succeed")
url := fmt.Sprintf("https://api-int.%s:%d/v2/", baseDomain, ctrlcommon.IRIRegistryPort)
args := []string{"curl", "-s", "--cacert", iriRootCAPath, "-o", "/dev/null", "-w", "%{http_code}", url}
statusCode := strings.TrimSpace(helpers.ExecCmdOnNode(t, cs, node, args...))
require.Equal(t, "200", statusCode, "unauthenticated read request should succeed")
}
Comment on lines +384 to 394

@coderabbitai coderabbitai Bot Jun 1, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Missing skipIfNoBaremetal(t) will cause test failures on non-baremetal platforms.

Every other IRI test in this file includes skipIfNoBaremetal(t) because the IRI registry is a baremetal-specific feature. This new test accesses the IRI registry but lacks this skip, so it will fail on non-baremetal platforms (e.g., AWS, GCP, vSphere).

Additionally, other registry connectivity tests (TestIRIController_VerifyIRIRegistryOnAllTheMasterNodes_NoCert, TestIRIController_VerifyIRIRegistryOnApiInt_WithCert) also use skipIfOpenShiftCI(t) due to proxy issues—consider whether this test has similar constraints.

🐛 Proposed fix to add skip conditions
 func TestIRIRegistry_UnauthenticatedReadSucceeds(t *testing.T) {
+	skipIfOpenShiftCI(t)
+	skipIfNoBaremetal(t)
+
 	cs := framework.NewClientSet("")
 
 	baseDomain := getBaseDomain(t, cs)
🤖 Prompt for 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.

In `@test/e2e-iri/iri_test.go` around lines 384 - 394, The new test
TestIRIRegistry_UnauthenticatedReadSucceeds is missing the baremetal guard and
will fail on non-baremetal platforms; add a call to skipIfNoBaremetal(t) at the
start of that test (and if needed also skipIfOpenShiftCI(t) to mirror other
registry tests) so the test is skipped on unsupported environments, ensuring
behavior matches TestIRIController_VerifyIRIRegistryOnAllTheMasterNodes_NoCert
and TestIRIController_VerifyIRIRegistryOnApiInt_WithCert.

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.

@andfasano Looks like a genuine suggestion. Will it really fail for none platfoem?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

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.

Yes, but for the moment that was intended, since in the MCO repo we only have the default compact (baremetal) iso-no-registry job. We don't have any plan to add more kind of jobs here, but in case that part will need to be bumped (but definitely not as part of this PR)


func TestIRIController_ShouldPreventDeletionWhenInUse(t *testing.T) {
Expand Down