diff --git a/internal/provider/authentication_helpers_test.go b/internal/provider/authentication_helpers_test.go index 8f51d18f..fef82429 100644 --- a/internal/provider/authentication_helpers_test.go +++ b/internal/provider/authentication_helpers_test.go @@ -1,6 +1,8 @@ package provider -import "testing" +import ( + "testing" +) func TestIsECRRepositoryURL(t *testing.T) { @@ -17,3 +19,19 @@ func TestIsECRRepositoryURL(t *testing.T) { t.Fatalf("Expected true") } } + +func TestParseAuthHeaders(t *testing.T) { + header := "Bearer realm=\"https://gcr.io/v2/token\",service=\"gcr.io\",scope=\"repository:/:/:pull\"" + result := parseAuthHeader(header) + wantScope := "repository:/:/:pull" + if result["scope"] != wantScope { + t.Errorf("want: %#v, got: %#v", wantScope, result["scope"]) + } + + header = "Bearer realm=\"https://gcr.io/v2/token\",service=\"gcr.io\",scope=\"repository:/:/:push,pull\"" + result = parseAuthHeader(header) + wantScope = "repository:/:/:push,pull" + if result["scope"] != wantScope { + t.Errorf("want: %#v, got: %#v", wantScope, result["scope"]) + } +}