@@ -63,4 +63,28 @@ func Test_NewCombinedDockerConfigJSON(t *testing.T) {
6363 assert .Equal (t , 1 , len (result ))
6464 assert .Equal (t , expected , result [corev1 .DockerConfigJsonKey ])
6565 })
66+
67+ t .Run ("skips entries with no auth data" , func (t * testing.T ) {
68+ // Secret with 1 valid and 1 empty auths
69+ secrets := []* corev1.Secret {
70+ & corev1.Secret {
71+ Data : map [string ][]byte {
72+ corev1 .DockerConfigJsonKey : []byte (`{"auths":{"valid-server1":{"username":"user1","password":"pass1","auth":"auth1"},"empty-server1":{"username":"","password":"","auth":""}}}` ),
73+ },
74+ },
75+ // Another Secret with 1 valid and 1 empty auths
76+ & corev1.Secret {
77+ Data : map [string ][]byte {
78+ corev1 .DockerConfigJsonKey : []byte (`{"auths":{"valid-server2":{"username":"user2","password":"pass2","auth":"auth2"},"empty-server2":{"username":"","password":"","auth":""}}}` ),
79+ },
80+ },
81+ }
82+ result , err := NewCombinedDockerConfigJSON (secrets )
83+ require .NoError (t , err )
84+
85+ // Expected result should have only the valid auths
86+ expected := []byte (`{"auths":{"valid-server1":{"username":"user1","password":"pass1","auth":"auth1"},"valid-server2":{"username":"user2","password":"pass2","auth":"auth2"}}}` )
87+ assert .Equal (t , 1 , len (result ))
88+ assert .Equal (t , expected , result [corev1 .DockerConfigJsonKey ])
89+ })
6690}
0 commit comments