Skip to content

feat(api): add wired network settings get and patch endpoints#1052

Open
shaoboon wants to merge 1 commit into
mainfrom
sb_wired_config
Open

feat(api): add wired network settings get and patch endpoints#1052
shaoboon wants to merge 1 commit into
mainfrom
sb_wired_config

Conversation

@shaoboon
Copy link
Copy Markdown
Contributor

@shaoboon shaoboon commented Jun 4, 2026

Add GET and PATCH /api/v1/amt/networkSettings/wired/:guid so callers can read and update a device's wired IPv4 configuration (DHCP or static IP) without touching the combined networkSettings payload.

The use case reuses GetNetworkSettings to read the wired port, then overlays the requested changes onto the current AMT Ethernet Port Settings 0 and issues a single Put. Static IP mode requires ipAddress, subnetMask, defaultGateway and primaryDNS; DHCP and IP-sync modes clear the explicit IP fields, matching AMT firmware rules.

Define a forward-looking ieee8021x request block on the patch DTO for future wired 802.1X support. It is not yet implemented: supplying the object returns 501 Not Implemented so the contract is stable and the later implementation is purely additive.

Wire the endpoints through the Gin handlers, the Fuego/OpenAPI declaration and the MPS Postman collection, regenerate mocks, and add use-case tests covering DHCP, static IP, validation errors and the not-supported 802.1X path.

Resolves: #837

NOTE:

When changing to a static IP, it may take several seconds before Intel AMT responds to packets addressed to the new IP address. It is recommended to wait 10 seconds after changing to a static IP before attempting to communicate with the platform.

  • The above note is quoted from AMT SDK, due to this limitation, it is expected that there will be few seconds device AMT down time after the configuration request, especially changing to a new static IP or pending for a new IP from DHCP server

Functional Test

Tested on-target using newman, test collections and environment file are as follow:
wired_network.postman_collection.json
wired_network.postman_environment.json

Test Instructions

Pre-requisites:

  • console app is running
  • device provisioned and guid captured
  • newman installed
  • device host dhcp is enabled
  • capture device ipAddress, subnetMask, defaultGateway, primaryDNS, secondaryDNS
# Modify the value of following keys in the environment file
# - protocol
# - host
# - consoleUser
# - consolePass
# - deviceId
# - ipAddress
# - subnetMask
# - defaultGateway
# - primaryDNS
# - secondaryDNS

# Execute newman test
newman run wired_network.postman_collection.json -e wired_network.postman_environment.json

Test Coverage Summary

Total 22 test cases.

Negative — Binding (400)

# Case Asserts
08 Missing dhcpEnabled (required) 400
09 Invalid ipAddress 400
10 Invalid subnetMask 400
11 Invalid defaultGateway 400
12 Invalid primaryDNS 400
13 Invalid secondaryDNS 400
13b IPv6 ipAddress rejected (IPv4-only contract) 400

Negative — Validation (400)

# Case Asserts
14 DHCP enabled + static IP 400
15 No mode chosen (dhcpEnabled:false only) 400
16 Static missing ipAddress 400
17 Static missing subnetMask 400
18 Static missing defaultGateway 400
19 Static missing primaryDNS 400
20 secondaryDNS only (triggers static, missing ipAddress) 400
20b IP sync enabled + static IP 400

Negative — Not Supported 802.1X (501)

# Case Asserts
21 ieee8021x EAP-TLS shape 501
22 ieee8021x PEAP + full static config 501
23 ieee8021x empty object (non-nil pointer) 501

Positive (validation passes)

# Request Asserts
04 Static IP (minimal) — PATCH 204; not 400/501; empty body
04 Verify Static IP (GET after settle) 200; well-formed body; dhcpEnabled=false, ipSyncEnabled=false; ip/subnet/gateway/primaryDNS echoed
05 Static IP + secondaryDNS — PATCH 204; empty body
05 Verify (GET after settle) 200; static applied; all 5 static fields incl. secondaryDNS echoed
01 DHCP (minimal) — PATCH 204; empty body
01 Verify DHCP (GET after settle, 15s) 200; well-formed; dhcpEnabled=true
02 DHCP (ipSyncEnabled ignored) — PATCH 204; empty body
02 Verify DHCP (GET after settle) 200; dhcpEnabled=true

NOTE: the static IP sync(DHCP disabled, IP sync enabled) case is not covered in this test suite, as it requires the device host dhcp to be disabled, however, it was covered using manual steps

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 4, 2026

Codecov Report

