1.18.0 (owner's decisions Q3, Q4, Q5): writes that keep others' saves, access answers announced, drafts out of related documents
- Q3: the integration status (emailStatus, turnstileStatus) is written alone through the database adapter (writeGlobalFields, exported): a visitor's form submit no longer puts back an admin's SMTP or Turnstile change saved at the same moment. addToCookieList reads the list again right before writing and works the change out again when an editor's save changed it (up to 5 times). Both races reproduced exactly in test/statusWrites.test.ts, on the three adapters. - Q4: cookieScanner.access and the doctor's access go through accessAllowed: any truthy answer still allows, an answer that is not a boolean is reported once per option; strict (only true) is announced for 1.19.0. - Q5: related documents that are drafts are left out of what the public helpers answer (resolveRoute, getSettings, getArchiveEntries, the 404 page, llms-full; Markdown and MCP through resolveRoute): null alone, removed from a list, value null in a polymorphic one. A preview keeps them; draftRelations: 'keep' keeps the old behaviour. withoutDraftRelations, applyDraftRelations exported. - Docs: content.md, frontend.md, integrations.md, cookie-scanner.md, security.md, AGENT.md; iapl-nav and iapl-doctor skills. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
fc70a34f3e
commit
21ef0fdeb0
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* Access callbacks of a project (`cookieScanner.access`, the doctor's `access`), owner's decision Q4, 1.18.0:
|
||||
* still allowed on any truthy answer, but an answer that is not a boolean is reported once per option, so a
|
||||
* project sees it before the next minor version allows only `true`. Every call site goes through one function.
|
||||
*/
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { beforeEach, describe, expect, test, vi } from 'vitest'
|
||||
|
||||
import { accessAllowed, resetAccessWarnings } from '../src/modules/shared/accessAnswer.js'
|
||||
|
||||
beforeEach(() => resetAccessWarnings())
|
||||
|
||||
describe('accessAllowed', () => {
|
||||
test('true and false are read as they are, without a word', () => {
|
||||
const warn = vi.fn()
|
||||
expect(accessAllowed('cookieScanner.access', true, { warn })).toBe(true)
|
||||
expect(accessAllowed('cookieScanner.access', false, { warn })).toBe(false)
|
||||
expect(warn).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
test.each([
|
||||
[{ id: 1 }, true, 'an object'],
|
||||
['no', true, 'a string'],
|
||||
[1, true, 'a number'],
|
||||
[null, false, 'null'],
|
||||
[undefined, false, 'a undefined'],
|
||||
])('%j is read as before (%s) and reported once', (answer, allowed, kind) => {
|
||||
const warn = vi.fn()
|
||||
expect(accessAllowed('doctor.access', answer, { warn })).toBe(allowed)
|
||||
expect(accessAllowed('doctor.access', answer, { warn })).toBe(allowed)
|
||||
expect(warn).toHaveBeenCalledTimes(1)
|
||||
expect(warn.mock.calls[0][0]).toContain(`doctor.access returned ${kind}`)
|
||||
expect(warn.mock.calls[0][0]).toContain('only `true` allows')
|
||||
})
|
||||
|
||||
test('each option is reported on its own', () => {
|
||||
const warn = vi.fn()
|
||||
accessAllowed('doctor.access', 'x', { warn })
|
||||
accessAllowed('cookieScanner.access', 'x', { warn })
|
||||
expect(warn).toHaveBeenCalledTimes(2)
|
||||
})
|
||||
})
|
||||
|
||||
test('every call of a project access callback goes through accessAllowed', () => {
|
||||
const sites = ['src/modules/consent/scanner/endpoint.ts', 'src/modules/consent/scanner/approval.ts', 'src/modules/consent/scanner/crawl/endpoints.ts', 'src/modules/doctor/status.ts']
|
||||
for (const file of sites) {
|
||||
const text = readFileSync(file, 'utf8')
|
||||
const calls = text.match(/await options\.access\(\{ req \}\)/g) ?? []
|
||||
expect(calls.length, file).toBeGreaterThan(0)
|
||||
expect(text.match(/accessAllowed\('[\w.]+', await options\.access\(\{ req \}\)\)/g)?.length, file).toBe(calls.length)
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user