mirror of
https://github.com/netbirdio/dex.git
synced 2026-05-22 18:43:53 -07:00
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:
@@ -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})
|
||||
|
||||
@@ -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",
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user