From 09c30d28d4e3414315ae8c5235d820be44a7fe72 Mon Sep 17 00:00:00 2001 From: Filip Rojek Date: Thu, 2 May 2024 00:37:59 +0200 Subject: [PATCH] Added: signin api --- api/src/routes/api_v1.ts | 1 + api/tests/auth.test.ts | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/api/src/routes/api_v1.ts b/api/src/routes/api_v1.ts index c8d274c..8789666 100644 --- a/api/src/routes/api_v1.ts +++ b/api/src/routes/api_v1.ts @@ -10,6 +10,7 @@ const router = Router(); //const mws = [requireAuth, handleValidation.handleValidationError]; router.post("/auth/signup",validate(AuthVal.signup) , authController.signup_post); +router.post("/auth/signin",validate(AuthVal.signin) , authController.signin_post); //router.post( // "/login", diff --git a/api/tests/auth.test.ts b/api/tests/auth.test.ts index ffaba26..acdd09c 100644 --- a/api/tests/auth.test.ts +++ b/api/tests/auth.test.ts @@ -172,7 +172,10 @@ describe('POST /api/v1/auth/signin', () => { email: 'thisistest@host.local', password: 'Test12365465132' }); + expect(res.statusCode).toBe(401); + expect(res.header['set-cookie'][0]).toContain("jwt=; Max-Age=0") + expect(res.header['set-cookie'][1]).toContain("auth=false") }); test('should login an user', async () => { @@ -182,6 +185,8 @@ describe('POST /api/v1/auth/signin', () => { }); expect(res.statusCode).toBe(200); + expect(res.header['set-cookie'][0]).toContain("jwt=") + expect(res.header['set-cookie'][1]).toContain("auth=true") }); });