diff --git a/internal/controller/imagerepository_controller_test.go b/internal/controller/imagerepository_controller_test.go index fb1af3b6..70039208 100644 --- a/internal/controller/imagerepository_controller_test.go +++ b/internal/controller/imagerepository_controller_test.go @@ -145,6 +145,17 @@ func TestImageRepositoryReconciler_setAuthOptions(t *testing.T) { corev1.TLSPrivateKeyKey: clientKeyPEM, } + testProxySecret := &corev1.Secret{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test-proxy-secret", + Namespace: testNamespace, + }, + Type: corev1.SecretTypeOpaque, + Data: map[string][]byte{ + "address": []byte("http://proxy.example.com"), + }, + } + testDeprecatedTLSSecret := &corev1.Secret{} testDeprecatedTLSSecret.Name = testDeprecatedTLSSecretName testDeprecatedTLSSecret.Namespace = testNamespace @@ -249,8 +260,28 @@ func TestImageRepositoryReconciler_setAuthOptions(t *testing.T) { wantErr: true, }, { - name: "secret ref and cert secret ref", - mockObjs: []client.Object{testSecret, testTLSSecret}, + name: "proxy secret ref with existing secret", + mockObjs: []client.Object{testProxySecret}, + imageRepoSpec: imagev1.ImageRepositorySpec{ + Image: testImg, + ProxySecretRef: &meta.LocalObjectReference{ + Name: testProxySecret.Name, + }, + }, + }, + { + name: "proxy secret ref with non-existing secret", + imageRepoSpec: imagev1.ImageRepositorySpec{ + Image: testImg, + ProxySecretRef: &meta.LocalObjectReference{ + Name: "non-existing-secret", + }, + }, + wantErr: true, + }, + { + name: "secret, cert secret and proxy secret refs", + mockObjs: []client.Object{testSecret, testTLSSecret, testProxySecret}, imageRepoSpec: imagev1.ImageRepositorySpec{ Image: testImg, SecretRef: &meta.LocalObjectReference{ @@ -259,6 +290,9 @@ func TestImageRepositoryReconciler_setAuthOptions(t *testing.T) { CertSecretRef: &meta.LocalObjectReference{ Name: testTLSSecretName, }, + ProxySecretRef: &meta.LocalObjectReference{ + Name: testProxySecret.Name, + }, }, }, {