diff --git a/integration-test/collections/console_mps_apis.postman_collection.json b/integration-test/collections/console_mps_apis.postman_collection.json index 53748b1c..31699aab 100644 --- a/integration-test/collections/console_mps_apis.postman_collection.json +++ b/integration-test/collections/console_mps_apis.postman_collection.json @@ -1148,7 +1148,7 @@ "header": [], "body": { "mode": "raw", - "raw": "{\r\n \"guid\": \"143e4567-e89b-12d3-a456-426614174000\",\r\n \"friendlyName\": \"friendlyName\",\r\n \"hostname\": \"hostname\",\r\n \"tags\": [],\r\n \"mpsusername\": \"admin\",\r\n \"deviceInfo\": {\r\n \"fwVersion\": \"16.1.30\",\r\n \"fwBuild\": \"3400\",\r\n \"fwSku\": \"11\",\r\n \"currentMode\": \"Admin\",\r\n \"features\": \"SOL,IDER,KVM\",\r\n \"ipAddress\": \"10.0.0.12\",\r\n \"lastUpdated\": \"2026-05-21T00:00:00Z\",\r\n \"tlsMode\": \"TLS 1.2\",\r\n \"upid\": {\r\n \"oemPlatformIdType\": \"Not Set (0)\",\r\n \"oemId\": \"\",\r\n \"csmeId\": \"4A45A39C5ED9462082510000\"\r\n },\r\n \"amtEnabledInBIOS\": true,\r\n \"meInterfaceVersion\": \"16.1.25.2124\",\r\n \"dhcpEnabled\": true,\r\n \"certHashes\": [\r\n \"a1b2c3\",\r\n \"d4e5f6\"\r\n ],\r\n \"lmsInstalled\": true,\r\n \"lmsVersion\": \"2410.5.0.0\",\r\n \"osName\": \"linux\",\r\n \"osVersion\": \"6.8.0-51-generic\",\r\n \"osDistro\": \"Ubuntu 24.04 LTS\",\r\n \"cpuModel\": \"Intel(R) Core(TM) Ultra 7 165H\",\r\n \"osIpAddress\": \"10.49.76.163\",\r\n \"ethernetAdapterCount\": 2,\r\n \"monitorConnected\": true,\r\n \"ieee8021xEnabled\": false\r\n }\r\n}", + "raw": "{\r\n \"guid\": \"143e4567-e89b-12d3-a456-426614174000\",\r\n \"friendlyName\": \"friendlyName\",\r\n \"hostname\": \"hostname\",\r\n \"tags\": [],\r\n \"mpsusername\": \"admin\",\r\n \"deviceInfo\": {\r\n \"fwVersion\": \"16.1.30\",\r\n \"fwBuild\": \"3400\",\r\n \"fwSku\": \"11\",\r\n \"discovered\": true,\r\n \"currentMode\": \"Admin\",\r\n \"features\": \"SOL,IDER,KVM\",\r\n \"ipAddress\": \"10.0.0.12\",\r\n \"lastUpdated\": \"2026-05-21T00:00:00Z\",\r\n \"tlsMode\": \"TLS 1.2\",\r\n \"upid\": {\r\n \"oemPlatformIdType\": \"Not Set (0)\",\r\n \"oemId\": \"\",\r\n \"csmeId\": \"4A45A39C5ED9462082510000\"\r\n },\r\n \"amtEnabledInBIOS\": true,\r\n \"meInterfaceVersion\": \"16.1.25.2124\",\r\n \"dhcpEnabled\": true,\r\n \"certHashes\": [\r\n \"a1b2c3\",\r\n \"d4e5f6\"\r\n ],\r\n \"lmsInstalled\": true,\r\n \"lmsVersion\": \"2410.5.0.0\",\r\n \"osName\": \"linux\",\r\n \"osVersion\": \"6.8.0-51-generic\",\r\n \"osDistro\": \"Ubuntu 24.04 LTS\",\r\n \"cpuModel\": \"Intel(R) Core(TM) Ultra 7 165H\",\r\n \"osIpAddress\": \"10.49.76.163\",\r\n \"ethernetAdapterCount\": 2,\r\n \"monitorConnected\": true,\r\n \"ieee8021xEnabled\": false\r\n }\r\n}", "options": { "raw": { "language": "json" diff --git a/internal/controller/httpapi/v1/devices_test.go b/internal/controller/httpapi/v1/devices_test.go index 49c49f43..9f6a625a 100644 --- a/internal/controller/httpapi/v1/devices_test.go +++ b/internal/controller/httpapi/v1/devices_test.go @@ -446,18 +446,21 @@ func TestDevicesUpdatePartialPatchTracksDeviceInfoSubfields(t *testing.T) { t.Parallel() guid := testDeviceGUID + discovered := true incoming := &dto.Device{ GUID: guid, DeviceInfo: &dto.DeviceInfo{ - FWVersion: "16.1.30", + FWVersion: "16.1.30", + Discovered: &discovered, }, } expectedFields := map[string]bool{ - "guid": true, - "deviceinfo": true, - "deviceinfo.fwversion": true, + "guid": true, + "deviceinfo": true, + "deviceinfo.fwversion": true, + "deviceinfo.discovered": true, } devicesFeature, engine := devicesTest(t) @@ -466,7 +469,7 @@ func TestDevicesUpdatePartialPatchTracksDeviceInfoSubfields(t *testing.T) { Update(context.Background(), incoming, expectedFields). Return(incoming, nil) - body := []byte(`{"guid":"` + guid + `","deviceInfo":{"fwVersion":"16.1.30"}}`) + body := []byte(`{"guid":"` + guid + `","deviceInfo":{"fwVersion":"16.1.30","discovered":true}}`) req, err := http.NewRequestWithContext(context.Background(), http.MethodPatch, "/api/v1/devices", bytes.NewBuffer(body)) require.NoError(t, err) @@ -481,6 +484,7 @@ func TestDevicesInsertAcceptsFullDeviceInfo(t *testing.T) { t.Parallel() lmsInstalled := false + discovered := true amtEnabledInBIOS := true dhcpEnabled := true ethernetAdapterCount := 2 @@ -494,6 +498,7 @@ func TestDevicesInsertAcceptsFullDeviceInfo(t *testing.T) { FWVersion: "16.1.30", FWBuild: "3400", FWSku: "11", + Discovered: &discovered, CurrentMode: "Admin", Features: "SOL,IDER,KVM", IPAddress: "10.0.0.12", @@ -534,6 +539,7 @@ func TestDevicesInsertAcceptsFullDeviceInfo(t *testing.T) { "fwVersion":"16.1.30", "fwBuild":"3400", "fwSku":"11", + "discovered":true, "currentMode":"Admin", "features":"SOL,IDER,KVM", "ipAddress":"10.0.0.12", diff --git a/internal/entity/dto/v1/device.go b/internal/entity/dto/v1/device.go index 27f51d10..a65587ef 100644 --- a/internal/entity/dto/v1/device.go +++ b/internal/entity/dto/v1/device.go @@ -41,6 +41,7 @@ type DeviceInfo struct { FWVersion string `json:"fwVersion"` FWBuild string `json:"fwBuild"` FWSku string `json:"fwSku"` + Discovered *bool `json:"discovered,omitempty"` CurrentMode string `json:"currentMode"` Features string `json:"features"` IPAddress string `json:"ipAddress"` diff --git a/internal/entity/dto/v1/device_test.go b/internal/entity/dto/v1/device_test.go index b21073fd..ccfaac18 100644 --- a/internal/entity/dto/v1/device_test.go +++ b/internal/entity/dto/v1/device_test.go @@ -14,6 +14,7 @@ func TestDeviceInfoJSONRoundTrip(t *testing.T) { amtEnabled := true dhcpEnabled := true lmsInstalled := true + discovered := true ethernetAdapterCount := 2 monitorConnected := true ieee8021xEnabled := false @@ -23,6 +24,7 @@ func TestDeviceInfoJSONRoundTrip(t *testing.T) { FWVersion: "16.1.30", FWBuild: "3400", FWSku: "11", + Discovered: &discovered, CurrentMode: "Admin", Features: "SOL,IDER,KVM", IPAddress: "10.0.0.12", @@ -59,6 +61,8 @@ func TestDeviceInfoJSONRoundTrip(t *testing.T) { require.Equal(t, info.MEInterfaceVersion, decoded.MEInterfaceVersion) require.Equal(t, info.CertHashes, decoded.CertHashes) require.Equal(t, info.LMSVersion, decoded.LMSVersion) + require.NotNil(t, decoded.Discovered) + require.Equal(t, *info.Discovered, *decoded.Discovered) require.NotNil(t, decoded.LMSInstalled) require.Equal(t, *info.LMSInstalled, *decoded.LMSInstalled) } diff --git a/internal/usecase/devices/repo_test.go b/internal/usecase/devices/repo_test.go index e9df3eb9..9b5ede05 100644 --- a/internal/usecase/devices/repo_test.go +++ b/internal/usecase/devices/repo_test.go @@ -759,13 +759,15 @@ func TestUpdatePartial(t *testing.T) { MEBXPassword: ptr("encrypted-mebx"), } - // Client sends only guid, tenantId and a new hostname. + // Client sends guid, a new hostname, and a partial deviceInfo update. + discovered := true incoming := &dto.Device{ GUID: "device-guid-123", TenantID: "tenant-id-456", Hostname: "new-hostname", DeviceInfo: &dto.DeviceInfo{ FWVersion: "16.1.30", + Discovered: &discovered, IPAddress: "10.0.0.55", LMSInstalled: boolPtr(true), }, @@ -776,13 +778,14 @@ func TestUpdatePartial(t *testing.T) { "hostname": true, "deviceinfo": true, "deviceinfo.fwversion": true, + "deviceinfo.discovered": true, "deviceinfo.ipaddress": true, "deviceinfo.lmsinstalled": true, } // After merge + dtoToEntity (MockCrypto re-encrypts plaintext to "encrypted"): // Only fields without omitempty tag are included in JSON for zero values. - expectedDeviceInfoJSON := `{"fwVersion":"16.1.30","fwBuild":"3400","fwSku":"","currentMode":"","features":"","ipAddress":"10.0.0.55","lmsInstalled":true}` + expectedDeviceInfoJSON := `{"fwVersion":"16.1.30","fwBuild":"3400","fwSku":"","discovered":true,"currentMode":"","features":"","ipAddress":"10.0.0.55","lmsInstalled":true}` expectedEntity := &entity.Device{ GUID: "device-guid-123", TenantID: "tenant-id-456", @@ -803,6 +806,7 @@ func TestUpdatePartial(t *testing.T) { DeviceInfo: &dto.DeviceInfo{ FWVersion: "16.1.30", FWBuild: "3400", + Discovered: boolPtr(true), IPAddress: "10.0.0.55", LMSInstalled: boolPtr(true), }, diff --git a/internal/usecase/devices/usecase.go b/internal/usecase/devices/usecase.go index 03f52c5d..dcd34b43 100644 --- a/internal/usecase/devices/usecase.go +++ b/internal/usecase/devices/usecase.go @@ -166,6 +166,7 @@ var deviceInfoFieldSetters = map[string]func(dst, src *dto.DeviceInfo){ "fwversion": func(dst, src *dto.DeviceInfo) { dst.FWVersion = src.FWVersion }, "fwbuild": func(dst, src *dto.DeviceInfo) { dst.FWBuild = src.FWBuild }, "fwsku": func(dst, src *dto.DeviceInfo) { dst.FWSku = src.FWSku }, + "discovered": func(dst, src *dto.DeviceInfo) { dst.Discovered = src.Discovered }, "currentmode": func(dst, src *dto.DeviceInfo) { dst.CurrentMode = src.CurrentMode }, "features": func(dst, src *dto.DeviceInfo) { dst.Features = src.Features }, "ipaddress": func(dst, src *dto.DeviceInfo) { dst.IPAddress = src.IPAddress },