@substrat-run/contract-tests 0.186.0 → 0.188.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.
@@ -0,0 +1,3 @@
1
+ import type { ScopeHostFixture } from './scope-host-suite.js';
2
+ export declare function verifiedEmailContractSuite(adapterName: string, makeFixture: () => Promise<ScopeHostFixture>): void;
3
+ //# sourceMappingURL=verified-email-suite.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verified-email-suite.d.ts","sourceRoot":"","sources":["../src/verified-email-suite.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAG9D,wBAAgB,0BAA0B,CACxC,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,OAAO,CAAC,gBAAgB,CAAC,GAC3C,IAAI,CAgEN"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Contract suite for `ctx.verifiedEmail` (K-61): who may hand an operation an address.
3
+ *
4
+ * The rule is that leaving it out fails closed, so most of this suite is doors that must
5
+ * answer null. A door here reads what the operation sees through a real scope, on both
6
+ * adapters: the DO builds its context inside workerd, across an RPC the address has to
7
+ * survive, and the SQLite host builds it in process.
8
+ */
9
+ import { afterAll, beforeAll, describe, expect, it } from 'vitest';
10
+ import { platformActorId, principalId, scopeId, tenantId } from '@substrat-run/contracts';
11
+ import { ulid } from '@substrat-run/kernel';
12
+ import { addressMod } from './modules.js';
13
+ export function verifiedEmailContractSuite(adapterName, makeFixture) {
14
+ describe(`ctx.verifiedEmail (K-61): ${adapterName}`, () => {
15
+ let fixture;
16
+ let host;
17
+ const t1 = tenantId.parse(ulid());
18
+ const s1 = scopeId.parse(ulid());
19
+ const anna = principalId.parse(ulid());
20
+ const staff = platformActorId.parse(ulid());
21
+ const address = 'Anna@Example.com';
22
+ const seenThrough = async (stub) => (await stub.invoke('address/who')).verifiedEmail;
23
+ beforeAll(async () => {
24
+ fixture = await makeFixture();
25
+ host = fixture.host;
26
+ host.registerModule(addressMod);
27
+ await host.admin.createTenant(staff, { id: t1, slug: 'address-tenant', name: 'Address Tenant' });
28
+ await host.admin.grantEntitlement(staff, t1, 'address');
29
+ await host.provisionScope(staff, { tenantId: t1, scopeId: s1, vertical: 'address-vertical' });
30
+ await host.admin.activateScope(staff, t1, s1);
31
+ });
32
+ afterAll(async () => {
33
+ await fixture.cleanup();
34
+ });
35
+ it('hands the operation the address the door passed, in the issuer’s spelling', async () => {
36
+ expect(await seenThrough(await host.getScope(anna, t1, s1, { verifiedEmail: address }))).toBe(address);
37
+ });
38
+ it.each([
39
+ ['a door that says nothing', async () => host.getScope(anna, t1, s1)],
40
+ ['a door that says null', async () => host.getScope(anna, t1, s1, { verifiedEmail: null })],
41
+ ['the system door', async () => host.getSystemScope(addressMod.manifest.id, t1, s1)],
42
+ [
43
+ 'acting as the person (K-42)',
44
+ async () => {
45
+ const session = await host.admin.beginImpersonation(staff, {
46
+ tenantId: t1,
47
+ scopeId: s1,
48
+ principal: anna,
49
+ reason: 'ticket #4182',
50
+ });
51
+ return host.getImpersonatedScope(session.id, t1, s1);
52
+ },
53
+ ],
54
+ ])('answers null through %s', async (_door, open) => {
55
+ expect(await seenThrough(await open())).toBeNull();
56
+ });
57
+ it('stays with the stub, so one person’s address does not reach another’s call', async () => {
58
+ const hers = await host.getScope(anna, t1, s1, { verifiedEmail: address });
59
+ const theirs = await host.getScope(principalId.parse(ulid()), t1, s1);
60
+ expect(await seenThrough(theirs)).toBeNull();
61
+ expect(await seenThrough(hers)).toBe(address);
62
+ });
63
+ it('is null in a consumer, which acts for nobody', async () => {
64
+ const stub = await host.getScope(anna, t1, s1, { verifiedEmail: address });
65
+ await stub.invoke('address/act');
66
+ await expect.poll(() => stub.invoke('address/consumer-saw')).toEqual([null]);
67
+ });
68
+ });
69
+ }
70
+ //# sourceMappingURL=verified-email-suite.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verified-email-suite.js","sourceRoot":"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CAAC,CAAC;YAC3E,MAAM,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;YACjC,MAAM,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAoB,sBAAsB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QAClG,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@substrat-run/contract-tests",
3
- "version": "0.186.0",
3
+ "version": "0.188.0",
4
4
  "description": "The suite every scope-host adapter must pass, forever (D-14)",
5
5
  "license": "AGPL-3.0-only",
6
6
  "repository": {
@@ -30,8 +30,8 @@
30
30
  "dist"
31
31
  ],
32
32
  "dependencies": {
33
- "@substrat-run/contracts": "^0.186.0",
34
- "@substrat-run/kernel": "^0.186.0"
33
+ "@substrat-run/contracts": "^0.188.0",
34
+ "@substrat-run/kernel": "^0.188.0"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/node": "^22.20.5",