Skip to content

feat: add wireless profile management API#921

Open
shaoboon wants to merge 1 commit into
mainfrom
sb_wifiprofile_api2
Open

feat: add wireless profile management API#921
shaoboon wants to merge 1 commit into
mainfrom
sb_wifiprofile_api2

Conversation

@shaoboon
Copy link
Copy Markdown
Contributor

@shaoboon shaoboon commented Apr 30, 2026

Change Summary

  • added CRUD wireless profile APIs
  • added wireless profile API input custom validators
  • added wireless profile CRUD use case device functions
  • added update wireless profile wsman message
  • added wireless profile APIs into openapi spec generation flow
  • added wireless profile API integration tests
  • added respective unit tests

NOTE:

Testing

Sample test data:

# curl cmds that were used in the testing
export HOST=http://localhost:8181 GUID=${device_guid} USER=${console_user} PASS=${console_password}
# get wifi profile list
curl -sS "http://localhost:8181/api/v1/amt/networkSettings/wireless/profile/$GUID" -H "Authorization: Bearer $(curl -sS -X POST "http://localhost:8181/api/v1/authorize" -H "Content-Type: application/json" -d "$(printf '{"username":"%s","password":"%s"}' "$USER" "$PASS")" | jq -r '.token')" | jq
# add wifi profile
curl -sS -X POST "http://localhost:8181/api/v1/amt/networkSettings/wireless/profile/$GUID" -H "Content-Type: application/json" -H "Authorization: Bearer $(curl -sS -X POST "http://localhost:8181/api/v1/authorize" -H "Content-Type: application/json" -d "$(printf '{"username":"%s","password":"%s"}' "$USER" "$PASS")" | jq -r '.token')" -d @wireless_profiles_payload_wiamt2.json
# delete wifi profile
curl -sS -X DELETE "http://localhost:8181/api/v1/amt/networkSettings/wireless/profile/$GUID/WiAMT2" -H "Content-Type: application/json" -H "Authorization: Bearer $(curl -sS -X POST "http://localhost:8181/api/v1/authorize" -H "Content-Type: application/json" -d "$(printf '{"username":"%s","password":"%s"}' "$USER" "$PASS")" | jq -r '.token')"
# update existing wifi profile
curl -sS -X PATCH "http://localhost:8181/api/v1/amt/networkSettings/wireless/profile/$GUID" -H "Content-Type: application/json" -H "Authorization: Bearer $(curl -sS -X POST "http://localhost:8181/api/v1/authorize" -H "Content-Type: application/json" -d "$(printf '{"username":"%s","password":"%s"}' "$USER" "$PASS")" | jq -r '.token')" -d @wireless_profiles_payload_wiamt2_patch.json

# Add wireless profiles

{
  "ProfileName": "WiAMT1",
  "SSID": "WiAMT1",
  "AuthenticationMethod": "WPAPSK",
  "EncryptionMethod": "CCMP",
  "Password": "password123",
  "Priority": 10
}

{
  "ProfileName": "WiAMT2",
  "SSID": "WiAMT2",
  "AuthenticationMethod": "WPA2PSK",
  "EncryptionMethod": "CCMP",
  "Password": "password123",
  "Priority": 20
}

{
  "ProfileName": "CorpEAP1",
  "SSID": "CorpNet1",
  "AuthenticationMethod": "WPAIEEE8021x",
  "EncryptionMethod": "CCMP",
  "Priority": 35,
  "IEEE8021x": {
    "AuthenticationProtocol": 2,
    "Username": "corpuser1",
    "Password": "corpsecret",
    "CACert": "[REDACTED]"
  }
}

{
  "ProfileName": "CorpEAP2",
  "SSID": "CorpNet2",
  "AuthenticationMethod": "WPA2IEEE8021x",
  "EncryptionMethod": "CCMP",
  "Priority": 40,
  "IEEE8021x": {
    "AuthenticationProtocol": 0,
    "Username": "corpuser2",
    "Password": "",
    "PrivateKey": "[REDACTED]",
    "ClientCert": "[REDACTED]",
    "CACert": "[REDACTED]"
  }
}

