diff --git a/pkg/runtime/auth_test.go b/pkg/runtime/auth_test.go index b29a00b..8da826f 100644 --- a/pkg/runtime/auth_test.go +++ b/pkg/runtime/auth_test.go @@ -47,6 +47,16 @@ func TestAPIKeyAuth_CustomHeader(t *testing.T) { } } +func TestAPIKeyAuth_CustomLowercaseHeader(t *testing.T) { + req, _ := http.NewRequest("GET", "http://x", nil) + if err := (APIKeyAuth{Key: "k3", Header: "x-api-key"}).Apply(req); err != nil { + t.Fatal(err) + } + if got := req.Header.Get("x-api-key"); got != "k3" { + t.Errorf("want k3, got %q", got) + } +} + func TestAPIKeyAuth_Empty(t *testing.T) { req, _ := http.NewRequest("GET", "http://x", nil) if err := (APIKeyAuth{}).Apply(req); err != nil { @@ -129,6 +139,19 @@ func TestNewAuthFromHost(t *testing.T) { } }, }, + { + name: "apikey lower-case header", + entry: config.HostEntry{AuthType: "apikey", APIKey: "k2", APIKeyHeader: "x-api-key"}, + check: func(t *testing.T, a Authenticator) { + ak, ok := a.(APIKeyAuth) + if !ok { + t.Fatalf("want APIKeyAuth, got %T", a) + } + if ak.Header != "x-api-key" { + t.Errorf("want x-api-key, got %q", ak.Header) + } + }, + }, { name: "basic", entry: config.HostEntry{AuthType: "basic", BasicUser: "u", BasicPassword: "p"},