Skip to content

Commit f84b663

Browse files
committed
test(cmc): update [CMCL1OA] for readOffer omit-streams contract
The contract test was asserting the buggy intermediate shape from PR #67 (`streams: [':_cmc:_internal:offer']`). PR #68 corrected that to omit the streams filter entirely (parent stream isn't auto-provisioned). Update the assertion to match the final correct wire-shape: no `streams`, no `streamIds`, with `types: ['consent/request-cmc']` as the only filter.
1 parent 7b7fe2a commit f84b663

1 file changed

Lines changed: 20 additions & 6 deletions

File tree

components/pryv-cmc/test/cmc.test.js

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,23 @@ describe('[CMCL1] @pryv/cmc Level-1 protocol functions', function () {
322322
};
323323
}
324324

325-
it('[CMCL1OA] calls events.get with `streams` (not `streamIds`) — schema-rejected otherwise', async function () {
325+
it('[CMCL1OA] calls events.get WITHOUT a streams filter — relies on capability-access permissions to narrow the response', async function () {
326+
// Bug history (two PRs back-to-back):
327+
// 1. PR #67 fixed `streamIds → streams` (api-server schema rejects
328+
// `streamIds` on events.get with OBJECT_ADDITIONAL_PROPERTIES).
329+
// 2. PR #68 fixed the resulting `unknown-referenced-resource` —
330+
// the parent stream `:_cmc:_internal:offer` is NOT
331+
// auto-provisioned on every user account (only the
332+
// per-capability children `:_cmc:_internal:offer:<capId>` are,
333+
// and the accepter doesn't know <capId> from the capabilityUrl).
334+
// The capability access's permissions already narrow the
335+
// response to the one offer event this token can read; a
336+
// streams filter at the request level is wrong.
337+
//
338+
// Contract: events.get is called WITHOUT a `streams` field (and
339+
// without the typo `streamIds`). The `types` filter is kept as
340+
// defense in case the offer stream ever holds more than one event
341+
// in future revisions.
326342
const calls = [];
327343
const fakePryv = fakePryvWithApiOne(async function (method, params, expectedKey) {
328344
calls.push({ method, params, expectedKey });
@@ -332,14 +348,12 @@ describe('[CMCL1] @pryv/cmc Level-1 protocol functions', function () {
332348
throw new Error('unexpected method: ' + method);
333349
});
334350
await cmc.readOffer('https://Tok@example.com/', { pryv: fakePryv });
335-
expect(calls).to.have.length.greaterThanOrEqual(1);
336351
const getCall = calls.find(function (c) { return c.method === 'events.get'; });
337352
expect(getCall, 'expected one events.get call').to.exist;
338-
// The contract: `streams` is the read filter (recursive). `streamIds`
339-
// here is the api-server-rejected typo.
340-
expect(getCall.params).to.have.property('streams');
341-
expect(getCall.params.streams).to.deep.equal([':_cmc:_internal:offer']);
353+
expect(getCall.params).to.not.have.property('streams');
342354
expect(getCall.params).to.not.have.property('streamIds');
355+
expect(getCall.params).to.have.property('types');
356+
expect(getCall.params.types).to.deep.equal(['consent/request-cmc']);
343357
});
344358
});
345359

0 commit comments

Comments
 (0)