Skip to content

Commit

Permalink
Add test for censoring response_content of null
Browse files Browse the repository at this point in the history
  • Loading branch information
kola-er committed Apr 17, 2024
1 parent 0d46855 commit 14c706d
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions packages/core/test/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,39 @@ describe('logger', () => {
]);
});

it('should leave response content of null uncensored', async () => {
const event = {
method: 'authentication.sessionConfig.perform',
};
const logger = createlogger(event, options);

const { message, data } = prepareTestRequest({
resBody: JSON.stringify(null),
});

await logger(message, data);
const response = await logger.end(1000);
response.status.should.eql(200);

response.content.logs.should.deepEqual([
{
message: '200 POST http://example.com',
data: {
log_type: 'http',
request_type: 'devplatform-outbound',
request_url: 'http://example.com',
request_method: 'POST',
request_headers: 'accept: application/json',
request_data: '{}',
request_via_client: true,
response_status_code: 200,
response_headers: 'content-type: application/json',
response_content: 'null',
},
},
]);
});

it('should handle missing bits of the request/response', async () => {
// this test should, as closely as possible, match what we actually log after an http request from z.request
const bundle = {
Expand Down

0 comments on commit 14c706d

Please sign in to comment.