minor documentation updates
[squeep-api-dingus] / test / lib / common.js
index a04bf614eeadac136f2df8ff44cf1519846d8221..57c4113a9db986dbee499942e6e11ea0a78964b9 100644 (file)
@@ -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 = {
@@ -156,6 +196,32 @@ describe('common', function () {
     });
   }); // responseLogData
 
+  describe('handlerLogData', function () {
+    it('covers', function () {
+      const req = {
+        method: 'GET',
+        somethingElse: 'blah',
+      };
+      const res = {
+        getHeaders: () => ({}),
+        statusCode: 200,
+        blah: 'blah',
+      };
+      const ctx = {};
+      const result = common.handlerLogData(req, res, ctx);
+      assert.deepStrictEqual(result, {
+        req: {
+          method: 'GET',
+        },
+        res: {
+          headers: {},
+          statusCode: 200,
+        },
+        ctx: {},
+      });
+    });
+  }); // handlerLogData
+
   describe('setOptions', function () {
     it('sets options', function () {
       const expected = {