diff --git a/app/controllers/cwmp_controller.ts b/app/controllers/cwmp_controller.ts index bd3f78d..edd6993 100644 --- a/app/controllers/cwmp_controller.ts +++ b/app/controllers/cwmp_controller.ts @@ -8,6 +8,7 @@ import { DeviceId } from '../domain/device/device_id.js' import { DeviceParameter, DeviceProperty } from '../domain/device/device_parameter.js' import DeviceModel from '../models/device.js' import { getDeviceHashIdentifier } from '../utils/device_utils.js' +import { getReferenceEngine } from '../services/references/reference_engine.js' import logger from '@adonisjs/core/services/logger' export default class CwmpController { @@ -185,7 +186,6 @@ export default class CwmpController { // Resolve references from configured providers (async, non-blocking) try { logger.debug({ hashId, events, xForwardedFor }, '[References] Starting resolution') - const { getReferenceEngine } = await import('../services/references/reference_engine.js') const engine = getReferenceEngine() // Use x-forwarded-for header (set by simulator) or fall back to TCP remote IP const cpeIp = (xForwardedFor || '').split(',')[0]?.trim() || remoteKey.split(':')[0] diff --git a/tests/unit/services/cwmp/configuration_evaluation_state.spec.ts b/tests/unit/services/cwmp/configuration_evaluation_state.spec.ts index 31447cf..3a2f50a 100644 --- a/tests/unit/services/cwmp/configuration_evaluation_state.spec.ts +++ b/tests/unit/services/cwmp/configuration_evaluation_state.spec.ts @@ -33,7 +33,10 @@ vi.mock('../../../../app/utils/provisioning_code.js', () => ({ buildProvisioningCode: () => 'test-prov-code-123', })) -import { ConfigurationEvaluationState, ComplianceUpdateState } from '../../../../app/services/cwmp/configuration_evaluation_state.js' +import { + ConfigurationEvaluationState, + ComplianceUpdateState, +} from '../../../../app/services/cwmp/configuration_evaluation_state.js' import { Device } from '../../../../app/domain/device/device.js' import { DeviceId } from '../../../../app/domain/device/device_id.js' import { CWMPTaskQueue } from '../../../../app/services/cwmp/task_queue.js' @@ -46,6 +49,7 @@ function makeContext(gpnStatus: 'supported' | 'unsupported' = 'supported') { return { device, session: 'sess-1', + message: undefined as { success: boolean; data: any } | undefined, taskQueue, services: { deviceAction: new DeviceActionExecutor(taskQueue) }, } @@ -103,9 +107,14 @@ describe('ConfigurationEvaluationState - full happy path', () => { expect(r1.response).toContain('Device.DeviceInfo.') // Step 2: GPN response → next GPN for Device.ManagementServer. - context.message = { success: true, data: { ParameterList: { ParameterInfoStruct: [ - { Name: 'Device.DeviceInfo.Manufacturer', Writable: '0' }, - ] } } } + context.message = { + success: true, + data: { + ParameterList: { + ParameterInfoStruct: [{ Name: 'Device.DeviceInfo.Manufacturer', Writable: '0' }], + }, + }, + } const r2 = await state.handle(context) expect(r2.response).toContain('GetParameterNames') expect(r2.response).toContain('Device.ManagementServer.')