From da3eef6b93a65acc6d46ef1af970d16d437d4898 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=95=E0=A4=BE=E0=A4=B0=E0=A4=A4=E0=A5=8B=E0=A4=AB?= =?UTF-8?q?=E0=A5=8D=E0=A4=AB=E0=A5=87=E0=A4=B2=E0=A4=B8=E0=A5=8D=E0=A4=95?= =?UTF-8?q?=E0=A5=8D=E0=A4=B0=E0=A4=BF=E0=A4=AA=E0=A5=8D=E0=A4=9F=E2=84=A2?= Date: Tue, 5 Mar 2024 15:19:11 +0100 Subject: [PATCH] disable secure cookies in tests --- packages/cli/src/auth/auth.service.ts | 4 ++-- packages/cli/test/unit/auth/auth.service.test.ts | 4 ++-- packages/cli/test/unit/controllers/me.controller.test.ts | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/cli/src/auth/auth.service.ts b/packages/cli/src/auth/auth.service.ts index 4d615557bc4871..de3c512c2b1057 100644 --- a/packages/cli/src/auth/auth.service.ts +++ b/packages/cli/src/auth/auth.service.ts @@ -4,7 +4,7 @@ import { createHash } from 'crypto'; import { JsonWebTokenError, TokenExpiredError, type JwtPayload } from 'jsonwebtoken'; import config from '@/config'; -import { AUTH_COOKIE_NAME, RESPONSE_ERROR_MESSAGES, Time } from '@/constants'; +import { AUTH_COOKIE_NAME, RESPONSE_ERROR_MESSAGES, Time, inTest } from '@/constants'; import type { User } from '@db/entities/User'; import { UserRepository } from '@db/repositories/user.repository'; import { AuthError } from '@/errors/response-errors/auth.error'; @@ -79,7 +79,7 @@ export class AuthService { maxAge: this.jwtExpiration * Time.seconds.toMilliseconds, httpOnly: true, sameSite: 'lax', - secure: true, + secure: !inTest, }); } diff --git a/packages/cli/test/unit/auth/auth.service.test.ts b/packages/cli/test/unit/auth/auth.service.test.ts index 99d962c4616637..30674d41eb35d6 100644 --- a/packages/cli/test/unit/auth/auth.service.test.ts +++ b/packages/cli/test/unit/auth/auth.service.test.ts @@ -76,7 +76,7 @@ describe('AuthService', () => { httpOnly: true, maxAge: 604800000, sameSite: 'lax', - secure: true, + secure: false, }); }); }); @@ -164,7 +164,7 @@ describe('AuthService', () => { httpOnly: true, maxAge: 604800000, sameSite: 'lax', - secure: true, + secure: false, }); }); diff --git a/packages/cli/test/unit/controllers/me.controller.test.ts b/packages/cli/test/unit/controllers/me.controller.test.ts index 5c0e8348572074..f0f9b8458623a4 100644 --- a/packages/cli/test/unit/controllers/me.controller.test.ts +++ b/packages/cli/test/unit/controllers/me.controller.test.ts @@ -70,7 +70,7 @@ describe('MeController', () => { maxAge: expect.any(Number), httpOnly: true, sameSite: 'lax', - secure: true, + secure: false, }), ); @@ -188,7 +188,7 @@ describe('MeController', () => { maxAge: expect.any(Number), httpOnly: true, sameSite: 'lax', - secure: true, + secure: false, }), );