@@ -29,7 +29,6 @@ import (
2929 k8sErrors "k8s.io/apimachinery/pkg/api/errors"
3030 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3131 "k8s.io/apimachinery/pkg/runtime"
32- "k8s.io/apimachinery/pkg/runtime/schema"
3332 "sigs.k8s.io/controller-runtime/pkg/client"
3433 "sigs.k8s.io/controller-runtime/pkg/client/fake"
3534 "sigs.k8s.io/controller-runtime/pkg/log/zap"
@@ -102,38 +101,22 @@ var _ = Describe("HandleRegistryAuthSecret (restore path: operatorConfigNamespac
102101 scheme = buildScheme ()
103102 })
104103
105- It ("returns the secret directly when the configured name is present in the workspace namespace" , func () {
106- By ("creating a workspace-namespace secret whose name matches the configured auth secret name" )
107- configuredName := "quay-backup-auth"
108- secret := makeSecret (configuredName , workspaceNS )
109-
110- fakeClient := fake .NewClientBuilder ().WithScheme (scheme ).WithObjects (secret ).Build ()
111- workspace := makeWorkspace (workspaceNS )
112- config := makeConfig (configuredName )
113-
114- result , err := secrets .HandleRegistryAuthSecret (ctx , fakeClient , workspace , config , "" , scheme , log )
115- Expect (err ).NotTo (HaveOccurred ())
116- Expect (result ).NotTo (BeNil ())
117- Expect (result .Name ).To (Equal (configuredName ))
118- })
119-
120- It ("returns the canonical backup auth secret as fallback when configured name is absent (the bug fix case)" , func () {
121- By ("creating only the canonical DevWorkspaceBackupAuthSecretName secret in the workspace namespace" )
104+ It ("returns the canonical secret when it exists in the workspace namespace" , func () {
105+ By ("creating the canonical DevWorkspaceBackupAuthSecretName secret in the workspace namespace" )
122106 canonicalSecret := makeSecret (constants .DevWorkspaceBackupAuthSecretName , workspaceNS )
123107
124108 fakeClient := fake .NewClientBuilder ().WithScheme (scheme ).WithObjects (canonicalSecret ).Build ()
125109 workspace := makeWorkspace (workspaceNS )
126- // Configured name is something like "quay-backup-auth" — different from the canonical name.
127110 config := makeConfig ("quay-backup-auth" )
128111
129112 result , err := secrets .HandleRegistryAuthSecret (ctx , fakeClient , workspace , config , "" , scheme , log )
130113 Expect (err ).NotTo (HaveOccurred ())
131- Expect (result ).NotTo (BeNil (), "should fall back to the canonical secret copied by CopySecret" )
114+ Expect (result ).NotTo (BeNil ())
132115 Expect (result .Name ).To (Equal (constants .DevWorkspaceBackupAuthSecretName ))
133116 })
134117
135- It ("returns nil, nil when neither the configured name nor the canonical name exists in the workspace namespace" , func () {
136- By ("using a fake client with no secrets at all " )
118+ It ("returns nil when the canonical secret does not exist in the workspace namespace" , func () {
119+ By ("using a fake client with no secrets" )
137120 fakeClient := fake .NewClientBuilder ().WithScheme (scheme ).Build ()
138121 workspace := makeWorkspace (workspaceNS )
139122 config := makeConfig ("quay-backup-auth" )
@@ -143,25 +126,8 @@ var _ = Describe("HandleRegistryAuthSecret (restore path: operatorConfigNamespac
143126 Expect (result ).To (BeNil ())
144127 })
145128
146- It ("returns the secret on the first lookup when the configured name IS the canonical name (no duplicate query)" , func () {
147- By ("creating the canonical secret in the workspace namespace and configuring the same name" )
148- canonicalSecret := makeSecret (constants .DevWorkspaceBackupAuthSecretName , workspaceNS )
149-
150- fakeClient := fake .NewClientBuilder ().WithScheme (scheme ).WithObjects (canonicalSecret ).Build ()
151- workspace := makeWorkspace (workspaceNS )
152- // Configured name equals the canonical constant — must be found on the first Get.
153- config := makeConfig (constants .DevWorkspaceBackupAuthSecretName )
154-
155- result , err := secrets .HandleRegistryAuthSecret (ctx , fakeClient , workspace , config , "" , scheme , log )
156- Expect (err ).NotTo (HaveOccurred ())
157- Expect (result ).NotTo (BeNil ())
158- Expect (result .Name ).To (Equal (constants .DevWorkspaceBackupAuthSecretName ))
159- })
160-
161- It ("propagates a real (non-NotFound) error from the fallback lookup" , func () {
162- By ("wrapping a fake client so that the fallback lookup returns a server error" )
163- // The configured name differs from the canonical name, so the code will attempt the fallback
164- // lookup. We simulate that lookup returning a non-NotFound error.
129+ It ("propagates a non-NotFound error from the workspace namespace lookup" , func () {
130+ By ("wrapping a fake client so that the canonical name lookup returns a server error" )
165131 errClient := & errorOnNameClient {
166132 Client : fake .NewClientBuilder ().WithScheme (scheme ).Build (),
167133 failName : constants .DevWorkspaceBackupAuthSecretName ,
@@ -196,6 +162,3 @@ func (e *errorOnNameClient) Get(ctx context.Context, key client.ObjectKey, obj c
196162
197163// Ensure errorOnNameClient satisfies client.Client at compile time.
198164var _ client.Client = & errorOnNameClient {}
199-
200- // secretGR is the GroupResource for secrets, used when constructing test errors.
201- var secretGR = schema.GroupResource {Group : "" , Resource : "secrets" } //nolint:unused
0 commit comments