mirror of
https://github.com/kreuzwerker/terraform-provider-docker.git
synced 2025-12-20 22:59:42 -05:00
tests: Add test for parsing auth headers.
This commit is contained in:
parent
e54559b7e0
commit
0017485163
1 changed files with 19 additions and 1 deletions
|
|
@ -1,6 +1,8 @@
|
||||||
package provider
|
package provider
|
||||||
|
|
||||||
import "testing"
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
func TestIsECRRepositoryURL(t *testing.T) {
|
func TestIsECRRepositoryURL(t *testing.T) {
|
||||||
|
|
||||||
|
|
@ -17,3 +19,19 @@ func TestIsECRRepositoryURL(t *testing.T) {
|
||||||
t.Fatalf("Expected true")
|
t.Fatalf("Expected true")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestParseAuthHeaders(t *testing.T) {
|
||||||
|
header := "Bearer realm=\"https://gcr.io/v2/token\",service=\"gcr.io\",scope=\"repository:<owner>/:<repo>/<name>:pull\""
|
||||||
|
result := parseAuthHeader(header)
|
||||||
|
wantScope := "repository:<owner>/:<repo>/<name>: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:<owner>/:<repo>/<name>:push,pull\""
|
||||||
|
result = parseAuthHeader(header)
|
||||||
|
wantScope = "repository:<owner>/:<repo>/<name>:push,pull"
|
||||||
|
if result["scope"] != wantScope {
|
||||||
|
t.Errorf("want: %#v, got: %#v", wantScope, result["scope"])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue