manager.db.topicGetById.resolves({
id: '56c557ce-e667-11eb-bd80-0025905f714a',
created: new Date(),
- url: 'https://example.com/',
+ url: 'https://example.com/topic',
leaseSecondsPreferred: 123,
leaseSecondsMin: 12,
leaseSecondsMax: 123456789,
});
it('covers matching profile', async function () {
ctx.session = {
- authenticatedProfile: 'https://example.com/profile',
+ authenticatedProfile: 'https://example.com/',
};
await manager.getTopicDetails(res, ctx);
assert(ctx.topic);
});
}); // postRoot
+ describe('_profileControlsTopic', function () {
+ let profileUrlObj, topicUrlObj;
+ it('allows exact match', function () {
+ profileUrlObj = new URL('https://profile.example.com/');
+ topicUrlObj = new URL('https://profile.example.com/');
+ const result = Manager._profileControlsTopic(profileUrlObj, topicUrlObj);
+ assert.strictEqual(result, true);
+ });
+ it('allows descendent-path match', function () {
+ profileUrlObj = new URL('https://profile.example.com/');
+ topicUrlObj = new URL('https://profile.example.com/feed/atom');
+ const result = Manager._profileControlsTopic(profileUrlObj, topicUrlObj);
+ assert.strictEqual(result, true);
+ });
+ it('disallows non-descendent-path', function () {
+ profileUrlObj = new URL('https://profile.example.com/itsame');
+ topicUrlObj = new URL('https://profile.example.com/');
+ const result = Manager._profileControlsTopic(profileUrlObj, topicUrlObj);
+ assert.strictEqual(result, false);
+ });
+ it('disallows non-matched host', function () {
+ profileUrlObj = new URL('https://profile.example.com/itsame');
+ topicUrlObj = new URL('https://elsewhere.example.com/itsame/feed');
+ const result = Manager._profileControlsTopic(profileUrlObj, topicUrlObj);
+ assert.strictEqual(result, false);
+ });
+ }); // _profileControlsTopic
+
describe('_getRootData', function () {
it('extracts expected values', function () {
req.getHeader.returns('user@example.com');
- ctx = Object.assign({}, testData.validSubscribeCtx)
+ ctx = Object.assign({}, testData.validSubscribeCtx);
const result = Manager._getRootData(req, ctx);
assert.deepStrictEqual(result, testData.validRootData);
});
assert(manager.db.topicFetchRequested.called);
assert.strictEqual(res.statusCode, 202);
assert(res.end.called);
- assert(manager.communication.topicFetchClaimAndProcessById.called)
+ assert(manager.communication.topicFetchClaimAndProcessById.called);
});
it('covers no immediate processing', async function() {
manager.options.manager.processImmediately = false;
assert(manager.db.topicFetchRequested.called);
assert.strictEqual(res.statusCode, 202);
assert(res.end.called);
- assert(!manager.communication.topicFetchClaimAndProcessById.called)
+ assert(!manager.communication.topicFetchClaimAndProcessById.called);
});
}); // _publishRequest