|
14 | 14 | // invoice against each (acceptance[0], acceptance[1], negative[0], |
15 | 15 | // negative[1]) and repoints a stored invoice at a churned account with a |
16 | 16 | // patch that carries no status (acceptance[2]). |
17 | | -// - A scratch pair for the persona the rule exists to constrain, which no |
18 | | -// stock showcase persona is (the item's fixtures.knownGaps): a member with |
19 | | -// create/edit on the child object and NO grant at all on the lookup's |
20 | | -// parent. The member writes against a non-tripping and a tripping parent |
21 | | -// (acceptance[3], negative[2]); a read of the parent as that member is the |
22 | | -// control that the persona really cannot read it. |
| 17 | +// - A scratch pair for a member with create/edit on the child object and NO |
| 18 | +// grant at all on the lookup's parent, which no stock showcase persona is |
| 19 | +// (the item's fixtures.knownGaps). Such a member may not name the parent at |
| 20 | +// all (#29029, revision 7): a write naming a parent the caller's own read |
| 21 | +// door does not return answers `reference_not_found` on the lookup, before |
| 22 | +// the record's rules, whether or not the parent trips one (acceptance[3], |
| 23 | +// negative[2]). A read of the parent as that member is the control that the |
| 24 | +// member really cannot read it. |
23 | 25 | // |
24 | | -// The refusal is scored on the envelope — 400 VALIDATION_FAILED, the |
| 26 | +// The rule's refusal is scored on the envelope — 400 VALIDATION_FAILED, the |
25 | 27 | // `_record` / `rule_violation` entry — and on the AUTHORED message, which is |
26 | 28 | // the one place the item names wording as the contract. A refusal that reads |
27 | 29 | // "could not be evaluated" is the pre-capability fault, and every case below |
@@ -54,6 +56,14 @@ function expectRuleRefusal(answer: Answer, message: string) { |
54 | 56 | expect(JSON.stringify(answer.json)).not.toContain(UNEVALUABLE); |
55 | 57 | } |
56 | 58 |
|
| 59 | +/** The refusal acceptance[3] names: the lookup's own `reference_not_found`, and no rule entry. */ |
| 60 | +function expectReferenceRefusal(answer: Answer, field: string) { |
| 61 | + expect(answer.status, JSON.stringify(answer.json)).toBe(400); |
| 62 | + expect(answer.json?.code, JSON.stringify(answer.json)).toBe('VALIDATION_FAILED'); |
| 63 | + expect(ruleEntries(answer.json).map((f) => ({ field: f.field, code: f.code }))).toEqual([{ field, code: 'reference_not_found' }]); |
| 64 | + expect(JSON.stringify(answer.json)).not.toContain(UNEVALUABLE); |
| 65 | +} |
| 66 | + |
57 | 67 | function expectAdmitted(answer: Answer) { |
58 | 68 | expect(answer.status, JSON.stringify(answer.json)).toBeLessThan(300); |
59 | 69 | expect(JSON.stringify(answer.json)).not.toContain(UNEVALUABLE); |
@@ -122,7 +132,7 @@ describe('records-forms.predicate-relationship-traversal — the showcase invoic |
122 | 132 | }); |
123 | 133 | }); |
124 | 134 |
|
125 | | -// ── The persona the rule exists to constrain ─────────────────────────────── |
| 135 | +// ── A member who cannot read the parent ──────────────────────────────────── |
126 | 136 |
|
127 | 137 | const PARENT = 'prt_parent'; |
128 | 138 | const CHILD = 'prt_child'; |
@@ -162,7 +172,7 @@ const prtStack = defineStack({ |
162 | 172 | ], |
163 | 173 | } as never); |
164 | 174 |
|
165 | | -describe('records-forms.predicate-relationship-traversal — a member who cannot read the parent', () => { |
| 175 | +describe('records-forms.predicate-relationship-traversal — a member who cannot read the parent cannot name it', () => { |
166 | 176 | let stack: VerifyStack; |
167 | 177 | let member = ''; |
168 | 178 | let openId = ''; |
@@ -196,14 +206,15 @@ describe('records-forms.predicate-relationship-traversal — a member who cannot |
196 | 206 | expect(read.json.code).toBe('PERMISSION_DENIED'); |
197 | 207 | }); |
198 | 208 |
|
199 | | - it('acceptance[3]: a legitimate write against a non-tripping parent goes through', async () => { |
200 | | - const created = await call('POST', `/data/${CHILD}`, { name: 'prt-open', parent: openId }); |
201 | | - expectAdmitted(created); |
202 | | - expect(await stack.rows(CHILD, { name: 'prt-open' })).toHaveLength(1); |
| 209 | + it('acceptance[3]: a write naming a non-tripping parent the member cannot read answers reference_not_found, and stores nothing', async () => { |
| 210 | + expectReferenceRefusal(await call('POST', `/data/${CHILD}`, { name: 'prt-open', parent: openId }), 'parent'); |
| 211 | + expect(await stack.rows(CHILD, { name: 'prt-open' })).toHaveLength(0); |
203 | 212 | }); |
204 | 213 |
|
205 | | - it('acceptance[3], negative[2]: a write against a tripping parent is refused with the authored message, never the unevaluable fault', async () => { |
206 | | - expectRuleRefusal(await call('POST', `/data/${CHILD}`, { name: 'prt-blocked', parent: blockedId }), BLOCKED_MESSAGE); |
| 214 | + it('acceptance[3], negative[2]: a write naming a tripping parent the member cannot read answers the same, never the rule\'s message', async () => { |
| 215 | + const answer = await call('POST', `/data/${CHILD}`, { name: 'prt-blocked', parent: blockedId }); |
| 216 | + expectReferenceRefusal(answer, 'parent'); |
| 217 | + expect(JSON.stringify(answer.json)).not.toContain(BLOCKED_MESSAGE); |
207 | 218 | expect(await stack.rows(CHILD, { name: 'prt-blocked' })).toHaveLength(0); |
208 | 219 | }); |
209 | 220 | }); |
0 commit comments