Skip to content

Commit

Permalink
Add proxy secret ref tests for setAuthOptions
Browse files Browse the repository at this point in the history
Signed-off-by: Matheus Pimenta <[email protected]>
  • Loading branch information
matheuscscp committed Aug 27, 2024
1 parent 17054ad commit 57aa68a
Showing 1 changed file with 36 additions and 2 deletions.
38 changes: 36 additions & 2 deletions internal/controller/imagerepository_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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{
Expand All @@ -259,6 +290,9 @@ func TestImageRepositoryReconciler_setAuthOptions(t *testing.T) {
CertSecretRef: &meta.LocalObjectReference{
Name: testTLSSecretName,
},
ProxySecretRef: &meta.LocalObjectReference{
Name: testProxySecret.Name,
},
},
},
{
Expand Down

0 comments on commit 57aa68a

Please sign in to comment.