❌ Patch coverage is 62.43655% with 74 lines in your changes missing coverage. Please review.
✅ Project coverage is 42.04%. Comparing base (2d1bb4d) to head (efe63f8).

Files with missing lines Patch % Lines
internal/controller/openapi/devicemanagement.go 0.00% 22 Missing ⚠️
internal/mocks/wsman_mocks.go 0.00% 18 Missing ⚠️
internal/mocks/devicemanagement_mocks.go 0.00% 17 Missing ⚠️
internal/mocks/wsv1_mocks.go 0.00% 17 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1052      +/-   ##
==========================================
+ Coverage   41.66%   42.04%   +0.37%     
==========================================
  Files         135      135              
  Lines       12433    12628     +195     
==========================================
+ Hits         5180     5309     +129     
- Misses       6698     6765      +67     
+ Partials      555      554       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds dedicated /api/v1/amt/networkSettings/wired/{guid} GET and PATCH endpoints to retrieve and update a device’s wired (AMT Ethernet Port Settings 0) IPv4 configuration without requiring callers to use the combined network settings payload, while reserving a forward-compatible (currently unsupported) request shape for wired 802.1X.

Changes:

  • Extend device WSMAN/usecase interfaces and implement usecase methods for wired network settings read + patch.
  • Add new v1 HTTP routes and OpenAPI (Fuego) route declarations for wired network settings.
  • Update mocks, Postman collection coverage, and add use-case tests for wired get/patch behaviors.

Reviewed changes

Copilot reviewed 10 out of 13 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
internal/usecase/devices/wsman/interfaces.go Extends WSMAN management interface with ethernet port settings get/put methods.
internal/usecase/devices/network.go Adds wired instance ID constants and implements Get/Patch wired network settings plus validation/request builder helpers.
internal/usecase/devices/network_test.go Adds unit tests for GetWiredNetworkSettings and PatchWiredNetworkSettings scenarios.
internal/usecase/devices/interfaces.go Extends devices.Feature interface with wired get/patch methods.
internal/mocks/wsv1_mocks.go Regenerated mocks for ws controller Feature interface additions.
internal/mocks/wsman_mocks.go Regenerated mocks for WSMAN Management interface additions.
internal/mocks/devicemanagement_mocks.go Regenerated mocks for device management feature interface additions.
internal/entity/dto/v1/network.go Introduces PATCH request DTO for wired IPv4 config and a forward-looking wired 802.1X config block.
internal/controller/ws/v1/interface.go Extends WS controller feature interface with wired get/patch methods.
internal/controller/openapi/devicemanagement.go Declares new OpenAPI routes for wired get/patch endpoints.
internal/controller/httpapi/v1/network.go Adds Gin handlers for wired get/patch endpoints and request binding.
internal/controller/httpapi/v1/devicemanagement.go Registers new Gin routes under the v1 AMT route group.
integration-test/collections/console_mps_apis.postman_collection.json Adds Postman requests for wired get/patch endpoints (404 baseline).
Files not reviewed (3)
  • internal/mocks/devicemanagement_mocks.go: Language not supported
  • internal/mocks/wsman_mocks.go: Language not supported
  • internal/mocks/wsv1_mocks.go: Language not supported

Comment thread internal/usecase/devices/network.go
Comment thread internal/controller/httpapi/v1/network.go
Comment thread internal/entity/dto/v1/network.go Outdated
@shaoboon shaoboon force-pushed the sb_wired_config branch 2 times, most recently from 10888e5 to bcd3fcf Compare June 5, 2026 11:12
@shaoboon shaoboon self-assigned this Jun 5, 2026
Add GET and PATCH /api/v1/amt/networkSettings/wired/:guid so callers
can read and update a device's wired IPv4 configuration (DHCP or
static IP) without touching the combined networkSettings payload.

The use case reuses GetNetworkSettings to read the wired port, then
overlays the requested changes onto the current AMT Ethernet Port
Settings 0 and issues a single Put. Static IP mode requires ipAddress,
subnetMask, defaultGateway and primaryDNS; DHCP and IP-sync modes
clear the explicit IP fields, matching AMT firmware rules.

Define a forward-looking ieee8021x request block on the patch DTO for
future wired 802.1X support. It is not yet implemented: supplying the
object returns 501 Not Implemented so the contract is stable and the
later implementation is purely additive.

Wire the endpoints through the Gin handlers, the Fuego/OpenAPI
declaration and the MPS Postman collection, regenerate mocks, and add
use-case tests covering DHCP, static IP, validation errors and the
not-supported 802.1X path.

Resolves: #837
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support configuring wired network settings from Console

2 participants