{
  "ProfileName": "CorpEAP3",
  "SSID": "CorpNet3",
  "AuthenticationMethod": "WPA2IEEE8021x",
  "EncryptionMethod": "CCMP",
  "Priority": 50,
  "IEEE8021x": {
    "AuthenticationProtocol": 2,
    "Username": "corpuser3",
    "Password": "corpsecret",
    "PrivateKey": "[REDACTED]",
    "ClientCert": "[REDACTED]",
    "CACert": "[REDACTED]"
  }
}

# Patch wireless profiles

{
  "ProfileName": "WiAMT2",
  "SSID": "WiAMT",
  "AuthenticationMethod": "WPA2PSK",
  "EncryptionMethod": "CCMP",
  "Password": "P@ssw0rd123456",
  "Priority": 36
}

{
  "ProfileName": "CorpEAP3",
  "SSID": "CorpNet3",
  "AuthenticationMethod": "WPA2IEEE8021x",
  "EncryptionMethod": "CCMP",
  "Priority": 60,
  "IEEE8021x": {
    "AuthenticationProtocol": 0,
    "Username": "corpuser3",
    "Password": "",
    "PrivateKey": "[REDACTED]",
    "ClientCert": "[REDACTED]",
    "CACert": "[REDACTED]"
  }
}

Test cases

  • Read
    • +ve: passed
  • Add
    • +ve (non-IEEE8021x): passed
    • +ve (IEEE8021x auth protocol 0): passed
    • +ve (IEEE8021x auth protocol 2): passed
    • -ve (duplicate profile name): passed
    • -ve (duplicate priority): passed
  • Update
    • +ve (remain priority): passed
    • +ve (change priority): passed
    • -ve (profile name mismatch): passed
    • -ve (profile name not exist): passed
    • -ve (duplicate priority): passed
  • Delete
    • +ve (non-IEEE8021x): passed
    • +ve (IEEE8021x): passed
    • -ve (profile name not exist): passed

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 30, 2026

Codecov Report

❌ Patch coverage is 66.98113% with 210 lines in your changes missing coverage. Please review.
✅ Project coverage is 42.91%. Comparing base (2d1bb4d) to head (6392a84).

Files with missing lines Patch % Lines
internal/mocks/wsman_mocks.go 0.00% 62 Missing ⚠️
internal/controller/openapi/devicemanagement.go 0.00% 52 Missing ⚠️
internal/mocks/devicemanagement_mocks.go 0.00% 33 Missing ⚠️
internal/mocks/wsv1_mocks.go 0.00% 33 Missing ⚠️
internal/entity/dto/v1/wifiprofile.go 66.66% 18 Missing ⚠️
internal/controller/httpapi/router.go 0.00% 11 Missing ⚠️
internal/usecase/devices/wifiprofile.go 99.70% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #921      +/-   ##
==========================================
+ Coverage   41.66%   42.91%   +1.24%     
==========================================
  Files         135      138       +3     
  Lines       12433    13064     +631     
==========================================
+ Hits         5180     5606     +426     
- Misses       6698     6903     +205     
  Partials      555      555              

☔ 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 a wireless profile management API to the device management surface, wiring new WSMAN operations through the devices usecase and exposing HTTP/OpenAPI endpoints backed by request validation.

