@substrat-run/contract-tests 0.168.0 → 0.169.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"scope-host-suite.d.ts","sourceRoot":"","sources":["../src/scope-host-suite.ts"],"names":[],"mappings":"AAEA,OAAO,EAuBL,KAAK,SAAS,EAuBf,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAsBL,KAAK,SAAS,EACf,MAAM,sBAAsB,CAAC;AAe9B,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,SAAS,CAAC;IAChB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAED,oGAAoG;AACpG,wBAAgB,+BAA+B,CAC7C,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,OAAO,CAAC,gBAAgB,GAAG;IAC5C,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;CAChF,CAAC,GACD,IAAI,CA+GN;AAuCD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,aAAa,MACrB,OAAO,CAAC,OAAO,CAAC,QACb,SAAS,YACL,MAAM,KACf,OAAO,CAAC,IAAI,CAOd,CAAC;AAEF,iFAAiF;AACjF,MAAM,WAAW,qBAAqB;IACpC;;;;;;OAMG;IACH,2BAA2B,CAAC,EAAE,OAAO,CAAC;CACvC;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,OAAO,CAAC,gBAAgB,CAAC,EAC5C,IAAI,GAAE,qBAA0B,GAC/B,IAAI,CA0wYN"}
1
+ {"version":3,"file":"scope-host-suite.d.ts","sourceRoot":"","sources":["../src/scope-host-suite.ts"],"names":[],"mappings":"AAEA,OAAO,EAuBL,KAAK,SAAS,EAuBf,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAsBL,KAAK,SAAS,EACf,MAAM,sBAAsB,CAAC;AAe9B,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,SAAS,CAAC;IAChB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAED,oGAAoG;AACpG,wBAAgB,+BAA+B,CAC7C,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,OAAO,CAAC,gBAAgB,GAAG;IAC5C,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;CAChF,CAAC,GACD,IAAI,CA+GN;AAuCD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,aAAa,MACrB,OAAO,CAAC,OAAO,CAAC,QACb,SAAS,YACL,MAAM,KACf,OAAO,CAAC,IAAI,CAOd,CAAC;AAEF,iFAAiF;AACjF,MAAM,WAAW,qBAAqB;IACpC;;;;;;OAMG;IACH,2BAA2B,CAAC,EAAE,OAAO,CAAC;CACvC;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,OAAO,CAAC,gBAAgB,CAAC,EAC5C,IAAI,GAAE,qBAA0B,GAC/B,IAAI,CAu0YN"}
@@ -5046,6 +5046,24 @@ export function scopeHostContractSuite(adapterName, makeFixture, opts = {}) {
5046
5046
  // An unknown account is simply not connected — the ordinary miss.
5047
5047
  expect(await host.admin.openConnection(t1, 'multigit', 'github', 'nobody')).toBeUndefined();
5048
5048
  });
5049
+ it("keys a scope's own connection apart from the tenant's and another scope's, on one account (#2732)", async () => {
5050
+ const [a, b] = [scopeId.parse(ulid()), scopeId.parse(ulid())];
5051
+ const connect = (token, ownerScopeId) => host.admin.createConnection(staff, {
5052
+ id: connectionId.parse(ulid()), tenantId: t1, vertical: 'owned', provider: 'planima', label: token,
5053
+ secret: { token }, ...(ownerScopeId ? { ownerScopeId } : {}),
5054
+ });
5055
+ await connect('tenant');
5056
+ await connect('a', a);
5057
+ await connect('b', b);
5058
+ // Each owner still holds one live connection per account.
5059
+ await expect(connect('a-again', a)).rejects.toThrow(/already has a live/);
5060
+ await expect(connect('tenant-again')).rejects.toThrow(/already has a live/);
5061
+ // A tenant-level read opens the tenant's alone; naming the owner opens that scope's.
5062
+ expect((await host.admin.openConnection(t1, 'owned', 'planima'))?.secret).toEqual({ token: 'tenant' });
5063
+ expect((await host.admin.openConnection(t1, 'owned', 'planima', undefined, a))?.secret).toEqual({ token: 'a' });
5064
+ expect((await host.admin.listConnections(staff, { tenantId: t1, vertical: 'owned', ownerScopeId: b })).map((c) => c.label)).toEqual(['b']);
5065
+ expect((await host.admin.listConnections(staff, { tenantId: t1, vertical: 'owned', ownerScopeId: null })).map((c) => c.label)).toEqual(['tenant']);
5066
+ });
5049
5067
  });
