fix: wrong error code returned in case of inactive token (#3441)

Signed-off-by: Romain Caire <super.cairos@gmail.com>
This commit is contained in:
Romain Caire
2024-03-31 16:47:38 +02:00
committed by GitHub
parent 7225198ae7
commit 86e92aaf1a
2 changed files with 5 additions and 5 deletions
+1 -1
View File
@@ -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})
+4 -4
View File
@@ -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
{
@@ -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,
},
}
@@ -380,7 +380,7 @@ func TestIntrospectErrHelper(t *testing.T) {
{
testName: "Inactive Token",
err: newIntrospectInactiveTokenError(),
resStatusCode: http.StatusUnauthorized,
resStatusCode: http.StatusOK,
resBody: "{\"active\":false}\n",
},
{