feat(api): add wired network settings get and patch endpoints#1052
Open
shaoboon wants to merge 1 commit into
Open
feat(api): add wired network settings get and patch endpoints#1052shaoboon wants to merge 1 commit into
shaoboon wants to merge 1 commit into
Conversation
Codecov Report❌ Patch coverage is 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. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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
10888e5 to
bcd3fcf
Compare
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
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:
Test Coverage Summary
Total 22 test cases.
Negative — Binding (400)
dhcpEnabled(required)ipAddresssubnetMaskdefaultGatewayprimaryDNSsecondaryDNSipAddressrejected (IPv4-only contract)Negative — Validation (400)
dhcpEnabled:falseonly)ipAddresssubnetMaskdefaultGatewayprimaryDNSsecondaryDNSonly (triggers static, missing ipAddress)Negative — Not Supported 802.1X (501)
ieee8021xEAP-TLS shapeieee8021xPEAP + full static configieee8021xempty object (non-nil pointer)Positive (validation passes)
dhcpEnabled=false,ipSyncEnabled=false; ip/subnet/gateway/primaryDNS echoedsecondaryDNS— PATCHsecondaryDNSechoeddhcpEnabled=trueipSyncEnabledignored) — PATCHdhcpEnabled=trueNOTE: 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