M1 review round 2: the transport is no way round, nobody raises its own role, late staff collections
R2-1 the SMTP password is bound to server, port and user whatever the transport says; the transport alone is not bound.
R2-2 where the plugin's update rule is in force the roles field is closed for the account itself
(the plugin's roles: only an admin; roles of the project's own: never one's own).
R2-3 auth collections a later plugin adds get the account rules, the password rule and the first-user endpoint when
the config goes live; a staff slug that is not an auth collection stops the start.
R2-4 smtpRequireTls is taken out: the branch adds no field, column or collection.
Also: read (a staff account) and unlock (an admin) defaults on staff collections (accounts.staffOnlyRead);
doctor staff-own-roles and read / unlock in staff-accounts-open; r1 NULL against the default, also inside a row;
r2 bound values compared exactly.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
co-authored by
Claude Fable 5.2
parent
a32329fbb4
commit
7002ebbfa6
@@ -82,6 +82,20 @@ test('the first account registers; accounts of the collection create, change and
|
||||
expect((await call(`/users/${third}`, boss, 'DELETE')).status).toBe(200)
|
||||
})
|
||||
|
||||
// Review round 2 (R2-2): the plugin cannot rank the project's roles, but one thing it can hold: nobody changes its OWN.
|
||||
test('an account does not change its own roles; another account of the collection does (the project\'s rules narrow that)', async () => {
|
||||
const writer = await login('users', '[email protected]')
|
||||
const id = await idOf('users', '[email protected]')
|
||||
const roles = async () => ((await payload.findByID({ id: id as never, collection: 'users' as never })) as { roles?: string[] }).roles
|
||||
await call(`/users/${id}`, writer, 'PATCH', { roles: ['superadmin'] })
|
||||
await call('/users?where[email][equals][email protected]', writer, 'PATCH', { roles: ['superadmin'] })
|
||||
expect(await roles()).toEqual(['writer'])
|
||||
const boss = await login('users', '[email protected]')
|
||||
expect((await call(`/users/${id}`, boss, 'PATCH', { roles: ['superadmin'] })).status).toBe(200)
|
||||
expect(await roles()).toEqual(['superadmin'])
|
||||
await payload.update({ id: id as never, collection: 'users' as never, data: { roles: ['writer'] } as never })
|
||||
})
|
||||
|
||||
test('an account of another collection, a half-signed-in one and nobody stay out', async () => {
|
||||
expect((await call('/customers', {}, 'POST', { email: '[email protected]', password: PASSWORD })).status).toBe(201)
|
||||
const visitor = await login('customers', '[email protected]')
|
||||
@@ -96,3 +110,16 @@ test('an account of another collection, a half-signed-in one and nobody stay out
|
||||
expect((await call('/users/login', {}, 'POST', { email: '[email protected]', password: 'taken-over-password-1' })).status).not.toBe(200)
|
||||
expect(await staffCollectionsOpenToOthers(payload as never)).toEqual([])
|
||||
})
|
||||
|
||||
test('a staff collection that does not exist stops the start, with the slug and the fix', async () => {
|
||||
const config = buildTestConfig({
|
||||
admin: { user: 'users' },
|
||||
collections: [{ slug: 'media', fields: [], upload: { staticDir: path.join(os.tmpdir(), 'ipal-test-media') } }],
|
||||
db: testDatabase('accounts_ghost'),
|
||||
editor: lexicalEditor(),
|
||||
plugins: [ipalKit({ access: { authCollection: 'users', staffCollections: ['ghost-staff'] }, i18n: { defaultLocale: 'en', locales: [{ code: 'en', label: 'English' }] }, twoFactor: false })],
|
||||
secret: 'integration-test-secret-0123456789',
|
||||
telemetry: false,
|
||||
})
|
||||
await expect(getPayload({ config, key: 'ghost' })).rejects.toThrow(/"ghost-staff"[\s\S]*no auth collection with that slug[\s\S]*staffCollections/)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user