From 022e4a28a86f631156616b614e469771bb8d97c3 Mon Sep 17 00:00:00 2001 From: pgayvallet Date: Tue, 7 Jul 2020 13:18:44 +0200 Subject: [PATCH] add test for encoded querystring --- .../client/configure_client.test.ts | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/core/server/elasticsearch/client/configure_client.test.ts b/src/core/server/elasticsearch/client/configure_client.test.ts index ba61e940d601b..32da142764a78 100644 --- a/src/core/server/elasticsearch/client/configure_client.test.ts +++ b/src/core/server/elasticsearch/client/configure_client.test.ts @@ -179,6 +179,42 @@ describe('configureClient', () => { `); }); + it('properly encode queries', () => { + const client = configureClient( + createFakeConfig({ + logQueries: true, + }), + { logger, scoped: false } + ); + + const response = createApiResponse({ + body: {}, + statusCode: 200, + params: { + method: 'GET', + path: '/foo', + querystring: { city: 'Münich' }, + }, + }); + + client.emit('response', null, response); + + expect(loggingSystemMock.collect(logger).debug).toMatchInlineSnapshot(` + Array [ + Array [ + "200 + GET /foo + city=M%C3%BCnich", + Object { + "tags": Array [ + "query", + ], + }, + ], + ] + `); + }); + it('logs queries even in case of errors if `logQueries` is true', () => { const client = configureClient( createFakeConfig({