refactor of authentication and html-templates into separate modules
[websub-hub] / test / src / service.js
index a00b2cea49d882790e8be6e427d913be467af6ff..23b50e15eb0a970e30a7f8bc00bd558d3d64e150 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,14 +61,6 @@ describe('Service', function () {
     });
   }); // maybeIngestBody
 
-  describe('handlerRedirect', function () {
-    it('covers', async function () {
-      await service.handlerRedirect(req, res, ctx, '/');
-      assert(res.end.called);
-      assert.strictEqual(res.statusCode, 307);
-    });
-  }); // handlerRedirect
-
   describe('handlerPostRoot', function () {
     it('covers public mode', async function () {
       await service.handlerPostRoot(req, res, ctx);
@@ -110,7 +103,7 @@ describe('Service', function () {
   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
@@ -118,24 +111,16 @@ 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
 
-  describe('handlerGetStaticFile', function () {
-    it('covers', async function () {
-      service.serveFile.resolves();
-      await service.handlerGetStaticFile(req, res, ctx);
-      assert(service.serveFile.called);
-    });
-  }); // handlerGetStaticFile
-
   describe('handlerPostAdminProcess', 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
@@ -144,7 +129,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
@@ -153,9 +138,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