Skip to content

Commit 261cfb8

Browse files
os-salesclaude
andcommitted
test(sharing): declare the fixture's publicSharing block in the envelope conformance double
The envelope conformance harness stubs `SharingEngine` without `getSchema`, so under the gated probe every one of its four row arms (`NEEDS_PASSWORD`, `WRONG_PASSWORD`, `SIGN_IN_REQUIRED`, `EXPIRED_OR_REVOKED`) fell through to the generic 404 — correctly, and fail-closed, but the refusals whose ENVELOPE this module exists to pin were then unreachable. The double now declares the block for the object its probe rows name, and those rows name it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AUF1NoViznQK32gqpK8wS8
1 parent 8ed0f4d commit 261cfb8

1 file changed

Lines changed: 24 additions & 4 deletions

File tree

packages/plugins/plugin-sharing/src/share-link-envelope.conformance.test.ts

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,26 @@ function mount(overrides: {
9090

9191
const engine = {
9292
find: vi.fn(async () => [{ id: 'acc_1', name: 'Acme', ssn: '123-45-6789' }]),
93+
// [#14637] The probe above the row arms reads the object's STANDING
94+
// `publicSharing` policy before it answers from the row, so an engine that
95+
// cannot answer `getSchema` refuses every arm with the generic 404 —
96+
// correctly, and fail-closed. This double therefore has to DECLARE the
97+
// block for the object its probe rows name, or the 401 / 410 refusals the
98+
// envelope cases below drive are simply not reachable. That is a fixture
99+
// declaration, not a relaxation: the gated behaviour itself is pinned in
100+
// `share-link-eligibility.test.ts`, and this module's subject is the
101+
// ENVELOPE each refusal is written in.
102+
getSchema: vi.fn((name: string) =>
103+
name === 'crm_account'
104+
? {
105+
name,
106+
publicSharing: {
107+
enabled: true,
108+
allowedAudiences: ['link_only', 'signed_in'],
109+
allowedPermissions: ['view'],
110+
},
111+
}
112+
: undefined),
93113
insert: vi.fn(), update: vi.fn(), delete: vi.fn(),
94114
...(overrides.engine ?? {}),
95115
} as unknown as SharingEngine;
@@ -337,7 +357,7 @@ describe('share-link envelope (#3983) — error bodies', () => {
337357
run: async () => drive(
338358
mount({
339359
service: { resolveToken: vi.fn(async () => null) },
340-
engine: { find: vi.fn(async () => [{ token: 'tok_abcdefgh', password_hash: 'h', revoked_at: null, expires_at: null }]) },
360+
engine: { find: vi.fn(async () => [{ token: 'tok_abcdefgh', object_name: 'crm_account', password_hash: 'h', revoked_at: null, expires_at: null }]) },
341361
}).http,
342362
`GET ${B}/:token/resolve`,
343363
{ params: { token: 'tok_abcdefgh' } },
@@ -350,7 +370,7 @@ describe('share-link envelope (#3983) — error bodies', () => {
350370
run: async () => drive(
351371
mount({
352372
service: { resolveToken: vi.fn(async () => null) },
353-
engine: { find: vi.fn(async () => [{ token: 'tok_abcdefgh', password_hash: 'h', revoked_at: null, expires_at: null }]) },
373+
engine: { find: vi.fn(async () => [{ token: 'tok_abcdefgh', object_name: 'crm_account', password_hash: 'h', revoked_at: null, expires_at: null }]) },
354374
}).http,
355375
`GET ${B}/:token/resolve`,
356376
{ params: { token: 'tok_abcdefgh' }, query: { password: 'nope' } },
@@ -364,7 +384,7 @@ describe('share-link envelope (#3983) — error bodies', () => {
364384
mount({
365385
userId: undefined,
366386
service: { resolveToken: vi.fn(async () => null) },
367-
engine: { find: vi.fn(async () => [{ token: 'tok_abcdefgh', audience: 'signed_in', revoked_at: null, expires_at: null }]) },
387+
engine: { find: vi.fn(async () => [{ token: 'tok_abcdefgh', object_name: 'crm_account', audience: 'signed_in', revoked_at: null, expires_at: null }]) },
368388
}).http,
369389
`GET ${B}/:token/resolve`,
370390
{ params: { token: 'tok_abcdefgh' } },
@@ -377,7 +397,7 @@ describe('share-link envelope (#3983) — error bodies', () => {
377397
run: async () => drive(
378398
mount({
379399
service: { resolveToken: vi.fn(async () => null) },
380-
engine: { find: vi.fn(async () => [{ token: 'tok_abcdefgh', revoked_at: '2026-01-02T00:00:00.000Z' }]) },
400+
engine: { find: vi.fn(async () => [{ token: 'tok_abcdefgh', object_name: 'crm_account', revoked_at: '2026-01-02T00:00:00.000Z' }]) },
381401
}).http,
382402
`GET ${B}/:token/resolve`,
383403
{ params: { token: 'tok_abcdefgh' } },

0 commit comments

Comments
 (0)