Development hosts, review V-1 to V-3: a malformed list stops the start, a trailing dot and Unicode patterns match, every send reads the store
- V-1: assertDevelopmentHosts - iapl({ developmentHosts }), mail.relay.developmentHosts and
mailAdapter({ relay }) refuse anything but an array of non-empty host patterns, and a pattern of `*` alone
(it would make the public site a development address). Nothing is ignored silently any more.
- V-2: one trailing dot of the host is stripped before matching; patterns are punycoded, so one written in
Unicode matches; a `*` inside a non-ASCII label is refused.
- V-3: the 30-second memory of other hosts is gone. A dump restored into a running development site stops
its very next e-mail.
- docs, AGENT.md, changelog draft, skills
Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
co-authored by
Claude Fable 5.2
parent
99c73ed0ff
commit
6c4e244094
+9
-2
@@ -4,6 +4,7 @@ import { describe, expect, test, vi } from 'vitest'
|
||||
|
||||
import type { I18nConfig } from '../src/modules/i18n/types.js'
|
||||
|
||||
import { mailAdapter } from '../src/modules/email/mailAdapter.js'
|
||||
import { pluginDevelopmentHosts } from '../src/modules/email/relay/options.js'
|
||||
import { iapl } from '../src/plugin.js'
|
||||
import { withTotpParts } from './helpers.js'
|
||||
@@ -24,13 +25,19 @@ const base = (): Config =>
|
||||
|
||||
describe('iapl — config transform', () => {
|
||||
test('developmentHosts: nothing in the config by default (the built-in list applies), the project\'s list when given, an empty list too', async () => {
|
||||
const hosts = async (own?: string[]) => {
|
||||
const config = await iapl({ access: { authCollection: 'users' }, i18n, twoFactor: false, ...(own ? { developmentHosts: own } : {}) })(base())
|
||||
const hosts = async (...own: [string[]?]) => {
|
||||
const config = await iapl({ access: { authCollection: 'users' }, i18n, twoFactor: false, ...(own.length ? { developmentHosts: own[0] } : {}) })(base())
|
||||
return pluginDevelopmentHosts({ config } as never)
|
||||
}
|
||||
expect(await hosts()).toEqual(['*.dev.netscale.pl'])
|
||||
expect(await hosts(['*.preview.agency-example.com'])).toEqual(['*.preview.agency-example.com'])
|
||||
expect(await hosts([])).toEqual([])
|
||||
// V-1: a malformed list stops the start — the plugin option, the mail option, the adapter's own
|
||||
for (const bad of ['*.dev.netscale.pl', null, [1, 2], [''], ['*']]) {
|
||||
await expect(hosts(bad as never), JSON.stringify(bad)).rejects.toThrow('[iapl] iapl({ developmentHosts }) must be an array of host patterns')
|
||||
await expect(Promise.resolve().then(() => iapl({ access: { authCollection: 'users' }, i18n, mail: { relay: { developmentHosts: bad as never } }, twoFactor: false })(base()))).rejects.toThrow('iapl({ mail: { relay: { developmentHosts } } })')
|
||||
expect(() => mailAdapter({ relay: { developmentHosts: bad as never } })({ payload: {} as never }), JSON.stringify(bad)).toThrow('mailAdapter({ relay: { developmentHosts } })')
|
||||
}
|
||||
})
|
||||
|
||||
test('adds globals, endpoint, localization and roles', async () => {
|
||||
|
||||
Reference in New Issue
Block a user