Skip to content

Commit

Permalink
fix: wrong error code returned in case of inactive token (#3441)
Browse files Browse the repository at this point in the history
Signed-off-by: Romain Caire <[email protected]>
  • Loading branch information
supercairos authored Mar 31, 2024
1 parent 7225198 commit 86e92aa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion server/introspectionhandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ func introspectInactiveErr(w http.ResponseWriter) {
w.Header().Set("Cache-Control", "no-store")
w.Header().Set("Pragma", "no-cache")
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(401)
w.WriteHeader(200)
json.NewEncoder(w).Encode(struct {
Active bool `json:"active"`
}{Active: false})
Expand Down
8 changes: 4 additions & 4 deletions server/introspectionhandler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ func TestHandleIntrospect(t *testing.T) {
testName: "Access Token: wrong",
token: "fake-token",
response: inactiveResponse,
responseStatusCode: 401,
responseStatusCode: 200,
},
// Refresh token tests
{
Expand All @@ -313,13 +313,13 @@ func TestHandleIntrospect(t *testing.T) {
testName: "Refresh Token: expired",
token: expiredRefreshToken,
response: inactiveResponse,
responseStatusCode: 401,
responseStatusCode: 200,
},
{
testName: "Refresh Token: active => false (wrong)",
token: "fake-token",
response: inactiveResponse,
responseStatusCode: 401,
responseStatusCode: 200,
},
}

Expand Down Expand Up @@ -380,7 +380,7 @@ func TestIntrospectErrHelper(t *testing.T) {
{
testName: "Inactive Token",
err: newIntrospectInactiveTokenError(),
resStatusCode: http.StatusUnauthorized,
resStatusCode: http.StatusOK,
resBody: "{\"active\":false}\n",
},
{
Expand Down

0 comments on commit 86e92aa

Please sign in to comment.