From d5470ec47f5191ce637226cb1390efde70be98a3 Mon Sep 17 00:00:00 2001 From: Karan Shah Date: Fri, 4 Feb 2022 14:24:03 +0000 Subject: [PATCH] Added a test for appending the API key to a URL parameter Signed-off-by: Karan Shah --- .../src/service/router.test.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/plugins/airbrake-backend/src/service/router.test.ts b/plugins/airbrake-backend/src/service/router.test.ts index f36d36d6f1..7fae43fe8c 100644 --- a/plugins/airbrake-backend/src/service/router.test.ts +++ b/plugins/airbrake-backend/src/service/router.test.ts @@ -58,7 +58,7 @@ describe('createRouter', () => { }); describe('GET /api', () => { - it('appends the API Key properly', () => { + it('appends the API Key properly with no other url parameters', () => { const options: RouterOptions = { logger: getVoidLogger(), airbrakeConfig, @@ -71,5 +71,21 @@ describe('createRouter', () => { '/random/endpoint?key=fakeApiKey', ); }); + + it('appends the API Key properly despite there being other URL parameters', () => { + const options: RouterOptions = { + logger: getVoidLogger(), + airbrakeConfig, + }; + const pathRewrite = generateAirbrakePathRewrite(options) as ( + path: string, + ) => string; + + expect( + pathRewrite( + '/airbrake-backend/api/random/endpoint?param1=123¶m2=abc', + ), + ).toBe('/random/endpoint?param1=123¶m2=abc&key=fakeApiKey'); + }); }); });