- Add GpnStatus type ('supported' | 'unsupported' | 'unknown') to Device domain
- Persist gpnStatus in DeviceRecord and all 3 persist paths
(cwmp_controller, main_state_machine, device_action_executor)
- Capture Fault 9000/9001 in getParameterNames → mark device as 'unsupported'
- Fix GPN NextLevel flag: false (non-recursive shallow scan)
- Add static TR-181 catalog (7 727 params, sourced from BBF cwmp-data-models)
- Add parameter_writability service with resolveWritability():
supported → live data; unsupported → catalog → default R/W;
unknown → catalog → null (genuinely unknown)
- Add scripts/generate-tr181-catalog.mjs to regenerate catalog from BBF XML
- Add design doc: docs/design-parameter-writability.md
- Add unit tests: 26 tests covering normalizePath and all gpnStatus branches
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
77 lines
2.6 KiB
TypeScript
77 lines
2.6 KiB
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import { Device, OnboardingStatus } from '../../../../app/domain/device/device.js'
|
|
import { DeviceId } from '../../../../app/domain/device/device_id.js'
|
|
import { DeviceParameter, DeviceProperty } from '../../../../app/domain/device/device_parameter.js'
|
|
import { ParameterType } from '../../../../app/domain/shared/types.js'
|
|
|
|
function makeDevice(): Device {
|
|
return new Device(new DeviceId('Sagemcom', '10:6f:3f', 'Fast5360', 'SN123'))
|
|
}
|
|
|
|
describe('Device.gpnStatus', () => {
|
|
it('defaults to "unknown"', () => {
|
|
expect(makeDevice().gpnStatus).toBe('unknown')
|
|
})
|
|
|
|
it('can be set to "supported"', () => {
|
|
const device = makeDevice()
|
|
device.setGpnStatus('supported')
|
|
expect(device.gpnStatus).toBe('supported')
|
|
})
|
|
|
|
it('can be set to "unsupported"', () => {
|
|
const device = makeDevice()
|
|
device.setGpnStatus('unsupported')
|
|
expect(device.gpnStatus).toBe('unsupported')
|
|
})
|
|
|
|
it('can be changed back to "unknown"', () => {
|
|
const device = makeDevice()
|
|
device.setGpnStatus('supported')
|
|
device.setGpnStatus('unknown')
|
|
expect(device.gpnStatus).toBe('unknown')
|
|
})
|
|
|
|
it('is included in the snapshot', () => {
|
|
const device = makeDevice()
|
|
device.setGpnStatus('unsupported')
|
|
expect(device.toSnapshot().gpnStatus).toBe('unsupported')
|
|
})
|
|
|
|
it('snapshot reflects the latest status', () => {
|
|
const device = makeDevice()
|
|
device.setGpnStatus('supported')
|
|
device.setGpnStatus('unsupported')
|
|
expect(device.toSnapshot().gpnStatus).toBe('unsupported')
|
|
})
|
|
})
|
|
|
|
describe('Device.toSnapshot', () => {
|
|
it('includes gpnStatus alongside other fields', () => {
|
|
const device = makeDevice()
|
|
device.setGpnStatus('supported')
|
|
const snapshot = device.toSnapshot()
|
|
|
|
expect(snapshot).toMatchObject({
|
|
gpnStatus: 'supported',
|
|
onboardingStatus: OnboardingStatus.PENDING,
|
|
isOnline: false,
|
|
parameters: [],
|
|
properties: [],
|
|
})
|
|
})
|
|
|
|
it('snapshot parameters/properties are consistent with gpnStatus semantics', () => {
|
|
const device = makeDevice()
|
|
device.setGpnStatus('supported')
|
|
device.setParameter(new DeviceParameter('Device.ManagementServer.URL', 'http://acs', ParameterType.STRING))
|
|
device.setProperty(new DeviceProperty('Device.DeviceInfo.Manufacturer', 'Sagemcom', ParameterType.STRING))
|
|
|
|
const snapshot = device.toSnapshot()
|
|
|
|
expect(snapshot.gpnStatus).toBe('supported')
|
|
expect(snapshot.parameters.map((p) => p.name)).toContain('Device.ManagementServer.URL')
|
|
expect(snapshot.properties.map((p) => p.name)).toContain('Device.DeviceInfo.Manufacturer')
|
|
})
|
|
})
|