diff --git a/container-engine-lib/lib/backend_impls/docker/docker_manager/docker_auth_test.go b/container-engine-lib/lib/backend_impls/docker/docker_manager/docker_auth_test.go index bd38048a59..73d81d8c49 100644 --- a/container-engine-lib/lib/backend_impls/docker/docker_manager/docker_auth_test.go +++ b/container-engine-lib/lib/backend_impls/docker/docker_manager/docker_auth_test.go @@ -29,22 +29,25 @@ func WriteStaticConfig(t *testing.T, configContent string) string { } func TestGetAuthConfigForRepoPlain(t *testing.T) { - cfg := ` + expectedAuth := registry.AuthConfig{ + Username: "user", + Password: "password", + } + + base64Auth := base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%s:%s", expectedAuth.Username, expectedAuth.Password))) + + cfg := fmt.Sprintf(` { "auths": { "https://index.docker.io/v1/": { - "auth": "dXNlcjpwYXNzd29yZA==" + "auth": "%s" } } - } - ` + }`, base64Auth) + tmpDir := WriteStaticConfig(t, cfg) defer os.RemoveAll(tmpDir) - expectedAuth := registry.AuthConfig{ - Username: "user", - Password: "password", - } encodedAuth := base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%s:%s", expectedAuth.Username, expectedAuth.Password))) // Test 1: Retrieve auth config for Docker Hub using docker.io domain