X-Git-Url: http://git.squeep.com/?p=squeep-api-dingus;a=blobdiff_plain;f=test%2Flib%2Fcommon.js;h=bacd6be3d54d2aaa7e6b019c98e0e664050392dc;hp=a04bf614eeadac136f2df8ff44cf1519846d8221;hb=4778ea0b65e1f22f3d85cfa8bad0e1b29f87b7d3;hpb=3cf325b9e87b66e16f05c9bcae769eea72b207ed diff --git a/test/lib/common.js b/test/lib/common.js index a04bf61..bacd6be 100644 --- a/test/lib/common.js +++ b/test/lib/common.js @@ -141,6 +141,46 @@ describe('common', function () { }); }); // requestLogData + describe('obscureAuthorizationHeader', function () { + it('obscures basic data', function () { + const authHeader = 'Basic Zm9vOmJhcg=='; + const expected = 'Basic ************'; + const result = common.obscureAuthorizationHeader(authHeader); + assert.strictEqual(result, expected); + }); + it('obscures all of other types', function () { + const authHeader = 'someWeirdAuth'; + const expected = '*************'; + const result = common.obscureAuthorizationHeader(authHeader); + assert.strictEqual(result, expected); + }); + it('does nothing when empty', function () { + const authHeader = undefined; + const expected = undefined; + const result = common.obscureAuthorizationHeader(authHeader); + assert.strictEqual(result, expected); + }); + }); // obscureAuthorizationHeader + + describe('scrubHeaderObject', function () { + it('', function () { + const data = { + headers: { + 'foo': 'bar', + 'authorization': 'Basic Zm9vOmJhcg==', + }, + }; + const expected = { + headers: { + 'foo': 'bar', + 'authorization': 'Basic ************', + }, + }; + common.scrubHeaderObject(data); + assert.deepStrictEqual(data, expected); + }); + }); // scrubHeaderObject + describe('responseLogData', function () { it('gives data', function () { const res = {