From f053a0cd3689eb294015b5c75e4b89ab545db7f8 Mon Sep 17 00:00:00 2001 From: golobitch Date: Sun, 17 Nov 2024 09:16:42 +0100 Subject: [PATCH] feat(auth): return GNAP 404 error if token cannot be rotated --- packages/auth/src/accessToken/routes.test.ts | 4 ++-- packages/auth/src/accessToken/routes.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/auth/src/accessToken/routes.test.ts b/packages/auth/src/accessToken/routes.test.ts index ab68870b5b..ac9fb14964 100644 --- a/packages/auth/src/accessToken/routes.test.ts +++ b/packages/auth/src/accessToken/routes.test.ts @@ -484,12 +484,12 @@ describe('Access Token Routes', (): void => { ) }) - test('Returns status 400 if could not rotate token', async (): Promise => { + test('Returns status 404 if could not rotate token', async (): Promise => { const ctx = createTokenHttpSigContext(token, grant) jest.spyOn(accessTokenService, 'rotate').mockResolvedValueOnce(undefined) await expect(accessTokenRoutes.rotate(ctx)).rejects.toMatchObject({ - status: 400, + status: 404, code: GNAPErrorCode.InvalidRotation, message: 'invalid access token' }) diff --git a/packages/auth/src/accessToken/routes.ts b/packages/auth/src/accessToken/routes.ts index 3c064e0297..739b32b1ed 100644 --- a/packages/auth/src/accessToken/routes.ts +++ b/packages/auth/src/accessToken/routes.ts @@ -164,7 +164,7 @@ async function rotateToken( const errorMessage = error instanceof Error ? error.message : 'Could not rotate token' throw new GNAPServerRouteError( - 400, + 404, GNAPErrorCode.InvalidRotation, errorMessage )