X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=test%2Fsrc%2Flogger.js;h=e28308c34413258b6abb6490aa47e11b612f0378;hb=f0bf29c75b0fd405ff92fa76f058e61162b87e43;hp=3441f940d40251caa678b4e20f5d1f2c839c2ddb;hpb=b0103b0d496262c438b40bc20304081dbfe41e73;p=squeep-indie-auther diff --git a/test/src/logger.js b/test/src/logger.js index 3441f94..e28308c 100644 --- a/test/src/logger.js +++ b/test/src/logger.js @@ -1,8 +1,8 @@ -/* eslint-env mocha */ +/* eslint-disable sonarjs/no-duplicate-string */ 'use strict'; const assert = require('assert'); -const sinon = require('sinon'); // eslint-disable-line node/no-unpublished-require +const sinon = require('sinon'); const Logger = require('../../src/logger'); const Config = require('../../config'); @@ -51,6 +51,32 @@ describe('Logger', function () { assert(logger.backend.info.args[0][0].includes('"********"')); }); + it('masks noisy cookie header', function () { + logger.info('testScope', 'message', { + ctx: { + cookie: { + squeepSession: 'blahblahblahblahblah', + }, + }, + }); + assert(logger.backend.info.called); + assert(logger.backend.info.args[0][0].includes('[scrubbed 20 bytes]')); + }); + + it('masks otp values', function () { + logger.info('teestScope', 'message', { + ctx: { + otpKey: '1234567890123456789012', + otpConfirmKey: '1234567890123456789012', + otpConfirmBox: 'xxxMysteryxxx', + otpState: 'xxxMysteryxxx', + }, + }); + assert(logger.backend.info.called); + assert(!logger.backend.info.args[0][0].includes('"1234567890123456789012"')); + assert(!logger.backend.info.args[0][0].includes('"xxxMysteryxxx"')); + }); + it('strips uninteresting scope dross', function () { logger.info('testScope', 'message', { ctx: {