Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
Signed-off-by: Mustafa Abdelrahman <[email protected]>
  • Loading branch information
MustafaSaber committed Jul 18, 2023
1 parent 2038c62 commit 74f0cc3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
4 changes: 2 additions & 2 deletions filters/auth/authclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (ac *authClient) getTokenintrospect(token string, ctx filters.FilterContext
if rsp.StatusCode != 200 {
io.Copy(io.Discard, rsp.Body)
if rsp.StatusCode != 403 && rsp.StatusCode != 401 {
return nil, fmt.Errorf("token introspection failed with status code: %d", rsp.StatusCode)
return nil, fmt.Errorf("failed with status code: %d", rsp.StatusCode)
}
return nil, errInvalidToken
}
Expand Down Expand Up @@ -131,7 +131,7 @@ func (ac *authClient) getTokeninfo(token string, ctx filters.FilterContext) (map
if rsp.StatusCode != 200 {
io.Copy(io.Discard, rsp.Body)
if rsp.StatusCode != 403 && rsp.StatusCode != 401 {
return nil, fmt.Errorf("token info failed with status code: %d", rsp.StatusCode)
return nil, fmt.Errorf("failed with status code: %d", rsp.StatusCode)
}
return doc, errInvalidToken
}
Expand Down
11 changes: 3 additions & 8 deletions filters/auth/tokeninfo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,28 +411,23 @@ func TestOAuth2Tokeninfo5xx(t *testing.T) {
URL: authServer.URL + testAuthPath,
Timeout: testAuthTimeout,
}
args := []interface{}{testScope}

t.Logf("ti.options: %#v", opts)

spec := newOAuthTokeninfoSpec(filters.OAuthTokeninfoAnyScopeName, opts)

_, err := spec.CreateFilter(args)
require.NoError(t, err, "error creating filter")

fr := make(filters.Registry)
fr.Register(spec)
r := &eskip.Route{Filters: []*eskip.Filter{{Name: spec.Name(), Args: args}}, Backend: backend.URL}
r := eskip.MustParse(fmt.Sprintf(`* -> oauthTokeninfoAnyScope("%s") -> "%s"`, testScope, backend.URL))

proxy := proxytest.New(fr, r)
proxy := proxytest.New(fr, r...)
defer proxy.Close()

req, err := http.NewRequest("GET", proxy.URL, nil)
require.NoError(t, err)

req.Header.Set(authHeaderName, authHeaderPrefix+testToken)

rsp, err := http.DefaultClient.Do(req)
rsp, err := proxy.Client().Do(req)
require.NoError(t, err)
rsp.Body.Close()

Expand Down

0 comments on commit 74f0cc3

Please sign in to comment.