@@ -11,12 +11,20 @@ import (
1111 "github.com/device-management-toolkit/go-wsman-messages/v2/pkg/wsman/amt/auditlog"
1212 "github.com/device-management-toolkit/go-wsman-messages/v2/pkg/wsman/amt/messagelog"
1313 "github.com/device-management-toolkit/go-wsman-messages/v2/pkg/wsman/amt/setupandconfiguration"
14+ "github.com/device-management-toolkit/go-wsman-messages/v2/pkg/wsman/cim/bios"
15+ "github.com/device-management-toolkit/go-wsman-messages/v2/pkg/wsman/cim/card"
16+ "github.com/device-management-toolkit/go-wsman-messages/v2/pkg/wsman/cim/chassis"
17+ "github.com/device-management-toolkit/go-wsman-messages/v2/pkg/wsman/cim/chip"
18+ "github.com/device-management-toolkit/go-wsman-messages/v2/pkg/wsman/cim/mediaaccess"
19+ "github.com/device-management-toolkit/go-wsman-messages/v2/pkg/wsman/cim/physical"
20+ "github.com/device-management-toolkit/go-wsman-messages/v2/pkg/wsman/cim/processor"
1421 "github.com/device-management-toolkit/go-wsman-messages/v2/pkg/wsman/cim/software"
1522
1623 "github.com/device-management-toolkit/console/internal/entity"
1724 "github.com/device-management-toolkit/console/internal/entity/dto/v1"
1825 "github.com/device-management-toolkit/console/internal/mocks"
1926 devices "github.com/device-management-toolkit/console/internal/usecase/devices"
27+ wsmanAPI "github.com/device-management-toolkit/console/internal/usecase/devices/wsman"
2028 "github.com/device-management-toolkit/console/pkg/logger"
2129)
2230
@@ -272,14 +280,71 @@ func TestGetHardwareInfo(t *testing.T) {
272280 Return (man2 , nil )
273281 man2 .EXPECT ().
274282 GetHardwareInfo ().
275- Return (gomock . Any () , nil )
283+ Return (wsmanAPI. HWResults {} , nil )
276284 },
277285 repoMock : func (repo * mocks.MockDeviceManagementRepository ) {
278286 repo .EXPECT ().
279287 GetByID (context .Background (), device .GUID , "" ).
280288 Return (device , nil )
281289 },
282- res : dto.HardwareInfo {},
290+ res : dto.HardwareInfo {
291+ CIMChassis : dto.CIMResponse {Response : chassis.PackageResponse {}},
292+ CIMChip : dto.CIMResponse {Responses : []any {chip.PackageResponse {}}},
293+ CIMCard : dto.CIMResponse {Response : card.PackageResponse {}},
294+ CIMBIOSElement : dto.CIMResponse {Response : bios.BiosElement {}},
295+ CIMProcessor : dto.CIMResponse {Responses : []any {processor.PackageResponse {}}},
296+ CIMPhysicalMemory : dto.CIMResponse {Responses : []any {}},
297+ },
298+ err : nil ,
299+ },
300+ {
301+ name : "success with populated data" ,
302+ action : 0 ,
303+ manMock : func (man * mocks.MockWSMAN , man2 * mocks.MockManagement ) {
304+ man .EXPECT ().
305+ SetupWsmanClient (gomock .Any (), false , true ).
306+ Return (man2 , nil )
307+ man2 .EXPECT ().
308+ GetHardwareInfo ().
309+ Return (wsmanAPI.HWResults {
310+ PhysicalMemoryResult : physical.Response {
311+ Body : physical.Body {
312+ PullResponse : physical.PullResponse {
313+ MemoryItems : []physical.PhysicalMemory {
314+ {
315+ ElementName : "Memory 0" ,
316+ Manufacturer : "Samsung" ,
317+ Capacity : 8388608 ,
318+ Speed : 3200 ,
319+ SerialNumber : "ABC123" ,
320+ BankLabel : "BANK0" ,
321+ },
322+ },
323+ },
324+ },
325+ },
326+ }, nil )
327+ },
328+ repoMock : func (repo * mocks.MockDeviceManagementRepository ) {
329+ repo .EXPECT ().
330+ GetByID (context .Background (), device .GUID , "" ).
331+ Return (device , nil )
332+ },
333+ res : dto.HardwareInfo {
334+ CIMChassis : dto.CIMResponse {Response : chassis.PackageResponse {}},
335+ CIMChip : dto.CIMResponse {Responses : []any {chip.PackageResponse {}}},
336+ CIMCard : dto.CIMResponse {Response : card.PackageResponse {}},
337+ CIMBIOSElement : dto.CIMResponse {Response : bios.BiosElement {}},
338+ CIMProcessor : dto.CIMResponse {Responses : []any {processor.PackageResponse {}}},
339+ CIMPhysicalMemory : dto.CIMResponse {Responses : []any {physical.PhysicalMemory {
340+ ElementName : "Memory 0" ,
341+ Manufacturer : "Samsung" ,
342+ Capacity : 8388608 ,
343+ Speed : 3200 ,
344+ SerialNumber : "ABC123" ,
345+ BankLabel : "BANK0" ,
346+ }}},
347+ },
283348 err : nil ,
284349 },
285350 {
@@ -303,7 +368,7 @@ func TestGetHardwareInfo(t *testing.T) {
303368 Return (man2 , nil )
304369 man2 .EXPECT ().
305370 GetHardwareInfo ().
306- Return (nil , ErrGeneral )
371+ Return (wsmanAPI. HWResults {} , ErrGeneral )
307372 },
308373 repoMock : func (repo * mocks.MockDeviceManagementRepository ) {
309374 repo .EXPECT ().
@@ -596,14 +661,84 @@ func TestGetDiskInfo(t *testing.T) {
596661 Return (man2 , nil )
597662 man2 .EXPECT ().
598663 GetDiskInfo ().
599- Return (gomock . Any () , nil )
664+ Return (wsmanAPI. DiskResults {} , nil )
600665 },
601666 repoMock : func (repo * mocks.MockDeviceManagementRepository ) {
602667 repo .EXPECT ().
603668 GetByID (context .Background (), device .GUID , "" ).
604669 Return (device , nil )
605670 },
606- res : dto.DiskInfo {},
671+ res : dto.DiskInfo {
672+ CIMMediaAccessDevice : dto.CIMResponse {Responses : []any {[]mediaaccess.MediaAccessDevice (nil )}},
673+ CIMPhysicalPackage : dto.CIMResponse {Responses : []any {[]physical.PhysicalPackage (nil )}},
674+ },
675+ err : nil ,
676+ },
677+ {
678+ name : "success with populated data" ,
679+ action : 0 ,
680+ manMock : func (man * mocks.MockWSMAN , man2 * mocks.MockManagement ) {
681+ man .EXPECT ().
682+ SetupWsmanClient (gomock .Any (), false , true ).
683+ Return (man2 , nil )
684+ man2 .EXPECT ().
685+ GetDiskInfo ().
686+ Return (wsmanAPI.DiskResults {
687+ MediaAccessPullResult : mediaaccess.Response {
688+ Body : mediaaccess.Body {
689+ PullResponse : mediaaccess.PullResponse {
690+ MediaAccessDevices : []mediaaccess.MediaAccessDevice {
691+ {
692+ CreationClassName : "CIM_MediaAccessDevice" ,
693+ DeviceID : "DISK0" ,
694+ ElementName : "SSD Drive" ,
695+ MaxMediaSize : 512000 ,
696+ },
697+ },
698+ },
699+ },
700+ },
701+ PPPullResult : physical.Response {
702+ Body : physical.Body {
703+ PullResponse : physical.PullResponse {
704+ PhysicalPackage : []physical.PhysicalPackage {
705+ {
706+ ElementName : "Physical Package 0" ,
707+ CreationClassName : "CIM_PhysicalPackage" ,
708+ Manufacturer : "Samsung" ,
709+ SerialNumber : "XYZ789" ,
710+ Model : "970 EVO" ,
711+ },
712+ },
713+ },
714+ },
715+ },
716+ }, nil )
717+ },
718+ repoMock : func (repo * mocks.MockDeviceManagementRepository ) {
719+ repo .EXPECT ().
720+ GetByID (context .Background (), device .GUID , "" ).
721+ Return (device , nil )
722+ },
723+ res : dto.DiskInfo {
724+ CIMMediaAccessDevice : dto.CIMResponse {Responses : []any {[]mediaaccess.MediaAccessDevice {
725+ {
726+ CreationClassName : "CIM_MediaAccessDevice" ,
727+ DeviceID : "DISK0" ,
728+ ElementName : "SSD Drive" ,
729+ MaxMediaSize : 512000 ,
730+ },
731+ }}},
732+ CIMPhysicalPackage : dto.CIMResponse {Responses : []any {[]physical.PhysicalPackage {
733+ {
734+ ElementName : "Physical Package 0" ,
735+ CreationClassName : "CIM_PhysicalPackage" ,
736+ Manufacturer : "Samsung" ,
737+ SerialNumber : "XYZ789" ,
738+ Model : "970 EVO" ,
739+ },
740+ }}},
741+ },
607742 err : nil ,
608743 },
609744 {
@@ -627,7 +762,7 @@ func TestGetDiskInfo(t *testing.T) {
627762 Return (man2 , nil )
628763 man2 .EXPECT ().
629764 GetDiskInfo ().
630- Return (nil , ErrGeneral )
765+ Return (wsmanAPI. DiskResults {} , ErrGeneral )
631766 },
632767 repoMock : func (repo * mocks.MockDeviceManagementRepository ) {
633768 repo .EXPECT ().
0 commit comments