display history of topic updates on topic details page
[websub-hub] / test / src / service.js
index 7a97cf5366f88a70a32702170658b4f2e50c7c97..bc74ff5c6dac6faff30fa8e14928c21e7d3e5285 100644 (file)
@@ -20,6 +20,7 @@ describe('Service', function () {
     options = new Config('test');
     service = new Service(stubLogger, stubDb, options);
     sinon.stub(service.manager);
+    sinon.stub(service.sessionManager);
     sinon.stub(service.authenticator);
     sinon.stub(service, 'setResponseType');
     sinon.stub(service, 'serveFile');
@@ -60,6 +61,20 @@ describe('Service', function () {
     });
   }); // maybeIngestBody
 
+  describe('setHeadHandler', function () {
+    it('covers', function () {
+      const origEnd = res.end;
+      sinon.stub(Service.__proto__, 'setHeadHandler');
+      ctx.responseBody = 'data';
+      req.method = 'HEAD';
+      Service.setHeadHandler(req, res, ctx);
+      res.end('foop');
+      assert(Service.__proto__.setHeadHandler.called);
+      assert(origEnd.called);
+      assert(!('responseBody' in ctx));
+    });
+  }); // setHeadHandler
+
   describe('handlerPostRoot', function () {
     it('covers public mode', async function () {
       await service.handlerPostRoot(req, res, ctx);
@@ -93,16 +108,23 @@ describe('Service', function () {
   }); // handlerGetHealthcheck
 
   describe('handlerGetInfo', function () {
-    it('covers', async function() {
+    it('covers', async function () {
       await service.handlerGetInfo(req, res, ctx);
       assert(service.manager.getInfo.called);
     });
   }); // handlerGetInfo
 
+  describe('handlerGetHistorySVG', function () {
+    it('covers', async function () {
+      await service.handlerGetHistorySVG(req, res, ctx);
+      assert(service.manager.getHistorySVG.called);
+    });
+  }); // handlerGetHistorySVG
+
   describe('handlerGetAdminOverview', function () {
     it('covers', async function () {
       await service.handlerGetAdminOverview(req, res, ctx);
-      assert(service.authenticator.required.called);
+      assert(service.authenticator.sessionRequired.called);
       assert(service.manager.getAdminOverview.called);
     })
   }); // handlerGetAdminOverview
@@ -110,7 +132,7 @@ describe('Service', function () {
   describe('handlerGetAdminTopicDetails', function () {
     it('covers', async function () {
       await service.handlerGetAdminTopicDetails(req, res, ctx);
-      assert(service.authenticator.required.called);
+      assert(service.authenticator.sessionRequired.called);
       assert(service.manager.getTopicDetails.called);
     })
   }); // handlerGetAdminTopicDetails
@@ -119,7 +141,7 @@ describe('Service', function () {
     it('covers', async function () {
       service.serveFile.resolves();
       await service.handlerPostAdminProcess(req, res, ctx);
-      assert(service.authenticator.required.called);
+      assert(service.authenticator.apiRequiredLocal.called);
       assert(service.manager.processTasks.called);
     });
   }); // handlerPostAdminProcess
@@ -128,7 +150,7 @@ describe('Service', function () {
     it('covers', async function () {
       sinon.stub(service, 'bodyData').resolves();
       await service.handlerUpdateTopic(req, res, ctx);
-      assert(service.authenticator.required.called);
+      assert(service.authenticator.apiRequiredLocal.called);
       assert(service.manager.updateTopic.called);
     });
   }); // handlerUpdateTopic
@@ -137,9 +159,38 @@ describe('Service', function () {
     it('covers', async function () {
       sinon.stub(service, 'bodyData').resolves();
       await service.handlerUpdateSubscription(req, res, ctx);
-      assert(service.authenticator.required.called);
+      assert(service.authenticator.apiRequiredLocal.called);
       assert(service.manager.updateSubscription.called);
     });
   }); // handlerUpdateSubscription
 
+  describe('handlerGetAdminLogin', function () {
+    it('covers', async function () {
+      await service.handlerGetAdminLogin(req, res, ctx);
+      assert(service.sessionManager.getAdminLogin.called);
+    });
+  }); // handlerGetAdminLogin
+
+  describe('handlerPostAdminLogin', function () {
+    it('covers', async function () {
+      sinon.stub(service, 'bodyData').resolves();
+      await service.handlerPostAdminLogin(req, res, ctx);
+      assert(service.sessionManager.postAdminLogin.called);
+    });
+  }); // handlerPostAdminLogin
+
+  describe('handlerGetAdminLogout', function () {
+    it('covers', async function () {
+      await service.handlerGetAdminLogout(req, res, ctx);
+      assert(service.sessionManager.getAdminLogout.called);
+    });
+}); // handlerGetAdminLogout
+
+  describe('handlerGetAdminIA', function () {
+    it('covers', async function () {
+      await service.handlerGetAdminIA(req, res, ctx);
+      assert(service.sessionManager.getAdminIA.called);
+    });
+  }); // handlerGetAdminIA
+
 });
\ No newline at end of file