CI / test (push) Successful in 9m54s
Ship remaining roadmap items: encrypted registry vault, peer invite/revoke, Swarm/plugins behind flags, binary streams, engine create validation, deploy rollback, schema validation, fleet/access UI, metrics, fuzz/load/soak tests, systemd packaging, and release tooling. Mark ROADMAP fully complete.
48 lines
1.3 KiB
JavaScript
48 lines
1.3 KiB
JavaScript
import test from 'brittle'
|
|
import { validateMethodArgs, MethodSchemas, SCHEMA_VERSION } from '../shared/schema.js'
|
|
import { Methods } from '../shared/protocol.js'
|
|
|
|
test('SCHEMA_VERSION is positive integer', (t) => {
|
|
t.is(typeof SCHEMA_VERSION, 'number')
|
|
t.ok(SCHEMA_VERSION >= 1)
|
|
})
|
|
|
|
test('validateMethodArgs accepts valid pullImage', (t) => {
|
|
const r = validateMethodArgs(Methods.pullImage, { image: 'nginx:latest' })
|
|
t.ok(r.ok)
|
|
t.is(r.args.image, 'nginx:latest')
|
|
})
|
|
|
|
test('validateMethodArgs rejects missing required', (t) => {
|
|
const r = validateMethodArgs(Methods.pullImage, {})
|
|
t.not(r.ok)
|
|
t.ok(r.error.includes('image'))
|
|
})
|
|
|
|
test('validateMethodArgs rejects bad types', (t) => {
|
|
const r = validateMethodArgs(Methods.stopContainer, { id: 'abc', t: 'nope' })
|
|
t.not(r.ok)
|
|
})
|
|
|
|
test('validateMethodArgs passes unknown methods', (t) => {
|
|
const r = validateMethodArgs('customThing', { a: 1 })
|
|
t.ok(r.ok)
|
|
})
|
|
|
|
test('invitePeer role enum', (t) => {
|
|
t.ok(validateMethodArgs(Methods.invitePeer, { role: 'operator' }).ok)
|
|
t.not(validateMethodArgs(Methods.invitePeer, { role: 'superuser' }).ok)
|
|
})
|
|
|
|
test('MethodSchemas covers critical write paths', (t) => {
|
|
for (const m of [
|
|
'createContainer',
|
|
'deployStack',
|
|
'vaultStoreCredential',
|
|
'invitePeer',
|
|
'binaryStreamOpen',
|
|
]) {
|
|
t.ok(MethodSchemas[m], m)
|
|
}
|
|
})
|