5050
5068
  // -- connection grants: the directory record behind the tuple (#592) --------
5051
5069
  //
@@ -5210,6 +5228,38 @@ export function scopeHostContractSuite(adapterName, makeFixture, opts = {}) {
5210
5228
  expect(byConnection.get(rconn)?.sort()).toEqual([INHERITED, SCOPED].sort());
5211
5229
  });
5212
5230
  });
5231
+ // -- one key taken back on one scope, from a connection that stays live (#2732) --
5232
+ describe('revokeFromConnection (#2732)', () => {
5233
+ it('takes one key back on one scope, out of the gather too, keeps the rest, and audits only a change', async () => {
5234
+ const vt = tenantId.parse(ulid());
5235
+ const vs = scopeId.parse(ulid());
5236
+ const vconn = connectionId.parse(ulid());
5237
+ const LAND = permissionKey.parse('protocol:record-signature');
5238
+ const KEEP = permissionKey.parse('protocol:attach');
5239
+ await host.admin.createTenant(staff, { id: vt, slug: `tenant-${vt.toLowerCase()}`, name: 'Revoke' });
5240
+ await host.provisionScope(staff, { tenantId: vt, scopeId: vs, vertical: 'signing' });
5241
+ await host.admin.activateScope(staff, vt, vs);
5242
+ await host.admin.createConnection(staff, {
5243
+ id: vconn, tenantId: vt, vertical: 'signing', provider: 'signer', label: 'Signer', secret: { accessToken: 'tok-revoke' },
5244
+ });
5245
+ for (const permission of [LAND, KEEP]) {
5246
+ await host.admin.grantToConnection(staff, { connectionId: vconn, permission, node: { tenantId: vt, scopeId: vs }, grantedBy: staff });
5247
+ }
5248
+ const revoke = () => host.admin.revokeFromConnection(staff, { connectionId: vconn, permission: LAND, node: { tenantId: vt, scopeId: vs } });
5249
+ const audited = async () => (await host.admin.auditLog(staff, { tenantId: vt })).filter((e) => e.action === 'revokeFromConnection').length;
5250
+ await revoke();
5251
+ expect((await host.connectionGrantsInScope(vt, vs)).map((g) => g.permission)).toEqual([KEEP]);
5252
+ // The gather provision and reconcile seat from: a revoked key is never delivered again.
5253
+ expect((await host.admin.listConnectionGrants(staff, vt)).map((g) => g.permission)).toEqual([KEEP]);
5254
+ // The connection itself is untouched.
5255
+ expect((await host.admin.openConnection(vt, 'signing', 'signer'))?.id).toBe(vconn);
5256
+ expect(await audited()).toBe(1);
5257
+ await revoke();
5258
+ expect(await audited()).toBe(1);
5259
+ // A scope the tenant does not hold is not found, as it is for `grantToConnection`.
5260
+ await expectRefusal(host.admin.revokeFromConnection(staff, { connectionId: vconn, permission: LAND, node: { tenantId: vt, scopeId: scopeId.parse(ulid()) } }), 'not_found');
5261
+ });
5262
+ });
5213
5263
  // -- connector state: a connector's own durable bookkeeping (#101 gap 3) ---
5214
5264
  describe('connector state', () => {
5215
5265
  it('round-trips arbitrary JSON keyed by (connection, key)', async () => {