[verified] refactor: harden operations and redesign device console
This commit is contained in:
@@ -4,11 +4,11 @@ import assert from 'node:assert/strict'
|
||||
import { createSimAdminClient, normalizeInstance, summarizeInstanceSnapshot, redactInstance } from '../server/core.js'
|
||||
|
||||
test('normalizeInstance supports passwordless and password-protected instances without exposing password', () => {
|
||||
const open = normalizeInstance({ id: 'open-1', name: '开放设备', url: 'http://127.0.0.1:3000/' }, 0)
|
||||
const open = normalizeInstance({ id: 'open-1', name: '开放设备', url: 'http://192.0.2.12:3000/' }, 0)
|
||||
assert.equal(open.auth.mode, 'none')
|
||||
assert.equal(open.url, 'http://127.0.0.1:3000')
|
||||
assert.equal(open.url, 'http://192.0.2.12:3000')
|
||||
|
||||
const protectedOne = normalizeInstance({ id: 'locked', url: 'http://cpe.local', auth: { password: 'secret' } }, 1)
|
||||
const protectedOne = normalizeInstance({ id: 'locked', url: 'http://192.0.2.13', auth: { password: 'secret' } }, 1)
|
||||
assert.equal(protectedOne.auth.mode, 'password')
|
||||
assert.equal(protectedOne.auth.password, 'secret')
|
||||
assert.equal(redactInstance(protectedOne).auth.hasPassword, true)
|
||||
@@ -30,7 +30,7 @@ test('client stores simadmin_session from login and sends it on later proxied re
|
||||
}
|
||||
return new Response('{}', { status: 404 })
|
||||
}
|
||||
const client = createSimAdminClient(normalizeInstance({ id: 'locked', url: 'http://sim.local', auth: { password: 'secret' } }, 0), { fetchImpl })
|
||||
const client = createSimAdminClient(normalizeInstance({ id: 'locked', url: 'http://192.0.2.14', auth: { password: 'secret' } }, 0), { fetchImpl })
|
||||
const auth = await client.ensureAuthenticated()
|
||||
assert.equal(auth.authenticated, true)
|
||||
const proxied = await client.fetchJson('/api/device')
|
||||
|
||||
Reference in New Issue
Block a user