Changes:

  • Extend WSMAN Management + devices Feature interfaces to support WiFi profile CRUD-like operations (list/apply) and IEEE802.1x dependencies.
  • Add devices usecase implementation for GetWirelessProfiles / ApplyWirelessProfiles, including certificate/credential handling for 802.1x.
  • Introduce DTO request type + custom validators and register them in the HTTP router; add HTTP routes, mocks, and tests.

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
internal/usecase/devices/wsman/interfaces.go Expands WSMAN management interface with WiFi profile + 802.1x/cert helpers.
internal/usecase/devices/wifistate.go Import cleanup (no functional change).
internal/usecase/devices/wifistate_test.go Import cleanup (no functional change).
internal/usecase/devices/wifiprofile.go New usecase logic to list/apply wireless profiles, map 802.1x associations, and manage cert handles.
internal/usecase/devices/wifiprofile_test.go New usecase tests for list/apply flows.
internal/usecase/devices/wifiprofile_private_test.go New unit tests for internal mapping/handle-resolution helpers.
internal/usecase/devices/interfaces.go Adds GetWirelessProfiles/ApplyWirelessProfiles to the devices feature interface.
internal/mocks/wsv1_mocks.go Updates WS v1 mocks for new feature methods.
internal/mocks/wsman_mocks.go Updates WSMAN mocks with new management methods.
internal/mocks/devicemanagement_mocks.go Updates device management feature mocks for new API methods.
internal/entity/dto/v1/wifiprofile.go Adds WirelessProfilesApplyRequest and custom validators for wireless profile payloads.
internal/entity/dto/v1/wifiprofile_test.go Adds tests for new validators.
internal/controller/ws/v1/interface.go Extends WS interface with wireless profile operations.
internal/controller/openapi/devicemanagement.go Adds OpenAPI route definitions + example handlers for wireless profiles.
internal/controller/httpapi/v1/wifiprofile.go Adds HTTP handlers for get/apply wireless profiles.
internal/controller/httpapi/v1/wifiprofile_test.go Adds route tests for wireless profile endpoints.
internal/controller/httpapi/v1/devicemanagement.go Registers new WiFi profile routes under /amt/networkSettings/wireless/profile/:guid.
internal/controller/httpapi/router.go Refactors and centralizes custom validator registration; registers new wireless-profile validators.
integration-test/collections/console_mps_apis.postman_collection.json Adds Postman collection entries for the new endpoints.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/controller/openapi/devicemanagement.go Outdated
Comment thread internal/usecase/devices/wifiprofile.go Outdated
Comment thread internal/usecase/devices/wifiprofile.go Outdated
Comment thread internal/controller/httpapi/v1/wifiprofile_test.go Outdated
Comment thread internal/usecase/devices/wifiprofile.go Outdated
Comment thread internal/usecase/devices/wifiprofile.go Outdated
@shaoboon shaoboon force-pushed the sb_wifiprofile_api2 branch 2 times, most recently from 66c8f6e to ef25e79 Compare May 5, 2026 10:13
@shaoboon shaoboon requested a review from Copilot May 5, 2026 10:13
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

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


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/usecase/devices/wifiprofile.go Outdated
Comment thread internal/usecase/devices/wifiprofile.go Outdated
Comment thread internal/entity/dto/v1/wifiprofile.go Outdated
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

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

Comment thread internal/usecase/devices/wifiprofile.go
Comment thread internal/controller/httpapi/v1/wifiprofile.go
Comment thread internal/controller/httpapi/v1/wifiprofile.go Outdated
@shaoboon shaoboon force-pushed the sb_wifiprofile_api2 branch from f4e17e6 to 2b73759 Compare May 8, 2026 10:38
@shaoboon shaoboon marked this pull request as ready for review May 8, 2026 10:42
@shaoboon shaoboon requested a review from a team as a code owner June 3, 2026 02:28
@shaoboon shaoboon force-pushed the sb_wifiprofile_api2 branch from 19b6fcc to 2ea3109 Compare June 3, 2026 02:43
@madhavilosetty-intel
Copy link
Copy Markdown
Contributor

  1. Please remove sensitive information (e.g., passwords, CACert, clientCert , privatekey) from the response. The payload should only include non-sensitive fields:
{
  "ProfileName": "WiAMT2",
  "SSID": "WiAMT",
  "AuthenticationMethod": "WPA2PSK",
  "EncryptionMethod": "CCMP",
  "Priority": 36
}

