Skip to content

Commit bf4458c

Browse files
add auth test for the default registry
1 parent aa75771 commit bf4458c

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

docker_auth_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,20 @@ func TestDockerImageAuth(t *testing.T) {
123123
require.Equal(t, base64, cfg.Auth)
124124
})
125125

126+
t.Run("match the default registry authentication by host", func(t *testing.T) {
127+
imageReg := "docker.io"
128+
imagePath := "/my/image:latest"
129+
reg := defaultRegistry(context.Background())
130+
base64 := setAuthConfig(t, reg, "gopher", "secret")
131+
132+
registry, cfg, err := DockerImageAuth(context.Background(), imageReg+imagePath)
133+
require.NoError(t, err)
134+
require.Equal(t, imageReg, registry)
135+
require.Equal(t, "gopher", cfg.Username)
136+
require.Equal(t, "secret", cfg.Password)
137+
require.Equal(t, base64, cfg.Auth)
138+
})
139+
126140
t.Run("fail to match registry authentication due to invalid host", func(t *testing.T) {
127141
imageReg := "example-auth.com"
128142
imagePath := "/my/image:latest"

0 commit comments

Comments
 (0)