From 6c3ea46ad7c41bb4289885ea578d3d4aeedc6d63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20M=C3=A9ndez=20Murias?= Date: Sun, 7 Apr 2024 21:59:34 +0200 Subject: [PATCH] Test for /verify added to gatewayservice tests --- gatewayservice/gateway-service.test.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gatewayservice/gateway-service.test.js b/gatewayservice/gateway-service.test.js index 06897177..61adf000 100644 --- a/gatewayservice/gateway-service.test.js +++ b/gatewayservice/gateway-service.test.js @@ -65,6 +65,8 @@ describe('Gateway Service', () => { } ] }); + }else if(url.endsWith('/verify')){ + return Promise.resolve({ data: { username: 'testuser' } }); } }); // Test /health endpoint @@ -85,6 +87,14 @@ describe('Gateway Service', () => { expect(response.statusCode).toBe(200); expect(response.body.token).toBe('mockedToken'); }); + // Test /verify endpoint + it('should verify authorization token with auth service', async () => { + const response = await request(app) + .get('/verify') + .set('Authorization', 'Bearer mockedToken'); + expect(response.statusCode).toBe(200); + expect(response.body).toHaveProperty('username', 'testuser'); + }); // Test /adduser endpoint it('should forward add user request to user service', async () => {