Skip to content

Commit

Permalink
Chore: add test for error when subject is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
till committed Feb 10, 2022
1 parent 7eb8e6e commit 5b393c2
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pipeline/authn/authenticator_bearer_token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,19 @@ func TestAuthenticatorBearerToken(t *testing.T) {
Extra: map[string]interface{}{"session": map[string]interface{}{"foo": "bar"}, "identity": map[string]interface{}{"id": "123"}},
},
},
{
d: "it should error when the subject is empty",
r: &http.Request{Header: http.Header{"Authorization": {"bearer token"}}, URL: &url.URL{Path: ""}},
setup: func(t *testing.T, m *httprouter.Router) {
m.GET("/", func(w http.ResponseWriter, _ *http.Request, _ httprouter.Params) {
w.WriteHeader(200)
w.Write([]byte(`{"identity": {"id": ""}, "session": {"foo": "bar"}}`))
})
},
config: []byte(`{"subject_from": "identity.id", "extra_from": "@this"}`),
expectErr: true,
expectSess: &AuthenticationSession{},
},
} {
t.Run(fmt.Sprintf("case=%d/description=%s", k, tc.d), func(t *testing.T) {
var ts *httptest.Server
Expand Down

0 comments on commit 5b393c2

Please sign in to comment.