X-Git-Url: http://git.squeep.com/?p=websub-hub;a=blobdiff_plain;f=test%2Fsrc%2Fmanager.js;fp=test%2Fsrc%2Fmanager.js;h=9d8c380ff3b300b25d2841de4dffea19b6b05cf5;hp=cbd83243d3faecabdf8d77667151a230ac180f88;hb=41ae00113d39abada54823b7133c473b8fb758f5;hpb=acf63f7913320f8edb9db9dc31d13ec7ff5d104f diff --git a/test/src/manager.js b/test/src/manager.js index cbd8324..9d8c380 100644 --- a/test/src/manager.js +++ b/test/src/manager.js @@ -207,7 +207,7 @@ describe('Manager', function () { 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, @@ -254,7 +254,7 @@ describe('Manager', function () { }); 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); @@ -367,6 +367,34 @@ describe('Manager', function () { }); }); // 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');