Outside-in tests (IAWL ideas 33, 34): closed doors on the built site as anonymous, customer and editor; every public route judged
- reference/e2e/closed-doors.ts + closed-doors.spec.ts: one table of doors, asked by pnpm e2e:built in both bundlers; doors still open while the owner decides are asserted open (test.fail) with their question - listPublicRoutes / listNextRouteFiles / compareRouteSnapshot / updateRouteSnapshot (main entry), runRouteCheck (/doctor) - reference/e2e/routes.ts + routes.snapshot.json (395 routes, one reason each); pnpm routes:check [--update], first step of e2e:built - create-test-admin.ts makes an editor test account - docs: security.md sections, AGENT.md 8a, iapl-audit templates, iapl-upgrade 1.17.1, changelog draft Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
498b3dbf38
commit
2468390538
@@ -10,7 +10,7 @@ import config from '@payload-config'
|
||||
import { verifyLimitKey } from '@intecion/ipal-kit'
|
||||
import { isLocalDatabase } from '@intecion/ipal-kit/seed'
|
||||
|
||||
import { secondTestAdmin } from './totp'
|
||||
import { editorTestAccount, secondTestAdmin } from './totp'
|
||||
import { getPayload } from 'payload'
|
||||
|
||||
const { E2E_ADMIN_EMAIL: email, E2E_ADMIN_PASSWORD: password, E2E_TOTP_SECRET: totpSecret } = process.env
|
||||
@@ -23,8 +23,9 @@ const payload = await getPayload({ config })
|
||||
// 10 minutes and is stored in the database, so it survives a restart of the site: the smoke and back-link specs
|
||||
// sign in as the first account, the setup spec as the second, and this script clears both counts — run it again
|
||||
// before repeating the tests within ten minutes.
|
||||
for (const address of [email, secondTestAdmin(email)]) {
|
||||
const data = { email: address, hasTotp: true, password, roles: ['admin'], totpSecret }
|
||||
// and an editor for the closed-doors spec (e2e/closed-doors.spec.ts), signed in through the same 2FA
|
||||
for (const [address, role] of [[email, 'admin'], [secondTestAdmin(email), 'admin'], [editorTestAccount(email), 'editor']] as const) {
|
||||
const data = { email: address, hasTotp: true, password, roles: [role], totpSecret }
|
||||
const found = await payload.find({ collection: 'users', limit: 1, overrideAccess: true, where: { email: { equals: address } } })
|
||||
const doc = found.docs[0]
|
||||
? await payload.update({ id: found.docs[0].id, collection: 'users', data: data as never, overrideAccess: true })
|
||||
@@ -32,7 +33,7 @@ for (const address of [email, secondTestAdmin(email)]) {
|
||||
// this site counts under the `iapl` prefix (payload.config.ts: storageNames: 'iapl'); the old key too, for a database from before
|
||||
await payload.kv.delete(verifyLimitKey('users', String(doc.id), 'iapl'))
|
||||
await payload.kv.delete(verifyLimitKey('users', String(doc.id)))
|
||||
console.log(`[e2e] test admin ready: ${address}`)
|
||||
console.log(`[e2e] test ${role} ready: ${address}`)
|
||||
}
|
||||
|
||||
// E-mail for the smoke tests goes to a local sink the test itself starts (e2e/smtp-sink.ts), so the test can
|
||||
|
||||
Reference in New Issue
Block a user