Skip to content

Commit

Permalink
check proxy requires email in the JWT token
Browse files Browse the repository at this point in the history
Signed-off-by: Francesco Ilario <[email protected]>
  • Loading branch information
filariow committed Sep 25, 2024
1 parent 599e2d2 commit 150dbd0
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pkg/proxy/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,23 @@ func (s *TestProxySuite) checkPlainHTTPErrors(fakeApp *fake.ProxyFakeApp) {
s.assertResponseBody(resp, "invalid bearer token: unable to extract userID from token: token does not comply to expected claims: subject missing")
})

s.Run("unauthorized if can't extract email from a valid token", func() {
// when
req, err := http.NewRequest("GET", "http://localhost:8081/api/mycoolworkspace/pods", nil)
require.NoError(s.T(), err)
require.NotNil(s.T(), req)
userID := uuid.New()
req.Header.Set("Authorization", "Bearer "+s.token(userID, authsupport.WithEmailClaim("")))
resp, err := http.DefaultClient.Do(req)

// then
require.NoError(s.T(), err)
require.NotNil(s.T(), resp)
defer resp.Body.Close()
assert.Equal(s.T(), http.StatusUnauthorized, resp.StatusCode)
s.assertResponseBody(resp, "invalid bearer token: unable to extract userID from token: token does not comply to expected claims: email missing")
})

s.Run("unauthorized if workspace context is invalid", func() {
// when
req := s.request()
Expand Down

0 comments on commit 150dbd0

Please sign in to comment.