Add nodes.delete with reauth, activity logs, and Administrators editing.

Allow deleting managed hosts with mandatory inline re-auth, record node mutations in an audit log with a sidebar Logs view, and let Administrators group permissions be edited from the Groups tab.
This commit is contained in:
2026-07-18 16:54:13 +02:00
parent f4dc8f63d7
commit 77be394407
17 changed files with 1326 additions and 71 deletions
+65
View File
@@ -1,10 +1,12 @@
import { afterEach, describe, expect, it, vi } from 'vitest'
import {
deleteGroup,
deleteNode,
deleteUser,
fetchGroups,
fetchHealth,
fetchNetwork,
fetchNodeLogs,
fetchSecurity,
fetchStatus,
fetchUsers,
@@ -326,6 +328,69 @@ describe('deleteUser', () => {
})
})
describe('deleteNode', () => {
afterEach(() => {
vi.restoreAllMocks()
})
it('sends DELETE by id with reauth credentials and returns nodes', async () => {
const fetchMock = vi.fn().mockResolvedValue({
ok: true,
json: async () => ({ nodes: [] }),
})
await deleteNode(
'node-1',
{ current_password: 'correct horse battery staple extra' },
fetchMock,
)
expect(fetchMock).toHaveBeenCalledWith(
'http://localhost:8080/api/v1/nodes/node-1',
expect.objectContaining({
method: 'DELETE',
credentials: 'include',
body: JSON.stringify({
current_password: 'correct horse battery staple extra',
totp_code: '',
}),
}),
)
})
})
describe('fetchNodeLogs', () => {
afterEach(() => {
vi.restoreAllMocks()
})
it('returns parsed logs payload with optional kind filter', async () => {
const events = [
{
id: 'e1',
at: '2026-01-01T00:00:00Z',
action: 'create',
actor: 'Admin',
node_id: 'n1',
node_name: 'ct1',
node_kind: 'container',
},
]
const fetchMock = vi.fn().mockResolvedValue({
ok: true,
json: async () => ({ events }),
})
const payload = await fetchNodeLogs('container', fetchMock)
expect(fetchMock).toHaveBeenCalledWith(
'http://localhost:8080/api/v1/node-logs?kind=container',
expect.objectContaining({ credentials: 'include' }),
)
expect(payload.events).toEqual(events)
})
})
describe('fetchSecurity', () => {
afterEach(() => {
vi.restoreAllMocks()