{
  "ProfileName": "CorpEAP3",
  "SSID": "CorpNet3",
  "AuthenticationMethod": "WPA2IEEE8021x",
  "EncryptionMethod": "CCMP",
  "Priority": 60,
  "IEEE8021x": {
    "AuthenticationProtocol": 0,
    "Username": "corpuser3",
  }
}
  1. Please add a footer to the PR description indicating the issue this change resolves (e.g., Fixes/Resolves #1355).

@shaoboon shaoboon force-pushed the sb_wifiprofile_api2 branch from 2ea3109 to ac1a829 Compare June 4, 2026 07:15
@shaoboon
Copy link
Copy Markdown
Contributor Author

shaoboon commented Jun 4, 2026

  1. Please remove sensitive information (e.g., passwords, CACert, clientCert , privatekey) from the response. The payload should only include non-sensitive fields:
{
  "ProfileName": "WiAMT2",
  "SSID": "WiAMT",
  "AuthenticationMethod": "WPA2PSK",
  "EncryptionMethod": "CCMP",
  "Priority": 36
}

{
  "ProfileName": "CorpEAP3",
  "SSID": "CorpNet3",
  "AuthenticationMethod": "WPA2IEEE8021x",
  "EncryptionMethod": "CCMP",
  "Priority": 60,
  "IEEE8021x": {
    "AuthenticationProtocol": 0,
    "Username": "corpuser3",
  }
}

All sensitive fields have been removed.

[
  {
    "profileName": "WiAMT1",
    "ssid": "TP-Link_WiAMT",
    "authenticationMethod": "WPAPSK",
    "encryptionMethod": "CCMP",
    "priority": 10
  },
  {
    "profileName": "CorpEAP1",
    "ssid": "CorpNet1",
    "authenticationMethod": "WPAIEEE8021x",
    "encryptionMethod": "CCMP",
    "priority": 30,
    "ieee8021x": {
      "username": "corpuser1",
      "authenticationProtocol": 2
    }
  }
]

  1. Please add a footer to the PR description indicating the issue this change resolves (e.g., Fixes/Resolves #1355).
  • Added comprehensive commit message
  • Added PR description footer indicating the issue this PR resolves

@shaoboon shaoboon self-assigned this Jun 5, 2026
Add CRUD wireless profile management to the device surface so operators
can list, create, update, and delete Intel AMT WiFi endpoint profiles
(including 802.1x/EAP profiles) directly through Console instead of
hand-driving WSMAN.

New HTTP routes under networkSettings/wireless/profile/{guid} are
backed by a devices usecase that talks to extended WSMAN Management
operations: it reads existing WiFi and CIM IEEE 802.1x settings,
resolves their concrete dependencies, and applies adds/updates while
enforcing profile-name and priority uniqueness. For 802.1x profiles the
usecase reconciles client/root certificates and private keys against the
device, reusing existing credential handles when present and adding them
otherwise, with a short pause to let AMT settle certificate handling
before the profile is applied.

Read responses are sanitized: passwords, CACert, ClientCert, and
PrivateKey are never returned, only non-sensitive fields (profile name,
SSID, auth/encryption method, priority, and 802.1x username/auth
protocol). Request payloads are guarded by custom validators wired into
the HTTP router, and the new endpoints are folded into the OpenAPI spec
generation flow alongside regenerated mocks, unit tests, and integration
tests covering the read/add/update/delete paths.

Depends on go-wsman-messages#686 for the update-WiFi-settings message.

Refs #834
@shaoboon shaoboon force-pushed the sb_wifiprofile_api2 branch from 2687c64 to 6392a84 Compare June 8, 2026 08:06
Copy link
Copy Markdown
Contributor

@sudhir-intc sudhir-intc left a comment

Choose a reason for hiding this comment

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

Thanks for handling the scenario when wifi adapter is missing.
LGTM, please merge post the CI checks pass.

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.

Add support for managing wireless profiles from Console

4 participants