keep sensitive credentials out of logs
[websub-hub] / test / src / communication.js
index 7c622274a8dfa0d00e2350c168bc356559d6eb24..960a0f994b27a572236a92131638b326c59f4ece 100644 (file)
@@ -405,6 +405,23 @@ describe('Communication', function () {
       assert(communication.db.verificationComplete.called);
     });
 
+    it('unsubscription from deleted topic deletes topic', async function () {
+      communication.db.verificationGetById.restore();
+      verification.mode = 'unsubscribe';
+      sinon.stub(communication.db, 'verificationGetById').resolves(verification);
+      communication.db.topicGetById.restore();
+      sinon.stub(communication.db, 'topicGetById').resolves({
+        ...topic,
+        isDeleted: true,
+      });
+
+      await communication.verificationProcess(dbCtx, callback, topicId, requestId);
+
+      assert(communication.db.subscriptionDelete.called);
+      assert(communication.db.verificationComplete.called);
+      assert(communication.db.topicPendingDelete.called);
+    });
+
     it('unsubscription denial succeeds', async function () {
       communication.db.verificationGetById.restore();
       verification.mode = 'unsubscribe';
@@ -837,8 +854,9 @@ describe('Communication', function () {
   }); // verificationClaimAndProcessById
 
   describe('workFeed', function () {
-    let wanted;
+    let stubCtx, wanted;
     beforeEach(function () {
+      stubCtx = {};
       sinon.stub(communication, 'topicFetchProcess');
       sinon.stub(communication, 'verificationProcess');
       sinon.stub(communication, 'subscriptionDeliveryProcess');
@@ -853,12 +871,13 @@ describe('Communication', function () {
       const expectedLength = [topicIds, verificationIds, subscriptionIds].map((x) => x.length).reduce((a, b) => a + b, 0);
       wanted = 10;
 
-      const result = await communication.workFeed(wanted);
+      const result = await communication.workFeed(stubCtx, wanted);
 
       assert.strictEqual(result.length, expectedLength);
     });
     it('covers no wanted work', async function () {
-      const result = await communication.workFeed(0);
+      wanted = 0;
+      const result = await communication.workFeed(stubCtx, wanted);
       assert.strictEqual(result.length, 0);
       assert(!communication.db.topicFetchClaim.called);
       assert(!communication.db.verificationClaim.called);
@@ -871,7 +890,7 @@ describe('Communication', function () {
       const expectedLength = topicIds.length;
       wanted = 10;
 
-      const result = await communication.workFeed(wanted);
+      const result = await communication.workFeed(stubCtx, wanted);
 
       assert.strictEqual(result.length, expectedLength);
     });