openvibers/openvibe.examples Commits
Developer path release step: Codes lists every release but drafts, a revoked one included (marked revoked); the step and the mock expect that (the first production run showed it)
Changes
@@@ -11,7 +11,7 @@* user and returns a Network user token for it; login returns one for an existing user (the mock* does not check passwords). It also stands in for OpenVibe.Codes' release API (the release step):* an app token for openvibe.codes carrying codes.release.manage manages the app's own releases,-- * draft → published → deprecated → revoked, and the public list shows published and deprecated ones.++ * draft → published → deprecated → revoked, and the public list shows every release but drafts, like Codes.* Everything else is the platform mock's own.*/const { createMockPlatform } = require('openvibe-sdk/testing');@@@ -26,7 +26,7 @@ function withAccounts(platform, network = PRODUCTION_NETWORK) {function codes(url, method, init) {const m = url.pathname.match(/^\/api\/v1\/(?:apps\/(app_[0-9A-Z]+)\/releases|releases\/([a-z0-9_]+)\/(publish|deprecate|revoke))$/i);if (!m) return reply(404, { code: 'route.not_found' });-- const list = (appId) => [...releases.values()].filter((r) => r.app_id === appId && ['published', 'deprecated'].includes(r.status));++ const list = (appId) => [...releases.values()].filter((r) => r.app_id === appId && r.status !== 'draft');if (m[1] && method === 'GET') return reply(200, { app_id: m[1], releases: list(m[1]) });let claims = null;try { claims = JSON.parse(Buffer.from(String((init.headers || {}).Authorization || '').replace(/^Bearer /, '').split('.')[1], 'base64url').toString('utf8')); } catch { claims = null; }@@@ -14,7 +14,8 @@* 6. media examples/media-uploader: upload a small file, read it back, delete it* 7. events examples/event-subscriber: publish app.<project_key>.developer_path.ran, pull it* 8. release as the app, on OpenVibe.Codes: a sandbox release of itself goes draft →-- * published → deprecated → revoked, checked in the public list at each step++ * published → deprecated → revoked, checked in the public list at each step (a++ * draft is never listed; a revoked release stays listed, marked revoked)* (roadmap WS-N task 5, the app release flow in production)* 9. credentials rotate with no overlap, revoke the first credential; the old secret is refused* at /oauth/token and the new one works@@@ -241,14 +242,15 @@ async function runDeveloperPath({ network = PRODUCTION_NETWORK, codes = PRODUCTIif (!draft || draft.status !== 'draft') throw new Error(`the new release is ${draft && draft.status}, not draft`);if (await listed(draft.id)) throw new Error('a draft is listed publicly');say(`draft ${draft.id} (${version})`);-- const steps = [['publish', {}, 'published', true], ['deprecate', { reason: 'developer path check' }, 'deprecated', true], ['revoke', { reason: 'developer path check done' }, 'revoked', false]];-- for (const [action, body, want, shown] of steps) {++ // Codes lists every release but drafts, a revoked one included (marked revoked), so people see it was pulled.++ const steps = [['publish', {}, 'published'], ['deprecate', { reason: 'developer path check' }, 'deprecated'], ['revoke', { reason: 'developer path check done' }, 'revoked']];++ for (const [action, body, want] of steps) {const r = await call('POST', `/releases/${draft.id}/${action}`, body);const status = (r.release || r).status;if (status !== want) throw new Error(`${action} left it ${status}, not ${want}`);const pub = await listed(draft.id);-- if (shown ? !(pub && pub.status === want) : pub) throw new Error(`after ${action} the public list ${pub ? `shows it ${pub.status}` : 'does not show it'}`);-- say(`${action}: ${want}${shown ? ', in the public list' : ', gone from the public list'}`);++ if (!(pub && pub.status === want)) throw new Error(`after ${action} the public list ${pub ? `shows it ${pub.status}` : 'does not show it'}`);++ say(`${action}: ${want}, and so in the public list`);}});
@@ -11,7 +11,7 @@
@@ -11,7 +11,7 @@
* user and returns a Network user token for it; login returns one for an existing user (the mock
* user and returns a Network user token for it; login returns one for an existing user (the mock
* does not check passwords). It also stands in for OpenVibe.Codes' release API (the release step):
* does not check passwords). It also stands in for OpenVibe.Codes' release API (the release step):
* an app token for openvibe.codes carrying codes.release.manage manages the app's own releases,
* an app token for openvibe.codes carrying codes.release.manage manages the app's own releases,
- * draft → published → deprecated → revoked, and the public list shows published and deprecated ones.
+ * draft → published → deprecated → revoked, and the public list shows every release but drafts, like Codes.
* Everything else is the platform mock's own.
* Everything else is the platform mock's own.
*/
*/
const { createMockPlatform } = require('openvibe-sdk/testing');
const { createMockPlatform } = require('openvibe-sdk/testing');
@@ -26,7 +26,7 @@ function withAccounts(platform, network = PRODUCTION_NETWORK) {
@@ -26,7 +26,7 @@ function withAccounts(platform, network = PRODUCTION_NETWORK) {
function codes(url, method, init) {
function codes(url, method, init) {
const m = url.pathname.match(/^\/api\/v1\/(?:apps\/(app_[0-9A-Z]+)\/releases|releases\/([a-z0-9_]+)\/(publish|deprecate|revoke))$/i);
const m = url.pathname.match(/^\/api\/v1\/(?:apps\/(app_[0-9A-Z]+)\/releases|releases\/([a-z0-9_]+)\/(publish|deprecate|revoke))$/i);
if (!m) return reply(404, { code: 'route.not_found' });
if (!m) return reply(404, { code: 'route.not_found' });
- const list = (appId) => [...releases.values()].filter((r) => r.app_id === appId && ['published', 'deprecated'].includes(r.status));
+ const list = (appId) => [...releases.values()].filter((r) => r.app_id === appId && r.status !== 'draft');
if (m[1] && method === 'GET') return reply(200, { app_id: m[1], releases: list(m[1]) });
if (m[1] && method === 'GET') return reply(200, { app_id: m[1], releases: list(m[1]) });
let claims = null;
let claims = null;
try { claims = JSON.parse(Buffer.from(String((init.headers || {}).Authorization || '').replace(/^Bearer /, '').split('.')[1], 'base64url').toString('utf8')); } catch { claims = null; }
try { claims = JSON.parse(Buffer.from(String((init.headers || {}).Authorization || '').replace(/^Bearer /, '').split('.')[1], 'base64url').toString('utf8')); } catch { claims = null; }
@@ -14,7 +14,8 @@
@@ -14,7 +14,8 @@
* 6. media examples/media-uploader: upload a small file, read it back, delete it
* 6. media examples/media-uploader: upload a small file, read it back, delete it
* 7. events examples/event-subscriber: publish app.<project_key>.developer_path.ran, pull it
* 7. events examples/event-subscriber: publish app.<project_key>.developer_path.ran, pull it
* 8. release as the app, on OpenVibe.Codes: a sandbox release of itself goes draft →
* 8. release as the app, on OpenVibe.Codes: a sandbox release of itself goes draft →
- * published → deprecated → revoked, checked in the public list at each step
+ * published → deprecated → revoked, checked in the public list at each step (a
+ * draft is never listed; a revoked release stays listed, marked revoked)
* (roadmap WS-N task 5, the app release flow in production)
* (roadmap WS-N task 5, the app release flow in production)
* 9. credentials rotate with no overlap, revoke the first credential; the old secret is refused
* 9. credentials rotate with no overlap, revoke the first credential; the old secret is refused
* at /oauth/token and the new one works
* at /oauth/token and the new one works
@@ -241,14 +242,15 @@ async function runDeveloperPath({ network = PRODUCTION_NETWORK, codes = PRODUCTI
@@ -241,14 +242,15 @@ async function runDeveloperPath({ network = PRODUCTION_NETWORK, codes = PRODUCTI
if (!draft || draft.status !== 'draft') throw new Error(`the new release is ${draft && draft.status}, not draft`);
if (!draft || draft.status !== 'draft') throw new Error(`the new release is ${draft && draft.status}, not draft`);
if (await listed(draft.id)) throw new Error('a draft is listed publicly');
if (await listed(draft.id)) throw new Error('a draft is listed publicly');
say(`draft ${draft.id} (${version})`);
say(`draft ${draft.id} (${version})`);
- const steps = [['publish', {}, 'published', true], ['deprecate', { reason: 'developer path check' }, 'deprecated', true], ['revoke', { reason: 'developer path check done' }, 'revoked', false]];
- for (const [action, body, want, shown] of steps) {
+ // Codes lists every release but drafts, a revoked one included (marked revoked), so people see it was pulled.
+ const steps = [['publish', {}, 'published'], ['deprecate', { reason: 'developer path check' }, 'deprecated'], ['revoke', { reason: 'developer path check done' }, 'revoked']];
+ for (const [action, body, want] of steps) {
const r = await call('POST', `/releases/${draft.id}/${action}`, body);
const r = await call('POST', `/releases/${draft.id}/${action}`, body);
const status = (r.release || r).status;
const status = (r.release || r).status;
if (status !== want) throw new Error(`${action} left it ${status}, not ${want}`);
if (status !== want) throw new Error(`${action} left it ${status}, not ${want}`);
const pub = await listed(draft.id);
const pub = await listed(draft.id);
- if (shown ? !(pub && pub.status === want) : pub) throw new Error(`after ${action} the public list ${pub ? `shows it ${pub.status}` : 'does not show it'}`);
- say(`${action}: ${want}${shown ? ', in the public list' : ', gone from the public list'}`);
+ if (!(pub && pub.status === want)) throw new Error(`after ${action} the public list ${pub ? `shows it ${pub.status}` : 'does not show it'}`);
+ say(`${action}: ${want}, and so in the public list`);
}
}
});
});