Skip to content

Commit 5b393c2

Browse files
committed
Chore: add test for error when subject is empty
1 parent 7eb8e6e commit 5b393c2

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

pipeline/authn/authenticator_bearer_token_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,19 @@ func TestAuthenticatorBearerToken(t *testing.T) {
272272
Extra: map[string]interface{}{"session": map[string]interface{}{"foo": "bar"}, "identity": map[string]interface{}{"id": "123"}},
273273
},
274274
},
275+
{
276+
d: "it should error when the subject is empty",
277+
r: &http.Request{Header: http.Header{"Authorization": {"bearer token"}}, URL: &url.URL{Path: ""}},
278+
setup: func(t *testing.T, m *httprouter.Router) {
279+
m.GET("/", func(w http.ResponseWriter, _ *http.Request, _ httprouter.Params) {
280+
w.WriteHeader(200)
281+
w.Write([]byte(`{"identity": {"id": ""}, "session": {"foo": "bar"}}`))
282+
})
283+
},
284+
config: []byte(`{"subject_from": "identity.id", "extra_from": "@this"}`),
285+
expectErr: true,
286+
expectSess: &AuthenticationSession{},
287+
},
275288
} {
276289
t.Run(fmt.Sprintf("case=%d/description=%s", k, tc.d), func(t *testing.T) {
277290
var ts *httptest.Server

0 commit comments

Comments
 (0)