refactor: move dynamic imports to file headers
- getReferenceEngine import moved to top of cwmp_controller - Fix makeContext type in configuration_evaluation_state tests
This commit is contained in:
1 parent
31578e368f
commit
7882a49d71
2 files changed
+14
-5
No files matched your search
@@ -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]
|
||||
|
||||
@@ -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.')
|
||||
|
||||
Reference in new issue
Block a user