openvibers/openvibe.mediahub Commits

agent.json: what a watch page's id is, and that it never changes meaning (AGT-4) (#279)

OP OpenVibers committed 10 days ago · 0a5733ebcd · 2 files, +10 −0

openvibe.video's manifest names its id rule under policy.stableIds: /v/{id} and /c/{id} carry
OpenVibe.Media's recording and clip ids, numbered by an identity column, never reused or renumbered;
a deleted, private or missing one answers 404, never another item. The test checks the manifest and
that a private recording's page is a 404.

Changes

ddiff --git a/server/agent-descriptor.js b/server/agent-descriptor.js
iindex 6cca8d3..e3297c1 100644
---- a/server/agent-descriptor.js
++++ b/server/agent-descriptor.js
@@@ -13,5 +13,11 @@ module.exports = {
policy: {
auth: ['none', 'Network OIDC'],
rateLimit: 'The public watch pages are not rate-limited by the app; the playlist API is limited to 120 reads a minute and 3,000 an hour per caller',
++ // What an id in a watch page's address is, and that it never changes meaning (AGT-4). The ids are OpenVibe.Media's:
++ // its vods and clips tables number them with a PostgreSQL identity column (migrations/0001_initial.sql).
++ stableIds: [
++ { kind: 'recording', url: 'https://openvibe.video/v/{id}', id: 'OpenVibe.Media\'s recording id, a positive integer from an identity column: never reused or renumbered, even after the recording is deleted', gone: 'a deleted, private or missing recording answers 404, never another recording' },
++ { kind: 'clip', url: 'https://openvibe.video/c/{id}', id: 'OpenVibe.Media\'s clip id, the same kind of integer: never reused or renumbered', gone: 'a deleted, private or missing clip answers 404, never another clip' },
++ ],
},
};
ddiff --git a/test/video-agent-layer.test.js b/test/video-agent-layer.test.js
iindex 22b4663..ce2dfb1 100644
---- a/test/video-agent-layer.test.js
++++ b/test/video-agent-layer.test.js
@@@ -75,6 +75,9 @@ function vreq(base, path, { method = 'GET', cookie, host = 'openvibe.video', acc
assert.strictEqual(d.llms, 'https://openvibe.video/llms.txt');
assert.strictEqual(d.sitemap, 'https://openvibe.video/sitemap.xml');
assert.deepStrictEqual(d.policy.auth, ['none', 'Network OIDC']);
++ // AGT-4: the id rule of the watch pages, as the pages behave (a private or missing id is a 404 below).
++ assert.deepStrictEqual(d.policy.stableIds.map((x) => [x.kind, x.url]), [['recording', 'https://openvibe.video/v/{id}'], ['clip', 'https://openvibe.video/c/{id}']]);
++ assert.ok(d.policy.stableIds.every((x) => /never reused/.test(x.id) && /404/.test(x.gone)));
const drive = await vreq(t.base, '/.well-known/agent.json', { host: 'openvibe.download' });
assert.strictEqual(drive.status, 200, 'the drive answers with its own manifest');
const dd = JSON.parse(drive.text);
@@@ -130,6 +133,7 @@ function vreq(base, path, { method = 'GET', cookie, host = 'openvibe.video', acc
assert.strictEqual((await vreq(t.base, '/v/103.md')).status, 404, 'a private recording is not a twin');
assert.strictEqual((await vreq(t.base, '/v/999.md')).status, 404, 'nor is a missing one');
assert.strictEqual((await vreq(t.base, '/v/999')).status, 404, 'and the page is a real 404');
++ assert.strictEqual((await vreq(t.base, '/v/103')).status, 404, 'a private recording\'s page is a 404 to anyone else, as the manifest says');
});
await live.close();