Update test to validate against v1 kubelet APIs

This commit is contained in:
Dixita Narang 2022-09-30 20:56:50 +00:00
parent a016b06bbd
commit d6ab1da1b5

View File

@ -36,7 +36,7 @@ func Test_getCredentials(t *testing.T) {
server := httptest.NewServer(&fakeTokenServer{token: "abc123"}) server := httptest.NewServer(&fakeTokenServer{token: "abc123"})
defer server.Close() defer server.Close()
in := bytes.NewBuffer([]byte(`{"kind":"CredentialProviderRequest","apiVersion":"credentialprovider.kubelet.k8s.io/v1beta1","image":"gcr.io/foobar"}`)) in := bytes.NewBuffer([]byte(`{"kind":"CredentialProviderRequest","apiVersion":"credentialprovider.kubelet.k8s.io/v1","image":"gcr.io/foobar"}`))
out := bytes.NewBuffer(nil) out := bytes.NewBuffer(nil)
err := getCredentials(server.URL, in, out) err := getCredentials(server.URL, in, out)
@ -44,7 +44,7 @@ func Test_getCredentials(t *testing.T) {
t.Fatalf("unexpected error running getCredentials: %v", err) t.Fatalf("unexpected error running getCredentials: %v", err)
} }
expected := `{"kind":"CredentialProviderResponse","apiVersion":"credentialprovider.kubelet.k8s.io/v1beta1","cacheKeyType":"Registry","auth":{"*.gcr.io":{"username":"_token","password":"abc123"},"*.pkg.dev":{"username":"_token","password":"abc123"},"container.cloud.google.com":{"username":"_token","password":"abc123"},"gcr.io":{"username":"_token","password":"abc123"}}} expected := `{"kind":"CredentialProviderResponse","apiVersion":"credentialprovider.kubelet.k8s.io/v1","cacheKeyType":"Registry","auth":{"*.gcr.io":{"username":"_token","password":"abc123"},"*.pkg.dev":{"username":"_token","password":"abc123"},"container.cloud.google.com":{"username":"_token","password":"abc123"},"gcr.io":{"username":"_token","password":"abc123"}}}
` `
if out.String() != expected { if out.String() != expected {