@@ -98,3 +98,12 @@ test('viewer can search images (read-only)', (t) => {
|
||||
t.ok(roleAllows(Roles.operator, Methods.scaleService))
|
||||
t.ok(roleAllows(Roles.operator, Methods.updateContainer))
|
||||
})
|
||||
|
||||
test('invites are admin-only (not viewer or operator)', (t) => {
|
||||
t.ok(roleAllows(Roles.admin, Methods.invitePeer))
|
||||
t.ok(roleAllows(Roles.admin, Methods.listInvites))
|
||||
t.absent(roleAllows(Roles.viewer, Methods.invitePeer))
|
||||
t.absent(roleAllows(Roles.viewer, Methods.listInvites))
|
||||
t.absent(roleAllows(Roles.operator, Methods.invitePeer))
|
||||
t.absent(roleAllows(Roles.operator, Methods.listInvites))
|
||||
})
|
||||
|
||||
@@ -75,6 +75,15 @@ test('presentError dedupes identical messages', (t) => {
|
||||
t.is(called, 1)
|
||||
})
|
||||
|
||||
test('PEER_NOT_FOUND is not misclassified as image not found', (t) => {
|
||||
const err = new Error('PEER_NOT_FOUND: Peer not found')
|
||||
err.code = 'PEER_NOT_FOUND'
|
||||
const info = explainError(err, 'connect')
|
||||
t.is(info.code, 'PEER_NOT_FOUND')
|
||||
t.ok(/server not found|peer not found/i.test(info.title + info.message))
|
||||
t.absent(/image not found/i.test(info.title))
|
||||
})
|
||||
|
||||
test('explainError surfaces How to fix from deploy messages', (t) => {
|
||||
const err = new Error(
|
||||
'Port conflict while starting "web" — Host port 8080 is already bound. — How to fix: Change the host port mapping.'
|
||||
|
||||
+10
-1
@@ -73,8 +73,14 @@ test('file cache round-trip under temp PEARDOCK_HOME', (t) => {
|
||||
const expectedPath = path.join(tmp, '.config', 'peardock', 'cache', 'peers.json')
|
||||
t.is(getPeersCachePath(), expectedPath)
|
||||
|
||||
const seed = 'cd'.repeat(32)
|
||||
const peers = {
|
||||
[KEY.slice(0, 12)]: { publicKeyHex: KEY, alias: 'alpha', inviteToken: 'tok' },
|
||||
[KEY.slice(0, 12)]: {
|
||||
publicKeyHex: KEY,
|
||||
alias: 'alpha',
|
||||
inviteToken: 'tok',
|
||||
adminSeed: seed,
|
||||
},
|
||||
[KEY2.slice(0, 12)]: { publicKeyHex: KEY2, alias: null },
|
||||
}
|
||||
const result = savePeers(peers)
|
||||
@@ -86,10 +92,13 @@ test('file cache round-trip under temp PEARDOCK_HOME', (t) => {
|
||||
const loaded = loadPeers()
|
||||
t.is(loaded[KEY.slice(0, 12)].alias, 'alpha')
|
||||
t.is(loaded[KEY.slice(0, 12)].inviteToken, 'tok')
|
||||
t.is(loaded[KEY.slice(0, 12)].adminSeed, seed)
|
||||
t.is(loaded[KEY2.slice(0, 12)].publicKeyHex, KEY2)
|
||||
t.absent(loaded[KEY2.slice(0, 12)].adminSeed)
|
||||
|
||||
const list = listSavedPeers()
|
||||
t.is(list.length, 2)
|
||||
t.is(list.find((p) => p.publicKeyHex === KEY)?.adminSeed, seed)
|
||||
|
||||
clearPeers()
|
||||
t.absent(fs.existsSync(expectedPath))
|
||||
|
||||
Reference in New Issue
Block a user