diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
index 81912686..5730ef1b 100644
--- a/.github/workflows/codeql-analysis.yml
+++ b/.github/workflows/codeql-analysis.yml
@@ -17,10 +17,10 @@ on:
types:
- created
push:
- branches: [ main ]
+ branches: [ main, v2.0 ]
pull_request:
# The branches below must be a subset of the branches above
- branches: [ main ]
+ branches: [ main, v2.0 ]
schedule:
- cron: '26 23 * * 0'
diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml
index cdeba02c..e16984f3 100644
--- a/.github/workflows/go.yml
+++ b/.github/workflows/go.yml
@@ -9,9 +9,9 @@ name: Go CI
on:
push:
- branches: [main]
+ branches: [ main, v2.0]
pull_request:
- branches: [main]
+ branches: [ main, v2.0]
workflow_dispatch:
permissions:
contents: read
diff --git a/.gitignore b/.gitignore
index 7f6ce308..5b1778de 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,4 @@
*.exe
**/*.xml
coverage
-
+!**/wsmantesting/responses/**/*.xml
diff --git a/CHANGELOG.md b/CHANGELOG.md
deleted file mode 100644
index e69de29b..00000000
diff --git a/go.mod b/go.mod
index 40fa566d..f53ef057 100644
--- a/go.mod
+++ b/go.mod
@@ -1,14 +1,19 @@
-module github.com/open-amt-cloud-toolkit/go-wsman-messages
+module github.com/open-amt-cloud-toolkit/go-wsman-messages/v2
go 1.20
-require github.com/stretchr/testify v1.8.4
+require (
+ github.com/google/uuid v1.4.0
+ github.com/stretchr/testify v1.8.4
+ gopkg.in/yaml.v3 v3.0.1
+)
-require golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
+require golang.org/x/sys v0.13.0 // indirect
require (
github.com/davecgh/go-spew v1.1.1 // indirect
+ github.com/gorilla/websocket v1.5.1
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/sirupsen/logrus v1.9.3
- gopkg.in/yaml.v3 v3.0.1 // indirect
+ golang.org/x/net v0.17.0 // indirect
)
diff --git a/go.sum b/go.sum
index a9c72e4e..9233b0b4 100644
--- a/go.sum
+++ b/go.sum
@@ -1,6 +1,10 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4=
+github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
+github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY=
+github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
@@ -9,8 +13,11 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
-golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ=
+golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
+golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
+golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
diff --git a/internal/message/base.go b/internal/message/base.go
index 294794cc..46421ab0 100644
--- a/internal/message/base.go
+++ b/internal/message/base.go
@@ -8,15 +8,9 @@ package message
import (
"fmt"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsman"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
)
-type Base struct {
- WSManMessageCreator *WSManMessageCreator
- className string
- client wsman.WSManClient
-}
-
func NewBase(wsmanMessageCreator *WSManMessageCreator, className string) Base {
return Base{
WSManMessageCreator: wsmanMessageCreator,
@@ -24,7 +18,7 @@ func NewBase(wsmanMessageCreator *WSManMessageCreator, className string) Base {
}
}
-func NewBaseWithClient(wsmanMessageCreator *WSManMessageCreator, className string, client wsman.WSManClient) Base {
+func NewBaseWithClient(wsmanMessageCreator *WSManMessageCreator, className string, client client.WSMan) Base {
return Base{
WSManMessageCreator: wsmanMessageCreator,
className: className,
@@ -32,7 +26,7 @@ func NewBaseWithClient(wsmanMessageCreator *WSManMessageCreator, className strin
}
}
-// Enumerates the instances of this class
+// Enumerate returns an enumeration context which is used in a subsequent Pull call
func (b *Base) Enumerate() string {
header := b.WSManMessageCreator.CreateHeader(BaseActionsEnumerate, b.className, nil, "", "")
@@ -45,7 +39,7 @@ func (b *Base) Get(selector *Selector) string {
return b.WSManMessageCreator.CreateXML(header, GetBody)
}
-// Pulls instances of this class, following an Enumerate operation
+// Pull returns the instances of this class. An enumeration context provided by the Enumerate call is used as input.
func (b *Base) Pull(enumerationContext string) string {
header := b.WSManMessageCreator.CreateHeader(BaseActionsPull, b.className, nil, "", "")
body := createCommonBodyPull(enumerationContext, 0, 0)
@@ -88,7 +82,7 @@ func (b *Base) RequestStateChange(actionName string, requestedState int) string
return b.WSManMessageCreator.CreateXML(header, body)
}
-func (b *Base) Execute(message *wsman.Message) error {
+func (b *Base) Execute(message *client.Message) error {
if b.client != nil {
xmlResponse, err := b.client.Post(message.XMLInput)
message.XMLOutput = string(xmlResponse)
diff --git a/internal/message/constants.go b/internal/message/constants.go
index d106b1cb..8a96dad1 100644
--- a/internal/message/constants.go
+++ b/internal/message/constants.go
@@ -60,4 +60,9 @@ const (
DeleteBody = "
"
EnumerateBody = ""
GetBody = ""
+ AMTSchema = "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ CIMSchema = "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
+ IPSSchema = "http://intel.com/wbem/wscim/1/ips-schema/1/"
+ XMLBodySpace = "http://www.w3.org/2003/05/soap-envelope"
+ XMLPullResponseSpace = "http://schemas.xmlsoap.org/ws/2004/09/enumeration"
)
diff --git a/internal/message/types.go b/internal/message/types.go
index 55d0768a..734acc98 100644
--- a/internal/message/types.go
+++ b/internal/message/types.go
@@ -7,8 +7,16 @@ package message
import (
"encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
)
+type Base struct {
+ WSManMessageCreator *WSManMessageCreator
+ className string
+ client client.WSMan
+}
+
type Header struct {
XMLName xml.Name `xml:"Header"`
To string `xml:"To"`
@@ -22,3 +30,33 @@ type Action struct {
MustUnderstand string `xml:"mustUnderstand,attr"`
Value string `xml:",chardata"`
}
+
+type SelectorSet struct {
+ XMLName xml.Name `xml:"SelectorSet"`
+ Selector Selector
+}
+
+type Selector struct {
+ XMLName xml.Name `xml:"Selector,omitempty"`
+ Name string `xml:"Name,attr"`
+ Value string `xml:",chardata"`
+}
+type Selector_OUTPUT struct {
+ XMLName xml.Name `xml:"Selector,omitempty"`
+ Name string `xml:"Name,attr"`
+ Value string `xml:",chardata"`
+}
+
+type ReturnValue struct {
+ XMLName xml.Name `xml:"RequestStateChange_OUTPUT,omitempty"`
+ ReturnValue int `xml:"ReturnValue,omitempty"`
+ ReturnValueStr string `xml:"ReturnValueStr,omitempty"`
+}
+type WSManMessageCreator struct {
+ MessageID int
+ XmlCommonPrefix string
+ XmlCommonEnd string
+ AnonymousAddress string
+ DefaultTimeout string
+ ResourceURIBase string
+}
diff --git a/internal/message/wsman.go b/internal/message/wsman.go
index e6307db9..437dfcd9 100644
--- a/internal/message/wsman.go
+++ b/internal/message/wsman.go
@@ -13,30 +13,6 @@ import (
"strings"
)
-type Selector struct {
- XMLName xml.Name `xml:"w:Selector,omitempty"`
- Name string `xml:"Name,attr"`
- Value string `xml:",chardata"`
-}
-type Selector_OUTPUT struct {
- XMLName xml.Name `xml:"Selector,omitempty"`
- Name string `xml:"Name,attr"`
- Value string `xml:",chardata"`
-}
-
-type ReturnValue struct {
- ReturnValue int
- ReturnValueStr string
-}
-type WSManMessageCreator struct {
- MessageID int
- XmlCommonPrefix string
- XmlCommonEnd string
- AnonymousAddress string
- DefaultTimeout string
- ResourceURIBase string
-}
-
func NewWSManMessageCreator(resourceUriBase string) *WSManMessageCreator {
return &WSManMessageCreator{
MessageID: 0,
@@ -118,30 +94,6 @@ func (w *WSManMessageCreator) createSelector(selectorSet Selector) string {
return fmt.Sprintf(`%s`, selectorSet.Name, selectorSet.Value)
}
return ""
-
- // result := ""
- // for propName, propValue := range v {
- // propValueMap := propValue.(map[string]interface{})
- // result += fmt.Sprintf(``, propName)
- // if refParams, ok := propValueMap["ReferenceParameters"].(map[string]interface{}); ok {
- // address := propValueMap["Address"].(string)
- // resourceURI := refParams["ResourceURI"].(string)
- // selectorSet := refParams["SelectorSet"].(map[string]interface{})
- // selectorArray := selectorSet["Selector"].(map[string]interface{})
- // result += ""
- // result += fmt.Sprintf(`%s%s`, address, resourceURI)
-
- // if name, ok := selectorArray["$.Name"].(string); ok {
- // value := selectorArray["_"].(string)
- // result += fmt.Sprintf(`%s`, name, value)
- // }
- // result += ""
- // }
- // result += ""
- // }
- // result += ""
- // return result
-
}
// createSelectorObjectForBody creates an object for the body using the given selector.
diff --git a/pkg/amt/actions/constants.go b/pkg/amt/actions/constants.go
deleted file mode 100644
index ff2f68bd..00000000
--- a/pkg/amt/actions/constants.go
+++ /dev/null
@@ -1,48 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-package actions
-
-import "fmt"
-
-type Actions string
-
-const (
- ReadRecords Actions = "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AuditLog/ReadRecords"
- AddTrustedRootCertificate Actions = "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyManagementService/AddTrustedRootCertificate"
- AddCertificate Actions = "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyManagementService/AddCertificate"
- GenerateKeyPair Actions = "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyManagementService/GenerateKeyPair"
- AddKey Actions = "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyManagementService/AddKey"
- AddMps Actions = "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_RemoteAccessService/AddMpServer"
- AddRemoteAccessPolicyRule Actions = "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_RemoteAccessService/AddRemoteAccessPolicyRule"
- SetBootConfigRole Actions = "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_BootService/SetBootConfigRole"
- GetRecords Actions = "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_MessageLog/GetRecords"
- PositionToFirstRecord Actions = "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_MessageLog/PositionToFirstRecord"
- CommitChanges Actions = "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_SetupAndConfigurationService/CommitChanges"
- Unprovision Actions = "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_SetupAndConfigurationService/Unprovision"
- SetMEBxPassword Actions = "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_SetupAndConfigurationService/SetMEBxPassword"
- GetUuid Actions = "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_SetupAndConfigurationService/GetUuid"
- SetAdminAclEntryEx Actions = "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AuthorizationService/SetAdminAclEntryEx"
- AddUserAclEntryEx Actions = "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AuthorizationService/AddUserAclEntryEx"
- GetLowAccuracyTimeSynch Actions = "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_TimeSynchronizationService/GetLowAccuracyTimeSynch"
- SetHighAccuracyTimeSynch Actions = "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_TimeSynchronizationService/SetHighAccuracyTimeSynch"
- AddWiFiSettings Actions = "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_WiFiPortConfigurationService/AddWiFiSettings"
- AddAlarm Actions = "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AlarmClockService/AddAlarm"
- GeneratePKCS10RequestEx Actions = "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyManagementService/GeneratePKCS10RequestEx"
- GetCredentialCacheState Actions = "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_KerberosSettingData/GetCredentialCacheState"
- SetCredentialCacheState Actions = "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_KerberosSettingData/SetCredentialCacheState"
- EnumerateUserAclEntries Actions = "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AuthorizationService/EnumerateUserAclEntries"
- GetUserAclEntryEx Actions = "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AuthorizationService/GetUserAclEntryEx"
- UpdateUserAclEntryEx Actions = "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AuthorizationService/UpdateUserAclEntryEx"
- RemoveUserAclEntry Actions = "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AuthorizationService/RemoveUserAclEntry"
- GetAdminAclEntry Actions = "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AuthorizationService/GetAdminAclEntry"
- GetAdminAclEntryStatus Actions = "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AuthorizationService/GetAdminAclEntryStatus"
- GetAdminNetAclEntryStatus Actions = "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AuthorizationService/GetAdminNetAclEntryStatus"
- SetAclEnabledState Actions = "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AuthorizationService/SetAclEnabledState"
- GetAclEnabledState Actions = "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AuthorizationService/GetAclEnabledState"
-)
-
-func RequestStateChange(className string) string {
- return fmt.Sprintf("http://schemas.dmtf.org/wbem/wscim/1/amt-schema/2/%s/RequestStateChange", className)
-}
diff --git a/pkg/amt/alarmclock/service.go b/pkg/amt/alarmclock/service.go
deleted file mode 100644
index c307f8be..00000000
--- a/pkg/amt/alarmclock/service.go
+++ /dev/null
@@ -1,98 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-// AMT Alarm Clock Service derived from Service and provides the ability to set an alarm time to turn the host computer system on. Setting an alarm time is done by calling "AddAlarm" method."NextAMTAlarmTime" and "AMTAlarmClockInterval" properties are deprecated and "AddAlarm" should be used instead.
-package alarmclock
-
-import (
- "strconv"
- "strings"
- "time"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/actions"
-)
-
-const AMT_AlarmClockService = "AMT_AlarmClockService"
-
-type AlarmClockOccurrence struct {
- // Elementname is a user-friendly name for the object
- ElementName string `json:"ElementName"`
- // InstanceID is the instance key, set by the caller of AMT_AlarmClockService.AddAlarm.
- InstanceID string `json:"InstanceID"`
- // StartTime is the next time when the alarm is scheduled to be set.
- StartTime time.Time `json:"StartTime"`
- // Interval between occurrences of the alarm (0 if the alarm is scheduled to run once).
- Interval int `json:"Interval,omitempty"`
- // DeleteOnComplete if set to TRUE, the instance will be deleted by the FW when the alarm is completed
- DeleteOnCompletion bool `json:"DeleteOnCompletion"`
-}
-
-type Service struct {
- base message.Base
-}
-
-func NewService(wsmanMessageCreator *message.WSManMessageCreator) Service {
- return Service{base: message.NewBase(wsmanMessageCreator, string(AMT_AlarmClockService))}
-}
-
-// Get retrieves the representation of the instance
-func (acs Service) Get() string {
- return acs.base.Get(nil)
-}
-
-// Enumerates the instances of this class
-func (acs Service) Enumerate() string {
- return acs.base.Enumerate()
-}
-
-// Pulls instances of this class, following an Enumerate operation
-func (acs Service) Pull(enumerationContext string) string {
- return acs.base.Pull(enumerationContext)
-}
-
-// AddAlarm creates an alarm that would wake the system at a given time.The method receives as input an embedded instance of type IPS_AlarmClockOccurrence, with the following fields set: StartTime, Interval, InstanceID, DeleteOnCompletion. Upon success, the method creates an instance of IPS_AlarmClockOccurrence which is associated with AlarmClockService.The method would fail if 5 instances or more of IPS_AlarmClockOccurrence already exist in the system.
-func (acs Service) AddAlarm(alarmClockOccurrence AlarmClockOccurrence) string {
- header := acs.base.WSManMessageCreator.CreateHeader(string(actions.AddAlarm), string(AMT_AlarmClockService), nil, "", "")
- startTime := alarmClockOccurrence.StartTime.UTC().Format(time.RFC3339Nano)
- startTime = strings.Split(startTime, ".")[0]
-
- var body strings.Builder
- body.WriteString(``)
- body.WriteString(alarmClockOccurrence.InstanceID)
- body.WriteString(``)
-
- if alarmClockOccurrence.ElementName != "" {
- body.WriteString(``)
- body.WriteString(alarmClockOccurrence.ElementName)
- body.WriteString(``)
- }
-
- body.WriteString(``)
- body.WriteString(startTime)
- body.WriteString(``)
-
- if alarmClockOccurrence.Interval != 0 {
- minutes := alarmClockOccurrence.Interval % 60
- hours := (alarmClockOccurrence.Interval / 60) % 24
- days := alarmClockOccurrence.Interval / 1440
-
- body.WriteString(`P`)
- body.WriteString(strconv.Itoa(days))
- body.WriteString("DT")
- body.WriteString(strconv.Itoa(hours))
- body.WriteString("H")
- body.WriteString(strconv.Itoa(minutes))
- body.WriteString(`M`)
- }
-
- body.WriteString(``)
- body.WriteString(strconv.FormatBool(alarmClockOccurrence.DeleteOnCompletion))
- body.WriteString(``)
-
- return acs.base.WSManMessageCreator.CreateXML(header, body.String())
-}
diff --git a/pkg/amt/alarmclock/service_test.go b/pkg/amt/alarmclock/service_test.go
deleted file mode 100644
index 9117455e..00000000
--- a/pkg/amt/alarmclock/service_test.go
+++ /dev/null
@@ -1,70 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package alarmclock
-
-import (
- "testing"
- "time"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/actions"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestAMT_AlarmClockService(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewService(wsmanMessageCreator)
-
- t.Run("amt_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid AMT_AlarmClockService Get wsman message", "AMT_AlarmClockService", wsmantesting.GET, "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid AMT_AlarmClockService Enumerate wsman message", "AMT_AlarmClockService", wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid AMT_AlarmClockService Pull wsman message", "AMT_AlarmClockService", wsmantesting.PULL, wsmantesting.PULL_BODY, func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- //AddAlarm
- {"should create a valid AMT_AlarmClockService AddAlarm wsman message", "AMT_AlarmClockService", string(actions.AddAlarm), `InstanceAlarm instance name2022-12-31T23:59:00ZP1DT23H59Mtrue`, func() string {
-
- startTime := "2022-12-31T23:59:00Z"
- minutes := 59
- hours := 23
- days := 1
- interval := minutes + hours*60 + days*1440
-
- startTimeFormatted, _ := time.Parse(time.RFC3339, startTime)
- return elementUnderTest.AddAlarm(AlarmClockOccurrence{
- InstanceID: "Instance",
- StartTime: startTimeFormatted,
- ElementName: "Alarm instance name",
- Interval: interval,
- DeleteOnCompletion: true,
- })
- }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-}
diff --git a/pkg/amt/auditlog/message.go b/pkg/amt/auditlog/message.go
deleted file mode 100644
index 47895b97..00000000
--- a/pkg/amt/auditlog/message.go
+++ /dev/null
@@ -1,58 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-// Represents an Audit Log in the Intel AMT subsystem.
-package auditlog
-
-import (
- "encoding/xml"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/actions"
-)
-
-const AMT_AuditLog = "AMT_AuditLog"
-
-type AuditLog struct {
- base message.Base
-}
-
-type readRecords_INPUT struct {
- XMLName xml.Name `xml:"h:ReadRecords_INPUT"`
- H string `xml:"xmlns:h,attr"`
- StartIndex int `xml:"h:StartIndex" json:"StartIndex"`
-}
-
-func NewAuditLog(wsmanMessageCreator *message.WSManMessageCreator) AuditLog {
- return AuditLog{base: message.NewBase(wsmanMessageCreator, AMT_AuditLog)}
-}
-
-// Get retrieves the representation of the instance
-func (AuditLog AuditLog) Get() string {
- return AuditLog.base.Get(nil)
-}
-
-// Enumerates the instances of this class
-func (AuditLog AuditLog) Enumerate() string {
- return AuditLog.base.Enumerate()
-}
-
-// Pulls instances of this class, following an Enumerate operation
-func (AuditLog AuditLog) Pull(enumerationContext string) string {
- return AuditLog.base.Pull(enumerationContext)
-}
-
-// ReadRecords returns a list of consecutive audit log records in chronological order:
-// The first record in the returned array is the oldest record stored in the log.
-// startIndex Identifies the position of the first record to retrieve. An index of 1 indicates the first record in the log.
-func (a AuditLog) ReadRecords(startIndex int) string {
- if startIndex < 1 {
- startIndex = 0
- }
- header := a.base.WSManMessageCreator.CreateHeader(string(actions.ReadRecords), AMT_AuditLog, nil, "", "")
- body := a.base.WSManMessageCreator.CreateBody("ReadRecords_INPUT", AMT_AuditLog, &readRecords_INPUT{StartIndex: startIndex})
-
- return a.base.WSManMessageCreator.CreateXML(header, body)
-}
diff --git a/pkg/amt/auditlog/message_test.go b/pkg/amt/auditlog/message_test.go
deleted file mode 100644
index dd7539e3..00000000
--- a/pkg/amt/auditlog/message_test.go
+++ /dev/null
@@ -1,54 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package auditlog
-
-import (
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestAMT_AuditLog(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewAuditLog(wsmanMessageCreator)
-
- t.Run("amt_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid AMT_AuditLog Get wsman message", "AMT_AuditLog", wsmantesting.GET, "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid AMT_AuditLog Enumerate wsman message", "AMT_AuditLog", wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid AMT_AuditLog Pull wsman message", "AMT_AuditLog", wsmantesting.PULL, wsmantesting.PULL_BODY, func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- //READ RECORDS
- {"should create a valid AMT_AuditLog Read Records wsman message", "AMT_AuditLog", `http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AuditLog/ReadRecords`, `1`, func() string {
- return elementUnderTest.ReadRecords(1)
- }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-}
diff --git a/pkg/amt/authorization/service.go b/pkg/amt/authorization/service.go
deleted file mode 100644
index 22552228..00000000
--- a/pkg/amt/authorization/service.go
+++ /dev/null
@@ -1,191 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package authorization
-
-import (
- "encoding/xml"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/actions"
-)
-
-type AddUserAclEntry struct {
- XMLName xml.Name `xml:"h:AddUserAclEntryEx_INPUT"`
- H string `xml:"xmlns:h,attr"`
- Handle int `xml:"h:Handle,omitempty"`
- DigestUsername string `xml:"h:DigestUsername"`
- DigestPassword string `xml:"h:DigestPassword"`
- AccessPermission AccessPermission `xml:"h:AccessPermission"`
- Realms []RealmValues `xml:"h:Realms>h:RealmValue,omitempty"`
- KerberosUserSid string `xml:"h:KerberosUserSid"`
-}
-type UpdateUserAclEntry struct {
- XMLName xml.Name `xml:"h:UpdateUserAclEntry_INPUT"`
- H string `xml:"xmlns:h,attr"`
- Handle int `xml:"h:Handle,omitempty"`
- DigestUsername string `xml:"h:DigestUsername"`
- DigestPassword string `xml:"h:DigestPassword"`
- AccessPermission AccessPermission `xml:"h:AccessPermission"`
- Realms []RealmValues `xml:"h:Realms>h:RealmValue,omitempty"`
- KerberosUserSid string `xml:"h:KerberosUserSid"`
-}
-
-type AccessPermission int
-
-const (
- LocalAccessOnly AccessPermission = iota
- NetworkAccessOnly
- LocalAndNetworkAccess
-)
-
-type RealmValues int
-
-const AMT_AuthorizationService = "AMT_AuthorizationService"
-
-const (
- RedirectionRealm RealmValues = 2
- PTAdministrationRealm RealmValues = 3
- HardwareAssetRealm RealmValues = 4
- RemoteControlRealm RealmValues = 5
- StorageRealm RealmValues = 6
- EventManagerRealm RealmValues = 7
- StorageAdminRealm RealmValues = 8
- AgentPresenceLocalRealm RealmValues = 9
- AgentPresenceRemoteRealm RealmValues = 10
- CircuitBreakerRealm RealmValues = 11
- NetworkTimeRealm RealmValues = 12
- GeneralInfoRealm RealmValues = 13
- EndpointAccessControlRealm RealmValues = 17
- EndpointAccessControlAdminRealm RealmValues = 18
- EventLogReaderRealm RealmValues = 19
- AuditLogRealm RealmValues = 20
- ACLRealm RealmValues = 21
- LocalSystemRealm RealmValues = 24
-)
-
-type AuthorizationService struct {
- base message.Base
-}
-type EnumerateUserAclEntries_INPUT struct {
- XMLName xml.Name `xml:"h:EnumerateUserAclEntries_INPUT"`
- H string `xml:"xmlns:h,attr"`
- StartIndex int `xml:"h:StartIndex"`
-}
-
-type GetAclEnabledState_INPUT struct {
- XMLName xml.Name `xml:"h:GetAclEnabledState_INPUT"`
- H string `xml:"xmlns:h,attr"`
- Handle int `xml:"h:Handle"`
-}
-type GetUserAclEntryEx_INPUT struct {
- XMLName xml.Name `xml:"h:GetUserAclEntryEx_INPUT"`
- H string `xml:"xmlns:h,attr"`
- Handle int `xml:"h:Handle"`
-}
-type RemoveUserAclEntry_INPUT struct {
- XMLName xml.Name `xml:"h:RemoveUserAclEntry_INPUT"`
- H string `xml:"xmlns:h,attr"`
- Handle int `xml:"h:Handle"`
-}
-
-type SetAclEnabledState_INPUT struct {
- XMLName xml.Name `xml:"h:SetAclEnabledState_INPUT"`
- H string `xml:"xmlns:h,attr"`
- Handle int `xml:"h:Handle"`
- Enabled bool `xml:"h:Enabled"`
-}
-
-type SetAdminACLEntryEx_INPUT struct {
- XMLName xml.Name `xml:"h:SetAdminACLEntryEx_INPUT"`
- H string `xml:"xmlns:h,attr"`
- Username string `xml:"h:Username"`
- DigestPassword string `xml:"h:DigestPassword"`
-}
-
-// Describes the Authorization Service, which is responsible for Access Control management in the Intel(R) AMT subsystem.
-// Additional Notes:
-// 1) Realms 'AuditLogRealm' (20) and 'ACLRealm' (21) are supported only in Intel AMT Release 4.0 and later releases.
-// 2) Realm 'DTRealm' (23) is supported only in 'ME 5.1' and Intel AMT Release 5.1 and later releases.
-// 3) All the methods of 'AMT_AuthorizationService' except for 'Get' are not supported in Remote Connectivity Service provisioning mode
-func NewAuthorizationService(wsmanMessageCreator *message.WSManMessageCreator) AuthorizationService {
- return AuthorizationService{
- base: message.NewBase(wsmanMessageCreator, AMT_AuthorizationService),
- }
-}
-
-// Get retrieves the representation of the instance
-func (AuthorizationService AuthorizationService) Get() string {
- return AuthorizationService.base.Get(nil)
-}
-
-// Enumerates the instances of this class
-func (AuthorizationService AuthorizationService) Enumerate() string {
- return AuthorizationService.base.Enumerate()
-}
-
-// Pulls instances of this class, following an Enumerate operation
-func (AuthorizationService AuthorizationService) Pull(enumerationContext string) string {
- return AuthorizationService.base.Pull(enumerationContext)
-}
-
-// EnumerateUserAclEntries enumerates entries in the User Access Control List (ACL).
-func (as AuthorizationService) EnumerateUserAclEntries(startIndex int) string {
- if startIndex == 0 {
- startIndex = 1
- }
- header := as.base.WSManMessageCreator.CreateHeader(string(actions.EnumerateUserAclEntries), AMT_AuthorizationService, nil, "", "")
- body := as.base.WSManMessageCreator.CreateBody("EnumerateUserAclEntries_INPUT", AMT_AuthorizationService, &EnumerateUserAclEntries_INPUT{StartIndex: startIndex})
- return as.base.WSManMessageCreator.CreateXML(header, body)
-}
-
-func (as AuthorizationService) GetAclEnabledState(handle int) string {
- header := as.base.WSManMessageCreator.CreateHeader(string(actions.GetAclEnabledState), AMT_AuthorizationService, nil, "", "")
- body := as.base.WSManMessageCreator.CreateBody("GetAclEnabledState_INPUT", AMT_AuthorizationService, &GetAclEnabledState_INPUT{Handle: handle})
- return as.base.WSManMessageCreator.CreateXML(header, body)
-}
-
-func (as AuthorizationService) GetAdminAclEntry() string {
- header := as.base.WSManMessageCreator.CreateHeader(string(actions.GetAdminAclEntry), AMT_AuthorizationService, nil, "", "")
- body := as.base.WSManMessageCreator.CreateBody("GetAdminAclEntry_INPUT", AMT_AuthorizationService, nil)
- return as.base.WSManMessageCreator.CreateXML(header, body)
-}
-
-func (as AuthorizationService) GetAdminAclEntryStatus() string {
- header := as.base.WSManMessageCreator.CreateHeader(string(actions.GetAdminAclEntryStatus), AMT_AuthorizationService, nil, "", "")
- body := as.base.WSManMessageCreator.CreateBody("GetAdminAclEntryStatus_INPUT", AMT_AuthorizationService, nil)
- return as.base.WSManMessageCreator.CreateXML(header, body)
-}
-
-func (as AuthorizationService) GetAdminNetAclEntryStatus() string {
- header := as.base.WSManMessageCreator.CreateHeader(string(actions.GetAdminNetAclEntryStatus), AMT_AuthorizationService, nil, "", "")
- body := as.base.WSManMessageCreator.CreateBody("GetAdminNetAclEntryStatus_INPUT", AMT_AuthorizationService, nil)
- return as.base.WSManMessageCreator.CreateXML(header, body)
-}
-
-// GetUserAclEntryEx reads a user entry from the Intel(R) AMT device.
-func (as AuthorizationService) GetUserAclEntryEx(handle int) string {
- header := as.base.WSManMessageCreator.CreateHeader(string(actions.GetUserAclEntryEx), AMT_AuthorizationService, nil, "", "")
- body := as.base.WSManMessageCreator.CreateBody("GetUserAclEntryEx_INPUT", AMT_AuthorizationService, &GetUserAclEntryEx_INPUT{Handle: handle})
- return as.base.WSManMessageCreator.CreateXML(header, body)
-}
-
-func (as AuthorizationService) RemoveUserAclEntry(handle int) string {
- header := as.base.WSManMessageCreator.CreateHeader(string(actions.RemoveUserAclEntry), AMT_AuthorizationService, nil, "", "")
- body := as.base.WSManMessageCreator.CreateBody("RemoveUserAclEntry_INPUT", AMT_AuthorizationService, &RemoveUserAclEntry_INPUT{Handle: handle})
- return as.base.WSManMessageCreator.CreateXML(header, body)
-}
-
-func (as AuthorizationService) SetAclEnabledState(handle int, enabled bool) string {
- header := as.base.WSManMessageCreator.CreateHeader(string(actions.SetAclEnabledState), AMT_AuthorizationService, nil, "", "")
- body := as.base.WSManMessageCreator.CreateBody("SetAclEnabledState_INPUT", AMT_AuthorizationService, &SetAclEnabledState_INPUT{Handle: handle, Enabled: enabled})
- return as.base.WSManMessageCreator.CreateXML(header, body)
-}
-
-func (as AuthorizationService) SetAdminACLEntryEx(username, digestPassword string) string {
- header := as.base.WSManMessageCreator.CreateHeader(string(actions.SetAdminAclEntryEx), AMT_AuthorizationService, nil, "", "")
- body := as.base.WSManMessageCreator.CreateBody("SetAdminAclEntryEx_INPUT", AMT_AuthorizationService, &SetAdminACLEntryEx_INPUT{Username: username, DigestPassword: digestPassword})
- return as.base.WSManMessageCreator.CreateXML(header, body)
-}
diff --git a/pkg/amt/authorization/service_test.go b/pkg/amt/authorization/service_test.go
deleted file mode 100644
index 20fb74d3..00000000
--- a/pkg/amt/authorization/service_test.go
+++ /dev/null
@@ -1,111 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package authorization
-
-import (
- "fmt"
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestAMT_AuthorizationService(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewAuthorizationService(wsmanMessageCreator)
-
- t.Run("amt_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid AMT_AuthorizationService Get wsman message", "AMT_AuthorizationService", wsmantesting.GET, "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid AMT_AuthorizationService Enumerate wsman message", "AMT_AuthorizationService", wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid AMT_AuthorizationService Pull wsman message", "AMT_AuthorizationService", wsmantesting.PULL, wsmantesting.PULL_BODY, func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- // AUTHORIZATION SERVICE
-
- // ADD USER ACL ENTRY EX
- // Verify with Matt - Typescript is referring to wrong realm values
- // {"should return a valid amt_AuthorizationService ADD_USER_ACL_ENTRY_EX wsman message using digest", "AMT_AuthorizationService", ADD_USER_ACL_ENTRY_EX, fmt.Sprintf(`%s%s%d%d`, "test", "P@ssw0rd", 2, 3), func() string {
- // return elementUnderTest.AddUserAclEntryEx(authorization.AccessPermissionLocalAndNetworkAccess, []authorization.RealmValues{authorization.RedirectionRealm}, "test", "P@ssw0rd", "")
- // }},
- // {"should return a valid amt_AuthorizationService ADD_USER_ACL_ENTRY_EX wsman message using kerberos", "AMT_AuthorizationService", ADD_USER_ACL_ENTRY_EX, fmt.Sprintf(`%d%d%d3`, 64, 2, 3), func() string {
- // return elementUnderTest.AddUserAclEntryEx(authorization.AccessPermissionLocalAndNetworkAccess, []authorization.RealmValues{authorization.RedirectionRealm}, "", "", "64")
- // }},
- // // Check how to verify for exceptions
- // // {"should throw an error if the digestUsername is longer than 16 when calling AddUserAclEntryEx", "", "", "", func() string {
- // // return elementUnderTest.AddUserAclEntryEx(2, []models.RealmValues{models.RedirectionRealm}, "thisusernameistoolong", "test", "")
- // // }},
- // ENUMERATE USER ACL ENTRIES
- {"should return a valid amt_AuthorizationService EnumerateUserAclEntries wsman message when startIndex is undefined", "AMT_AuthorizationService", `http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AuthorizationService/EnumerateUserAclEntries`, fmt.Sprintf(`%d`, 1), func() string {
- var index int
- return elementUnderTest.EnumerateUserAclEntries(index)
- }},
- {"should return a valid amt_AuthorizationService EnumerateUserAclEntries wsman message when startIndex is not 1", "AMT_AuthorizationService", `http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AuthorizationService/EnumerateUserAclEntries`, fmt.Sprintf(`%d`, 50), func() string {
- return elementUnderTest.EnumerateUserAclEntries(50)
- }},
- // GET USER ACL ENTRY EX
- {"should return a valid amt_AuthorizationService GetUserAclEntryEx wsman message", "AMT_AuthorizationService", `http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AuthorizationService/GetUserAclEntryEx`, `1`, func() string {
- return elementUnderTest.GetUserAclEntryEx(1)
- }},
- // UPDATE USER ACL ENTRY EX
- // {"should return a valid amt_AuthorizationService UpdateUserAclEntryEx wsman message using digest", "AMT_AuthorizationService", `http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AuthorizationService/UpdateUserAclEntryEx`, `1`, func() string {
- // return elementUnderTest.UpdateUserAclEntryEx(1, 2, []authorization.RealmValues{authorization.RedirectionRealm}, "test", "test123!", "")
- // }},
- // {"should return a valid amt_AuthorizationService UpdateUserAclEntryEx wsman message using kerberos", "AMT_AuthorizationService", `http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AuthorizationService/UpdateUserAclEntryEx`, `16423`, func() string {
- // return elementUnderTest.UpdateUserAclEntryEx(1, 2, []authorization.RealmValues{authorization.RedirectionRealm}, "", "", "64")
- // }},
- // // should throw an error if digest or kerberos credentials are not provided to UpdateUserAclEntryEx
- // // should throw an error if the digestUsername is longer than 16 when calling UpdateUserAclEntryEx
-
- // REMOVE USER ACL ENTRY
- {"should return a valid amt_AuthorizationService RemoveUserAclEntry wsman message", "AMT_AuthorizationService", `http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AuthorizationService/RemoveUserAclEntry`, `1`, func() string {
- return elementUnderTest.RemoveUserAclEntry(1)
- }},
-
- // GET ADMIN ACL ENTRY
- {"should return a valid amt_AuthorizationService GetAdminAclEntry wsman message", "AMT_AuthorizationService", `http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AuthorizationService/GetAdminAclEntry`, ``, func() string {
- return elementUnderTest.GetAdminAclEntry()
- }},
-
- // GET ADMIN ACL ENTRY STATUS
- {"should return a valid amt_AuthorizationService GetAdminAclEntry wsman message", "AMT_AuthorizationService", `http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AuthorizationService/GetAdminAclEntryStatus`, ``, func() string {
- return elementUnderTest.GetAdminAclEntryStatus()
- }},
-
- // GET ADMIN NET ACL ENTRY STATUS
- {"should return a valid amt_AuthorizationService GetAdminNetAclEntryStatus wsman message", "AMT_AuthorizationService", `http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AuthorizationService/GetAdminNetAclEntryStatus`, ``, func() string {
- return elementUnderTest.GetAdminNetAclEntryStatus()
- }},
-
- // GET ACL ENABLED STATE
- {"should return a valid amt_AuthorizationService GetAclEnabledState wsman message", "AMT_AuthorizationService", `http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AuthorizationService/GetAclEnabledState`, `1`, func() string {
- return elementUnderTest.GetAclEnabledState(1)
- }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-}
diff --git a/pkg/amt/boot/capabilities.go b/pkg/amt/boot/capabilities.go
deleted file mode 100644
index ccf8b5fd..00000000
--- a/pkg/amt/boot/capabilities.go
+++ /dev/null
@@ -1,38 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package boot
-
-import (
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
-)
-
-const AMT_BootCapabilities = "AMT_BootCapabilities"
-
-type BootCapabilities struct {
- ClassName string
- base message.Base
-}
-
-func NewBootCapabilities(wsmanMessageCreator *message.WSManMessageCreator) BootCapabilities {
- return BootCapabilities{
- base: message.NewBase(wsmanMessageCreator, AMT_BootCapabilities),
- }
-}
-
-// Get retrieves the representation of the instance
-func (BootCapabilities BootCapabilities) Get() string {
- return BootCapabilities.base.Get(nil)
-}
-
-// Enumerates the instances of this class
-func (BootCapabilities BootCapabilities) Enumerate() string {
- return BootCapabilities.base.Enumerate()
-}
-
-// Pulls instances of this class, following an Enumerate operation
-func (BootCapabilities BootCapabilities) Pull(enumerationContext string) string {
- return BootCapabilities.base.Pull(enumerationContext)
-}
diff --git a/pkg/amt/boot/capabilities_test.go b/pkg/amt/boot/capabilities_test.go
deleted file mode 100644
index b39f27ab..00000000
--- a/pkg/amt/boot/capabilities_test.go
+++ /dev/null
@@ -1,50 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package boot
-
-import (
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestAMT_BootCapabilities(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewBootCapabilities(wsmanMessageCreator)
-
- t.Run("amt_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid AMT_BootCapabilities Get wsman message", "AMT_BootCapabilities", wsmantesting.GET, "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid AMT_BootCapabilities Enumerate wsman message", "AMT_BootCapabilities", wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid AMT_BootCapabilities Pull wsman message", "AMT_BootCapabilities", wsmantesting.PULL, wsmantesting.PULL_BODY, func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-}
diff --git a/pkg/amt/boot/settingdata.go b/pkg/amt/boot/settingdata.go
deleted file mode 100644
index 93fa19f8..00000000
--- a/pkg/amt/boot/settingdata.go
+++ /dev/null
@@ -1,99 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package boot
-
-import (
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/cim/models"
-)
-
-const AMT_BootSettingData = "AMT_BootSettingData"
-
-type BootSettingData struct {
- models.BootSettingData
- InstanceID string
- ElementName string
- UseSOL bool
- UseSafeMode bool
- ReflashBIOS bool
- BIOSSetup bool
- BIOSPause bool
- LockPowerButton bool
- LockResetButton bool
- LockKeyboard bool
- LockSleepButton bool
- UserPasswordBypass bool
- ForcedProgressEvents bool
- FirmwareVerbosity FirmwareVerbosity
- ConfigurationDataReset bool
- IDERBootDevice IDERBootDevice
- UseIDER bool
- EnforceSecureBoot bool
- BootMediaIndex int
- SecureErase bool
- RSEPassword string
- WinREBootEnabled bool //readonly
- UEFILocalPBABootEnabled bool //readonly
- UEFIHTTPSBootEnabled bool //readonly
- SecureBootControlEnabled bool //readonly
- BootguardStatus bool //readonly
- OptionsCleared bool //readonly
- BIOSLastStatus []int //readonly
- UEFIBootParametersArray []int
- UEFIBootNumberOfParams []int
- RPEEnabled bool
- PlatformErase bool
-}
-
-type FirmwareVerbosity uint8
-
-const (
- SystemDefault FirmwareVerbosity = iota
- QuietMinimal
- VerboseAll
- ScreenBlank
-)
-
-type IDERBootDevice uint8
-
-const (
- FloppyBoot IDERBootDevice = iota
- CDBoot
-)
-
-type BootSettingDataResponse struct {
- AMT_BootSettingData BootSettingData
-}
-
-type SettingData struct {
- base message.Base
-}
-
-func NewBootSettingData(wsmanMessageCreator *message.WSManMessageCreator) SettingData {
- return SettingData{
- base: message.NewBase(wsmanMessageCreator, AMT_BootSettingData),
- }
-}
-
-// Get retrieves the representation of the instance
-func (BootSettingData SettingData) Get() string {
- return BootSettingData.base.Get(nil)
-}
-
-// Enumerates the instances of this class
-func (BootSettingData SettingData) Enumerate() string {
- return BootSettingData.base.Enumerate()
-}
-
-// Pulls instances of this class, following an Enumerate operation
-func (BootSettingData SettingData) Pull(enumerationContext string) string {
- return BootSettingData.base.Pull(enumerationContext)
-}
-
-// Put will change properties of the selected instance
-func (BootSettingData SettingData) Put(bootSettingData BootSettingData) string {
- return BootSettingData.base.Put(bootSettingData, false, nil)
-}
diff --git a/pkg/amt/boot/settingdata_test.go b/pkg/amt/boot/settingdata_test.go
deleted file mode 100644
index a1bad24c..00000000
--- a/pkg/amt/boot/settingdata_test.go
+++ /dev/null
@@ -1,50 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package boot
-
-import (
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestAMT_BootSettingData(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewBootSettingData(wsmanMessageCreator)
-
- t.Run("amt_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid AMT_BootSettingData Get wsman message", "AMT_BootSettingData", wsmantesting.GET, "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid AMT_BootSettingData Enumerate wsman message", "AMT_BootSettingData", wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid AMT_BootSettingData Pull wsman message", "AMT_BootSettingData", wsmantesting.PULL, wsmantesting.PULL_BODY, func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-}
diff --git a/pkg/amt/constants.go b/pkg/amt/constants.go
deleted file mode 100644
index 93eb4b9b..00000000
--- a/pkg/amt/constants.go
+++ /dev/null
@@ -1,65 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package amt
-
-// Realms represents a set of enumerated constants for managing various aspects of the system.
-type Realms int
-
-const (
- // ADMINISTRATION manages security control data, power saving options, Intel AMT setup and configuration, and local network options.
- ADMINISTRATION Realms = 3
-
- // AGENT_PRESENCE_LOCAL is used by an application designed to run on the local platform to report that it is running and to send heartbeats periodically.
- AGENT_PRESENCE_LOCAL Realms = 9
-
- // AGENT_PRESENCE_REMOTE is used to register Local Agent applications and to specify the behavior of Intel AMT when an application is running or stops running unexpectedly.
- AGENT_PRESENCE_REMOTE Realms = 10
-
- // AUDIT_LOG configures the Audit Log.
- AUDIT_LOG Realms = 20
-
- // CIRCUIT_BREAKER is used to define filters, counters, and policies to monitor incoming and outgoing network traffic and to block traffic when a suspicious condition is detected.
- CIRCUIT_BREAKER Realms = 11
-
- // ENDPOINT_ACCESS_CONTROL is deprecated and not supported starting CSME release 18.0. Returns settings associated with NAC/NAP posture.
- ENDPOINT_ACCESS_CONTROL Realms = 17
-
- // ENDPOINT_ACCESS_CONTROL_ADMIN is deprecated and not supported starting CSME release 18.0. Configures and enables the NAC/NAP posture.
- ENDPOINT_ACCESS_CONTROL_ADMIN Realms = 18
-
- // EVENT_LOG_READER controls access for reading the Intel AMT event log.
- EVENT_LOG_READER Realms = 19
-
- // EVENT_MANAGER allows configuring hardware and software events to generate alerts and to send them to a remote console and/or log them locally.
- EVENT_MANAGER Realms = 7
-
- // GENERAL_INFO returns general setting and status information.
- GENERAL_INFO Realms = 13
-
- // HARDWARE_ASSET is used to retrieve information about the hardware inventory of the platform.
- HARDWARE_ASSET Realms = 4
-
- // LOCAL_APPS provides alerts to a user on the local interface.
- LOCAL_APPS Realms = 24
-
- // NETWORK_TIME is used to set the clock in the Intel AMT device and synchronize it to network time.
- NETWORK_TIME Realms = 12
-
- // REDIRECTION enables and disables the redirection capability and retrieves the redirection log.
- REDIRECTION Realms = 2
-
- // REMOTE_CONTROL enables powering a platform up or down remotely.
- REMOTE_CONTROL Realms = 5
-
- // STORAGE is used to access, configure, manage, write to and read from non-volatile user storage.
- STORAGE Realms = 6
-
- // STORAGE_ADMIN is used to configure the global parameters that govern the allocation and use of non-volatile storage.
- STORAGE_ADMIN Realms = 8
-
- // USER_ACCESS_CONTROL allows users to control the properties of their own ACL entries.
- USER_ACCESS_CONTROL Realms = 21
-)
diff --git a/pkg/amt/environmentdetection/settingdata.go b/pkg/amt/environmentdetection/settingdata.go
deleted file mode 100644
index 9278b50e..00000000
--- a/pkg/amt/environmentdetection/settingdata.go
+++ /dev/null
@@ -1,57 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package environmentdetection
-
-import (
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/cim/models"
-)
-
-const AMT_EnvironmentDetectionSettingData = "AMT_EnvironmentDetectionSettingData"
-
-type EnvironmentDetectionSettingData struct {
- models.SettingData
- DetectionAlgorithm DetectionAlgorithm
- DetectionStrings []string
- DetectionIPv6LocalPrefixes []string
-}
-
-type DetectionAlgorithm uint8
-
-const (
- LocalDomains DetectionAlgorithm = iota
- RemoteURLs
-)
-
-type SettingData struct {
- base message.Base
-}
-
-func NewEnvironmentDetectionSettingData(wsmanMessageCreator *message.WSManMessageCreator) SettingData {
- return SettingData{
- base: message.NewBase(wsmanMessageCreator, AMT_EnvironmentDetectionSettingData),
- }
-}
-
-// Get retrieves the representation of the instance
-func (EnvironmentDetectionSettingData SettingData) Get() string {
- return EnvironmentDetectionSettingData.base.Get(nil)
-}
-
-// Enumerates the instances of this class
-func (EnvironmentDetectionSettingData SettingData) Enumerate() string {
- return EnvironmentDetectionSettingData.base.Enumerate()
-}
-
-// Pulls instances of this class, following an Enumerate operation
-func (EnvironmentDetectionSettingData SettingData) Pull(enumerationContext string) string {
- return EnvironmentDetectionSettingData.base.Pull(enumerationContext)
-}
-
-// Put will change properties of the selected instance
-func (EnvironmentDetectionSettingData SettingData) Put(environmentDetectionSettingData EnvironmentDetectionSettingData) string {
- return EnvironmentDetectionSettingData.base.Put(environmentDetectionSettingData, false, nil)
-}
diff --git a/pkg/amt/environmentdetection/settingdata_test.go b/pkg/amt/environmentdetection/settingdata_test.go
deleted file mode 100644
index 592a17d1..00000000
--- a/pkg/amt/environmentdetection/settingdata_test.go
+++ /dev/null
@@ -1,50 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package environmentdetection
-
-import (
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestAMT_EnvironmentDetectionSettingData(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewEnvironmentDetectionSettingData(wsmanMessageCreator)
-
- t.Run("amt_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid AMT_EnvironmentDetectionSettingData Get wsman message", "AMT_EnvironmentDetectionSettingData", wsmantesting.GET, "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid AMT_EnvironmentDetectionSettingData Enumerate wsman message", "AMT_EnvironmentDetectionSettingData", wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid AMT_EnvironmentDetectionSettingData Pull wsman message", "AMT_EnvironmentDetectionSettingData", wsmantesting.PULL, wsmantesting.PULL_BODY, func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-}
diff --git a/pkg/amt/ethernetport/settings.go b/pkg/amt/ethernetport/settings.go
deleted file mode 100644
index d14e4a0e..00000000
--- a/pkg/amt/ethernetport/settings.go
+++ /dev/null
@@ -1,125 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package ethernetport
-
-import (
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/cim/models"
-)
-
-type EthernetPortSettings struct {
- models.SettingData
- VLANTag int
- SharedMAC bool
- MACAddress string
- LinkIsUp bool
- LinkPolicy LinkPolicy
- LinkPreference LinkPreference
- LinkControl LinkControl
- SharedStaticIp bool
- SharedDynamicIP bool
- IpSyncEnabled bool
- DHCPEnabled bool
- IPAddress string
- SubnetMask string
- DefaultGateway string
- PrimaryDNS string
- SecondaryDNS string
- ConsoleTcpMaxRetransmissions ConsoleTcpMaxRetransmissions
- WLANLinkProtectionLevel WLANLinkProtectionLevel
- PhysicalConnectionType PhysicalConnectionType
- PhysicalNicMedium PhysicalNicMedium
-}
-
-type LinkPolicyValues int
-
-const AMT_EthernetPortSettings = "AMT_EthernetPortSettings"
-
-const (
- S0AC LinkPolicyValues = 1
- SxAC LinkPolicyValues = 14
- S0DC LinkPolicyValues = 16
- SxDC LinkPolicyValues = 224
-)
-
-type LinkPolicy []LinkPolicyValues
-
-type LinkPreference int
-
-const (
- LinkPreferenceME LinkPreference = iota + 1
- LinkPreferenceHOST
-)
-
-type LinkControl int
-
-const (
- LinkControlME LinkControl = iota + 1
- LinkControlHOST
-)
-
-type ConsoleTcpMaxRetransmissions int
-
-const (
- ConsoleTcpMaxRetransmissions5 ConsoleTcpMaxRetransmissions = iota + 5
- ConsoleTcpMaxRetransmissions6
- ConsoleTcpMaxRetransmissions7
-)
-
-type WLANLinkProtectionLevel int
-
-const (
- OVERRIDE WLANLinkProtectionLevel = iota
- NONE
- PASSIVE
- HIGH
-)
-
-type PhysicalConnectionType int
-
-const (
- IntegratedLANNIC PhysicalConnectionType = iota
- DiscreteLANNIC
- LANviaThunderboldDock
- WirelessLAN
-)
-
-type PhysicalNicMedium int
-
-const (
- SMBUS PhysicalNicMedium = iota
- PCIe
-)
-
-type Settings struct {
- base message.Base
-}
-
-func NewEthernetPortSettings(wsmanMessageCreator *message.WSManMessageCreator) Settings {
- return Settings{
- base: message.NewBase(wsmanMessageCreator, AMT_EthernetPortSettings),
- }
-}
-
-// Get retrieves the representation of the instance
-func (EthernetPortSettings Settings) Get() string {
- return EthernetPortSettings.base.Get(nil)
-}
-
-// Enumerates the instances of this class
-func (EthernetPortSettings Settings) Enumerate() string {
- return EthernetPortSettings.base.Enumerate()
-}
-
-// Pulls instances of this class, following an Enumerate operation
-func (EthernetPortSettings Settings) Pull(enumerationContext string) string {
- return EthernetPortSettings.base.Pull(enumerationContext)
-}
-
-// Put will change properties of the selected instance
-func (EthernetPortSettings Settings) Put(ethernetPortSettings EthernetPortSettings) string {
- return EthernetPortSettings.base.Put(ethernetPortSettings, false, nil)
-}
diff --git a/pkg/amt/ethernetport/settings_test.go b/pkg/amt/ethernetport/settings_test.go
deleted file mode 100644
index 441920b6..00000000
--- a/pkg/amt/ethernetport/settings_test.go
+++ /dev/null
@@ -1,50 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package ethernetport
-
-import (
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestAMT_EthernetPortSettings(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewEthernetPortSettings(wsmanMessageCreator)
-
- t.Run("amt_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid AMT_EthernetPortSettings Get wsman message", "AMT_EthernetPortSettings", wsmantesting.GET, "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid AMT_EthernetPortSettings Enumerate wsman message", "AMT_EthernetPortSettings", wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid AMT_EthernetPortSettings Pull wsman message", "AMT_EthernetPortSettings", wsmantesting.PULL, wsmantesting.PULL_BODY, func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-}
diff --git a/pkg/amt/general/settings.go b/pkg/amt/general/settings.go
deleted file mode 100644
index 7dc83db3..00000000
--- a/pkg/amt/general/settings.go
+++ /dev/null
@@ -1,114 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package general
-
-import (
- "encoding/xml"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/cim/models"
-)
-
-type Response struct {
- XMLName xml.Name `xml:"Envelope"`
- Header message.Header `xml:"Header"`
- Body Body `xml:"Body"`
-}
-
-type Body struct {
- XMLName xml.Name `xml:"Body"`
- AMTGeneralSettings GeneralSettings `xml:"AMT_GeneralSettings"`
-}
-
-type GeneralSettings struct {
- models.SettingData
- XMLName xml.Name `xml:"AMT_GeneralSettings"`
- NetworkInterfaceEnabled bool
- DigestRealm string
- IdleWakeTimeout int
- HostName string
- DomainName string
- PingResponseEnabled bool
- WsmanOnlyMode bool
- PreferredAddressFamily PreferredAddressFamily
- DHCPv6ConfigurationTimeout int
- DDNSUpdateEnabled bool
- DDNSUpdateByDHCPServerEnabled bool
- SharedFQDN bool
- HostOSFQDN string
- DDNSTTL int
- AMTNetworkEnabled AMTNetworkEnabled
- RmcpPingResponseEnabled bool
- DDNSPeriodicUpdateInterval int
- PresenceNotificationInterval int
- PrivacyLevel PrivacyLevel
- PowerSource PowerSource
- ThunderboltDockEnabled ThunderboltDockEnabled
- OemID int
-}
-
-type PreferredAddressFamily int
-
-const AMT_GeneralSettings = "AMT_GeneralSettings"
-
-const (
- IPv4 PreferredAddressFamily = iota
- IPv6
-)
-
-type PrivacyLevel int
-
-const (
- PrivacyLevelDefault PrivacyLevel = iota
- PrivacyLevelEnhanced
- PrivacyLevelExtreme
-)
-
-type PowerSource int
-
-const (
- AC PowerSource = iota
- DC
-)
-
-type AMTNetworkEnabled FeatureEnabled
-type ThunderboltDockEnabled FeatureEnabled
-type FeatureEnabled int
-
-const (
- Disabled FeatureEnabled = iota
- Enabled
-)
-
-type Settings struct {
- base message.Base
-}
-
-func NewGeneralSettings(wsmanMessageCreator *message.WSManMessageCreator) Settings {
- return Settings{
- base: message.NewBase(wsmanMessageCreator, AMT_GeneralSettings),
- }
-}
-
-// Get retrieves the representation of the instance
-func (GeneralSettings Settings) Get() string {
- return GeneralSettings.base.Get(nil)
-}
-
-// Enumerates the instances of this class
-func (GeneralSettings Settings) Enumerate() string {
- return GeneralSettings.base.Enumerate()
-}
-
-// Pulls instances of this class, following an Enumerate operation
-func (GeneralSettings Settings) Pull(enumerationContext string) string {
- return GeneralSettings.base.Pull(enumerationContext)
-}
-
-// Put will change properties of the selected instance
-func (GeneralSettings Settings) Put(generalSettings GeneralSettings) string {
- return GeneralSettings.base.Put(generalSettings, false, nil)
-}
diff --git a/pkg/amt/general/settings_test.go b/pkg/amt/general/settings_test.go
deleted file mode 100644
index 6d5059e4..00000000
--- a/pkg/amt/general/settings_test.go
+++ /dev/null
@@ -1,50 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package general
-
-import (
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestAMT_GeneralSettings(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewGeneralSettings(wsmanMessageCreator)
-
- t.Run("amt_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid AMT_GeneralSettings Get wsman message", "AMT_GeneralSettings", wsmantesting.GET, "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid AMT_GeneralSettings Enumerate wsman message", "AMT_GeneralSettings", wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid AMT_GeneralSettings Pull wsman message", "AMT_GeneralSettings", wsmantesting.PULL, wsmantesting.PULL_BODY, func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-}
diff --git a/pkg/amt/ieee8021x/credentialcontext.go b/pkg/amt/ieee8021x/credentialcontext.go
deleted file mode 100644
index b2560ba5..00000000
--- a/pkg/amt/ieee8021x/credentialcontext.go
+++ /dev/null
@@ -1,37 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package ieee8021x
-
-import (
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
-)
-
-const AMT_IEEE8021xCredentialContext = "AMT_8021xCredentialContext"
-
-type CredentialContext struct {
- base message.Base
-}
-
-func NewIEEE8021xCredentialContext(wsmanMessageCreator *message.WSManMessageCreator) CredentialContext {
- return CredentialContext{
- base: message.NewBase(wsmanMessageCreator, AMT_IEEE8021xCredentialContext),
- }
-}
-
-// Get retrieves the representation of the instance
-func (IEEE8021xCredentialContext CredentialContext) Get() string {
- return IEEE8021xCredentialContext.base.Get(nil)
-}
-
-// Enumerates the instances of this class
-func (IEEE8021xCredentialContext CredentialContext) Enumerate() string {
- return IEEE8021xCredentialContext.base.Enumerate()
-}
-
-// Pulls instances of this class, following an Enumerate operation
-func (IEEE8021xCredentialContext CredentialContext) Pull(enumerationContext string) string {
- return IEEE8021xCredentialContext.base.Pull(enumerationContext)
-}
diff --git a/pkg/amt/ieee8021x/credentialcontext_test.go b/pkg/amt/ieee8021x/credentialcontext_test.go
deleted file mode 100644
index 86d8e62e..00000000
--- a/pkg/amt/ieee8021x/credentialcontext_test.go
+++ /dev/null
@@ -1,50 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package ieee8021x
-
-import (
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestAMT_8021xCredentialContext(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewIEEE8021xCredentialContext(wsmanMessageCreator)
-
- t.Run("amt_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid AMT_8021xCredentialContext Get wsman message", "AMT_8021xCredentialContext", wsmantesting.GET, "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid AMT_8021xCredentialContext Enumerate wsman message", "AMT_8021xCredentialContext", wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid AMT_8021xCredentialContext Pull wsman message", "AMT_8021xCredentialContext", wsmantesting.PULL, wsmantesting.PULL_BODY, func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-}
diff --git a/pkg/amt/ieee8021x/profile.go b/pkg/amt/ieee8021x/profile.go
deleted file mode 100644
index 8f0e3088..00000000
--- a/pkg/amt/ieee8021x/profile.go
+++ /dev/null
@@ -1,80 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package ieee8021x
-
-import (
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
-)
-
-type IEEE8021xProfile struct {
- ElementName string
- InstanceID string
- Enabled bool
- ActiveInS0 bool
- AuthenticationProtocol AuthenticationProtocol
- RoamingIdentity string
- ServerCertificateName string
- ServerCertificateNameComparison ServerCertificateNameComparison
- Username string
- Password string
- Domain string
- ProtectedAccessCredential []int
- PACPassword string
- ClientCertificate string
- ServerCertificateIssue string
- PxeTimeout int
-}
-
-type AuthenticationProtocol int
-
-const AMT_IEEE8021xProfile = "AMT_8021XProfile"
-
-const (
- TLS AuthenticationProtocol = iota
- TTLS_MSCHAPv2
- PEAP_MSCHAPv2
- EAP_GTC
- EAPFAST_MSCHAPv2
- EAPFAST_GTC
- EAPFAST_TLS
-)
-
-type ServerCertificateNameComparison int
-
-const (
- FullName ServerCertificateNameComparison = iota
- DomainSuffix
-)
-
-type Profile struct {
- base message.Base
-}
-
-func NewIEEE8021xProfile(wsmanMessageCreator *message.WSManMessageCreator) Profile {
- return Profile{
- base: message.NewBase(wsmanMessageCreator, AMT_IEEE8021xProfile),
- }
-}
-
-// Get retrieves the representation of the instance
-func (IEEE8021xProfile Profile) Get() string {
- return IEEE8021xProfile.base.Get(nil)
-}
-
-// Enumerates the instances of this class
-func (IEEE8021xProfile Profile) Enumerate() string {
- return IEEE8021xProfile.base.Enumerate()
-}
-
-// Pulls instances of this class, following an Enumerate operation
-func (IEEE8021xProfile Profile) Pull(enumerationContext string) string {
- return IEEE8021xProfile.base.Pull(enumerationContext)
-}
-
-// Put will change properties of the selected instance
-func (IEEE8021xProfile Profile) Put(ieee8021xProfile IEEE8021xProfile) string {
- return IEEE8021xProfile.base.Put(ieee8021xProfile, false, nil)
-}
diff --git a/pkg/amt/ieee8021x/profile_test.go b/pkg/amt/ieee8021x/profile_test.go
deleted file mode 100644
index 616968b4..00000000
--- a/pkg/amt/ieee8021x/profile_test.go
+++ /dev/null
@@ -1,50 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package ieee8021x
-
-import (
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestAMT_8021XProfile(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewIEEE8021xProfile(wsmanMessageCreator)
-
- t.Run("amt_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid AMT_8021XProfile Get wsman message", "AMT_8021XProfile", wsmantesting.GET, "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid AMT_8021XProfile Enumerate wsman message", "AMT_8021XProfile", wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid AMT_8021XProfile Pull wsman message", "AMT_8021XProfile", wsmantesting.PULL, wsmantesting.PULL_BODY, func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-}
diff --git a/pkg/amt/kerberos/settingdata.go b/pkg/amt/kerberos/settingdata.go
deleted file mode 100644
index 70a97c06..00000000
--- a/pkg/amt/kerberos/settingdata.go
+++ /dev/null
@@ -1,58 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package kerberos
-
-import (
- "encoding/xml"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/actions"
-)
-
-const AMT_KerberosSettingData = "AMT_KerberosSettingData"
-
-type KerberosSettingData struct {
- base message.Base
-}
-type SetCredentialCacheState_INPUT struct {
- XMLName xml.Name `xml:"h:SetCredentialCacheState_INPUT"`
- H string `xml:"xmlns:h,attr"`
- Enabled bool `xml:"h:Enabled"`
-}
-
-func NewKerberosSettingData(wsmanMessageCreator *message.WSManMessageCreator) KerberosSettingData {
- return KerberosSettingData{
- base: message.NewBase(wsmanMessageCreator, AMT_KerberosSettingData),
- }
-}
-
-// Get retrieves the representation of the instance
-func (KerberosSettingData KerberosSettingData) Get() string {
- return KerberosSettingData.base.Get(nil)
-}
-
-// Enumerates the instances of this class
-func (KerberosSettingData KerberosSettingData) Enumerate() string {
- return KerberosSettingData.base.Enumerate()
-}
-
-// Pulls instances of this class, following an Enumerate operation
-func (KerberosSettingData KerberosSettingData) Pull(enumerationContext string) string {
- return KerberosSettingData.base.Pull(enumerationContext)
-}
-func (k KerberosSettingData) GetCredentialCacheState() string {
- header := k.base.WSManMessageCreator.CreateHeader(string(actions.GetCredentialCacheState), AMT_KerberosSettingData, nil, "", "")
- body := k.base.WSManMessageCreator.CreateBody("GetCredentialCacheState_INPUT", AMT_KerberosSettingData, nil)
-
- return k.base.WSManMessageCreator.CreateXML(header, body)
-}
-
-// func (k KerberosSettingData) SetCredentialCacheState(enabled bool) string {
-// header := k.base.WSManMessageCreator.CreateHeader(string(actions.SetCredentialCacheState), AMT_KerberosSettingData, nil, "", "")
-// body := k.base.WSManMessageCreator.CreateBody("SetCredentialCacheState_INPUT", AMT_KerberosSettingData, SetCredentialCacheState_INPUT{Enabled: enabled})
-
-// return k.base.WSManMessageCreator.CreateXML(header, body)
-// }
diff --git a/pkg/amt/kerberos/settingdata_test.go b/pkg/amt/kerberos/settingdata_test.go
deleted file mode 100644
index b166a492..00000000
--- a/pkg/amt/kerberos/settingdata_test.go
+++ /dev/null
@@ -1,60 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package kerberos
-
-import (
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestAMT_KerberosSettingData(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewKerberosSettingData(wsmanMessageCreator)
-
- t.Run("amt_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid AMT_KerberosSettingData Get wsman message", "AMT_KerberosSettingData", wsmantesting.GET, "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid AMT_KerberosSettingData Enumerate wsman message", "AMT_KerberosSettingData", wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid AMT_KerberosSettingData Pull wsman message", "AMT_KerberosSettingData", wsmantesting.PULL, wsmantesting.PULL_BODY, func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- // KERBEROS SETTING DATA
- // GET CREDENTIAL CACHE STATE
- {"should return a valid amt_KerberosSettingData GetCredentialCacheState wsman message", "AMT_KerberosSettingData", `http://intel.com/wbem/wscim/1/amt-schema/1/AMT_KerberosSettingData/GetCredentialCacheState`, ``, func() string {
- return elementUnderTest.GetCredentialCacheState()
- }},
-
- // GET CREDENTIAL CACHE STATE
- // {"should return a valid amt_KerberosSettingData SetCredentialCacheState wsman message", "AMT_KerberosSettingData", `http://intel.com/wbem/wscim/1/amt-schema/1/AMT_KerberosSettingData/SetCredentialCacheState`, ``, func() string {
- // return elementUnderTest.SetCredentialCacheState(true)
- // }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-}
diff --git a/pkg/amt/managementpresence/remotesap.go b/pkg/amt/managementpresence/remotesap.go
deleted file mode 100644
index b5e14c36..00000000
--- a/pkg/amt/managementpresence/remotesap.go
+++ /dev/null
@@ -1,41 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package managementpresence
-
-import "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
-
-const AMT_ManagementPresenceRemoteSAP = "AMT_ManagementPresenceRemoteSAP"
-
-type RemoteSAP struct {
- base message.Base
-}
-
-func NewManagementPresenceRemoteSAP(wsmanMessageCreator *message.WSManMessageCreator) RemoteSAP {
- return RemoteSAP{
- base: message.NewBase(wsmanMessageCreator, AMT_ManagementPresenceRemoteSAP),
- }
-}
-
-// Get retrieves the representation of the instance
-func (ManagementPresenceRemoteSAP RemoteSAP) Get() string {
- return ManagementPresenceRemoteSAP.base.Get(nil)
-}
-
-// Enumerates the instances of this class
-func (ManagementPresenceRemoteSAP RemoteSAP) Enumerate() string {
- return ManagementPresenceRemoteSAP.base.Enumerate()
-}
-
-// Pulls instances of this class, following an Enumerate operation
-func (ManagementPresenceRemoteSAP RemoteSAP) Pull(enumerationContext string) string {
- return ManagementPresenceRemoteSAP.base.Pull(enumerationContext)
-}
-
-// Delete removes a the specified instance
-func (ManagementPresenceRemoteSAP RemoteSAP) Delete(handle string) string {
- selector := message.Selector{Name: "Name", Value: handle}
- return ManagementPresenceRemoteSAP.base.Delete(selector)
-}
diff --git a/pkg/amt/managementpresence/remotesap_test.go b/pkg/amt/managementpresence/remotesap_test.go
deleted file mode 100644
index 3c7aca25..00000000
--- a/pkg/amt/managementpresence/remotesap_test.go
+++ /dev/null
@@ -1,53 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package managementpresence
-
-import (
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestAMT_ManagementPresenceRemoteSAP(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewManagementPresenceRemoteSAP(wsmanMessageCreator)
-
- t.Run("amt_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- extraHeader string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid AMT_ManagementPresenceRemoteSAP Get wsman message", "AMT_ManagementPresenceRemoteSAP", wsmantesting.GET, "", "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid AMT_ManagementPresenceRemoteSAP Enumerate wsman message", "AMT_ManagementPresenceRemoteSAP", wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, "", elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid AMT_ManagementPresenceRemoteSAP Pull wsman message", "AMT_ManagementPresenceRemoteSAP", wsmantesting.PULL, wsmantesting.PULL_BODY, "", func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- //DELETE
- {"should create a valid AMT_ManagementPresenceRemoteSAP Delete wsman message", "AMT_ManagementPresenceRemoteSAP", wsmantesting.DELETE, "", "instanceID123", func() string { return elementUnderTest.Delete("instanceID123") }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, test.extraHeader, test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-}
diff --git a/pkg/amt/messagelog/log.go b/pkg/amt/messagelog/log.go
deleted file mode 100644
index 6ce075f5..00000000
--- a/pkg/amt/messagelog/log.go
+++ /dev/null
@@ -1,67 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package messagelog
-
-import (
- "encoding/xml"
- "fmt"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/actions"
-)
-
-const AMT_MessageLog = "AMT_MessageLog"
-
-type MessageLog struct {
- base message.Base
-}
-type GetRecords_INPUT struct {
- XMLName xml.Name `xml:"h:GetRecords_INPUT"`
- H string `xml:"xmlns:h,attr"`
- IterationIdentifier int `xml:"h:IterationIdentifier"`
- MaxReadRecords int `xml:"h:MaxReadRecords"`
-}
-
-func NewMessageLog(wsmanMessageCreator *message.WSManMessageCreator) MessageLog {
- return MessageLog{
- base: message.NewBase(wsmanMessageCreator, AMT_MessageLog),
- }
-}
-
-// Get retrieves the representation of the instance
-func (MessageLog MessageLog) Get() string {
- return MessageLog.base.Get(nil)
-}
-
-// Enumerates the instances of this class
-func (MessageLog MessageLog) Enumerate() string {
- return MessageLog.base.Enumerate()
-}
-
-// Pulls instances of this class, following an Enumerate operation
-func (MessageLog MessageLog) Pull(enumerationContext string) string {
- return MessageLog.base.Pull(enumerationContext)
-}
-func (MessageLog MessageLog) GetRecords(identifier int) string {
- if identifier < 1 {
- identifier = 1
- }
-
- header := MessageLog.base.WSManMessageCreator.CreateHeader(string(actions.GetRecords), AMT_MessageLog, nil, "", "")
- body := MessageLog.base.WSManMessageCreator.CreateBody("GetRecords_INPUT", AMT_MessageLog, &GetRecords_INPUT{
- IterationIdentifier: identifier,
- MaxReadRecords: 390,
- })
-
- return MessageLog.base.WSManMessageCreator.CreateXML(header, body)
-}
-
-func (MessageLog MessageLog) PositionToFirstRecord() string {
- header := MessageLog.base.WSManMessageCreator.CreateHeader(string(actions.PositionToFirstRecord), AMT_MessageLog, nil, "", "")
- body := fmt.Sprintf(``, MessageLog.base.WSManMessageCreator.ResourceURIBase, AMT_MessageLog)
-
- return MessageLog.base.WSManMessageCreator.CreateXML(header, body)
-}
diff --git a/pkg/amt/messagelog/log_test.go b/pkg/amt/messagelog/log_test.go
deleted file mode 100644
index 1c8db239..00000000
--- a/pkg/amt/messagelog/log_test.go
+++ /dev/null
@@ -1,59 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package messagelog
-
-import (
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestAMT_MessageLog(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewMessageLog(wsmanMessageCreator)
-
- t.Run("amt_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid AMT_MessageLog Get wsman message", "AMT_MessageLog", wsmantesting.GET, "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid AMT_MessageLog Enumerate wsman message", "AMT_MessageLog", wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid AMT_MessageLog Pull wsman message", "AMT_MessageLog", wsmantesting.PULL, wsmantesting.PULL_BODY, func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- // MESSAGE LOG
- // POSITION TO FIRST RECORD
- {"should return a valid amt_MessageLog PositionToFirstRecords wsman message", "AMT_MessageLog", `http://intel.com/wbem/wscim/1/amt-schema/1/AMT_MessageLog/PositionToFirstRecord`, ``, func() string {
- return elementUnderTest.PositionToFirstRecord()
- }},
- // GET RECORDS
- {"should return a valid amt_MessageLog GetRecords wsman message", "AMT_MessageLog", `http://intel.com/wbem/wscim/1/amt-schema/1/AMT_MessageLog/GetRecords`, `1390`, func() string {
- return elementUnderTest.GetRecords(1)
- }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-}
diff --git a/pkg/amt/messages.go b/pkg/amt/messages.go
deleted file mode 100644
index bb65ef9a..00000000
--- a/pkg/amt/messages.go
+++ /dev/null
@@ -1,98 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package amt
-
-import (
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/alarmclock"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/auditlog"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/authorization"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/boot"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/environmentdetection"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/ethernetport"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/general"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/ieee8021x"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/kerberos"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/managementpresence"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/messagelog"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/mps"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/publickey"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/publicprivate"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/redirection"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/remoteaccess"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/setupandconfiguration"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/timesynchronization"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/tls"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/userinitiatedconnection"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/wifiportconfiguration"
-)
-
-type Messages struct {
- wsmanMessageCreator *message.WSManMessageCreator
- AlarmClockService alarmclock.Service
- AuditLog auditlog.AuditLog
- AuthorizationService authorization.AuthorizationService
- BootCapabilities boot.BootCapabilities
- BootSettingData boot.SettingData
- EnvironmentDetectionSettingData environmentdetection.SettingData
- EthernetPortSettings ethernetport.Settings
- GeneralSettings general.Settings
- IEEE8021xCredentialContext ieee8021x.CredentialContext
- IEEE8021xProfile ieee8021x.Profile
- KerberosSettingData kerberos.KerberosSettingData
- ManagementPresenceRemoteSAP managementpresence.RemoteSAP
- MessageLog messagelog.MessageLog
- MPSUsernamePassword mps.UsernamePassword
- PublicKeyCertificate publickey.Certificate
- PublicKeyManagementService publickey.ManagementService
- PublicPrivateKeyPair publicprivate.KeyPair
- RedirectionService redirection.Service
- RemoteAccessPolicyAppliesToMPS remoteaccess.PolicyAppliesToMPS
- RemoteAccessPolicyRule remoteaccess.PolicyRule
- RemoteAccessService remoteaccess.Service
- SetupAndConfigurationService setupandconfiguration.Service
- TimeSynchronizationService timesynchronization.Service
- TLSCredentialContext tls.CredentialContext
- TLSSettingData tls.SettingData
- UserInitiatedConnectionService userinitiatedconnection.Service
- WiFiPortConfigurationService wifiportconfiguration.Service
-}
-
-func NewMessages() Messages {
- resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- m := Messages{
- wsmanMessageCreator: wsmanMessageCreator,
- }
- m.AlarmClockService = alarmclock.NewService(wsmanMessageCreator)
- m.AuditLog = auditlog.NewAuditLog(wsmanMessageCreator)
- m.AuthorizationService = authorization.NewAuthorizationService(wsmanMessageCreator)
- m.BootCapabilities = boot.NewBootCapabilities(wsmanMessageCreator)
- m.BootSettingData = boot.NewBootSettingData(wsmanMessageCreator)
- m.EnvironmentDetectionSettingData = environmentdetection.NewEnvironmentDetectionSettingData(wsmanMessageCreator)
- m.EthernetPortSettings = ethernetport.NewEthernetPortSettings(wsmanMessageCreator)
- m.GeneralSettings = general.NewGeneralSettings(wsmanMessageCreator)
- m.IEEE8021xCredentialContext = ieee8021x.NewIEEE8021xCredentialContext(wsmanMessageCreator)
- m.IEEE8021xProfile = ieee8021x.NewIEEE8021xProfile(wsmanMessageCreator)
- m.KerberosSettingData = kerberos.NewKerberosSettingData(wsmanMessageCreator)
- m.ManagementPresenceRemoteSAP = managementpresence.NewManagementPresenceRemoteSAP(wsmanMessageCreator)
- m.MessageLog = messagelog.NewMessageLog(wsmanMessageCreator)
- m.MPSUsernamePassword = mps.NewMPSUsernamePassword(wsmanMessageCreator)
- m.PublicKeyCertificate = publickey.NewPublicKeyCertificate(wsmanMessageCreator)
- m.PublicKeyManagementService = publickey.NewPublicKeyManagementService(wsmanMessageCreator)
- m.PublicPrivateKeyPair = publicprivate.NewPublicPrivateKeyPair(wsmanMessageCreator)
- m.RedirectionService = redirection.NewRedirectionService(wsmanMessageCreator)
- m.RemoteAccessPolicyAppliesToMPS = remoteaccess.NewRemoteAccessPolicyAppliesToMPS(wsmanMessageCreator)
- m.RemoteAccessPolicyRule = remoteaccess.NewRemoteAccessPolicyRule(wsmanMessageCreator)
- m.RemoteAccessService = remoteaccess.NewRemoteAccessService(wsmanMessageCreator)
- m.SetupAndConfigurationService = setupandconfiguration.NewSetupAndConfigurationService(wsmanMessageCreator)
- m.TimeSynchronizationService = timesynchronization.NewTimeSynchronizationService(wsmanMessageCreator)
- m.TLSCredentialContext = tls.NewTLSCredentialContext(wsmanMessageCreator)
- m.TLSSettingData = tls.NewTLSSettingData(wsmanMessageCreator)
- m.UserInitiatedConnectionService = userinitiatedconnection.NewUserInitiatedConnectionService(wsmanMessageCreator)
- m.WiFiPortConfigurationService = wifiportconfiguration.NewWiFiPortConfigurationService(wsmanMessageCreator)
- return m
-}
diff --git a/pkg/amt/methods/constants.go b/pkg/amt/methods/constants.go
deleted file mode 100644
index 8daf4e51..00000000
--- a/pkg/amt/methods/constants.go
+++ /dev/null
@@ -1,48 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package methods
-
-type Methods string
-
-const (
- Get Methods = "Get"
- Pull Methods = "Pull"
- Enumerate Methods = "Enumerate"
- Put Methods = "Put"
- Delete Methods = "Delete"
- ReadRecords Methods = "ReadRecords"
- AddTrustedRootCertificate Methods = "AddTrustedRootCertificate"
- AddCertificate Methods = "AddCertificate"
- AddMps Methods = "AddMpServer"
- AddRemoteAccessPolicyRule Methods = "AddRemoteAccessPolicyRule"
- Create Methods = "Create"
- RequestStateChange Methods = "RequestStateChange"
- SetBootConfigRole Methods = "SetBootConfigRole"
- GetRecords Methods = "GetRecords"
- PositionToFirstRecord Methods = "PositionToFirstRecord"
- CommitChanges Methods = "commitChanges"
- Unprovision Methods = "Unprovision"
- SetMEBxPassword Methods = "SetMEBxPassword"
- SetAdminAclEntryEx Methods = "SetAdminAclEntryEx"
- GetLowAccuracyTimeSynch Methods = "GetLowAccuracyTimeSynch"
- SetHighAccuracyTimeSynch Methods = "SetHighAccuracyTimeSynch"
- GenerateKeyPair Methods = "GenerateKeyPair"
- AddWiFiSettings Methods = "AddWiFiSettings"
- AddAlarm Methods = "AddAlarm"
- GeneratePKCS10RequestEx Methods = "GeneratePKCS10RequestEx"
- GetUuid Methods = "GetUuid"
- AddAdminAclEntryEx Methods = "AddUserAclEntryEx"
- EnumerateUserAclEntries Methods = "EnumerateUserAclEntries"
- GetAclEnabledState Methods = "GetAclEnabledState"
- GetAdminAclEntry Methods = "GetAdminAclEntry"
- GetAdminAclEntryStatus Methods = "GetAdminAclEntryStatus"
- GetAdminNetAclEntryStatus Methods = "GetAdminNetAclEntryStatus"
- GetUserAclEntryEx Methods = "GetUserAclEntryEx"
- RemoveUserAclEntry Methods = "RemoveUserAclEntry"
- SetAclEnabledState Methods = "SetAclEnabledState"
- UpdateUserAclEntryEx Methods = "UpdateUserAclEntryEx"
- AddUserAclEntryEx Methods = "AddUserAclEntryEx"
-)
diff --git a/pkg/amt/models/types.go b/pkg/amt/models/types.go
deleted file mode 100644
index a6dc0843..00000000
--- a/pkg/amt/models/types.go
+++ /dev/null
@@ -1,147 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package models
-
-import (
- "time"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/cim/models"
-)
-
-type AMTAuthenticateObject struct {
- Nonce []int
- UUID []string
- FQDN string
- FWVersion string
- AMTSVN int
- SignatureMechanism AMTAuthenticateObjectSignatureMechanism
- Signature []int
- LengthOfCertificates []int
- Certificates []int
-}
-
-type AMTAuthenticateObjectSignatureMechanism int
-
-const (
- AMTAuthenticateObjectSignatureMechanismTLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 AMTAuthenticateObjectSignatureMechanism = 0
-)
-
-type SystemDefensePolicy struct {
- models.ManagedElement
- PolicyName string
- PolicyPrecedence int
- AntiSpoofingSupport SystemDefensePolicyAntiSpoofingSupport
- FilterCreationHandles []int
- TxDefaultDrop bool
- TxDefaultMatchEvent bool
- TxDefaultCount bool
- RxDefaultDrop bool
- RxDefaultMatchEvent bool
- RxDefaultCount bool
-}
-
-type SystemDefensePolicyAntiSpoofingSupport uint8
-
-const (
- SystemDefensePolicyAntiSpoofingSupportOff SystemDefensePolicyAntiSpoofingSupport = 0
- SystemDefensePolicyAntiSpoofingSupportEventOnMatch SystemDefensePolicyAntiSpoofingSupport = 1
- SystemDefensePolicyAntiSpoofingSupportCount SystemDefensePolicyAntiSpoofingSupport = 2
- SystemDefensePolicyAntiSpoofingSupportCountingEventOnMatch SystemDefensePolicyAntiSpoofingSupport = 3
- SystemDefensePolicyAntiSpoofingSupportOnWithoutCountingOrEventOnMatch SystemDefensePolicyAntiSpoofingSupport = 4
-)
-
-type BootCapabilities struct {
- models.ManagedElement
- AMT_BootCapabilities struct {
- ElementName string
- InstanceID string
- IDER bool
- SOL bool
- BIOSReflash bool
- BIOSSetup bool
- BIOSPause bool
- ForcePXEBoot bool
- ForceHardDriveBoot bool
- ForceHardDriveSafeModeBoot bool
- ForceDiagnosticBoot bool
- ForceCDorDVDBoot bool
- VerbosityScreenBlank bool
- PowerButtonLock bool
- ResetButtonLock bool
- KeyboardLock bool
- SleepButtonLock bool
- UserPasswordBypass bool
- ForcedProgressEvents bool
- VerbosityVerbose bool
- VerbosityQuiet bool
- ConfigurationDataReset bool
- BIOSSecureBoot bool
- SecureErase bool
- ForceWinREBoot bool
- ForceUEFILocalPBABoot bool
- ForceUEFIHTTPSBoot bool
- AMTSecureBootControl bool
- UEFIWiFiCoExistenceAndProfileShare bool
- PlatformErase int
- }
-}
-
-type MessageLog struct {
- models.MessageLog
-}
-
-type EVENT_DATA struct {
- DeviceAddress int `json:"DeviceAddress,omitempty"`
- EventSensorType int `json:"EventSensorType,omitempty"`
- EventType int `json:"EventType,omitempty"`
- EventOffset int `json:"EventOffset,omitempty"`
- EventSourceType int `json:"EventSourceType,omitempty"`
- EventSeverity EVENT_DATAEventSeverity `json:"EventSeverity,omitempty"`
- SensorNumber int `json:"SensorNumber,omitempty"`
- Entity int `json:"Entity,omitempty"`
- EntityInstance int `json:"EntityInstance,omitempty"`
- EventData []int `json:"EventData,omitempty"`
- TimeStamp time.Time `json:"TimeStamp,omitempty"`
-}
-
-type EVENT_DATAEventSeverity int
-
-const (
- EVENT_DATAEventSeverityUnspecified EVENT_DATAEventSeverity = 0
- EVENT_DATAEventSeverityMonitor EVENT_DATAEventSeverity = 1
- EVENT_DATAEventSeverityInformation EVENT_DATAEventSeverity = 2
- EVENT_DATAEventSeverityOK EVENT_DATAEventSeverity = 4
- EVENT_DATAEventSeverityNonCritical EVENT_DATAEventSeverity = 8
- EVENT_DATAEventSeverityCritical EVENT_DATAEventSeverity = 16
- EVENT_DATAEventSeverityNonRecoverable EVENT_DATAEventSeverity = 32
-)
-
-type AuditLogReadRecords struct {
- ReadRecordsOutput struct {
- TotalRecordCount string
- RecordsReturned string
- EventRecords []string
- ReturnValue string
- }
-}
-
-type TLSProtocolEndpointCollection struct {
- models.Collection
-}
-
-// IEEE8021xProfile represents the IEEE8021xProfile interface extending the CIM.Models.SettingData struct.
-
-type AuthorizationService struct {
- models.Service
- AllowHttpQopAuthOnly int
-}
-
-// type SignatureMechanism int
-
-// const (
-// TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 SignatureMechanism = 0
-// Reserved SignatureMechanism = 1
-// )
diff --git a/pkg/amt/mps/usernamepassword.go b/pkg/amt/mps/usernamepassword.go
deleted file mode 100644
index 35ce6bed..00000000
--- a/pkg/amt/mps/usernamepassword.go
+++ /dev/null
@@ -1,46 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package mps
-
-import (
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/cim/models"
-)
-
-const AMT_MPSUsernamePassword = "AMT_MPSUsernamePassword"
-
-type MPSUsernamePassword struct {
- models.SharedCredential
-}
-type UsernamePassword struct {
- base message.Base
-}
-
-func NewMPSUsernamePassword(wsmanMessageCreator *message.WSManMessageCreator) UsernamePassword {
- return UsernamePassword{
- base: message.NewBase(wsmanMessageCreator, AMT_MPSUsernamePassword),
- }
-}
-
-// Get retrieves the representation of the instance
-func (MPSUsernamePassword UsernamePassword) Get() string {
- return MPSUsernamePassword.base.Get(nil)
-}
-
-// Enumerates the instances of this class
-func (MPSUsernamePassword UsernamePassword) Enumerate() string {
- return MPSUsernamePassword.base.Enumerate()
-}
-
-// Pulls instances of this class, following an Enumerate operation
-func (MPSUsernamePassword UsernamePassword) Pull(enumerationContext string) string {
- return MPSUsernamePassword.base.Pull(enumerationContext)
-}
-
-// Put will change properties of the selected instance
-func (MPSUsernamePassword UsernamePassword) Put(mpsUsernamePassword MPSUsernamePassword) string {
- return MPSUsernamePassword.base.Put(mpsUsernamePassword, false, nil)
-}
diff --git a/pkg/amt/mps/usernamepassword_test.go b/pkg/amt/mps/usernamepassword_test.go
deleted file mode 100644
index 1c777815..00000000
--- a/pkg/amt/mps/usernamepassword_test.go
+++ /dev/null
@@ -1,50 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package mps
-
-import (
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestAMT_MPSUsernamePassword(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewMPSUsernamePassword(wsmanMessageCreator)
-
- t.Run("amt_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid AMT_MPSUsernamePassword Get wsman message", "AMT_MPSUsernamePassword", wsmantesting.GET, "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid AMT_MPSUsernamePassword Enumerate wsman message", "AMT_MPSUsernamePassword", wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid AMT_MPSUsernamePassword Pull wsman message", "AMT_MPSUsernamePassword", wsmantesting.PULL, wsmantesting.PULL_BODY, func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-}
diff --git a/pkg/amt/publickey/certificate.go b/pkg/amt/publickey/certificate.go
deleted file mode 100644
index 59fb115d..00000000
--- a/pkg/amt/publickey/certificate.go
+++ /dev/null
@@ -1,75 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package publickey
-
-import (
- "encoding/xml"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
-)
-
-const AMT_PublicKeyCertificate = "AMT_PublicKeyCertificate"
-
-type PullResponseEnvelope struct {
- XMLName xml.Name `xml:"Envelope"`
- Header message.Header
- Body PullResponseBody
-}
-
-type PullResponseBody struct {
- PullResponse PullResponse
-}
-
-type PullResponse struct {
- Items []PublicKeyCertificate `xml:"Items>AMT_PublicKeyCertificate"`
- EndOfSequence string
-}
-
-type PublicKeyCertificate struct {
- ElementName string // A user-friendly name for the object . . .
- InstanceID string // Within the scope of the instantiating Namespace, InstanceID opaquely and uniquely identifies an instance of this class.
- X509Certificate string // uint8[4100] // The X.509 Certificate blob.
- TrustedRootCertficate bool // For root certificate [that were added by AMT_PublicKeyManagementService.AddTrustedRootCertificate()]this property will be true.
- Issuer string // The Issuer field of this certificate.
- Subject string // The Subject field of this certificate.
- ReadOnlyCertificate bool // Indicates whether the certificate is an Intel AMT self-signed certificate. If True, the certificate cannot be deleted.
-}
-
-type Certificate struct {
- base message.Base
-}
-
-func NewPublicKeyCertificate(wsmanMessageCreator *message.WSManMessageCreator) Certificate {
- return Certificate{
- base: message.NewBase(wsmanMessageCreator, AMT_PublicKeyCertificate),
- }
-}
-
-// Get retrieves the representation of the instance
-func (PublicKeyCertificate Certificate) Get() string {
- return PublicKeyCertificate.base.Get(nil)
-}
-
-// Enumerates the instances of this class
-func (PublicKeyCertificate Certificate) Enumerate() string {
- return PublicKeyCertificate.base.Enumerate()
-}
-
-// Pulls instances of this class, following an Enumerate operation
-func (PublicKeyCertificate Certificate) Pull(enumerationContext string) string {
- return PublicKeyCertificate.base.Pull(enumerationContext)
-}
-
-// Put will change properties of the selected instance
-func (PublicKeyCertificate Certificate) Put(publicKeyCertificate PublicKeyCertificate) string {
- return PublicKeyCertificate.base.Put(publicKeyCertificate, false, nil)
-}
-
-// Delete removes a the specified instance
-func (PublicKeyCertificate Certificate) Delete(instanceID string) string {
- selector := message.Selector{Name: "InstanceID", Value: instanceID}
- return PublicKeyCertificate.base.Delete(selector)
-}
diff --git a/pkg/amt/publickey/certificate_test.go b/pkg/amt/publickey/certificate_test.go
deleted file mode 100644
index 731d9b22..00000000
--- a/pkg/amt/publickey/certificate_test.go
+++ /dev/null
@@ -1,65 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package publickey
-
-import (
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestAMT_PublicKeyCertificate(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewPublicKeyCertificate(wsmanMessageCreator)
- putCert := PublicKeyCertificate{
- ElementName: "",
- InstanceID: "",
- X509Certificate: "",
- TrustedRootCertficate: false,
- Issuer: "",
- Subject: "",
- ReadOnlyCertificate: false,
- }
- expectedPutCertBody := `falsefalse`
-
- t.Run("amt_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- extraHeader string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid AMT_PublicKeyCertificate Get wsman message", AMT_PublicKeyCertificate, wsmantesting.GET, "", "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid AMT_PublicKeyCertificate Enumerate wsman message", AMT_PublicKeyCertificate, wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, "", elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid AMT_PublicKeyCertificate Pull wsman message", AMT_PublicKeyCertificate, wsmantesting.PULL, wsmantesting.PULL_BODY, "", func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- //PUTS
- {"should create a valid AMT_PublicKeyCertificate Put wsman message", AMT_PublicKeyCertificate, wsmantesting.PUT, expectedPutCertBody, "", func() string { return elementUnderTest.Put(putCert) }},
- //DELETE
- {"should create a valid AMT_PublicKeyCertificate Delete wsman message", AMT_PublicKeyCertificate, wsmantesting.DELETE, "", "instanceID123", func() string { return elementUnderTest.Delete("instanceID123") }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, test.extraHeader, test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-}
diff --git a/pkg/amt/publickey/managementservice.go b/pkg/amt/publickey/managementservice.go
deleted file mode 100644
index a12248cb..00000000
--- a/pkg/amt/publickey/managementservice.go
+++ /dev/null
@@ -1,169 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package publickey
-
-import (
- "encoding/xml"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/actions"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/cim/models"
-)
-
-const AMT_PublicKeyManagementService = "AMT_PublicKeyManagementService"
-
-type Response struct {
- XMLName xml.Name `xml:"Envelope"`
- Header message.Header `xml:"Header"`
- Body Body `xml:"Body"`
-}
-type Body struct {
- AddTrustedRootCertificate_OUTPUT AddTrustedCertificate_OUTPUT `xml:"AddTrustedRootCertificate_OUTPUT,omitempty"`
- AddTrustedCertificate_OUTPUT AddTrustedCertificate_OUTPUT `xml:"AddCertificate_OUTPUT,omitempty"`
- AddKey_OUTPUT AddKey_OUTPUT `xml:"AddKey_OUTPUT,omitempty"`
- GeneratedKeyPair_OUTPUT GenerateKeyPair_OUTPUT `xml:"GenerateKeyPair_OUTPUT,omitempty"`
-}
-type AddTrustedCertificate_OUTPUT struct {
- CreatedCertificate CreatedCertificate `xml:"CreatedCertificate"`
- ReturnValue int
-}
-
-type CreatedCertificate struct {
- Address string `xml:"Address,omitempty"`
- ReferenceParameters models.ReferenceParameters_OUTPUT `xml:"ReferenceParameters,omitempty"`
-}
-type AddCertificate_INPUT struct {
- XMLName xml.Name `xml:"h:AddCertificate_INPUT"`
- H string `xml:"xmlns:h,attr"`
- CertificateBlob string `xml:"h:CertificateBlob"`
-}
-type AddTrustedRootCertificate_INPUT struct {
- XMLName xml.Name `xml:"h:AddTrustedRootCertificate_INPUT"`
- H string `xml:"xmlns:h,attr"`
- CertificateBlob string `xml:"h:CertificateBlob"`
-}
-type AddKey_OUTPUT struct {
- CreatedKey CreatedCertificate `xml:"CreatedKey"`
- ReturnValue int
-}
-type AddKey_INPUT struct {
- XMLName xml.Name `xml:"h:AddKey_INPUT"`
- H string `xml:"xmlns:h,attr"`
- KeyBlob []byte `xml:"h:KeyBlob"`
-}
-
-type GenerateKeyPair_INPUT struct {
- XMLName xml.Name `xml:"h:GenerateKeyPair_INPUT"`
- H string `xml:"xmlns:h,attr"`
- KeyAlgorithm KeyAlgorithm `xml:"h:KeyAlgorithm"`
- KeyLength KeyLength `xml:"h:KeyLength"`
-}
-
-type GenerateKeyPair_OUTPUT struct {
- KeyPair CreatedCertificate `xml:"KeyPair"`
- ReturnValue int
-}
-
-type KeyAlgorithm int
-
-const (
- RSA KeyAlgorithm = 0
-)
-
-type KeyLength int
-
-const (
- KeyLength2048 KeyLength = 2048
-)
-
-type PKCS10Request struct {
- XMLName xml.Name `xml:"h:GeneratePKCS10RequestEx_INPUT"`
- H string `xml:"xmlns:h,attr"`
- KeyPair string `xml:"h:KeyPair"`
- NullSignedCertificateRequest string `xml:"h:NullSignedCertificateRequest"`
- SigningAlgorithm SigningAlgorithm `xml:"h:SigningAlgorithm"`
-}
-type SigningAlgorithm int
-
-const (
- SHA1RSA SigningAlgorithm = iota
- SHA256RSA
-)
-
-type ManagementService struct {
- base message.Base
-}
-
-func NewPublicKeyManagementService(wsmanMessageCreator *message.WSManMessageCreator) ManagementService {
- return ManagementService{
- base: message.NewBase(wsmanMessageCreator, AMT_PublicKeyManagementService),
- }
-}
-
-// Get retrieves the representation of the instance
-func (PublicKeyManagementService ManagementService) Get() string {
- return PublicKeyManagementService.base.Get(nil)
-}
-
-// Enumerates the instances of this class
-func (PublicKeyManagementService ManagementService) Enumerate() string {
- return PublicKeyManagementService.base.Enumerate()
-}
-
-// Pulls instances of this class, following an Enumerate operation
-func (PublicKeyManagementService ManagementService) Pull(enumerationContext string) string {
- return PublicKeyManagementService.base.Pull(enumerationContext)
-}
-
-// Delete removes a the specified instance
-func (PublicKeyManagementService ManagementService) Delete(instanceID string) string {
- selector := message.Selector{Name: "InstanceID", Value: instanceID}
- return PublicKeyManagementService.base.Delete(selector)
-}
-func (p ManagementService) AddCertificate(certificateBlob string) string {
- header := p.base.WSManMessageCreator.CreateHeader(string(actions.AddCertificate), AMT_PublicKeyManagementService, nil, "", "")
- certificate := AddCertificate_INPUT{CertificateBlob: certificateBlob}
- body := p.base.WSManMessageCreator.CreateBody("AddCertificate_INPUT", AMT_PublicKeyManagementService, &certificate)
-
- return p.base.WSManMessageCreator.CreateXML(header, body)
-}
-
-func (p ManagementService) AddTrustedRootCertificate(certificateBlob string) string {
- header := p.base.WSManMessageCreator.CreateHeader(string(actions.AddTrustedRootCertificate), AMT_PublicKeyManagementService, nil, "", "")
- trustedRootCert := AddTrustedRootCertificate_INPUT{CertificateBlob: certificateBlob}
- body := p.base.WSManMessageCreator.CreateBody("AddTrustedRootCertificate_INPUT", AMT_PublicKeyManagementService, &trustedRootCert)
-
- return p.base.WSManMessageCreator.CreateXML(header, body)
-}
-
-func (p ManagementService) GenerateKeyPair(keyPairParameters GenerateKeyPair_INPUT) string {
- header := p.base.WSManMessageCreator.CreateHeader(string(actions.GenerateKeyPair), AMT_PublicKeyManagementService, nil, "", "")
- body := p.base.WSManMessageCreator.CreateBody("GenerateKeyPair_INPUT", AMT_PublicKeyManagementService, &keyPairParameters)
-
- return p.base.WSManMessageCreator.CreateXML(header, body)
-}
-
-func (p ManagementService) GeneratePKCS10RequestEx(pkcs10Request PKCS10Request) string {
- header := p.base.WSManMessageCreator.CreateHeader(string(actions.GeneratePKCS10RequestEx), AMT_PublicKeyManagementService, nil, "", "")
- body := p.base.WSManMessageCreator.CreateBody("GeneratePKCS10RequestEx_INPUT", AMT_PublicKeyManagementService, &pkcs10Request)
-
- return p.base.WSManMessageCreator.CreateXML(header, body)
-}
-
-// AddKey adds a new certificate key to the Intel(R) AMT CertStore.
-// A key cannot be removed if its corresponding certificate is referenced (for example, used by TLS, 802.1X, or EAC).
-// After the method succeeds, a new instance of AMT_PublicPrivateKeyPair will be created.
-// Possible return values are: PT_STATUS_SUCCESS(0), PT_STATUS_INTERNAL_ERROR(1), PT_STATUS_MAX_LIMIT_REACHED(23),
-// PT_STATUS_FLASH_WRITE_LIMIT_EXCEEDED(38), PT_STATUS_DUPLICATE(2068), PT_STATUS_INVALID_KEY(2062).
-func (p ManagementService) AddKey(keyBlob []byte) string {
- header := p.base.WSManMessageCreator.CreateHeader(string(actions.AddKey), AMT_PublicKeyManagementService, nil, "", "")
- params := &AddKey_INPUT{
- KeyBlob: keyBlob,
- }
- body := p.base.WSManMessageCreator.CreateBody("AddKey_INPUT", AMT_PublicKeyManagementService, params)
-
- return p.base.WSManMessageCreator.CreateXML(header, body)
-}
diff --git a/pkg/amt/publickey/managementservice_test.go b/pkg/amt/publickey/managementservice_test.go
deleted file mode 100644
index ce44f7a6..00000000
--- a/pkg/amt/publickey/managementservice_test.go
+++ /dev/null
@@ -1,84 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package publickey
-
-import (
- "fmt"
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestAMT_PublicKeyManagementService(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewPublicKeyManagementService(wsmanMessageCreator)
-
- t.Run("amt_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- extraHeader string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid AMT_PublicKeyManagementService Get wsman message", "AMT_PublicKeyManagementService", wsmantesting.GET, "", "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid AMT_PublicKeyManagementService Enumerate wsman message", "AMT_PublicKeyManagementService", wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, "", elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid AMT_PublicKeyManagementService Pull wsman message", "AMT_PublicKeyManagementService", wsmantesting.PULL, wsmantesting.PULL_BODY, "", func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
-
- // PUBLIC KEY MANAGEMENT SERVICE
- {"should return a valid amt_PublicKeyManagementService AddTrustedRootCertificate wsman message", "AMT_PublicKeyManagementService", `http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyManagementService/AddTrustedRootCertificate`, fmt.Sprintf(`%s`, wsmantesting.TrustedRootCert), "", func() string {
- return elementUnderTest.AddTrustedRootCertificate(wsmantesting.TrustedRootCert)
- }},
-
- {"should return a valid amt_PublicKeyManagementService GenerateKeyPair wsman message", "AMT_PublicKeyManagementService", `http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyManagementService/GenerateKeyPair`, `02048`, "", func() string {
- params := GenerateKeyPair_INPUT{
- KeyAlgorithm: 0,
- KeyLength: 2048,
- }
- return elementUnderTest.GenerateKeyPair(params)
- }},
-
- {"should return a valid amt_PublicKeyManagementService AddCertificate wsman message", "AMT_PublicKeyManagementService", `http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyManagementService/AddCertificate`, fmt.Sprintf(`%s`, wsmantesting.TrustedRootCert), "", func() string {
- return elementUnderTest.AddCertificate(wsmantesting.TrustedRootCert)
- }},
-
- {"should return a valid amt_PublicKeyManagementService GeneratePKCS10RequestEx wsman message", "AMT_PublicKeyManagementService", "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyManagementService/GeneratePKCS10RequestEx", `testreallylongcertificateteststring1`, "", func() string {
- pkcs10Request := PKCS10Request{
- KeyPair: "test",
- NullSignedCertificateRequest: "reallylongcertificateteststring",
- SigningAlgorithm: 1,
- }
- return elementUnderTest.GeneratePKCS10RequestEx(pkcs10Request)
- }},
- {"should return a valid amt_PublicKeyManagementService AddKey wsman message", "AMT_PublicKeyManagementService", "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyManagementService/AddKey", `privatekey`, "", func() string {
- cert := []byte("privatekey")
- return elementUnderTest.AddKey(cert)
- }},
- //DELETE
- {"should create a valid amt_PublicKeyManagementService Delete wsman message", "AMT_PublicKeyManagementService", wsmantesting.DELETE, "", "instanceID123", func() string { return elementUnderTest.Delete("instanceID123") }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, test.extraHeader, test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-}
diff --git a/pkg/amt/publicprivate/keypair.go b/pkg/amt/publicprivate/keypair.go
deleted file mode 100644
index d1b1d274..00000000
--- a/pkg/amt/publicprivate/keypair.go
+++ /dev/null
@@ -1,65 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package publicprivate
-
-import (
- "encoding/xml"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
-)
-
-const AMT_PublicPrivateKeyPair = "AMT_PublicPrivateKeyPair"
-
-type PullResponseEnvelope struct {
- XMLName xml.Name `xml:"Envelope"`
- Header message.Header
- Body PullResponseBody
-}
-
-type PullResponseBody struct {
- PullResponse PullResponse
-}
-
-type PullResponse struct {
- Items []PublicPrivateKeyPair `xml:"Items>AMT_PublicPrivateKeyPair"`
- EndOfSequence string
-}
-
-type PublicPrivateKeyPair struct {
- ElementName string // A user-friendly name for the object . . .
- InstanceID string // Within the scope of the instantiating Namespace, InstanceID opaquely and uniquely identifies an instance of this class.
- //DERKey [1210]uint8 // RSA Key encoded as DES PKCS#1.
- DERKey string
-}
-
-type KeyPair struct {
- base message.Base
-}
-
-func NewPublicPrivateKeyPair(wsmanMessageCreator *message.WSManMessageCreator) KeyPair {
- return KeyPair{
- base: message.NewBase(wsmanMessageCreator, AMT_PublicPrivateKeyPair),
- }
-}
-
-// Get retrieves the representation of the instance
-func (PublicPrivateKeyPair KeyPair) Get() string {
- return PublicPrivateKeyPair.base.Get(nil)
-}
-
-// Enumerates the instances of this class
-func (PublicPrivateKeyPair KeyPair) Enumerate() string {
- return PublicPrivateKeyPair.base.Enumerate()
-}
-
-// Pulls instances of this class, following an Enumerate operation
-func (PublicPrivateKeyPair KeyPair) Pull(enumerationContext string) string {
- return PublicPrivateKeyPair.base.Pull(enumerationContext)
-}
-func (PublicPrivateKeyPair KeyPair) Delete(instanceID string) string {
- selector := message.Selector{Name: "InstanceID", Value: instanceID}
- return PublicPrivateKeyPair.base.Delete(selector)
-}
diff --git a/pkg/amt/publicprivate/keypair_test.go b/pkg/amt/publicprivate/keypair_test.go
deleted file mode 100644
index 3542c232..00000000
--- a/pkg/amt/publicprivate/keypair_test.go
+++ /dev/null
@@ -1,53 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package publicprivate
-
-import (
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestAMT_PublicPrivateKeyPair(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewPublicPrivateKeyPair(wsmanMessageCreator)
-
- t.Run("amt_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- extraHeader string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid AMT_PublicPrivateKeyPair Get wsman message", "AMT_PublicPrivateKeyPair", wsmantesting.GET, "", "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid AMT_PublicPrivateKeyPair Enumerate wsman message", "AMT_PublicPrivateKeyPair", wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, "", elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid AMT_PublicPrivateKeyPair Pull wsman message", "AMT_PublicPrivateKeyPair", wsmantesting.PULL, wsmantesting.PULL_BODY, "", func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- //DELETE
- {"should create a valid AMT_PublicPrivateKeyPair Delete wsman message", "AMT_PublicPrivateKeyPair", wsmantesting.DELETE, "", "instanceID123", func() string { return elementUnderTest.Delete("instanceID123") }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, test.extraHeader, test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-}
diff --git a/pkg/amt/redirection/service.go b/pkg/amt/redirection/service.go
deleted file mode 100644
index bd46326e..00000000
--- a/pkg/amt/redirection/service.go
+++ /dev/null
@@ -1,93 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package redirection
-
-import (
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/actions"
-)
-
-type RedirectionResponse struct {
- AMT_RedirectionService RedirectionService
-}
-
-type RedirectionService struct {
- Name string
- CreationClassName string
- SystemName string
- SystemCreationClassName string
- ElementName string
- ListenerEnabled bool
- AccessLog []string
- EnabledState EnabledState
-}
-
-type EnabledState int
-
-const AMT_RedirectionService = "AMT_RedirectionService"
-
-const (
- Unknown EnabledState = iota
- Other
- Enabled
- Disabled
- ShuttingDown
- NotApplicable
- EnabledButOffline
- InTest
- Deferred
- Quiesce
- Starting
- DMTFReserved
- IDERAndSOLAreDisabled = 32768
- IDERIsEnabledAndSOLIsDisabled = 32769
- SOLIsEnabledAndIDERIsDisabled = 32770
- IDERAndSOLAreEnabled = 32771
-)
-
-type RequestedState int
-
-const (
- DisableIDERAndSOL RequestedState = 32768
- EnableIDERAndDisableSOL RequestedState = 32769
- EnableSOLAndDisableIDER RequestedState = 32770
- EnableIDERAndSOL RequestedState = 32771
-)
-
-type Service struct {
- base message.Base
-}
-
-func NewRedirectionService(wsmanMessageCreator *message.WSManMessageCreator) Service {
- return Service{
- base: message.NewBase(wsmanMessageCreator, AMT_RedirectionService),
- }
-}
-
-// Get retrieves the representation of the instance
-func (RedirectionService Service) Get() string {
- return RedirectionService.base.Get(nil)
-}
-
-// Enumerates the instances of this class
-func (RedirectionService Service) Enumerate() string {
- return RedirectionService.base.Enumerate()
-}
-
-// Pulls instances of this class, following an Enumerate operation
-func (RedirectionService Service) Pull(enumerationContext string) string {
- return RedirectionService.base.Pull(enumerationContext)
-}
-
-// Put will change properties of the selected instance
-func (RedirectionService Service) Put(redirectionService RedirectionService) string {
- return RedirectionService.base.Put(redirectionService, false, nil)
-}
-
-// RequestStateChange requests that the state of the element be changed to the value specified in the RequestedState parameter . . .
-func (RedirectionService Service) RequestStateChange(requestedState RequestedState) string {
- return RedirectionService.base.RequestStateChange(actions.RequestStateChange(AMT_RedirectionService), int(requestedState))
-}
diff --git a/pkg/amt/redirection/service_test.go b/pkg/amt/redirection/service_test.go
deleted file mode 100644
index 66515879..00000000
--- a/pkg/amt/redirection/service_test.go
+++ /dev/null
@@ -1,50 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package redirection
-
-import (
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestAMT_RedirectionService(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewRedirectionService(wsmanMessageCreator)
-
- t.Run("amt_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid AMT_RedirectionService Get wsman message", "AMT_RedirectionService", wsmantesting.GET, "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid AMT_RedirectionService Enumerate wsman message", "AMT_RedirectionService", wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid AMT_RedirectionService Pull wsman message", "AMT_RedirectionService", wsmantesting.PULL, wsmantesting.PULL_BODY, func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-}
diff --git a/pkg/amt/remoteaccess/policyappliestomps.go b/pkg/amt/remoteaccess/policyappliestomps.go
deleted file mode 100644
index cde2fb0c..00000000
--- a/pkg/amt/remoteaccess/policyappliestomps.go
+++ /dev/null
@@ -1,100 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package remoteaccess
-
-import (
- "encoding/xml"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/cim/models"
-)
-
-const AMT_RemoteAccessPolicyAppliesToMPS = "AMT_RemoteAccessPolicyAppliesToMPS"
-
-type RemoteAccessPolicyAppliesToMPS struct {
- XMLName xml.Name `xml:"h:AMT_RemoteAccessPolicyAppliesToMPS"`
- H string `xml:"xmlns:h,attr"`
- PolicySetAppliesToElement
- OrderOfAccess int `xml:"h:OrderOfAccess"`
- MPSType MPSType `xml:"h:MpsType"`
-}
-type Policy struct {
- models.ManagedElement
- CommonName string `xml:"h:CommonName"`
- PolicyKeywords []string `xml:"h:PolicyKeywords"`
-}
-
-type PolicySet struct {
- XMLName xml.Name `xml:"h:PolicySet"`
- Policy
- PolicyDecisionStrategy PolicyDecisionStrategy `xml:"h:PolicyDecisionStrategy"` // ValueMap={1, 2} Values={First Matching, All}
- PolicyRoles []string `xml:"h:PolicyRoles"` // MaxLen=256
- Enabled models.Enabled `xml:"h:Enabled"` // ValueMap={1, 2, 3} Values={Enabled, Disabled, Enabled For Debug}
-}
-
-type PolicySetAppliesToElement struct {
- PolicySet PolicySet
- ManagedElement models.ManagedElement
-}
-
-/**
- * First Matching:1 | All:2
- */
-type PolicyDecisionStrategy uint8
-
-const (
- PolicyDecisionStrategyFirstMatching PolicyDecisionStrategy = 1
- PolicyDecisionStrategyAll PolicyDecisionStrategy = 2
-)
-
-type MPSType int
-
-const (
- ExternalMPS MPSType = iota
- InternalMPS
- BothMPS
-)
-
-type PolicyAppliesToMPS struct {
- base message.Base
-}
-
-func NewRemoteAccessPolicyAppliesToMPS(wsmanMessageCreator *message.WSManMessageCreator) PolicyAppliesToMPS {
- return PolicyAppliesToMPS{
- base: message.NewBase(wsmanMessageCreator, AMT_RemoteAccessPolicyAppliesToMPS),
- }
-}
-
-// Get retrieves the representation of the instance
-func (RemoteAccessPolicyAppliesToMPS PolicyAppliesToMPS) Get() string {
- return RemoteAccessPolicyAppliesToMPS.base.Get(nil)
-}
-
-// Enumerates the instances of this class
-func (RemoteAccessPolicyAppliesToMPS PolicyAppliesToMPS) Enumerate() string {
- return RemoteAccessPolicyAppliesToMPS.base.Enumerate()
-}
-
-// Pulls instances of this class, following an Enumerate operation
-func (RemoteAccessPolicyAppliesToMPS PolicyAppliesToMPS) Pull(enumerationContext string) string {
- return RemoteAccessPolicyAppliesToMPS.base.Pull(enumerationContext)
-}
-
-// Put will change properties of the selected instance
-func (RemoteAccessPolicyAppliesToMPS PolicyAppliesToMPS) Put(remoteAccessPolicyAppliesToMPS *RemoteAccessPolicyAppliesToMPS) string {
- return RemoteAccessPolicyAppliesToMPS.base.Put(remoteAccessPolicyAppliesToMPS, false, nil)
-}
-
-// Delete removes a the specified instance
-func (RemoteAccessPolicyAppliesToMPS PolicyAppliesToMPS) Delete(handle string) string {
- selector := message.Selector{Name: "Name", Value: handle}
- return RemoteAccessPolicyAppliesToMPS.base.Delete(selector)
-}
-
-// Creates a new instance of this class
-func (RemoteAccessPolicyAppliesToMPS PolicyAppliesToMPS) Create(remoteAccessPolicyAppliesToMPS RemoteAccessPolicyAppliesToMPS) string {
- return RemoteAccessPolicyAppliesToMPS.base.Create(remoteAccessPolicyAppliesToMPS, nil)
-}
diff --git a/pkg/amt/remoteaccess/policyappliestomps_test.go b/pkg/amt/remoteaccess/policyappliestomps_test.go
deleted file mode 100644
index b3c6c3c4..00000000
--- a/pkg/amt/remoteaccess/policyappliestomps_test.go
+++ /dev/null
@@ -1,85 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package remoteaccess
-
-import (
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/cim/models"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestAMT_RemoteAccessPolicyAppliesToMPS(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewRemoteAccessPolicyAppliesToMPS(wsmanMessageCreator)
-
- t.Run("amt_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- extraHeader string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid AMT_RemoteAccessPolicyAppliesToMPS Get wsman message", "AMT_RemoteAccessPolicyAppliesToMPS", wsmantesting.GET, "", "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid AMT_RemoteAccessPolicyAppliesToMPS Enumerate wsman message", "AMT_RemoteAccessPolicyAppliesToMPS", wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, "", elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid AMT_RemoteAccessPolicyAppliesToMPS Pull wsman message", "AMT_RemoteAccessPolicyAppliesToMPS", wsmantesting.PULL, wsmantesting.PULL_BODY, "", func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- {"should create a valid AMT_RemoteAccessPolicyAppliesToMPS Put wsman message", "AMT_RemoteAccessPolicyAppliesToMPS", wsmantesting.PUT, `testtesttesttesttest1test1testtesttest02`, "", func() string {
- rapatmps := RemoteAccessPolicyAppliesToMPS{
- PolicySetAppliesToElement: PolicySetAppliesToElement{
- ManagedElement: models.ManagedElement{
- Caption: "test",
- Description: "test",
- ElementName: "test",
- },
- PolicySet: PolicySet{
- Enabled: 1,
- PolicyDecisionStrategy: PolicyDecisionStrategyFirstMatching,
- PolicyRoles: []string{"test"},
- Policy: Policy{
- ManagedElement: models.ManagedElement{
- Caption: "test",
- Description: "test",
- ElementName: "test",
- },
- CommonName: "test",
- PolicyKeywords: []string{"test"},
- },
- },
- },
- MPSType: BothMPS,
- OrderOfAccess: 0,
- }
-
- return elementUnderTest.Put(&rapatmps)
- }},
- //{"should create a valid AMT_RemoteAccessPolicyAppliesToMPS Create wsman message", "AMT_RemoteAccessPolicyAppliesToMPS", wsmantesting.PULL, wsmantesting.PULL_BODY, "", func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- {"should create a valid AMT_RemoteAccessPolicyAppliesToMPS Delete wsman message", "AMT_RemoteAccessPolicyAppliesToMPS", wsmantesting.DELETE, "", "Instance", func() string {
- return elementUnderTest.Delete("Instance")
- }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, test.extraHeader, test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-}
diff --git a/pkg/amt/remoteaccess/policyrule.go b/pkg/amt/remoteaccess/policyrule.go
deleted file mode 100644
index 0336c758..00000000
--- a/pkg/amt/remoteaccess/policyrule.go
+++ /dev/null
@@ -1,63 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package remoteaccess
-
-import (
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
-)
-
-const AMT_RemoteAccessPolicyRule = "AMT_RemoteAccessPolicyRule"
-
-type RemoteAccessPolicyRule struct {
- Trigger Trigger
- TunnelLifeTime int
- ExtendedData string
-}
-
-type Trigger uint8
-
-const (
- UserInitiated Trigger = iota
- Alert
- Periodic
- HomeProvisioning
-)
-
-type PolicyRule struct {
- base message.Base
-}
-
-func NewRemoteAccessPolicyRule(wsmanMessageCreator *message.WSManMessageCreator) PolicyRule {
- return PolicyRule{
- base: message.NewBase(wsmanMessageCreator, AMT_RemoteAccessPolicyRule),
- }
-}
-
-// Get retrieves the representation of the instance
-func (RemoteAccessPolicyRule PolicyRule) Get() string {
- return RemoteAccessPolicyRule.base.Get(nil)
-}
-
-// Enumerates the instances of this class
-func (RemoteAccessPolicyRule PolicyRule) Enumerate() string {
- return RemoteAccessPolicyRule.base.Enumerate()
-}
-
-// Pulls instances of this class, following an Enumerate operation
-func (RemoteAccessPolicyRule PolicyRule) Pull(enumerationContext string) string {
- return RemoteAccessPolicyRule.base.Pull(enumerationContext)
-}
-
-// Put will change properties of the selected instance
-func (RemoteAccessPolicyRule PolicyRule) Put(remoteAccessPolicyRule RemoteAccessPolicyRule) string {
- return RemoteAccessPolicyRule.base.Put(remoteAccessPolicyRule, false, nil)
-}
-
-// Delete removes a the specified instance
-func (RemoteAccessPolicyRule PolicyRule) Delete(handle string) string {
- selector := message.Selector{Name: "PolicyRuleName", Value: handle}
- return RemoteAccessPolicyRule.base.Delete(selector)
-}
diff --git a/pkg/amt/remoteaccess/policyrule_test.go b/pkg/amt/remoteaccess/policyrule_test.go
deleted file mode 100644
index aa4017bd..00000000
--- a/pkg/amt/remoteaccess/policyrule_test.go
+++ /dev/null
@@ -1,55 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package remoteaccess
-
-import (
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestAMT_RemoteAccessPolicyRule(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewRemoteAccessPolicyRule(wsmanMessageCreator)
-
- t.Run("amt_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- extraHeader string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid AMT_RemoteAccessPolicyRule Get wsman message", "AMT_RemoteAccessPolicyRule", wsmantesting.GET, "", "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid AMT_RemoteAccessPolicyRule Enumerate wsman message", "AMT_RemoteAccessPolicyRule", wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, "", elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid AMT_RemoteAccessPolicyRule Pull wsman message", "AMT_RemoteAccessPolicyRule", wsmantesting.PULL, wsmantesting.PULL_BODY, "", func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- //DELETE
- {"should create a valid AMT_RemoteAccessPolicyRule Delete wsman message", "AMT_RemoteAccessPolicyRule", wsmantesting.DELETE, "", "Instance", func() string {
- return elementUnderTest.Delete("Instance")
- }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, test.extraHeader, test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-}
diff --git a/pkg/amt/remoteaccess/service.go b/pkg/amt/remoteaccess/service.go
deleted file mode 100644
index 563422b4..00000000
--- a/pkg/amt/remoteaccess/service.go
+++ /dev/null
@@ -1,81 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package remoteaccess
-
-import (
- "fmt"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/actions"
-)
-
-const AMT_RemoteAccessService = "AMT_RemoteAccessService"
-
-type Service struct {
- base message.Base
-}
-type MPServer struct {
- AccessInfo string
- InfoFormat MPServerInfoFormat
- Port int
- AuthMethod MPServerAuthMethod
- Username string
- Password string
- CommonName string
-}
-
-type MPServerInfoFormat uint8
-
-const (
- IPv4Address MPServerInfoFormat = 3
- IPv6Address MPServerInfoFormat = 4
- FQDN MPServerInfoFormat = 201
-)
-
-type MPServerAuthMethod uint8
-
-const (
- MutualAuthentication MPServerAuthMethod = 1
- UsernamePasswordAuthentication MPServerAuthMethod = 2
-)
-
-func NewRemoteAccessService(wsmanMessageCreator *message.WSManMessageCreator) Service {
- return Service{
- base: message.NewBase(wsmanMessageCreator, AMT_RemoteAccessService),
- }
-}
-
-// Get retrieves the representation of the instance
-func (RemoteAccessService Service) Get() string {
- return RemoteAccessService.base.Get(nil)
-}
-
-// Enumerates the instances of this class
-func (RemoteAccessService Service) Enumerate() string {
- return RemoteAccessService.base.Enumerate()
-}
-
-// Pulls instances of this class, following an Enumerate operation
-func (RemoteAccessService Service) Pull(enumerationContext string) string {
- return RemoteAccessService.base.Pull(enumerationContext)
-}
-func (r Service) AddMPS(mpServer MPServer) string {
- header := r.base.WSManMessageCreator.CreateHeader(string(actions.AddMps), AMT_RemoteAccessService, nil, "", "")
- body := fmt.Sprintf(`%s%d%d%d%s%s%s`, r.base.WSManMessageCreator.ResourceURIBase, AMT_RemoteAccessService, mpServer.AccessInfo, mpServer.InfoFormat, mpServer.Port, mpServer.AuthMethod, mpServer.Username, mpServer.Password, mpServer.CommonName)
- return r.base.WSManMessageCreator.CreateXML(header, body)
-}
-
-func (r Service) AddRemoteAccessPolicyRule(remoteAccessPolicyRule RemoteAccessPolicyRule, selector message.Selector) string {
- header := r.base.WSManMessageCreator.CreateHeader(string(actions.AddRemoteAccessPolicyRule), AMT_RemoteAccessService, nil, "", "")
- body := fmt.Sprintf(`%d%d%shttp://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous%s%s%s`, r.base.WSManMessageCreator.ResourceURIBase,
- AMT_RemoteAccessService,
- remoteAccessPolicyRule.Trigger,
- remoteAccessPolicyRule.TunnelLifeTime,
- remoteAccessPolicyRule.ExtendedData,
- r.base.WSManMessageCreator.ResourceURIBase,
- "AMT_ManagementPresenceRemoteSAP", selector.Name, selector.Value)
- return r.base.WSManMessageCreator.CreateXML(header, body)
-}
diff --git a/pkg/amt/remoteaccess/service_test.go b/pkg/amt/remoteaccess/service_test.go
deleted file mode 100644
index 4c50f70e..00000000
--- a/pkg/amt/remoteaccess/service_test.go
+++ /dev/null
@@ -1,76 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package remoteaccess
-
-import (
- "fmt"
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/actions"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestAMT_AlarmClockService(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewRemoteAccessService(wsmanMessageCreator)
-
- t.Run("amt_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid AMT_RemoteAccessService Get wsman message", "AMT_RemoteAccessService", wsmantesting.GET, "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid AMT_RemoteAccessService Enumerate wsman message", "AMT_RemoteAccessService", wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid AMT_RemoteAccessService Pull wsman message", "AMT_RemoteAccessService", wsmantesting.PULL, wsmantesting.PULL_BODY, func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- {"should create a valid AMT_RemoteAccessService AddMPS wsman message", "AMT_RemoteAccessService", string(actions.AddMps), fmt.Sprintf(`%s%d%d%d%s%s%s`, resourceUriBase, AMT_RemoteAccessService, "AccessInfo", 1, 2, 3, "Username", "Password", "CommonName"), func() string {
- mpsServer := MPServer{
- AccessInfo: "AccessInfo",
- InfoFormat: 1,
- Port: 2,
- AuthMethod: 3,
- Username: "Username",
- Password: "Password",
- CommonName: "CommonName",
- }
- return elementUnderTest.AddMPS(mpsServer)
- }},
- {"should create a valid AMT_RemoteAccessPolicyRule wsman message", "AMT_RemoteAccessService", string(actions.AddRemoteAccessPolicyRule), fmt.Sprintf(`%d%d%shttp://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous%s%strue`, resourceUriBase, AMT_RemoteAccessService, 2, 0, "0300", "http://intel.com/wbem/wscim/1/amt-schema/1/", "AMT_ManagementPresenceRemoteSAP"), func() string {
- remoteAccessPolicyRule := RemoteAccessPolicyRule{
- Trigger: 2,
- TunnelLifeTime: 0,
- ExtendedData: "0300",
- }
- selector := message.Selector{
- Name: "myselector",
- Value: "true",
- }
- return elementUnderTest.AddRemoteAccessPolicyRule(remoteAccessPolicyRule, selector)
- }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-}
diff --git a/pkg/amt/setupandconfiguration/service.go b/pkg/amt/setupandconfiguration/service.go
deleted file mode 100644
index ea73007d..00000000
--- a/pkg/amt/setupandconfiguration/service.go
+++ /dev/null
@@ -1,115 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package setupandconfiguration
-
-import (
- "encoding/xml"
- "fmt"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/actions"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/cim/models"
-)
-
-const AMT_SetupAndConfigurationService = "AMT_SetupAndConfigurationService"
-
-type (
- Response struct {
- XMLName xml.Name `xml:"Envelope"`
- Header message.Header
- Body Body
- }
- Body struct {
- CommitChanges_OUTPUT message.ReturnValue
- Unprovision_OUTPUT message.ReturnValue
- }
-)
-
-type UnprovisionResponse struct {
- XMLName xml.Name `xml:"Envelope"`
- Header message.Header `xml:"Header"`
- Body UnprovisionBody `xml:"Body"`
-}
-
-type UnprovisionBody struct {
- XMLName xml.Name `xml:"Body"`
- Unprovision_OUTPUT Unprovision_OUTPUT `xml:"Unprovision_OUTPUT"`
-}
-
-type Unprovision_OUTPUT struct {
- XMLName xml.Name `xml:"Unprovision_OUTPUT"`
- ReturnValue int
-}
-type SetupAndConfigurationService struct {
- models.CredentialManagementService
- AMT_SetupAndConfigurationService struct {
- CreationClassName string
- ElementName string
- EnabledState string
- Name string
- PasswordModel string
- ProvisioningMode string
- ProvisioningServerOTP string
- ProvisioningState string
- RequestedState string
- SystemCreationClassName string
- SystemName string
- ZeroTouchConfigurationEnabled string
- }
-}
-type Service struct {
- base message.Base
-}
-
-func NewSetupAndConfigurationService(wsmanMessageCreator *message.WSManMessageCreator) Service {
- return Service{
- base: message.NewBase(wsmanMessageCreator, AMT_SetupAndConfigurationService),
- }
-}
-func (s Service) Get() string {
- return s.base.Get(nil)
-}
-
-// Enumerates the instances of this class
-func (s Service) Enumerate() string {
- return s.base.Enumerate()
-}
-
-// Pulls instances of this class, following an Enumerate operation
-func (s Service) Pull(enumerationContext string) string {
- return s.base.Pull(enumerationContext)
-}
-
-// Put will change properties of the selected instance
-func (s Service) Put(setupAndConfigurationService SetupAndConfigurationService) string {
- return s.base.Put(setupAndConfigurationService, false, nil)
-}
-func (s Service) CommitChanges() string {
- header := s.base.WSManMessageCreator.CreateHeader(string(actions.CommitChanges), AMT_SetupAndConfigurationService, nil, "", "")
- body := s.base.WSManMessageCreator.CreateBody("CommitChanges_INPUT", AMT_SetupAndConfigurationService, nil)
- return s.base.WSManMessageCreator.CreateXML(header, body)
-}
-
-func (s Service) GetUuid() string {
- header := s.base.WSManMessageCreator.CreateHeader(string(actions.GetUuid), AMT_SetupAndConfigurationService, nil, "", "")
- body := s.base.WSManMessageCreator.CreateBody("GetUuid_INPUT", AMT_SetupAndConfigurationService, nil)
- return s.base.WSManMessageCreator.CreateXML(header, body)
-}
-
-func (s Service) SetMEBXPassword(password string) string {
- header := s.base.WSManMessageCreator.CreateHeader(string(actions.SetMEBxPassword), AMT_SetupAndConfigurationService, nil, "", "")
- body := fmt.Sprintf(`%s`, s.base.WSManMessageCreator.ResourceURIBase, AMT_SetupAndConfigurationService, password)
- return s.base.WSManMessageCreator.CreateXML(header, body)
-}
-
-func (s Service) Unprovision(provisioningMode int) string {
- if provisioningMode == 0 {
- provisioningMode = 1
- }
- header := s.base.WSManMessageCreator.CreateHeader(string(actions.Unprovision), AMT_SetupAndConfigurationService, nil, "", "")
- body := fmt.Sprintf(`%d`, s.base.WSManMessageCreator.ResourceURIBase, AMT_SetupAndConfigurationService, provisioningMode)
- return s.base.WSManMessageCreator.CreateXML(header, body)
-}
diff --git a/pkg/amt/setupandconfiguration/service_test.go b/pkg/amt/setupandconfiguration/service_test.go
deleted file mode 100644
index b9b4f6c4..00000000
--- a/pkg/amt/setupandconfiguration/service_test.go
+++ /dev/null
@@ -1,55 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package setupandconfiguration
-
-import (
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/actions"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestAMT_SetupAndConfigurationService(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewSetupAndConfigurationService(wsmanMessageCreator)
-
- t.Run("amt_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid AMT_SetupAndConfigurationService Get wsman message", "AMT_SetupAndConfigurationService", wsmantesting.GET, "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid AMT_SetupAndConfigurationService Enumerate wsman message", "AMT_SetupAndConfigurationService", wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid AMT_SetupAndConfigurationService Pull wsman message", "AMT_SetupAndConfigurationService", wsmantesting.PULL, wsmantesting.PULL_BODY, func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- {"should create a valid AMT_SetupAndConfigurationService CommitChanges wsman message", "AMT_SetupAndConfigurationService", string(actions.CommitChanges), ``, elementUnderTest.CommitChanges},
- {"should create a valid AMT_SetupAndConfigurationService GetUuid wsman message", "AMT_SetupAndConfigurationService", string(actions.GetUuid), ``, elementUnderTest.GetUuid},
- {"should create a valid AMT_SetupAndConfigurationService SetMEBxPassword wsman message", "AMT_SetupAndConfigurationService", string(actions.SetMEBxPassword), `P@ssw0rd`, func() string { return elementUnderTest.SetMEBXPassword("P@ssw0rd") }},
- {"should create a valid AMT_SetupAndConfigurationService Unprovision wsman message", "AMT_SetupAndConfigurationService", string(actions.Unprovision), `1`, func() string { return elementUnderTest.Unprovision(1) }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-}
diff --git a/pkg/amt/timesynchronization/service.go b/pkg/amt/timesynchronization/service.go
deleted file mode 100644
index 1d7a0d1a..00000000
--- a/pkg/amt/timesynchronization/service.go
+++ /dev/null
@@ -1,79 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package timesynchronization
-
-import (
- "encoding/xml"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/actions"
-)
-
-const AMT_TimeSynchronizationService = "AMT_TimeSynchronizationService"
-
-type (
- Response struct {
- XMLName xml.Name `xml:"Envelope"`
- Header message.Header `xml:"Header"`
- Body Body `xml:"Body"`
- }
- Body struct {
- XMLName xml.Name `xml:"Body"`
- GetLowAccuracyTimeSynch_OUTPUT GetLowAccuracyTimeSynch_OUTPUT
- SetHighAccuracyTimeSynch_OUTPUT message.ReturnValue
- }
- GetLowAccuracyTimeSynch_OUTPUT struct {
- Ta0 int64
- ReturnValue int
- }
-)
-
-type Service struct {
- base message.Base
-}
-type SetHighAccuracyTimeSynch_INPUT struct {
- XMLName xml.Name `xml:"h:SetHighAccuracyTimeSynch_INPUT"`
- H string `xml:"xmlns:h,attr"`
- Ta0 int64 `xml:"h:Ta0"`
- Tm1 int64 `xml:"h:Tm1"`
- Tm2 int64 `xml:"h:Tm2"`
-}
-
-func NewTimeSynchronizationService(wsmanMessageCreator *message.WSManMessageCreator) Service {
- return Service{
- base: message.NewBase(wsmanMessageCreator, AMT_TimeSynchronizationService),
- }
-}
-
-// Get retrieves the representation of the instance
-func (s Service) Get() string {
- return s.base.Get(nil)
-}
-
-// Enumerates the instances of this class
-func (s Service) Enumerate() string {
- return s.base.Enumerate()
-}
-
-// Pulls instances of this class, following an Enumerate operation
-func (s Service) Pull(enumerationContext string) string {
- return s.base.Pull(enumerationContext)
-}
-func (s Service) SetHighAccuracyTimeSynch(ta0, tm1, tm2 int64) string {
- header := s.base.WSManMessageCreator.CreateHeader(string(actions.SetHighAccuracyTimeSynch), AMT_TimeSynchronizationService, nil, "", "")
- body := s.base.WSManMessageCreator.CreateBody("SetHighAccuracyTimeSynch_INPUT", AMT_TimeSynchronizationService, &SetHighAccuracyTimeSynch_INPUT{
- Ta0: ta0,
- Tm1: tm1,
- Tm2: tm2,
- })
- return s.base.WSManMessageCreator.CreateXML(header, body)
-}
-
-func (s Service) GetLowAccuracyTimeSynch() string {
- header := s.base.WSManMessageCreator.CreateHeader(string(actions.GetLowAccuracyTimeSynch), AMT_TimeSynchronizationService, nil, "", "")
- body := s.base.WSManMessageCreator.CreateBody("GetLowAccuracyTimeSynch_INPUT", AMT_TimeSynchronizationService, nil)
- return s.base.WSManMessageCreator.CreateXML(header, body)
-}
diff --git a/pkg/amt/timesynchronization/service_test.go b/pkg/amt/timesynchronization/service_test.go
deleted file mode 100644
index f4ed1777..00000000
--- a/pkg/amt/timesynchronization/service_test.go
+++ /dev/null
@@ -1,132 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package timesynchronization
-
-import (
- "encoding/xml"
- "strings"
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/actions"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestAMT_TimeSynchronizationService(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewTimeSynchronizationService(wsmanMessageCreator)
-
- t.Run("amt_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid AMT_TimeSynchronizationService Get wsman message", "AMT_TimeSynchronizationService", wsmantesting.GET, "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid AMT_TimeSynchronizationService Enumerate wsman message", "AMT_TimeSynchronizationService", wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid AMT_TimeSynchronizationService Pull wsman message", "AMT_TimeSynchronizationService", wsmantesting.PULL, wsmantesting.PULL_BODY, func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- {"should create a valid AMT_TimeSynchronizationService GetLowAccuracyTimeSynch wsman message", "AMT_TimeSynchronizationService", string(actions.GetLowAccuracyTimeSynch), ``, elementUnderTest.GetLowAccuracyTimeSynch},
- {"should create a valid AMT_TimeSynchronizationService SetHighAccuracyTimeSynch wsman message", "AMT_TimeSynchronizationService", string(actions.SetHighAccuracyTimeSynch), "164424091116442409431644240943", func() string { return elementUnderTest.SetHighAccuracyTimeSynch(1644240911, 1644240943, 1644240943) }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-
- t.Run("should parse GetLowAccuracyTimeSynch response", func(t *testing.T) {
- // change the return value from 0 as that is default and doesn't
- // prove that xml was parsed correctly
- xmlWithErr := strings.Replace(getLowAccuracyTimeSynchXMLResponse,
- `0`,
- `1`, 1)
- var rsp Response
- err := xml.Unmarshal([]byte(xmlWithErr), &rsp)
- assert.Nil(t, err)
- assert.Equal(t, int64(1704394160), rsp.Body.GetLowAccuracyTimeSynch_OUTPUT.Ta0)
- assert.Equal(t, 1, rsp.Body.GetLowAccuracyTimeSynch_OUTPUT.ReturnValue)
- })
-
- t.Run("should parse SetHighAccuracyTimeSynch response", func(t *testing.T) {
- // change the return value from 0 as that is default and doesn't
- // prove that xml was parsed correctly
- xmlWithErr := strings.Replace(setHighAccuracyTimeSynchXMLResponse,
- `0`,
- `1`, 1)
- var rsp Response
- err := xml.Unmarshal([]byte(xmlWithErr), &rsp)
- assert.Nil(t, err)
- assert.Equal(t, 1, rsp.Body.SetHighAccuracyTimeSynch_OUTPUT.ReturnValue)
- })
-}
-
-const getLowAccuracyTimeSynchXMLResponse = `
-
-
- http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous
- 0
-
- http://intel.com/wbem/wscim/1/amt-schema/1/AMT_TimeSynchronizationService/GetLowAccuracyTimeSynchResponse
-
- uuid:00000000-8086-8086-8086-000000011E1F
- http://intel.com/wbem/wscim/1/amt-schema/1/AMT_TimeSynchronizationService
-
-
-
- 1704394160
- 0
-
-
-`
-
-const setHighAccuracyTimeSynchXMLResponse = `
-
-
-
- http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous
- 9
-
- http://intel.com/wbem/wscim/1/amt-schema/1/AMT_TimeSynchronizationService/SetHighAccuracyTimeSynchResponse
-
- uuid:00000000-8086-8086-8086-000000000061
- http://intel.com/wbem/wscim/1/amt-schema/1/AMT_TimeSynchronizationService
-
-
-
- 0
-
-
-
-`
diff --git a/pkg/amt/tls/credentialcontext.go b/pkg/amt/tls/credentialcontext.go
deleted file mode 100644
index 5d79d5e8..00000000
--- a/pkg/amt/tls/credentialcontext.go
+++ /dev/null
@@ -1,52 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package tls
-
-import (
- "fmt"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
-)
-
-const AMT_TLSCredentialContext = "AMT_TLSCredentialContext"
-
-type CredentialContext struct {
- base message.Base
-}
-
-func NewTLSCredentialContext(wsmanMessageCreator *message.WSManMessageCreator) CredentialContext {
- return CredentialContext{
- base: message.NewBase(wsmanMessageCreator, AMT_TLSCredentialContext),
- }
-}
-
-// Get retrieves the representation of the instance
-func (TLSCredentialContext CredentialContext) Get() string {
- return TLSCredentialContext.base.Get(nil)
-}
-
-// Enumerates the instances of this class
-func (TLSCredentialContext CredentialContext) Enumerate() string {
- return TLSCredentialContext.base.Enumerate()
-}
-
-// Pulls instances of this class, following an Enumerate operation
-func (TLSCredentialContext CredentialContext) Pull(enumerationContext string) string {
- return TLSCredentialContext.base.Pull(enumerationContext)
-}
-
-// Delete removes a the specified instance
-func (TLSCredentialContext CredentialContext) Delete(handle string) string {
- selector := message.Selector{Name: "Name", Value: handle}
- return TLSCredentialContext.base.Delete(selector)
-}
-
-// Creates a new instance of this class
-func (TLSCredentialContext CredentialContext) Create(certHandle string) string {
- header := TLSCredentialContext.base.WSManMessageCreator.CreateHeader(string(message.BaseActionsCreate), AMT_TLSCredentialContext, nil, "", "")
- body := fmt.Sprintf(`/wsman%sAMT_PublicKeyCertificate%s/wsman%sAMT_TLSProtocolEndpointCollectionTLSProtocolEndpointInstances Collection`, TLSCredentialContext.base.WSManMessageCreator.ResourceURIBase, TLSCredentialContext.base.WSManMessageCreator.ResourceURIBase, certHandle, TLSCredentialContext.base.WSManMessageCreator.ResourceURIBase)
- return TLSCredentialContext.base.WSManMessageCreator.CreateXML(header, body)
-}
diff --git a/pkg/amt/tls/credentialcontext_test.go b/pkg/amt/tls/credentialcontext_test.go
deleted file mode 100644
index 5c16fb12..00000000
--- a/pkg/amt/tls/credentialcontext_test.go
+++ /dev/null
@@ -1,53 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package tls
-
-import (
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestAMT_TLSCredentialContext(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewTLSCredentialContext(wsmanMessageCreator)
-
- t.Run("amt_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- extraHeader string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid AMT_TLSCredentialContext Get wsman message", "AMT_TLSCredentialContext", wsmantesting.GET, "", "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid AMT_TLSCredentialContext Enumerate wsman message", "AMT_TLSCredentialContext", wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, "", elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid AMT_TLSCredentialContext Pull wsman message", "AMT_TLSCredentialContext", wsmantesting.PULL, wsmantesting.PULL_BODY, "", func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- //DELETE
- {"should create a valid AMT_TLSCredentialContext Delete wsman message", "AMT_TLSCredentialContext", wsmantesting.DELETE, "", "instanceID123", func() string { return elementUnderTest.Delete("instanceID123") }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, test.extraHeader, test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-}
diff --git a/pkg/amt/tls/settingdata.go b/pkg/amt/tls/settingdata.go
deleted file mode 100644
index 1f7766db..00000000
--- a/pkg/amt/tls/settingdata.go
+++ /dev/null
@@ -1,88 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package tls
-
-import (
- "encoding/xml"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/common"
-)
-
-const AMT_TLSSettingData = "AMT_TLSSettingData"
-
-type (
- Response struct {
- XMLName xml.Name `xml:"Envelope"`
- Header message.Header `xml:"Header"`
- Body Body `xml:"Body"`
- }
- Body struct {
- XMLName xml.Name `xml:"Body"`
- TlsSetting TlsSetting `xml:"AMT_TLSSettingData"`
- EnumerateResponse common.EnumerateResponse
- PullResponse PullResponse
- }
- TlsSetting struct {
- AcceptNonSecureConnections bool
- ElementName string
- Enabled bool
- InstanceID string
- MutualAuthentication bool
- NonSecureConnectionsSupported *bool
- }
- PullResponse struct {
- TlsSettingItems []TlsSetting `xml:"Items>AMT_TLSSettingData"`
- }
-)
-
-// TLSSettingData supports aliased namespace for the PUT call to AMT
-// TLSSettings responses from AMT have different aliases, and the PUT call requires namespace
-// PUT response --
-// PULL response --
-type TLSSettingData struct {
- XMLName xml.Name `xml:"h:AMT_TLSSettingData"`
- H string `xml:"xmlns:h,attr"`
- AcceptNonSecureConnections bool `xml:"h:AcceptNonSecureConnections"`
- ElementName string `xml:"h:ElementName,omitempty"`
- Enabled bool `xml:"h:Enabled"`
- InstanceID string `xml:"h:InstanceID,omitempty"`
- MutualAuthentication bool `xml:"h:MutualAuthentication"`
- TrustedCN string `xml:"h:TrustedCN,omitempty"`
-}
-
-type SettingData struct {
- base message.Base
-}
-
-func NewTLSSettingData(wsmanMessageCreator *message.WSManMessageCreator) SettingData {
- return SettingData{
- base: message.NewBase(wsmanMessageCreator, AMT_TLSSettingData),
- }
-}
-
-// Get retrieves the representation of the instance
-func (TLSSettingData SettingData) Get() string {
- return TLSSettingData.base.Get(nil)
-}
-
-// Enumerate the instances of this class
-func (TLSSettingData SettingData) Enumerate() string {
- return TLSSettingData.base.Enumerate()
-}
-
-// Pull instances of this class, following an Enumerate operation
-func (TLSSettingData SettingData) Pull(enumerationContext string) string {
- return TLSSettingData.base.Pull(enumerationContext)
-}
-
-// Put will change properties of the selected instance
-func (TLSSettingData SettingData) Put(data TLSSettingData) string {
- selector := message.Selector{
- Name: "InstanceID",
- Value: data.InstanceID,
- }
- return TLSSettingData.base.Put(&data, true, &selector)
-}
diff --git a/pkg/amt/tls/settingdata_test.go b/pkg/amt/tls/settingdata_test.go
deleted file mode 100644
index fcfb3f1e..00000000
--- a/pkg/amt/tls/settingdata_test.go
+++ /dev/null
@@ -1,68 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package tls
-
-import (
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestAMT_TLSSettingData(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewTLSSettingData(wsmanMessageCreator)
- data := TLSSettingData{
- ElementName: `Intel(r) AMT LMS TLS Settings`,
- InstanceID: `Intel(r) AMT LMS TLS Settings`,
- AcceptNonSecureConnections: true,
- Enabled: true,
- MutualAuthentication: true,
- }
- expectedPutSelector := `Intel(r) AMT LMS TLS Settings`
- expectedPutBody := `` +
- `true` +
- `Intel(r) AMT LMS TLS Settings` +
- `true` +
- `Intel(r) AMT LMS TLS Settings` +
- `true` +
- ``
-
- t.Run("amt_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- extraHeader string
- body string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid AMT_TLSSettingData Get wsman message", "AMT_TLSSettingData", wsmantesting.GET, "", "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid AMT_TLSSettingData Enumerate wsman message", "AMT_TLSSettingData", wsmantesting.ENUMERATE, "", wsmantesting.ENUMERATE_BODY, elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid AMT_TLSSettingData Pull wsman message", "AMT_TLSSettingData", wsmantesting.PULL, "", wsmantesting.PULL_BODY, func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- //PUT
- {"should create a valid AMT_TLSSettingData Put wsman message", "AMT_TLSSettingData", wsmantesting.PUT, expectedPutSelector, expectedPutBody, func() string { return elementUnderTest.Put(data) }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, test.extraHeader, test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-}
diff --git a/pkg/amt/userinitiatedconnection/service.go b/pkg/amt/userinitiatedconnection/service.go
deleted file mode 100644
index c3960249..00000000
--- a/pkg/amt/userinitiatedconnection/service.go
+++ /dev/null
@@ -1,54 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package userinitiatedconnection
-
-import (
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/actions"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/redirection"
-)
-
-type RequestedState int
-
-const AMT_UserInitiatedConnectionService = "AMT_UserInitiatedConnectionService"
-
-const (
- AllInterfacesDisabled RequestedState = 32768
- BIOSInterfaceEnabled RequestedState = 32769
- OSInterfaceEnabled RequestedState = 32770
- BIOSandOSInterfacesEnabled RequestedState = 32771
-)
-
-type Service struct {
- base message.Base
-}
-
-func NewUserInitiatedConnectionService(wsmanMessageCreator *message.WSManMessageCreator) Service {
- return Service{
- base: message.NewBase(wsmanMessageCreator, AMT_UserInitiatedConnectionService),
- }
-}
-
-// Get retrieves the representation of the instance
-func (UserInitiatedConnectionService Service) Get() string {
- return UserInitiatedConnectionService.base.Get(nil)
-}
-
-// Enumerates the instances of this class
-func (UserInitiatedConnectionService Service) Enumerate() string {
- return UserInitiatedConnectionService.base.Enumerate()
-}
-
-// Pulls instances of this class, following an Enumerate operation
-func (UserInitiatedConnectionService Service) Pull(enumerationContext string) string {
- return UserInitiatedConnectionService.base.Pull(enumerationContext)
-}
-
-// RequestStateChange requests that the state of the element be changed to the value specified in the RequestedState parameter . . .
-func (UserInitiatedConnectionService Service) RequestStateChange(requestedState RequestedState) string {
- return UserInitiatedConnectionService.base.RequestStateChange(actions.RequestStateChange(redirection.AMT_RedirectionService), int(requestedState))
-
-}
diff --git a/pkg/amt/userinitiatedconnection/service_test.go b/pkg/amt/userinitiatedconnection/service_test.go
deleted file mode 100644
index 976e1de5..00000000
--- a/pkg/amt/userinitiatedconnection/service_test.go
+++ /dev/null
@@ -1,50 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package userinitiatedconnection
-
-import (
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestAMT_UserInitiatedConnectionService(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewUserInitiatedConnectionService(wsmanMessageCreator)
-
- t.Run("amt_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid AMT_UserInitiatedConnectionService Get wsman message", "AMT_UserInitiatedConnectionService", wsmantesting.GET, "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid AMT_UserInitiatedConnectionService Enumerate wsman message", "AMT_UserInitiatedConnectionService", wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid AMT_UserInitiatedConnectionService Pull wsman message", "AMT_UserInitiatedConnectionService", wsmantesting.PULL, wsmantesting.PULL_BODY, func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-}
diff --git a/pkg/amt/wifiportconfiguration/service.go b/pkg/amt/wifiportconfiguration/service.go
deleted file mode 100644
index c804b7f6..00000000
--- a/pkg/amt/wifiportconfiguration/service.go
+++ /dev/null
@@ -1,267 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package wifiportconfiguration
-
-import (
- "encoding/xml"
- "strconv"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/actions"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/methods"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/cim/models"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/cim/wifi"
-)
-
-type Response struct {
- XMLName xml.Name `xml:"Envelope"`
- Header message.Header `xml:"Header"`
- Body Body
-}
-
-type Body struct {
- XMLName xml.Name `xml:"Body"`
- WiFiPortConfigurationService WiFiPortConfigurationService
-}
-
-const AMT_WiFiPortConfigurationService = "AMT_WiFiPortConfigurationService"
-
-type WiFiPortConfigurationService struct {
- XMLName xml.Name `xml:"http://intel.com/wbem/wscim/1/amt-schema/1/AMT_WiFiPortConfigurationService AMT_WiFiPortConfigurationService"`
- RequestedState RequestedState
- EnabledState EnabledState
- HealthState HealthState
- ElementName string
- SystemCreationClassName string
- SystemName string
- CreationClassName string
- Name string
- LocalProfileSynchronizationEnabled LocalProfileSynchronizationEnabled `xml:"localProfileSynchronizationEnabled"`
- LastConnectedSsidUnderMeControl string
- NoHostCsmeSoftwarePolicy NoHostCsmeSoftwarePolicy
- UEFIWiFiProfileShareEnabled UEFIWiFiProfileShareEnabled
-}
-
-type RequestedState int
-
-const (
- RequestedStateUnknown RequestedState = 0
- RequestedStateEnabled RequestedState = 2
- RequestedStateDisabled RequestedState = 3
- RequestedStateShutDown RequestedState = 4
- RequestedStateNoChange RequestedState = 5
- RequestedStateOffline RequestedState = 6
- RequestedStateTest RequestedState = 7
- RequestedStateDeferred RequestedState = 8
- RequestedStateQuiesce RequestedState = 9
- RequestedStateReboot RequestedState = 10
- RequestedStateReset RequestedState = 11
- RequestedStateNotApplicable RequestedState = 12
-)
-
-type EnabledState int
-
-const (
- EnabledStateUnknown EnabledState = iota
- EnabledStateOther
- EnabledStateEnabled
- EnabledStateDisabled
- EnabledStateShuttingDown
- EnabledStateNotApplicable
- EnabledStateEnabledButOffline
- EnabledStateInTest
- EnabledStateDeferred
- EnabledStateQuiesce
- EnabledStateStarting
-)
-
-type HealthState int
-
-const (
- Unknown HealthState = 0
- OK HealthState = 5
- DegradedWarning HealthState = 10
- MinorFailure HealthState = 15
- MajorFailure HealthState = 20
- CriticalFailure HealthState = 25
- NonRecoverableError HealthState = 30
-)
-
-type LocalProfileSynchronizationEnabled int
-
-const (
- LocalSyncDisabled LocalProfileSynchronizationEnabled = 0
- UnrestrictedSync LocalProfileSynchronizationEnabled = 3
-)
-
-type NoHostCsmeSoftwarePolicy int
-
-const (
- RelaxedPolicy NoHostCsmeSoftwarePolicy = iota
- AggressivePolicy
- Reserved
-)
-
-type UEFIWiFiProfileShareEnabled int
-
-func (t *UEFIWiFiProfileShareEnabled) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
- var strVal string
- err := d.DecodeElement(&strVal, &start)
- if err != nil {
- return err
- }
- enabled, _ := strconv.ParseBool(strVal)
- if enabled {
- //*t = true
- *t = (UEFIWiFiProfileShareEnabled)(1)
- } else {
- //*t = false
- *t = (UEFIWiFiProfileShareEnabled)(0)
- }
- return nil
-}
-
-const (
- Disabled UEFIWiFiProfileShareEnabled = iota
- Enabled
-)
-
-type Service struct {
- base message.Base
-}
-type AddWiFiSettings_INPUT struct {
- XMLName xml.Name `xml:"h:AddWiFiSettings_INPUT"`
- H string `xml:"xmlns:h,attr"`
- WifiEndpoint WiFiEndpoint
- WiFiEndpointSettings models.WiFiEndpointSettings
- IEEE8021xSettings *models.IEEE8021xSettings `xml:"h:IEEE8021xSettingsInput,omitempty"`
- ClientCredential *ClientCredential `xml:"h:ClientCredential,omitempty"`
- CACredential *CACredential `xml:"h:CACredential,omitempty"`
-}
-type WiFiEndpoint struct {
- XMLName xml.Name `xml:"h:WiFiEndpoint,omitempty"`
- Address string `xml:"a:Address,omitempty"`
- ReferenceParameters models.ReferenceParameters `xml:"a:ReferenceParameters,omitempty"`
-}
-type CACredential struct {
- XMLName xml.Name `xml:"h:CACredential,omitempty"`
- Address string `xml:"a:Address,omitempty"`
- ReferenceParameters models.ReferenceParameters `xml:"a:ReferenceParameters,omitempty"`
-}
-type ClientCredential struct {
- XMLName xml.Name `xml:"h:ClientCredential,omitempty"`
- Address string `xml:"a:Address,omitempty"`
- ReferenceParameters models.ReferenceParameters `xml:"a:ReferenceParameters,omitempty"`
-}
-
-func NewWiFiPortConfigurationService(wsmanMessageCreator *message.WSManMessageCreator) Service {
- return Service{
- base: message.NewBase(wsmanMessageCreator, AMT_WiFiPortConfigurationService),
- }
-}
-
-// Get retrieves the representation of the instance
-func (s Service) Get() string {
- return s.base.Get(nil)
-}
-
-// Enumerates the instances of this class
-func (s Service) Enumerate() string {
- return s.base.Enumerate()
-}
-
-// Pulls instances of this class, following an Enumerate operation
-func (s Service) Pull(enumerationContext string) string {
- return s.base.Pull(enumerationContext)
-}
-
-// Put will change properties of the selected instance
-func (s Service) Put(wiFiPortConfigurationService WiFiPortConfigurationService) string {
- //wiFiPortConfigurationService.XMLSchema = "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_WiFiPortConfigurationService"
- return s.base.Put(wiFiPortConfigurationService, false, nil)
-}
-
-// AddWiFiSettings atomically creates instances and associates them based on the input parameters.
-func (s Service) AddWiFiSettings(wifiEndpointSettings models.WiFiEndpointSettings, ieee8021xSettingsInput *models.IEEE8021xSettings, wifiEndpoint, clientCredential, caCredential string) string {
- header := s.base.WSManMessageCreator.CreateHeader(string(actions.AddWiFiSettings), AMT_WiFiPortConfigurationService, nil, "", "")
-
- input := AddWiFiSettings_INPUT{
- WifiEndpoint: WiFiEndpoint{
- Address: "/wsman",
- ReferenceParameters: models.ReferenceParameters{
- ResourceURI: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/" + wifi.CIM_WiFiEndpoint,
- SelectorSet: models.SelectorSet{
- Selector: []message.Selector{
- {
- Name: "Name",
- Value: wifiEndpoint,
- },
- },
- },
- },
- },
- WiFiEndpointSettings: wifiEndpointSettings,
- }
- input.WiFiEndpointSettings.H = "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_WiFiEndpointSettings"
- if ieee8021xSettingsInput != nil {
- input.IEEE8021xSettings = ieee8021xSettingsInput
- input.IEEE8021xSettings.H = "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_IEEE8021xSettings"
- input.CACredential = &CACredential{
- Address: "default",
- ReferenceParameters: models.ReferenceParameters{
- ResourceURI: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyCertificate",
- SelectorSet: models.SelectorSet{
- Selector: []message.Selector{
- {
- Name: "InstanceID",
- Value: caCredential,
- },
- },
- },
- },
- }
- if clientCredential != "" {
- input.ClientCredential = &ClientCredential{
- Address: "default",
- ReferenceParameters: models.ReferenceParameters{
- ResourceURI: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyCertificate",
- SelectorSet: models.SelectorSet{
- Selector: []message.Selector{
- {
- Name: "InstanceID",
- Value: clientCredential,
- },
- },
- },
- },
- }
- }
- }
-
- body := s.base.WSManMessageCreator.CreateBody(string(methods.AddWiFiSettings)+"_INPUT", AMT_WiFiPortConfigurationService, &input)
- return s.base.WSManMessageCreator.CreateXML(header, body)
-}
-
-type AddWiFiSettingsResponse struct {
- XMLName xml.Name `xml:"Envelope"`
- Header message.Header
- Body AddWiFiSettingsBody
-}
-
-type AddWiFiSettingsBody struct {
- XMLName xml.Name `xml:"Body"`
- AddWiFiSettings_OUTPUT AddWiFiSettings_OUTPUT
-}
-
-type AddWiFiSettings_OUTPUT struct {
- XMLName xml.Name `xml:"http://intel.com/wbem/wscim/1/amt-schema/1/AMT_WiFiPortConfigurationService AddWiFiSettings_OUTPUT"`
- WiFiEndpointSettings models.WiFiEndpointSettings
- // not concerned with these entries on OUTPUT
- //IEEE8021xSettings *models.IEEE8021xSettings `xml:"g:IEEE8021xSettingsInput,omitempty"`
- //ClientCredential *ClientCredential `xml:"g:ClientCredential,omitempty"`
- //CACredential *CACredential `xml:"g:CACredential,omitempty"`
- ReturnValue int
-}
diff --git a/pkg/amt/wifiportconfiguration/service_test.go b/pkg/amt/wifiportconfiguration/service_test.go
deleted file mode 100644
index 811ed9bf..00000000
--- a/pkg/amt/wifiportconfiguration/service_test.go
+++ /dev/null
@@ -1,167 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package wifiportconfiguration
-
-import (
- "encoding/xml"
- "regexp"
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/cim/models"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestAMT_WiFiPortConfigurationService(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewWiFiPortConfigurationService(wsmanMessageCreator)
- wiFiPortConfigurationService := WiFiPortConfigurationService{}
- expectedPutBodyXml, err := xml.Marshal(wiFiPortConfigurationService)
- assert.Nil(t, err)
-
- t.Run("amt_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid AMT_WiFiPortConfigurationService Get wsman message", AMT_WiFiPortConfigurationService, wsmantesting.GET, "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid AMT_WiFiPortConfigurationService Enumerate wsman message", AMT_WiFiPortConfigurationService, wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid AMT_WiFiPortConfigurationService Pull wsman message", AMT_WiFiPortConfigurationService, wsmantesting.PULL, wsmantesting.PULL_BODY, func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- // PUTS
- {"should create a valid AMT_WiFiPortConfigurationService Put wsman message", AMT_WiFiPortConfigurationService, wsmantesting.PUT, string(expectedPutBodyXml), func() string { return elementUnderTest.Put(wiFiPortConfigurationService) }},
- // WIFI PORT CONFIGURATION SERVICE
- {"should return a valid amt_WiFiPortConfigurationService ADD_WIFI_SETTINGS wsman message", AMT_WiFiPortConfigurationService, `http://intel.com/wbem/wscim/1/amt-schema/1/AMT_WiFiPortConfigurationService/AddWiFiSettings`, `/wsmanhttp://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_WiFiEndpointWiFi Endpoint 0homeIntel(r) AMT:WiFi Endpoint Settings home64admin1p'ass<>&"code`, func() string {
- wifiEndpointSettings := models.WiFiEndpointSettings{
- H: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_WiFiEndpointSettings", //todo: make more dynamic
- ElementName: "home",
- InstanceID: "Intel(r) AMT:WiFi Endpoint Settings home",
- AuthenticationMethod: 6,
- EncryptionMethod: 4,
- SSID: "admin",
- Priority: 1,
- PSKPassPhrase: "p'ass<>&\"code",
- }
- return elementUnderTest.AddWiFiSettings(wifiEndpointSettings, nil, "WiFi Endpoint 0", "", "")
- }},
- {"should create a valid AMT_WiFiPortConfigurationService ADD_WIFI_SETTINGS 8021x wsman message", "AMT_WiFiPortConfigurationService", `http://intel.com/wbem/wscim/1/amt-schema/1/AMT_WiFiPortConfigurationService/AddWiFiSettings`, `/wsmanhttp://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_WiFiEndpointWiFi Endpoint 0homeIntel(r) AMT:WiFi Endpoint Settings home64admin1p'ass<>&"codewifi_8021x_profile0defaulthttp://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyCertificatehandle 0defaulthttp://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyCertificatehandle 1`, func() string {
- wifiEndpointSettings := models.WiFiEndpointSettings{
- H: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_WiFiEndpointSettings",
- ElementName: "home",
- InstanceID: "Intel(r) AMT:WiFi Endpoint Settings home",
- AuthenticationMethod: 6,
- EncryptionMethod: 4,
- SSID: "admin",
- Priority: 1,
- PSKPassPhrase: "p'ass<>&\"code",
- }
- ieee8021xSettingsInput := &models.IEEE8021xSettings{
- H: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_IEEE8021xSettings",
- ElementName: "wifi_8021x_profile",
- AuthenticationProtocol: 0,
- }
- clientCredential := "handle 0"
- caCredential := "handle 1"
- return elementUnderTest.AddWiFiSettings(wifiEndpointSettings, ieee8021xSettingsInput, "WiFi Endpoint 0", clientCredential, caCredential)
- }},
- {"should create a valid AMT_WiFiPortConfigurationService ADD_WIFI_SETTINGS 8021x wsman message", "AMT_WiFiPortConfigurationService", `http://intel.com/wbem/wscim/1/amt-schema/1/AMT_WiFiPortConfigurationService/AddWiFiSettings`, `/wsmanhttp://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_WiFiEndpointWiFi Endpoint 0homeIntel(r) AMT:WiFi Endpoint Settings home64admin1p'ass<>&"codewifi_8021x_profile2defaulthttp://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyCertificatehandle 1`, func() string {
- wifiEndpointSettings := models.WiFiEndpointSettings{
- H: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_WiFiEndpointSettings",
- ElementName: "home",
- InstanceID: "Intel(r) AMT:WiFi Endpoint Settings home",
- AuthenticationMethod: 6,
- EncryptionMethod: 4,
- SSID: "admin",
- Priority: 1,
- PSKPassPhrase: "p'ass<>&\"code",
- }
- ieee8021xSettingsInput := &models.IEEE8021xSettings{
- H: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_IEEE8021xSettings",
- ElementName: "wifi_8021x_profile",
- AuthenticationProtocol: 2,
- }
- clientCredential := ""
- caCredential := "handle 1"
- return elementUnderTest.AddWiFiSettings(wifiEndpointSettings, ieee8021xSettingsInput, "WiFi Endpoint 0", clientCredential, caCredential)
- }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-
- t.Run("unmarshall UEFIWiFiProfileShareEnabled for Disabled - 0", func(t *testing.T) {
- original := Response{}
- originalXML, err := xml.Marshal(original)
- assert.Nil(t, err)
- var received Response
- err = xml.Unmarshal(originalXML, &received)
- assert.Nil(t, err)
- assert.Equal(t,
- Disabled,
- received.Body.WiFiPortConfigurationService.UEFIWiFiProfileShareEnabled)
- })
-
- t.Run("unmarshall UEFIWiFiProfileShareEnabled for Enabled - 1", func(t *testing.T) {
- original := Response{}
- original.Body.WiFiPortConfigurationService.UEFIWiFiProfileShareEnabled = Enabled
- originalXML, err := xml.Marshal(original)
- assert.Nil(t, err)
- var received Response
- err = xml.Unmarshal(originalXML, &received)
- assert.Nil(t, err)
- assert.Equal(t,
- Enabled,
- received.Body.WiFiPortConfigurationService.UEFIWiFiProfileShareEnabled)
- })
-
- t.Run("unmarshall UEFIWiFiProfileShareEnabled for Disabled - false", func(t *testing.T) {
- original := Response{}
- originalXML, err := xml.Marshal(original)
- assert.Nil(t, err)
- re := regexp.MustCompile(`0`)
- originalXML = []byte(re.ReplaceAllString(string(originalXML), `false`))
- var received Response
- err = xml.Unmarshal(originalXML, &received)
- assert.Nil(t, err)
- assert.Equal(t,
- Disabled,
- received.Body.WiFiPortConfigurationService.UEFIWiFiProfileShareEnabled)
- })
-
- t.Run("unmarshall UEFIWiFiProfileShareEnabled for Enabled - true", func(t *testing.T) {
- original := Response{}
- original.Body.WiFiPortConfigurationService.UEFIWiFiProfileShareEnabled = Enabled
- originalXML, err := xml.Marshal(original)
- assert.Nil(t, err)
- re := regexp.MustCompile(`1`)
- originalXML = []byte(re.ReplaceAllString(string(originalXML), `true`))
- var received Response
- err = xml.Unmarshal(originalXML, &received)
- assert.Nil(t, err)
- assert.Equal(t,
- Enabled,
- received.Body.WiFiPortConfigurationService.UEFIWiFiProfileShareEnabled)
- })
-
-}
diff --git a/pkg/apf/processor.go b/pkg/apf/processor.go
new file mode 100644
index 00000000..d684dec1
--- /dev/null
+++ b/pkg/apf/processor.go
@@ -0,0 +1,370 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2022
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+package apf
+
+import (
+ "bytes"
+ "encoding/binary"
+ "errors"
+ "fmt"
+ "time"
+
+ log "github.com/sirupsen/logrus"
+)
+
+func Process(data []byte, session *Session) bytes.Buffer {
+ var bin_buf bytes.Buffer
+ var dataToSend interface{}
+ switch data[0] {
+ case APF_GLOBAL_REQUEST: // 80
+ log.Debug("received APF_GLOBAL_REQUEST")
+ dataToSend = ProcessGlobalRequest(data)
+ case APF_CHANNEL_OPEN: // (90) Sent by Intel AMT when a channel needs to be open from Intel AMT. This is not common, but WSMAN events are a good example of channel coming from AMT.
+ log.Debug("received APF_CHANNEL_OPEN")
+ case APF_DISCONNECT: // (1) Intel AMT wants to completely disconnect. Not sure when this happens.
+ log.Debug("received APF_DISCONNECT")
+ case APF_SERVICE_REQUEST: // (5)
+ log.Debug("received APF SERVICE REQUEST")
+ dataToSend = ProcessServiceRequest(data)
+ case APF_CHANNEL_OPEN_CONFIRMATION: // (91) Intel AMT confirmation to an APF_CHANNEL_OPEN request.
+ log.Debug("received APF_CHANNEL_OPEN_CONFIRMATION")
+ ProcessChannelOpenConfirmation(data, session)
+ case APF_CHANNEL_OPEN_FAILURE: // (92) Intel AMT rejected our connection attempt.
+ log.Debug("received APF_CHANNEL_OPEN_FAILURE")
+ ProcessChannelOpenFailure(data, session)
+ case APF_CHANNEL_CLOSE: // (97) Intel AMT is closing this channel, we need to disconnect the LMS TCP connection
+ log.Debug("received APF_CHANNEL_CLOSE")
+ ProcessChannelClose(data, session)
+ case APF_CHANNEL_DATA: // (94) Intel AMT is sending data that we must relay into an LMS TCP connection.
+ ProcessChannelData(data, session)
+ case APF_CHANNEL_WINDOW_ADJUST: // 93
+ log.Debug("received APF_CHANNEL_WINDOW_ADJUST")
+ ProcessChannelWindowAdjust(data, session)
+ case APF_PROTOCOLVERSION: // 192
+ log.Debug("received APF PROTOCOL VERSION")
+ dataToSend = ProcessProtocolVersion(data)
+ case APF_USERAUTH_REQUEST: // 50
+ default:
+ }
+ if dataToSend != nil {
+ err := binary.Write(&bin_buf, binary.BigEndian, dataToSend)
+ if err != nil {
+ log.Error(err)
+ }
+ }
+ return bin_buf
+}
+
+func ProcessChannelWindowAdjust(data []byte, session *Session) {
+ adjustMessage := APF_CHANNEL_WINDOW_ADJUST_MESSAGE{}
+ dataBuffer := bytes.NewBuffer(data)
+ err := binary.Read(dataBuffer, binary.BigEndian, &adjustMessage)
+ if err != nil {
+ log.Error(err)
+ }
+ session.TXWindow += adjustMessage.BytesToAdd
+ log.Tracef("%+v", adjustMessage)
+}
+func ProcessChannelClose(data []byte, session *Session) APF_CHANNEL_CLOSE_MESSAGE {
+ closeMessage := APF_CHANNEL_CLOSE_MESSAGE{}
+ dataBuffer := bytes.NewBuffer(data)
+ err := binary.Read(dataBuffer, binary.BigEndian, &closeMessage)
+ if err != nil {
+ log.Error(err)
+ }
+ log.Tracef("%+v", closeMessage)
+ // session.DataBuffer <- session.Tempdata
+ // session.Tempdata = []byte{}
+ close := ChannelClose(closeMessage.RecipientChannel)
+ return close
+}
+func ProcessGlobalRequest(data []byte) interface{} {
+ genericHeader := APF_GENERIC_HEADER{}
+ dataBuffer := bytes.NewBuffer(data)
+
+ err := binary.Read(dataBuffer, binary.BigEndian, &genericHeader.MessageType)
+ if err != nil {
+ log.Error(err)
+ }
+ err = binary.Read(dataBuffer, binary.BigEndian, &genericHeader.StringLength)
+ if err != nil {
+ log.Error(err)
+ }
+
+ var reply interface{}
+ if int(genericHeader.StringLength) > 0 {
+ stringBuffer := make([]byte, genericHeader.StringLength)
+ tcpForwardRequest := APF_TCP_FORWARD_REQUEST{}
+
+ err = binary.Read(dataBuffer, binary.BigEndian, &stringBuffer)
+ if err != nil {
+ log.Error(err)
+ }
+ genericHeader.String = string(stringBuffer[:int(genericHeader.StringLength)])
+ err = binary.Read(dataBuffer, binary.BigEndian, &tcpForwardRequest.WantReply)
+ if err != nil {
+ log.Error(err)
+ }
+ err = binary.Read(dataBuffer, binary.BigEndian, &tcpForwardRequest.AddressLength)
+ if err != nil {
+ log.Error(err)
+ }
+ if int(tcpForwardRequest.AddressLength) > 0 {
+ addressBuffer := make([]byte, tcpForwardRequest.AddressLength)
+ err = binary.Read(dataBuffer, binary.BigEndian, &addressBuffer)
+ if err != nil {
+ log.Error(err)
+ }
+ tcpForwardRequest.Address = string(addressBuffer[:int(tcpForwardRequest.AddressLength)])
+ }
+ err = binary.Read(dataBuffer, binary.BigEndian, &tcpForwardRequest.Port)
+ if err != nil {
+ log.Error(err)
+ }
+ log.Tracef("%+v", genericHeader)
+ log.Tracef("%+v", tcpForwardRequest)
+
+ if genericHeader.String == APF_GLOBAL_REQUEST_STR_TCP_FORWARD_REQUEST {
+ if tcpForwardRequest.Port == 16992 || tcpForwardRequest.Port == 16993 {
+ reply = TcpForwardReplySuccess(tcpForwardRequest.Port)
+ } else {
+ reply = APF_REQUEST_FAILURE
+ }
+ } else if genericHeader.String == APF_GLOBAL_REQUEST_STR_TCP_FORWARD_CANCEL_REQUEST {
+ reply = APF_REQUEST_SUCCESS
+ }
+ }
+ return reply
+}
+func ProcessChannelData(data []byte, session *Session) {
+ channelData := APF_CHANNEL_DATA_MESSAGE{}
+ buf2 := bytes.NewBuffer(data)
+
+ err := binary.Read(buf2, binary.BigEndian, &channelData.MessageType)
+ if err != nil {
+ log.Error(err)
+ }
+ err = binary.Read(buf2, binary.BigEndian, &channelData.RecipientChannel)
+ if err != nil {
+ log.Error(err)
+ }
+ err = binary.Read(buf2, binary.BigEndian, &channelData.DataLength)
+ if err != nil {
+ log.Error(err)
+ }
+ session.RXWindow = channelData.DataLength
+ dataBuffer := make([]byte, channelData.DataLength)
+ err = binary.Read(buf2, binary.BigEndian, &dataBuffer)
+ if err != nil {
+ log.Error(err)
+ }
+ //log.Debug("received APF_CHANNEL_DATA - " + fmt.Sprint(channelData.DataLength))
+ //log.Tracef("%+v", channelData)
+
+ session.Tempdata = append(session.Tempdata, dataBuffer[:channelData.DataLength]...)
+ // var windowAdjust APF_CHANNEL_WINDOW_ADJUST_MESSAGE
+ // if session.RXWindow > 1024 { // TODO: Check this
+ // windowAdjust = ChannelWindowAdjust(channelData.RecipientChannel, session.RXWindow)
+ // session.RXWindow = 0
+ // }
+ session.Timer.Reset(3 * time.Second)
+ // var windowAdjust APF_CHANNEL_WINDOW_ADJUST_MESSAGE
+ // if session.RXWindow > 1024 { // TODO: Check this
+ // windowAdjust = ChannelWindowAdjust(channelData.RecipientChannel, session.RXWindow)
+ // session.RXWindow = 0
+ // }
+ // // log.Tracef("%+v", session)
+ // return windowAdjust
+ //return windowAdjust
+}
+func ProcessServiceRequest(data []byte) APF_SERVICE_ACCEPT_MESSAGE {
+ service := 0
+ message := APF_SERVICE_REQUEST_MESSAGE{}
+ dataBuffer := bytes.NewBuffer(data)
+ err := binary.Read(dataBuffer, binary.BigEndian, &message.MessageType)
+ if err != nil {
+ log.Error(err)
+ }
+ err = binary.Read(dataBuffer, binary.BigEndian, &message.ServiceNameLength)
+ if err != nil {
+ log.Error(err)
+ }
+
+ if int(message.ServiceNameLength) > 0 {
+ serviceNameBuffer := make([]byte, message.ServiceNameLength)
+ err = binary.Read(dataBuffer, binary.BigEndian, &serviceNameBuffer)
+ if err != nil {
+ log.Error(err)
+ }
+ message.ServiceName = string(serviceNameBuffer[:int(message.ServiceNameLength)])
+ }
+ log.Tracef("%+v", message)
+
+ if message.ServiceNameLength == 18 {
+ if message.ServiceName == "pfwd@amt.intel.com" {
+ service = 1
+ } else if message.ServiceName == "auth@amt.intel.com" {
+ service = 2
+ }
+ }
+ var serviceAccept APF_SERVICE_ACCEPT_MESSAGE
+ if service > 0 {
+ serviceAccept = ServiceAccept(message.ServiceName)
+ }
+ return serviceAccept
+}
+func ProcessChannelOpenConfirmation(data []byte, session *Session) {
+ confirmationMessage := APF_CHANNEL_OPEN_CONFIRMATION_MESSAGE{}
+ dataBuffer := bytes.NewBuffer(data)
+ err := binary.Read(dataBuffer, binary.BigEndian, &confirmationMessage)
+ if err != nil {
+ log.Error(err)
+ }
+ log.Tracef("%+v", confirmationMessage)
+ // replySuccess := ChannelOpenReplySuccess(confirmationMessage.RecipientChannel, confirmationMessage.SenderChannel)
+
+ log.Trace("our channel: "+fmt.Sprint(confirmationMessage.RecipientChannel), " AMT's channel: "+fmt.Sprint(confirmationMessage.SenderChannel))
+ log.Trace("initial window: " + fmt.Sprint(confirmationMessage.InitialWindowSize))
+ session.SenderChannel = confirmationMessage.SenderChannel
+ session.RecipientChannel = confirmationMessage.RecipientChannel
+ session.TXWindow = confirmationMessage.InitialWindowSize
+ session.Status <- true
+}
+func ProcessChannelOpenFailure(data []byte, session *Session) {
+ channelOpenFailure := APF_CHANNEL_OPEN_FAILURE_MESSAGE{}
+ dataBuffer := bytes.NewBuffer(data)
+ err := binary.Read(dataBuffer, binary.BigEndian, &channelOpenFailure)
+ if err != nil {
+ log.Error(err)
+ }
+ log.Tracef("%+v", channelOpenFailure)
+ session.Status <- false
+ session.ErrorBuffer <- errors.New("error opening APF channel, reason code: " + fmt.Sprint(channelOpenFailure.ReasonCode))
+}
+func ProcessProtocolVersion(data []byte) APF_PROTOCOL_VERSION_MESSAGE {
+ message := APF_PROTOCOL_VERSION_MESSAGE{}
+ dataBuffer := bytes.NewBuffer(data)
+ err := binary.Read(dataBuffer, binary.BigEndian, &message)
+ if err != nil {
+ log.Error(err)
+ }
+ log.Tracef("%+v", message)
+ version := ProtocolVersion(message.MajorVersion, message.MinorVersion, message.TriggerReason)
+ return version
+}
+
+// Send the AFP service accept message to the MEI
+func ServiceAccept(serviceName string) APF_SERVICE_ACCEPT_MESSAGE {
+ log.Debug("sending APF_SERVICE_ACCEPT_MESSAGE")
+ var test [18]byte
+ copy(test[:], []byte(serviceName)[:18])
+ serviceAcceptMessage := APF_SERVICE_ACCEPT_MESSAGE{
+ MessageType: APF_SERVICE_ACCEPT,
+ ServiceNameLength: 18,
+ ServiceName: test,
+ }
+ log.Tracef("%+v", serviceAcceptMessage)
+ return serviceAcceptMessage
+}
+
+func ProtocolVersion(majorversion uint32, minorversion uint32, triggerreason uint32) APF_PROTOCOL_VERSION_MESSAGE {
+ log.Debug("sending APF_PROTOCOL_VERSION_MESSAGE")
+ protVersion := APF_PROTOCOL_VERSION_MESSAGE{}
+ protVersion.MessageType = APF_PROTOCOLVERSION
+ protVersion.MajorVersion = majorversion
+ protVersion.MinorVersion = minorversion
+ protVersion.TriggerReason = triggerreason
+ log.Tracef("%+v", protVersion)
+ return protVersion
+}
+
+func TcpForwardReplySuccess(port uint32) APF_TCP_FORWARD_REPLY_MESSAGE {
+ log.Debug("sending APF_TCP_FORWARD_REPLY_MESSAGE")
+ message := APF_TCP_FORWARD_REPLY_MESSAGE{
+ MessageType: APF_REQUEST_SUCCESS,
+ PortBound: port,
+ }
+ log.Tracef("%+v", message)
+ return message
+}
+
+func ChannelOpen(senderChannel int) bytes.Buffer {
+ var channelType [15]byte
+ copy(channelType[:], []byte(APF_OPEN_CHANNEL_REQUEST_FORWARDED)[:15])
+ var address [3]byte
+ copy(address[:], []byte("::1")[:3])
+ openMessage := APF_CHANNEL_OPEN_MESSAGE{
+ MessageType: APF_CHANNEL_OPEN,
+ ChannelTypeLength: 15,
+ ChannelType: channelType,
+ SenderChannel: uint32(senderChannel), //hmm
+ Reserved: 0xFFFFFFFF,
+ InitialWindowSize: LME_RX_WINDOW_SIZE,
+ ConnectedAddressLength: 3,
+ ConnectedAddress: address,
+ ConnectedPort: 16992,
+ OriginatorIPAddressLength: 3,
+ OriginatorIPAddress: address,
+ OriginatorPort: 123,
+ }
+ log.Tracef("%+v", openMessage)
+ var bin_buf bytes.Buffer
+ err := binary.Write(&bin_buf, binary.BigEndian, openMessage)
+ if err != nil {
+ log.Error(err)
+ }
+ return bin_buf
+}
+
+func ChannelOpenReplySuccess(recipientChannel uint32, senderChannel uint32) APF_CHANNEL_OPEN_CONFIRMATION_MESSAGE {
+ log.Debug("sending APF_CHANNEL_OPEN_CONFIRMATION")
+ message := APF_CHANNEL_OPEN_CONFIRMATION_MESSAGE{}
+ message.MessageType = APF_CHANNEL_OPEN_CONFIRMATION
+ message.RecipientChannel = recipientChannel
+ message.SenderChannel = senderChannel
+ message.InitialWindowSize = LME_RX_WINDOW_SIZE
+ message.Reserved = 0xFFFFFFFF
+ log.Tracef("%+v", message)
+ return message
+}
+
+func ChannelOpenReplyFailure(recipientChannel uint32, reason uint32) APF_CHANNEL_OPEN_FAILURE_MESSAGE {
+ log.Debug("sending APF_CHANNEL_OPEN_FAILURE")
+
+ message := APF_CHANNEL_OPEN_FAILURE_MESSAGE{}
+ message.MessageType = APF_CHANNEL_OPEN_FAILURE
+ message.RecipientChannel = recipientChannel
+ message.ReasonCode = reason
+ message.Reserved = 0x00000000
+ message.Reserved2 = 0x00000000
+ return message
+}
+
+func ChannelClose(recipientChannel uint32) APF_CHANNEL_CLOSE_MESSAGE {
+ log.Debug("sending APF_CHANNEL_CLOSE_MESSAGE")
+ message := APF_CHANNEL_CLOSE_MESSAGE{}
+ message.MessageType = APF_CHANNEL_CLOSE
+ message.RecipientChannel = recipientChannel
+ return message
+}
+
+func ChannelData(recipientChannel uint32, buffer []byte) APF_CHANNEL_DATA_MESSAGE {
+ log.Debug("sending APF_CHANNEL_DATA_MESSAGE")
+ message := APF_CHANNEL_DATA_MESSAGE{}
+ message.MessageType = APF_CHANNEL_DATA
+ message.RecipientChannel = recipientChannel
+ message.DataLength = uint32(len(buffer))
+ message.Data = buffer
+ return message
+}
+
+func ChannelWindowAdjust(recipientChannel uint32, len uint32) APF_CHANNEL_WINDOW_ADJUST_MESSAGE {
+ log.Debug("sending APF_CHANNEL_WINDOW_ADJUST_MESSAGE")
+ message := APF_CHANNEL_WINDOW_ADJUST_MESSAGE{}
+ message.MessageType = APF_CHANNEL_WINDOW_ADJUST
+ message.RecipientChannel = recipientChannel
+ message.BytesToAdd = len
+ return message
+}
diff --git a/pkg/apf/processor_test.go b/pkg/apf/processor_test.go
new file mode 100644
index 00000000..0159d6ec
--- /dev/null
+++ b/pkg/apf/processor_test.go
@@ -0,0 +1,155 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2022
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+package apf
+
+import (
+ "testing"
+ "time"
+
+ "github.com/stretchr/testify/assert"
+)
+
+func TestProcess(t *testing.T) {
+ data := []byte{0x01}
+
+ session := &Session{}
+
+ result := Process(data, session)
+ assert.NotNil(t, result)
+}
+func TestProcessChannelOpenFailure(t *testing.T) {
+ data := []byte{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
+ errorChannel := make(chan error)
+ statusChannel := make(chan bool)
+
+ session := &Session{
+ ErrorBuffer: errorChannel,
+ Status: statusChannel,
+ }
+ defer close(errorChannel)
+ go func() {
+ status := <-statusChannel
+ err := <-errorChannel
+ assert.Error(t, err)
+ assert.False(t, status)
+ }()
+ ProcessChannelOpenFailure(data, session)
+}
+func TestProcessChannelWindowAdjust(t *testing.T) {
+ data := []byte{0x01}
+ session := &Session{}
+ ProcessChannelWindowAdjust(data, session)
+}
+func TestProcessChannelClose(t *testing.T) {
+ data := []byte{0x01}
+ session := &Session{}
+ result := ProcessChannelClose(data, session)
+ assert.NotNil(t, result)
+}
+func TestProcessGlobalRequest(t *testing.T) {
+ data := []byte{0x01,
+ 0x00, 0x00, 0x00, 0x0D,
+ 0x74, 0x63, 0x70, 0x69, 0x70, 0x2d, 0x66, 0x6f, 0x72, 0x77, 0x61, 0x72, 0x64,
+ 0x00,
+ 0x00, 0x00, 0x00, 0x03,
+ 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x42, 0x60}
+
+ result := ProcessGlobalRequest(data)
+ assert.NotNil(t, result)
+}
+func TestProcessChannelData(t *testing.T) {
+ data := []byte{0x01,
+ 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x01,
+ }
+ timer := time.NewTimer(time.Duration(2 * time.Second))
+ session := &Session{
+ Timer: timer,
+ }
+ go func() {
+ <-timer.C
+ }()
+ ProcessChannelData(data, session)
+
+}
+func TestProcessServiceRequestWhenAUTH(t *testing.T) {
+ data := []byte{0x01, 0x00, 0x00, 0x00, 0x12, 0x61, 0x75, 0x74, 0x68, 0x40, 0x61, 0x6d, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x6c, 0x2e, 0x63, 0x6f, 0x6d}
+ hi := int(0x12)
+ println(hi)
+ result := ProcessServiceRequest(data)
+ assert.NotNil(t, result)
+ assert.Equal(t, uint8(0x6), result.MessageType) // APF_SERVICE_ACCEPT
+ assert.Equal(t, uint32(0x12), result.ServiceNameLength)
+ assert.Equal(t, [18]uint8{0x61, 0x75, 0x74, 0x68, 0x40, 0x61, 0x6d, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x6c, 0x2e, 0x63, 0x6f, 0x6d}, result.ServiceName)
+}
+
+func TestProcessServiceRequestWhenPWFD(t *testing.T) {
+ data := []byte{0x01, 0x00, 0x00, 0x00, 0x12, 0x70, 0x66, 0x77, 0x64, 0x40, 0x61, 0x6d, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x6c, 0x2e, 0x63, 0x6f, 0x6d}
+ hi := int(0x12)
+ println(hi)
+ result := ProcessServiceRequest(data)
+ assert.NotNil(t, result)
+ assert.Equal(t, uint8(0x6), result.MessageType) // APF_SERVICE_ACCEPT
+ assert.Equal(t, uint32(0x12), result.ServiceNameLength)
+ assert.Equal(t, [18]uint8{0x70, 0x66, 0x77, 0x64, 0x40, 0x61, 0x6d, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x6c, 0x2e, 0x63, 0x6f, 0x6d}, result.ServiceName)
+}
+func TestProcessChannelOpenConfirmation(t *testing.T) {
+ data := []byte{0x01}
+ statusChannel := make(chan bool)
+ session := &Session{
+ Status: statusChannel,
+ }
+ defer close(statusChannel)
+ go func() {
+ <-statusChannel
+ println("Hello, status is done")
+ }()
+ ProcessChannelOpenConfirmation(data, session)
+}
+func TestProcessProtocolVersion(t *testing.T) {
+ data := []byte{0x01}
+ result := ProcessProtocolVersion(data)
+ assert.NotNil(t, result)
+}
+
+func TestServiceAccept(t *testing.T) {
+ serviceName := ""
+ result := ServiceAccept(serviceName)
+ assert.NotNil(t, result)
+}
+func TestProtocolVersion(t *testing.T) {
+ result := ProtocolVersion(1, 0, 9)
+ assert.NotNil(t, result)
+}
+func TestTcpForwardReplySuccess(t *testing.T) {
+ result := TcpForwardReplySuccess(16992)
+ assert.NotNil(t, result)
+}
+func TestChannelOpen(t *testing.T) {
+ result := ChannelOpen(1)
+ assert.NotNil(t, result)
+}
+func TestChannelOpenReplySuccess(t *testing.T) {
+ result := ChannelOpenReplySuccess(0, 1)
+ assert.NotNil(t, result)
+}
+func TestChannelOpenReplyFailure(t *testing.T) {
+ result := ChannelOpenReplyFailure(0, 1)
+ assert.NotNil(t, result)
+}
+func TestChannelClose(t *testing.T) {
+ result := ChannelClose(0)
+ assert.NotNil(t, result)
+}
+func TestChannelData(t *testing.T) {
+ data := []byte{0x01}
+ result := ChannelData(0, data)
+ assert.NotNil(t, result)
+}
+func TestChannelWindowAdjust(t *testing.T) {
+ result := ChannelWindowAdjust(0, 32)
+ assert.NotNil(t, result)
+}
diff --git a/pkg/apf/types.go b/pkg/apf/types.go
new file mode 100644
index 00000000..8f18a852
--- /dev/null
+++ b/pkg/apf/types.go
@@ -0,0 +1,254 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2022
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+package apf
+
+import "time"
+
+const LMS_PROTOCOL_VERSION = 4
+const LME_RX_WINDOW_SIZE = 4096
+
+// message op codes
+const APF_DISCONNECT = 1
+const APF_SERVICE_REQUEST = 5
+const APF_SERVICE_ACCEPT = 6
+const APF_USERAUTH_REQUEST = 50
+const APF_USERAUTH_FAILURE = 51
+const APF_USERAUTH_SUCCESS = 52
+const APF_GLOBAL_REQUEST = 80
+const APF_REQUEST_SUCCESS = 81
+const APF_REQUEST_FAILURE = 82
+const APF_CHANNEL_OPEN = 90
+const APF_CHANNEL_OPEN_CONFIRMATION = 91
+const APF_CHANNEL_OPEN_FAILURE = 92
+const APF_CHANNEL_WINDOW_ADJUST = 93
+const APF_CHANNEL_DATA = 94
+const APF_CHANNEL_CLOSE = 97
+const APF_PROTOCOLVERSION = 192
+
+// disconnect reason codes
+const APF_DISCONNECT_HOST_NOT_ALLOWED_TO_CONNECT = 1
+const APF_DISCONNECT_PROTOCOL_ERROR = 2
+const APF_DISCONNECT_KEY_EXCHANGE_FAILED = 3
+const APF_DISCONNECT_RESERVED = 4
+const APF_DISCONNECT_MAC_ERROR = 5
+const APF_DISCONNECT_COMPRESSION_ERROR = 6
+const APF_DISCONNECT_SERVICE_NOT_AVAILABLE = 7
+const APF_DISCONNECT_PROTOCOL_VERSION_NOT_SUPPORTED = 8
+const APF_DISCONNECT_HOST_KEY_NOT_VERIFIABLE = 9
+const APF_DISCONNECT_CONNECTION_LOST = 10
+const APF_DISCONNECT_BY_APPLICATION = 11
+const APF_DISCONNECT_TOO_MANY_CONNECTIONS = 12
+const APF_DISCONNECT_AUTH_CANCELLED_BY_USER = 13
+const APF_DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLE = 14
+const APF_DISCONNECT_ILLEGAL_USER_NAME = 15
+
+// strings used in global messages
+const APF_GLOBAL_REQUEST_STR_TCP_FORWARD_REQUEST = "tcpip-forward"
+const APF_GLOBAL_REQUEST_STR_TCP_FORWARD_CANCEL_REQUEST = "cancel-tcpip-forward"
+const APF_GLOBAL_REQUEST_STR_UDP_SEND_TO = "udp-send-to@amt.intel.com"
+const APF_OPEN_CHANNEL_REQUEST_FORWARDED = "forwarded-tcpip"
+const APF_OPEN_CHANNEL_REQUEST_DIRECT = "direct-tcpip"
+
+// APF service names
+const APF_SERVICE_PFWD = "pfwd@amt.intel.com"
+const APF_SERVICE_AUTH = "auth@amt.intel.com"
+
+// APF Authentication method
+const APF_AUTH_NONE = "none"
+const APF_AUTH_PASSWORD = "password"
+
+const APF_TRIGGER_REASON_USER_INITIATED_REQUEST = 1
+const APF_TRIGGER_REASON_ALERT_REQUEST = 2
+const APF_TRIGGER_REASON_HIT_PROVISIONING_REQUEST = 3
+const APF_TRIGGER_REASON_PERIODIC_REQUEST = 4
+const APF_TRIGGER_REASON_LME_REQUEST = 254
+
+const OPEN_FAILURE_REASON_ADMINISTRATIVELY_PROHIBITED = 1
+const OPEN_FAILURE_REASON_CONNECT_FAILED = 2
+const OPEN_FAILURE_REASON_UNKNOWN_CHANNEL_TYPE = 3
+const OPEN_FAILURE_REASON_RESOURCE_SHORTAGE = 4
+
+type APF_MESSAGE_HEADER struct {
+ MessageType byte
+}
+
+/**
+ * APF_GENERIC_HEADER - generic request header (note that its not complete header per protocol (missing WantReply)
+ *
+ * @MessageType:
+ * @RequestStringLength: length of the string identifies the request
+ * @RequestString: the string that identifies the request
+ **/
+
+type APF_GENERIC_HEADER struct {
+ MessageType byte
+ StringLength uint32
+ String string
+}
+type APF_TCP_FORWARD_REQUEST struct {
+ WantReply uint8
+ AddressLength uint32
+ Address string
+ Port uint32
+}
+
+/**
+ * TCP forward reply message
+ * @MessageType - Protocol's Major version
+ * @PortBound - the TCP port was bound on the server
+ **/
+type APF_TCP_FORWARD_REPLY_MESSAGE struct {
+ MessageType byte
+ PortBound uint32
+}
+
+/**
+ * response to ChannelOpen when channel open succeed
+ * @MessageType - APF_CHANNEL_OPEN_CONFIRMATION
+ * @RecipientChannel - channel number given in the open request
+ * @SenderChannel - channel number assigned by the sender
+ * @InitialWindowSize - Number of bytes in the window
+ * @Reserved - Reserved
+ **/
+type APF_CHANNEL_OPEN_CONFIRMATION_MESSAGE struct {
+ MessageType byte
+ RecipientChannel uint32
+ SenderChannel uint32
+ InitialWindowSize uint32
+ Reserved uint32
+}
+
+/**
+ * response to ChannelOpen when a channel open failed
+ * @MessageType - APF_CHANNEL_OPEN_FAILURE
+ * @RecipientChannel - channel number given in the open request
+ * @ReasonCode - code for the reason channel could not be open
+ * @Reserved - Reserved
+ **/
+type APF_CHANNEL_OPEN_FAILURE_MESSAGE struct {
+ MessageType byte
+ RecipientChannel uint32
+ ReasonCode uint32
+ Reserved uint32
+ Reserved2 uint32
+}
+
+/**
+ * close channel message
+ * @MessageType - APF_CHANNEL_CLOSE
+ * @RecipientChannel - channel number given in the open request
+ **/
+type APF_CHANNEL_CLOSE_MESSAGE struct {
+ MessageType byte
+ RecipientChannel uint32
+}
+
+/**
+ * used to send/receive data.
+ * @MessageType - APF_CHANNEL_DATA
+ * @RecipientChannel - channel number given in the open request
+ * @Length - Length of the data in the message
+ * @Data - The data in the message
+ **/
+type APF_CHANNEL_DATA_MESSAGE struct {
+ MessageType byte
+ RecipientChannel uint32
+ DataLength uint32
+ Data []byte
+}
+
+/**
+ * used to adjust receive window size.
+ * @MessageType - APF_WINDOW_ADJUST
+ * @RecipientChannel - channel number given in the open request
+ * @BytesToAdd - number of bytes to add to current window size value
+ **/
+type APF_CHANNEL_WINDOW_ADJUST_MESSAGE struct {
+ MessageType byte
+ RecipientChannel uint32
+ BytesToAdd uint32
+}
+
+/**
+ * This message causes immediate termination of the connection with AMT.
+ * @ReasonCode - A Reason code for the disconnection event
+ * @Reserved - Reserved must be set to 0
+ **/
+type APF_DISCONNECT_MESSAGE struct {
+ MessageType byte
+ ReasonCode uint32
+ Reserved uint //short32
+}
+
+/**
+ * Used to request a service identified by name
+ * @ServiceNameLength - The length of the service name string.
+ * @ServiceName - The name of the service being requested.
+ **/
+type APF_SERVICE_REQUEST_MESSAGE struct {
+ MessageType byte
+ ServiceNameLength uint32
+ ServiceName string
+}
+
+/**
+ * Used to send a service accept identified by name
+ * @ServiceNameLength - The length of the service name string.
+ * @ServiceName - The name of the service being requested.
+ **/
+type APF_SERVICE_ACCEPT_MESSAGE struct {
+ MessageType byte
+ ServiceNameLength uint32
+ ServiceName [18]byte
+}
+
+/**
+ * holds the protocol major and minor version implemented by AMT.
+ * @MajorVersion - Protocol's Major version
+ * @MinorVersion - Protocol's Minor version
+ * @Trigger - The open session reason
+ * @UUID - System Id
+ **/
+type APF_PROTOCOL_VERSION_MESSAGE struct {
+ MessageType byte
+ MajorVersion uint32
+ MinorVersion uint32
+ TriggerReason uint32
+ UUID [16]byte
+ Reserved [64]byte
+}
+
+/**
+ * holds the user authentication request success response.
+ **/
+type APF_USERAUTH_SUCCESS_MESSAGE struct {
+ MessageType byte
+}
+type APF_CHANNEL_OPEN_MESSAGE struct {
+ MessageType byte
+ ChannelTypeLength uint32
+ ChannelType [15]uint8
+ SenderChannel uint32
+ InitialWindowSize uint32
+ Reserved uint32
+ ConnectedAddressLength uint32
+ ConnectedAddress [3]uint8
+ ConnectedPort uint32
+ OriginatorIPAddressLength uint32
+ OriginatorIPAddress [3]uint8
+ OriginatorPort uint32
+}
+
+type Session struct {
+ SenderChannel uint32
+ RecipientChannel uint32
+ TXWindow uint32
+ RXWindow uint32
+ Tempdata []byte
+ DataBuffer chan []byte
+ ErrorBuffer chan error
+ Status chan bool
+ Timer *time.Timer
+}
diff --git a/pkg/cim/bios/element.go b/pkg/cim/bios/element.go
deleted file mode 100644
index c4e52de7..00000000
--- a/pkg/cim/bios/element.go
+++ /dev/null
@@ -1,36 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package bios
-
-import "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
-
-type Element struct {
- base message.Base
-}
-
-const CIM_BiosElement = "CIM_BIOSElement"
-
-// NewBIOSElement returns a new instance of the BIOSElement struct.
-func NewBIOSElement(wsmanMessageCreator *message.WSManMessageCreator) Element {
- return Element{
- base: message.NewBase(wsmanMessageCreator, string(CIM_BiosElement)),
- }
-}
-
-// Get retrieves the representation of the instance
-func (b Element) Get() string {
- return b.base.Get(nil)
-}
-
-// Enumerates the instances of this class
-func (b Element) Enumerate() string {
- return b.base.Enumerate()
-}
-
-// Pulls instances of this class, following an Enumerate operation
-func (b Element) Pull(enumerationContext string) string {
- return b.base.Pull(enumerationContext)
-}
diff --git a/pkg/cim/bios/element_test.go b/pkg/cim/bios/element_test.go
deleted file mode 100644
index 61d1a71a..00000000
--- a/pkg/cim/bios/element_test.go
+++ /dev/null
@@ -1,50 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package bios
-
-import (
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestCIM(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewBIOSElement(wsmanMessageCreator)
-
- t.Run("cim_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid cim_BIOSElement Get wsman message", "CIM_BIOSElement", wsmantesting.GET, "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid cim_BIOSElement Enumerate wsman message", "CIM_BIOSElement", wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid cim_BIOSElement Pull wsman message", "CIM_BIOSElement", wsmantesting.PULL, wsmantesting.PULL_BODY, func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-}
diff --git a/pkg/cim/boot/configsetting.go b/pkg/cim/boot/configsetting.go
deleted file mode 100644
index 101b81d8..00000000
--- a/pkg/cim/boot/configsetting.go
+++ /dev/null
@@ -1,47 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package boot
-
-import (
- "fmt"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/cim/actions"
-)
-
-const CIM_BootConfigSetting = "CIM_BootConfigSetting"
-
-type ConfigSetting struct {
- base message.Base
-}
-
-// NewBootConfigSetting returns a new instance of the BootConfigSetting struct.
-func NewBootConfigSetting(wsmanMessageCreator *message.WSManMessageCreator) ConfigSetting {
- return ConfigSetting{
- base: message.NewBase(wsmanMessageCreator, string(CIM_BootConfigSetting)),
- }
-}
-
-// Get retrieves the representation of the instance
-func (b ConfigSetting) Get() string {
- return b.base.Get(nil)
-}
-
-// Enumerates the instances of this class
-func (b ConfigSetting) Enumerate() string {
- return b.base.Enumerate()
-}
-
-// Pulls instances of this class, following an Enumerate operation
-func (b ConfigSetting) Pull(enumerationContext string) string {
- return b.base.Pull(enumerationContext)
-}
-
-func (b ConfigSetting) ChangeBootOrder(source string) string {
- header := b.base.WSManMessageCreator.CreateHeader(string(actions.ChangeBootOrder), string(CIM_BootConfigSetting), nil, "", "")
- body := fmt.Sprintf(`http://schemas.xmlsoap.org/ws/2004/08/addressinghttp://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_BootSourceSetting%s`, source)
- return b.base.WSManMessageCreator.CreateXML(header, body)
-}
diff --git a/pkg/cim/boot/configsetting_test.go b/pkg/cim/boot/configsetting_test.go
deleted file mode 100644
index 0fe2897e..00000000
--- a/pkg/cim/boot/configsetting_test.go
+++ /dev/null
@@ -1,50 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package boot
-
-import (
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestConfigSetting(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewBootConfigSetting(wsmanMessageCreator)
-
- t.Run("cim_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid cim_BootConfigSetting Get wsman message", "CIM_BootConfigSetting", wsmantesting.GET, "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid cim_BootConfigSetting Enumerate wsman message", "CIM_BootConfigSetting", wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid cim_BootConfigSetting Pull wsman message", "CIM_BootConfigSetting", wsmantesting.PULL, wsmantesting.PULL_BODY, func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-}
diff --git a/pkg/cim/boot/service.go b/pkg/cim/boot/service.go
deleted file mode 100644
index 5752e41e..00000000
--- a/pkg/cim/boot/service.go
+++ /dev/null
@@ -1,61 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package boot
-
-import (
- "fmt"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/cim/actions"
-)
-
-const CIM_BootService = "CIM_BootService"
-
-type BootServiceRole int
-
-const (
- // IsNext corresponds to the value 0.
- IsNext BootServiceRole = iota
-
- // IsNextSingleUse corresponds to the value 1.
- IsNextSingleUse
-
- // IsDefault corresponds to the value 2.
- IsDefault
-)
-
-type Service struct {
- base message.Base
-}
-
-// NewBootService returns a new instance of the BootService struct.
-func NewBootService(wsmanMessageCreator *message.WSManMessageCreator) Service {
- return Service{
- base: message.NewBase(wsmanMessageCreator, string(CIM_BootService)),
- }
-}
-
-// Get retrieves the representation of the instance
-func (b Service) Get() string {
- return b.base.Get(nil)
-}
-
-// Enumerates the instances of this class
-func (b Service) Enumerate() string {
- return b.base.Enumerate()
-}
-
-// Pulls instances of this class, following an Enumerate operation
-func (b Service) Pull(enumerationContext string) string {
- return b.base.Pull(enumerationContext)
-}
-
-// SetBootConfigRole sets the role of the BootConfigSetting that is directly or indirectly associated to one or more ComputerSystems.
-func (b Service) SetBootConfigRole(bootSource string, role BootServiceRole) string {
- header := b.base.WSManMessageCreator.CreateHeader(string(actions.SetBootConfigRole), string(CIM_BootService), nil, "", "")
- body := fmt.Sprintf(`http://schemas.xmlsoap.org/ws/2004/08/addressinghttp://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_BootConfigSetting%s%d`, bootSource, role)
- return b.base.WSManMessageCreator.CreateXML(header, body)
-}
diff --git a/pkg/cim/boot/service_test.go b/pkg/cim/boot/service_test.go
deleted file mode 100644
index b2c1779e..00000000
--- a/pkg/cim/boot/service_test.go
+++ /dev/null
@@ -1,50 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package boot
-
-import (
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestService(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewBootService(wsmanMessageCreator)
-
- t.Run("cim_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid cim_BootService Get wsman message", "CIM_BootService", wsmantesting.GET, "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid cim_BootService Enumerate wsman message", "CIM_BootService", wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid cim_BootService Pull wsman message", "CIM_BootService", wsmantesting.PULL, wsmantesting.PULL_BODY, func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-}
diff --git a/pkg/cim/boot/sourcesetting.go b/pkg/cim/boot/sourcesetting.go
deleted file mode 100644
index 4b3a7041..00000000
--- a/pkg/cim/boot/sourcesetting.go
+++ /dev/null
@@ -1,38 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package boot
-
-import (
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
-)
-
-const CIM_BootSourceSetting = "CIM_BootSourceSetting"
-
-type SourceSetting struct {
- base message.Base
-}
-
-// NewBootSourceSetting returns a new instance of the BootSourceSetting struct.
-func NewBootSourceSetting(wsmanMessageCreator *message.WSManMessageCreator) SourceSetting {
- return SourceSetting{
- base: message.NewBase(wsmanMessageCreator, string(CIM_BootSourceSetting)),
- }
-}
-
-// Get retrieves the representation of the instance
-func (b SourceSetting) Get() string {
- return b.base.Get(nil)
-}
-
-// Enumerates the instances of this class
-func (b SourceSetting) Enumerate() string {
- return b.base.Enumerate()
-}
-
-// Pulls instances of this class, following an Enumerate operation
-func (b SourceSetting) Pull(enumerationContext string) string {
- return b.base.Pull(enumerationContext)
-}
diff --git a/pkg/cim/boot/sourcesetting_test.go b/pkg/cim/boot/sourcesetting_test.go
deleted file mode 100644
index 20b973e0..00000000
--- a/pkg/cim/boot/sourcesetting_test.go
+++ /dev/null
@@ -1,50 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package boot
-
-import (
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestSourceSetting(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewBootSourceSetting(wsmanMessageCreator)
-
- t.Run("cim_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid cim_BootSourceSetting Get wsman message", "CIM_BootSourceSetting", wsmantesting.GET, "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid cim_BootSourceSetting Enumerate wsman message", "CIM_BootSourceSetting", wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid cim_BootSourceSetting Pull wsman message", "CIM_BootSourceSetting", wsmantesting.PULL, wsmantesting.PULL_BODY, func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-}
diff --git a/pkg/cim/computer/systempackage.go b/pkg/cim/computer/systempackage.go
deleted file mode 100644
index 4dafb82e..00000000
--- a/pkg/cim/computer/systempackage.go
+++ /dev/null
@@ -1,36 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package computer
-
-import "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
-
-const CIM_ComputerSystemPackage = "CIM_ComputerSystemPackage"
-
-type SystemPackage struct {
- base message.Base
-}
-
-// NewComputerSystemPackage returns a new instance of the ComputerSystemPackage struct.
-func NewComputerSystemPackage(wsmanMessageCreator *message.WSManMessageCreator) SystemPackage {
- return SystemPackage{
- base: message.NewBase(wsmanMessageCreator, string(CIM_ComputerSystemPackage)),
- }
-}
-
-// Get retrieves the representation of the instance
-func (b SystemPackage) Get() string {
- return b.base.Get(nil)
-}
-
-// Enumerates the instances of this class
-func (b SystemPackage) Enumerate() string {
- return b.base.Enumerate()
-}
-
-// Pulls instances of this class, following an Enumerate operation
-func (b SystemPackage) Pull(enumerationContext string) string {
- return b.base.Pull(enumerationContext)
-}
diff --git a/pkg/cim/computer/systempackage_test.go b/pkg/cim/computer/systempackage_test.go
deleted file mode 100644
index 56b44333..00000000
--- a/pkg/cim/computer/systempackage_test.go
+++ /dev/null
@@ -1,50 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package computer
-
-import (
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestCIM(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewComputerSystemPackage(wsmanMessageCreator)
-
- t.Run("cim_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid cim_ComputerSystemPackage Get wsman message", "CIM_ComputerSystemPackage", wsmantesting.GET, "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid cim_ComputerSystemPackage Enumerate wsman message", "CIM_ComputerSystemPackage", wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid cim_ComputerSystemPackage Pull wsman message", "CIM_ComputerSystemPackage", wsmantesting.PULL, wsmantesting.PULL_BODY, func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-}
diff --git a/pkg/cim/concrete/dependency.go b/pkg/cim/concrete/dependency.go
deleted file mode 100644
index e1d85624..00000000
--- a/pkg/cim/concrete/dependency.go
+++ /dev/null
@@ -1,62 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package concrete
-
-import (
- "encoding/xml"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/cim/models"
-)
-
-type DependencyPullResponseEnvelope struct {
- XMLName xml.Name `xml:"Envelope"`
- Header message.Header
- Body DependencyPullResponseBody
-}
-
-type DependencyPullResponseBody struct {
- PullResponse DependencyResponse
-}
-
-type DependencyResponse struct {
- EnumerationContext string
- Items []Relationship `xml:"Items>CIM_ConcreteDependency"`
-}
-
-type Relationship struct {
- Antecedent models.AssociationReference
- Dependent models.AssociationReference
-}
-
-type Dependency struct {
- base message.Base
-}
-
-const ClassName = "CIM_ConcreteDependency"
-
-// NewDependency returns a new instance of the NewDependency struct.
-// should be NewDependency() because concrete is scoped already as package name.
-func NewDependency(wsmanMessageCreator *message.WSManMessageCreator) Dependency {
- return Dependency{
- base: message.NewBase(wsmanMessageCreator, ClassName),
- }
-}
-
-// Get the representation of the instance
-func (b Dependency) Get() string {
- return b.base.Get(nil)
-}
-
-// Enumerate the instances of this class
-func (b Dependency) Enumerate() string {
- return b.base.Enumerate()
-}
-
-// Pull instances of this class, following an Enumerate operation
-func (b Dependency) Pull(enumerationContext string) string {
- return b.base.Pull(enumerationContext)
-}
diff --git a/pkg/cim/concrete/dependency_test.go b/pkg/cim/concrete/dependency_test.go
deleted file mode 100644
index fd94f472..00000000
--- a/pkg/cim/concrete/dependency_test.go
+++ /dev/null
@@ -1,49 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package concrete
-
-import (
- "testing"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
- "github.com/stretchr/testify/assert"
-)
-
-func TestCIM(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewDependency(wsmanMessageCreator)
-
- t.Run("cim_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid cim_IEEE8021xSettings Get wsman message", ClassName, wsmantesting.GET, "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid cim_IEEE8021xSettings Enumerate wsman message", ClassName, wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid cim_IEEE8021xSettings Pull wsman message", ClassName, wsmantesting.PULL, wsmantesting.PULL_BODY, func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-}
diff --git a/pkg/cim/credential/context.go b/pkg/cim/credential/context.go
deleted file mode 100644
index 0467ee95..00000000
--- a/pkg/cim/credential/context.go
+++ /dev/null
@@ -1,61 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package credential
-
-import (
- "encoding/xml"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/cim/models"
-)
-
-type ContextPullResponseEnvelope struct {
- XMLName xml.Name `xml:"Envelope"`
- Header message.Header
- Body ContextPullResponseBody
-}
-
-type ContextPullResponseBody struct {
- PullResponse ContextResponse
-}
-
-type ContextResponse struct {
- EnumerationContext string
- Items []Relationship `xml:"Items>CIM_CredentialContext"`
-}
-
-type Relationship struct {
- ElementInContext models.AssociationReference
- ElementProvidingContext models.AssociationReference
-}
-
-type Context struct {
- base message.Base
-}
-
-const ClassName = "CIM_CredentialContext"
-
-// NewContext returns a new instance of the NewContext struct.
-func NewContext(wsmanMessageCreator *message.WSManMessageCreator) Context {
- return Context{
- base: message.NewBase(wsmanMessageCreator, ClassName),
- }
-}
-
-// Get the representation of the instance
-func (b Context) Get() string {
- return b.base.Get(nil)
-}
-
-// Enumerate the instances of this class
-func (b Context) Enumerate() string {
- return b.base.Enumerate()
-}
-
-// Pull instances of this class, following an Enumerate operation
-func (b Context) Pull(enumerationContext string) string {
- return b.base.Pull(enumerationContext)
-}
diff --git a/pkg/cim/credential/context_test.go b/pkg/cim/credential/context_test.go
deleted file mode 100644
index a9379640..00000000
--- a/pkg/cim/credential/context_test.go
+++ /dev/null
@@ -1,49 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package credential
-
-import (
- "testing"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
- "github.com/stretchr/testify/assert"
-)
-
-func TestCIM(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewContext(wsmanMessageCreator)
-
- t.Run("cim_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid cim_IEEE8021xSettings Get wsman message", ClassName, wsmantesting.GET, "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid cim_IEEE8021xSettings Enumerate wsman message", ClassName, wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid cim_IEEE8021xSettings Pull wsman message", ClassName, wsmantesting.PULL, wsmantesting.PULL_BODY, func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-}
diff --git a/pkg/cim/ieee8021x/settings.go b/pkg/cim/ieee8021x/settings.go
deleted file mode 100644
index 0869a306..00000000
--- a/pkg/cim/ieee8021x/settings.go
+++ /dev/null
@@ -1,36 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package ieee8021x
-
-import "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
-
-const CIM_IEEE8021xSettings = "CIM_IEEE8021xSettings"
-
-type Settings struct {
- base message.Base
-}
-
-// NewIEEE8021xSettings returns a new instance of the IEEE8021xSettings struct.
-func NewIEEE8021xSettings(wsmanMessageCreator *message.WSManMessageCreator) Settings {
- return Settings{
- base: message.NewBase(wsmanMessageCreator, string(CIM_IEEE8021xSettings)),
- }
-}
-
-// Get retrieves the representation of the instance
-func (b Settings) Get() string {
- return b.base.Get(nil)
-}
-
-// Enumerates the instances of this class
-func (b Settings) Enumerate() string {
- return b.base.Enumerate()
-}
-
-// Pulls instances of this class, following an Enumerate operation
-func (b Settings) Pull(enumerationContext string) string {
- return b.base.Pull(enumerationContext)
-}
diff --git a/pkg/cim/ieee8021x/settings_test.go b/pkg/cim/ieee8021x/settings_test.go
deleted file mode 100644
index fdb24ad7..00000000
--- a/pkg/cim/ieee8021x/settings_test.go
+++ /dev/null
@@ -1,50 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package ieee8021x
-
-import (
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestCIM(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewIEEE8021xSettings(wsmanMessageCreator)
-
- t.Run("cim_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid cim_IEEE8021xSettings Get wsman message", "CIM_IEEE8021xSettings", wsmantesting.GET, "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid cim_IEEE8021xSettings Enumerate wsman message", "CIM_IEEE8021xSettings", wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid cim_IEEE8021xSettings Pull wsman message", "CIM_IEEE8021xSettings", wsmantesting.PULL, wsmantesting.PULL_BODY, func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-}
diff --git a/pkg/cim/kvm/redirectionsap.go b/pkg/cim/kvm/redirectionsap.go
deleted file mode 100644
index db9dae0b..00000000
--- a/pkg/cim/kvm/redirectionsap.go
+++ /dev/null
@@ -1,44 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package kvm
-
-import (
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/cim/actions"
-)
-
-const CIM_KVMRedirectionSAP = "CIM_KVMRedirectionSAP"
-
-type RedirectionSAP struct {
- base message.Base
-}
-
-// NewKVMRedirectionSAP returns a new instance of the KVMRedirectionSAP struct.
-func NewKVMRedirectionSAP(wsmanMessageCreator *message.WSManMessageCreator) RedirectionSAP {
- return RedirectionSAP{
- base: message.NewBase(wsmanMessageCreator, string(CIM_KVMRedirectionSAP)),
- }
-}
-
-// RequestStateChange requests that the state of the element be changed to the value specified in the RequestedState parameter . . .
-func (k RedirectionSAP) RequestStateChange(requestedState int) string {
- return k.base.RequestStateChange(actions.RequestStateChange(string(CIM_KVMRedirectionSAP)), requestedState)
-}
-
-// Get retrieves the representation of the instance
-func (b RedirectionSAP) Get() string {
- return b.base.Get(nil)
-}
-
-// Enumerates the instances of this class
-func (b RedirectionSAP) Enumerate() string {
- return b.base.Enumerate()
-}
-
-// Pulls instances of this class, following an Enumerate operation
-func (b RedirectionSAP) Pull(enumerationContext string) string {
- return b.base.Pull(enumerationContext)
-}
diff --git a/pkg/cim/kvm/redirectionsap_test.go b/pkg/cim/kvm/redirectionsap_test.go
deleted file mode 100644
index 85726979..00000000
--- a/pkg/cim/kvm/redirectionsap_test.go
+++ /dev/null
@@ -1,50 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package kvm
-
-import (
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestCIM(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewKVMRedirectionSAP(wsmanMessageCreator)
-
- t.Run("cim_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid cim_KVMRedirectionSAP Get wsman message", "CIM_KVMRedirectionSAP", wsmantesting.GET, "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid cim_KVMRedirectionSAP Enumerate wsman message", "CIM_KVMRedirectionSAP", wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid cim_KVMRedirectionSAP Pull wsman message", "CIM_KVMRedirectionSAP", wsmantesting.PULL, wsmantesting.PULL_BODY, func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-}
diff --git a/pkg/cim/mediaaccess/device.go b/pkg/cim/mediaaccess/device.go
deleted file mode 100644
index eb52b73f..00000000
--- a/pkg/cim/mediaaccess/device.go
+++ /dev/null
@@ -1,36 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package mediaaccess
-
-import "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
-
-const CIM_MediaAccessDevice = "CIM_MediaAccessDevice"
-
-type Device struct {
- base message.Base
-}
-
-// NewMediaAccessDevice returns a new instance of the MediaAccessDevice struct.
-func NewMediaAccessDevice(wsmanMessageCreator *message.WSManMessageCreator) Device {
- return Device{
- base: message.NewBase(wsmanMessageCreator, string(CIM_MediaAccessDevice)),
- }
-}
-
-// Get retrieves the representation of the instance
-func (b Device) Get() string {
- return b.base.Get(nil)
-}
-
-// Enumerates the instances of this class
-func (b Device) Enumerate() string {
- return b.base.Enumerate()
-}
-
-// Pulls instances of this class, following an Enumerate operation
-func (b Device) Pull(enumerationContext string) string {
- return b.base.Pull(enumerationContext)
-}
diff --git a/pkg/cim/mediaaccess/device_test.go b/pkg/cim/mediaaccess/device_test.go
deleted file mode 100644
index 6b0efd51..00000000
--- a/pkg/cim/mediaaccess/device_test.go
+++ /dev/null
@@ -1,50 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package mediaaccess
-
-import (
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestCIM(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewMediaAccessDevice(wsmanMessageCreator)
-
- t.Run("cim_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid cim_MediaAccessDevice Get wsman message", "CIM_MediaAccessDevice", wsmantesting.GET, "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid cim_MediaAccessDevice Enumerate wsman message", "CIM_MediaAccessDevice", wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid cim_MediaAccessDevice Pull wsman message", "CIM_MediaAccessDevice", wsmantesting.PULL, wsmantesting.PULL_BODY, func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-}
diff --git a/pkg/cim/messages.go b/pkg/cim/messages.go
deleted file mode 100644
index 64463a32..00000000
--- a/pkg/cim/messages.go
+++ /dev/null
@@ -1,81 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package cim
-
-import (
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/cim/bios"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/cim/boot"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/cim/computer"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/cim/concrete"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/cim/credential"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/cim/ieee8021x"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/cim/kvm"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/cim/mediaaccess"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/cim/physical"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/cim/power"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/cim/service"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/cim/software"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/cim/system"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/cim/wifi"
-)
-
-type Messages struct {
- wsmanMessageCreator *message.WSManMessageCreator
- BIOSElement bios.Element
- BootConfigSetting boot.ConfigSetting
- BootService boot.Service
- BootSourceSetting boot.SourceSetting
- Card physical.Card
- Chassis physical.Chassis
- Chip physical.Chip
- ComputerSystemPackage computer.SystemPackage
- ConcreteDependency concrete.Dependency
- CredentialContext credential.Context
- IEEE8021xSettings ieee8021x.Settings
- KVMRedirectionSAP kvm.RedirectionSAP
- MediaAccessDevice mediaaccess.Device
- PhysicalMemory physical.Memory
- PhysicalPackage physical.Package
- PowerManagementService power.ManagementService
- Processor physical.Processor
- ServiceAvailableToElement service.AvailableToElement
- SoftwareIdentity software.Identity
- SystemPackaging system.Packaging
- WiFiEndpointSettings wifi.EndpointSettings
- WiFiPort wifi.Port
-}
-
-func NewMessages() Messages {
- resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- m := Messages{
- wsmanMessageCreator: wsmanMessageCreator,
- }
- m.BIOSElement = bios.NewBIOSElement(wsmanMessageCreator)
- m.BootConfigSetting = boot.NewBootConfigSetting(wsmanMessageCreator)
- m.BootService = boot.NewBootService(wsmanMessageCreator)
- m.BootSourceSetting = boot.NewBootSourceSetting(wsmanMessageCreator)
- m.Card = physical.NewCard(wsmanMessageCreator)
- m.Chassis = physical.NewChassis(wsmanMessageCreator)
- m.Chip = physical.NewChip(wsmanMessageCreator)
- m.ComputerSystemPackage = computer.NewComputerSystemPackage(wsmanMessageCreator)
- m.ConcreteDependency = concrete.NewDependency(wsmanMessageCreator)
- m.CredentialContext = credential.NewContext(wsmanMessageCreator)
- m.IEEE8021xSettings = ieee8021x.NewIEEE8021xSettings(wsmanMessageCreator)
- m.KVMRedirectionSAP = kvm.NewKVMRedirectionSAP(wsmanMessageCreator)
- m.MediaAccessDevice = mediaaccess.NewMediaAccessDevice(wsmanMessageCreator)
- m.PhysicalMemory = physical.NewPhysicalMemory(wsmanMessageCreator)
- m.PhysicalPackage = physical.NewPhysicalPackage(wsmanMessageCreator)
- m.PowerManagementService = power.NewPowerManagementService(wsmanMessageCreator)
- m.Processor = physical.NewProcessor(wsmanMessageCreator)
- m.ServiceAvailableToElement = service.NewServiceAvailableToElement(wsmanMessageCreator)
- m.SoftwareIdentity = software.NewSoftwareIdentity(wsmanMessageCreator)
- m.SystemPackaging = system.NewSystemPackaging(wsmanMessageCreator)
- m.WiFiEndpointSettings = wifi.NewWiFiEndpointSettings(wsmanMessageCreator)
- m.WiFiPort = wifi.NewWiFiPort(wsmanMessageCreator)
- return m
-}
diff --git a/pkg/cim/methods/constants.go b/pkg/cim/methods/constants.go
deleted file mode 100644
index 35eb17f9..00000000
--- a/pkg/cim/methods/constants.go
+++ /dev/null
@@ -1,20 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package methods
-
-type Methods string
-
-const (
- Get Methods = "Get"
- Pull Methods = "Pull"
- Enumerate Methods = "Enumerate"
- Put Methods = "Put"
- Delete Methods = "Delete"
- SetBootConfigRole Methods = "SetBootConfigRole"
- ChangeBootOrder Methods = "ChangeBootOrder"
- RequestPowerStateChange Methods = "RequestPowerStateChange"
- RequestStateChange Methods = "RequestStateChange"
-)
diff --git a/pkg/cim/models/types.go b/pkg/cim/models/types.go
deleted file mode 100644
index fc891aa0..00000000
--- a/pkg/cim/models/types.go
+++ /dev/null
@@ -1,1170 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package models
-
-import (
- "encoding/xml"
- "time"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
-)
-
-type SettingData struct {
- ManagedElement
- InstanceID string `xml:"InstanceID,omitempty"` // MaxLen=256
-}
-
-type ManagedElement struct {
- XMLName xml.Name `xml:"h:ManagedElement"`
- Caption string `xml:"h:Caption,omitempty"` // MaxLen=64
- Description string `xml:"h:Description,omitempty"` // MaxLen=256
- ElementName string `xml:"h:ElementName,omitempty"` // MaxLen=256
-}
-type Collection struct {
- ManagedElement
-}
-
-type Role struct {
- Collection
- CreationClassName string
- Name string
- CommonName string
- RoleCharacteristics []RoleCharacteristics
-}
-
-type RoleCharacteristics int
-
-const (
- RoleCharacteristicsStatic RoleCharacteristics = 2
- RoleCharacteristicsOpaque RoleCharacteristics = 3
-)
-
-type MediaAccessDevice struct {
- LogicalDevice
- Capabilities []CapabilitiesValues // ValueMap={0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Values={Unknown, Other, Sequential Access, Random Access, Supports Writing, Encryption, Compression, Supports Removeable Media, Manual Cleaning, Automatic Cleaning, SMART Notification, Supports Dual Sided Media, Predismount Eject Not Required} ArrayType=Indexed
- MaxMediaSize int
- Security SecurityValues // ValueMap={1, 2, 3, 4, 5, 6, 7} Values={Other, Unknown, None, Read Only, Locked Out, Boot Bypass, Boot Bypass and Read Only}
-}
-
-type CapabilitiesValues int
-
-const (
- CapabilitiesValuesUnknown CapabilitiesValues = iota
- CapabilitiesValuesOther
- CapabilitiesValuesSequentialAccess
- CapabilitiesValuesRandomAccess
- CapabilitiesValuesSupportsWriting
- CapabilitiesValuesEncryption
- CapabilitiesValuesCompression
- CapabilitiesValuesSupportsRemoveableMedia
- CapabilitiesValuesManualCleaning
- CapabilitiesValuesAutomaticCleaning
- CapabilitiesValuesSMARTNotification
- CapabilitiesValuesSupportsDualSidedMedia
- CapabilitiesValuesPredismountEjectNotRequired
-)
-
-type SecurityValues int
-
-const (
- SecurityValuesOther SecurityValues = iota + 1
- SecurityValuesUnknown
- SecurityValuesNone
- SecurityValuesReadOnly
- SecurityValuesLockedOut
- SecurityValuesBootBypass
- SecurityValuesBootBypassAndReadOnly
-)
-
-type LogicalPort struct {
- LogicalDevice
- Speed int
- MaxSpeed int
- RequestedSpeed int
- UsageRestriction UsageRestriction
- PortType PortType
- OtherPortType string
-}
-type UsageRestriction int
-
-const (
- UsageRestrictionUnknown int = iota
- UsageRestrictionFrontEndOnly
- UsageRestrictionBackEndOnly
- UsageRestrictionNotRestricted
-)
-
-type PortType int
-
-const (
- PortTypeUnknown int = iota
- PortTypeOther
- PortTypeNotApplicable
-)
-
-type NetworkPort struct {
- LogicalPort
- PortNumber int
- LinkTechnology LinkTechnology
- OtherLinkTechnology string
- PermanentAddress string
- NetworkAddresses []string
- FullDuplex bool
- AutoSense bool
- SupportedMaximumTransmissionUnit int
- ActiveMaximumTransmissionUnit int
-}
-
-type LinkTechnology int
-
-const (
- LinkTechnologyUnknown LinkTechnology = iota
- LinkTechnologyOther
- LinkTechnologyEthernet
- LinkTechnologyIB
- LinkTechnologyFC
- LinkTechnologyFDDI
- LinkTechnologyATM
- LinkTechnologyTokenRing
- LinkTechnologyFrameRelay
- LinkTechnologyInfrared
- LinkTechnologyBlueTooth
- LinkTechnologyWirelessLAN
-)
-
-type EthernetPort struct {
- NetworkPort
-}
-
-type WiFiPort struct {
- NetworkPort
-}
-
-// TODO:fix types
-type Dependency struct {
- Antecedent interface{}
- Dependent interface{}
-}
-
-type SystemPackaging struct {
- Dependency
-}
-
-type ComputerSystemPackage struct {
- SystemPackaging
- PlatformGuid string //maxlen 40
-}
-
-type PhysicalElement struct {
- ManagedSystemElement
- Tag string // MaxLen=256
- CreationClassName string // MaxLen=256
- Manufacturer string // MaxLen=256
- Model string // MaxLen=256
- Sku string // MaxLen=64
- SerialNumber string // MaxLen=256
- Version string // MaxLen=64
- PartNumber string // MaxLen=256
- OtherIdentifyingInfo string // MaxLen=256
- PoweredOn bool
- ManufactureDate time.Time
- VendorEquipmentType string // MaxLen=256
- UserTracking string // MaxLen=256
- CanBeFRUed bool
-}
-
-type PhysicalComponent struct {
- PhysicalElement
- RemovalConditions RemovalConditions
- Removable bool
- Replaceable bool
- HotSwappable bool
-}
-type Chip struct {
- PhysicalComponent
- Tag string
- CreationClassName string
- ElementName string
- Manufacturer string
- Version string
- CanBeFRUed bool
-}
-
-type PhysicalMemory struct {
- Chip
- FormFactor int
- MemoryType MemoryType
- Speed int
- Capacity int
- BankLabel string
- ConfiguredMemoryClockSpeed int
- IsSpeedInMhz bool
- MaxMemorySpeed int
-}
-
-type PhysicalPackage struct {
- PhysicalElement
- PackageType PackageType
-}
-
-type Card struct {
- PhysicalPackage
-}
-
-/**
- * Enabled:1 | Disabled:2 | Enabled For Debug:3
- */
-type Enabled uint8
-
-const (
- EnabledEnabled Enabled = 1
- EnabledDisabled Enabled = 2
- EnabledEnabledForDebug Enabled = 3
-)
-
-type PowerActionResponse struct {
- RequestPowerStateChange_OUTPUT message.ReturnValue
-}
-type PhysicalFrame struct {
- PhysicalPackage
- VendorCompatibilityStrings []string
- OtherPackageType string
- Weight int
- Width int
- Depth int
- Height int
- RemovalConditions RemovalConditions
- Removable bool
- Replaceable bool
- HotSwappable bool
- CableManagementStrategy string
- ServicePhilosophy ServicePhilosophy
- ServiceDescriptions []string
- LockPresent bool
- AudibleAlarm bool
- VisibleAlarm bool
- SecurityBreach SecurityBreach
- BreachDescription string
- IsLocked bool
-}
-
-type Chassis struct {
- PhysicalFrame
- ChassisPackageType ChassisPackageType
-}
-
-type LogicalElement struct {
- ManagedSystemElement
-}
-
-type SoftwareElement struct {
- LogicalElement
- Version string
- SoftwareElementState SoftwareElementState
- SoftwareElementId string
- TargetOperatingSystem TargetOperatingSystem
- OtherTargetOs string
- Manufacturer string
- BuildNumber string
- SerialNumber string
- CodeSet string
- IdentificationCode string
- LanguageEdition string
-}
-type BIOSElement struct {
- SoftwareElement
- PrimaryBIOS bool
- ReleaseDate time.Time
-}
-type BootSettingData struct {
- SettingData
- OwningEntity string // MaxLen=256
-}
-
-// SharedCredential represents a shared credential for a device.
-type SharedCredential struct {
- InstanceID string
- RemoteID string
- Secret string
- Algorithm string
- Protocol string
-}
-
-// IEEE8021xSettings represents the IEEE 802.1x settings for a network interface.
-type IEEE8021xSettings struct {
- XMLName xml.Name `xml:"h:IEEE8021xSettingsInput,omitempty"`
- H string `xml:"xmlns:q,attr"`
- ElementName string `xml:"q:ElementName,omitempty"`
- InstanceID string `xml:"q:InstanceID,omitempty"`
- AuthenticationProtocol AuthenticationProtocol `xml:"q:AuthenticationProtocol"`
- RoamingIdentity string `xml:"q:RoamingIdentity,omitempty"`
- ServerCertificateName string `xml:"q:ServerCertificateName,omitempty"`
- ServerCertificateNameComparison ServerCertificateNameComparison `xml:"q:ServerCertificateNameComparison,omitempty"`
- Username string `xml:"q:Username,omitempty"`
- Password string `xml:"q:Password,omitempty"`
- Domain string `xml:"q:Domain,omitempty"`
- ProtectedAccessCredential string `xml:"q:ProtectedAccessCredential,omitempty"`
- PACPassword string `xml:"q:PACPassword,omitempty"`
- PSK string `xml:"q:PSK,omitempty"`
-}
-
-type AuthenticationProtocol int
-
-const (
- AuthenticationProtocolEAPTLS AuthenticationProtocol = iota
- AuthenticationProtocolEAPTTLS_MSCHAPv2
- AuthenticationProtocolPEAPv0_EAPMSCHAPv2
- AuthenticationProtocolPEAPv1_EAPGTC
- AuthenticationProtocolEAPFAST_MSCHAPv2
- AuthenticationProtocolEAPFAST_GTC
- AuthenticationProtocolEAP_MD5
- AuthenticationProtocolEAP_PSK
- AuthenticationProtocolEAP_SIM
- AuthenticationProtocolEAP_AKA
- AuthenticationProtocolEAPFAST_TLS
-)
-
-type WiFiEndpointSettings struct {
- XMLName xml.Name `xml:"h:WiFiEndpointSettingsInput"`
- H string `xml:"xmlns:q,attr"`
- // SettingData
- ElementName string `xml:"q:ElementName"`
- InstanceID string `xml:"q:InstanceID"`
- AuthenticationMethod AuthenticationMethod `xml:"q:AuthenticationMethod"`
- EncryptionMethod EncryptionMethod `xml:"q:EncryptionMethod"`
- SSID string `xml:"q:SSID"` // Max Length 32
- Priority int `xml:"q:Priority"`
- PSKPassPhrase string `xml:"q:PSKPassPhrase,omitempty"` // Min Length 8 Max Length 63
- BSSType BSSType `xml:"q:BSSType,omitempty"`
- Keys []string `xml:"q:Keys,omitempty"` // OctetString ArrayType=Indexed Max Length 256
- KeyIndex int `xml:"q:KeyIndex,omitempty"`
- PSKValue uint64 `xml:"q:PSKValue,omitempty"` // OctetString
-}
-
-// BootSourceSetting represents the boot source settings for a device.
-type BootSourceSetting struct {
- SettingData
- ElementName string
- InstanceID BootConfigSettingInstanceID
- StructuredBootString string
- BIOSBootString string
- BootString string
- FailThroughSupported FailThroughSupported
-}
-
-type Service struct {
- EnabledLogicalElement
- SystemCreationClassName string
- SystemName string
- CreationClassName string
- PrimaryOwnerName string
- PrimaryOwnerContact string
- StartMode string
- Started bool
-}
-
-type SecurityService struct {
- Service
-}
-
-type AuthenticationService struct {
- SecurityService
-}
-type NetworkPortConfigurationService struct {
- Service
-}
-type CredentialManagementService struct {
- AuthenticationService
- // InstanceID is an optional property that may be used to opaquely and uniquely identify an instance of this class within the scope of the instantiating Namespace . . .
- InstanceID string // MaxLen=256
-}
-
-type EnabledLogicalElement struct {
- LogicalElement
- EnabledState EnabledLogicalElementEnabledState
- OtherEnabledState string
- RequestedState EnabledLogicalElementRequestedState
- EnabledDefault EnabledLogicalElementEnabledDefault
- TimeOfLastStateChange time.Time // You may use "time.Time" from the standard library
-}
-type LogicalDevice struct {
- SystemCreationClassName string `json:"SystemCreationClassName,omitempty"`
- SystemName string `json:"SystemName,omitempty"`
- CreationClassName string `json:"CreationClassName,omitempty"`
- DeviceId string `json:"DeviceId,omitempty"`
- PowerManagementSupported bool `json:"PowerManagementSupported,omitempty"`
- PowerManagementCapabilities []LogicalDevicePowerManagementCapabilitiesValues `json:"PowerManagementCapabilities,omitempty"`
- Availability LogicalDeviceAvailabilityValues `json:"Availability,omitempty"`
- StatusInfo LogicalDeviceStatusInfoValues `json:"StatusInfo,omitempty"`
- LastErrorCode int `json:"LastErrorCode,omitempty"`
- ErrorDescription string `json:"ErrorDescription,omitempty"`
- ErrorCleared bool `json:"ErrorCleared,omitempty"`
- OtherIdentifyingInfo []string `json:"OtherIdentifyingInfo,omitempty"`
- PowerOnHours int `json:"PowerOnHours,omitempty"`
- TotalPowerOnHours int `json:"TotalPowerOnHours,omitempty"`
- IdentifyingDescriptions []string `json:"IdentifyingDescriptions,omitempty"`
- AdditionalAvailability []LogicalDeviceAdditionalAvailabilityValues `json:"AdditionalAvailability,omitempty"`
- MaxQuiesceTime int `json:"MaxQuiesceTime,omitempty"`
-}
-type KVMRedirectionSAP struct {
- Name string
- CreationClassName string
- SystemName string
- SystemCreationClassName string
- ElementName string
- EnabledState KVMRedirectionSAPEnabledState
- RequestedState KVMRedirectionSAPRequestedState
- KVMProtocol KVMRedirectionSAPKVMProtocol
-}
-type KVMRedirectionSAPResponse struct {
- CIM_KVMRedirectionSAP KVMRedirectionSAP
-}
-type KVMRedirectionSAPEnabledState int
-
-const (
- KVMRedirectionSAPEUnknown KVMRedirectionSAPEnabledState = iota
- KVMRedirectionSAPEOther
- KVMRedirectionSAPEEnabled
- KVMRedirectionSAPEDisabled
- KVMRedirectionSAPEShuttingDown
- KVMRedirectionSAPENotApplicable
- KVMRedirectionSAPEEnabledButOffline
- KVMRedirectionSAPENInTest
- KVMRedirectionSAPEDeferred
- KVMRedirectionSAPEQuiesce
- KVMRedirectionSAPEStarting
-)
-
-type KVMRedirectionSAPRequestedState int
-
-const (
- KVMRedirectionSAPRUnknown KVMRedirectionSAPRequestedState = iota
- KVMRedirectionSAPREnabled
- KVMRedirectionSAPRDisabled
- KVMRedirectionSAPRShutDown
- KVMRedirectionSAPRNoChange
- KVMRedirectionSAPOffline
- KVMRedirectionSAPRTest
- KVMRedirectionSAPRDeferred
- KVMRedirectionSAPRQuiesce
- KVMRedirectionSAPRReboot
- KVMRedirectionSAPRReset
- KVMRedirectionSAPRNotApplicable
-)
-
-type KVMRedirectionSAPRequestedStateInputs int
-
-const (
- KVMRedirectionSAPEEnabledInput KVMRedirectionSAPRequestedStateInputs = iota + 2
- KVMRedirectionSAPEDisabledInput
- KVMRedirectionSAPRShutDownInput
- KVMRedirectionSAPOfflineInput
- KVMRedirectionSAPRTestInput
- KVMRedirectionSAPEDeferredInput
- KVMRedirectionSAPEQuiesceInput
- KVMRedirectionSAPRRebootInput
- KVMRedirectionSAPRResetInput
-)
-
-type KVMRedirectionSAPKVMProtocol int
-
-const (
- KVMRedirectionSAPKUnknown KVMRedirectionSAPKVMProtocol = iota
- KVMRedirectionSAPKOther
- KVMRedirectionSAPKRaw
- KVMRedirectionSAPKRDP
- KVMRedirectionSAPKVNC_RFB
-)
-
-type Job struct {
- LogicalElement
- InstanceId string
- CommunicationStatus CommunicationStatus
- DetailedStatus DetailedStatus
- OperatingStatus OperatingStatus
- PrimaryStatus PrimaryStatus
- JobStatus string
- TimeSubmitted time.Time
- ScheduledStartTime time.Time
- StartTime time.Time
- ElapsedTime time.Time
- JobRunTimes int
- RunMonth RunMonth
- RunDay int
- RunDayOfWeek RunDayOfWeek
- RunStartInterval time.Time
- LocalOrUtcTime LocalOrUtcTime
- Notify string
- Owner string
- Priority int
- PercentComplete int
- DeleteOnCompletion bool
- ErrorCode int
- ErrorDescription string
- RecoveryAction RecoveryAction
- OtherRecoveryAction string
-}
-type ConcreteJob struct {
- Job
- UntilTime time.Time
- JobState ConcreteJobState
- TimeOfLastStateChange time.Time
- TimeBeforeRemoval time.Time
-}
-type Processor struct {
- LogicalDevice
- Role string
- Family int
- OtherFamilyDescription string
- UpgradeMethod UpgradeMethod
- MaxClockSpeed int
- CurrentClockSpeed int
- Stepping string
- CPUStatus CPUStatus
- ExternalBusClockSpeed int
-}
-type UpgradeMethod int
-
-const (
- UpgradeMethodOther UpgradeMethod = iota + 1
- UpgradeMethodUnknown
- UpgradeMethodDaughterBoard
- UpgradeMethodZIFSocket
- UpgradeMethodReplacementPiggyBack
- UpgradeMethodNone
- UpgradeMethodLIFSocket
- UpgradeMethodSlot1
- UpgradeMethodSlot2
- UpgradeMethod370PinSocket
- UpgradeMethodSlotA
- UpgradeMethodSlotM
- UpgradeMethodSocket423
- UpgradeMethodSocketA
- UpgradeMethodSocket478
- UpgradeMethodSocket754
- UpgradeMethodSocket940
- UpgradeMethodSocket939
- UpgradeMethodSocketmPGA604
- UpgradeMethodSocketLGA771
- UpgradeMethodSocketLGA775
- UpgradeMethodSocketS1
- UpgradeMethodSocketAM2
- UpgradeMethodSocketF1207
- UpgradeMethodSocketLGA1366
- UpgradeMethodSocketG34
- UpgradeMethodSocketAM3
- UpgradeMethodSocketC32
- UpgradeMethodSocketLGA1156
- UpgradeMethodSocketLGA1567
- UpgradeMethodSocketPGA988A
- UpgradeMethodSocketBGA1288
- UpgradeMethodrPGA988B
- UpgradeMethodBGA1023
- UpgradeMethodBGA1224
- UpgradeMethodLGA1155
- UpgradeMethodLGA1356
- UpgradeMethodLGA2011
- UpgradeMethodSocketFS1
- UpgradeMethodSocketFS2
- UpgradeMethodSocketFM1
- UpgradeMethodSocketFM2
- UpgradeMethodSocketLGA20113
- UpgradeMethodSocketLGA13563
- UpgradeMethodSocketLGA1150
- UpgradeMethodSocketBGA1168
- UpgradeMethodSocketBGA1234
- UpgradeMethodSocketBGA1364
- UpgradeMethodSocketAM4
- UpgradeMethodSocketLGA1151
- UpgradeMethodSocketBGA1356
- UpgradeMethodSocketBGA1440
- UpgradeMethodSocketBGA1515
- UpgradeMethodSocketLGA36471
- UpgradeMethodSocketSP3
- UpgradeMethodSocketSP3r2
- UpgradeMethodSocketLGA2066
- UpgradeMethodSocketBGA1392
- UpgradeMethodSocketBGA1510
- UpgradeMethodSocketBGA1528
- UpgradeMethodSocketLGA4189
- UpgradeMethodSocketLGA1200
- UpgradeMethodSocketLGA4677
- UpgradeMethodSocketLGA1700
- UpgradeMethodSocketBGA1744
- UpgradeMethodSocketBGA1781
- UpgradeMethodSocketBGA1211
- UpgradeMethodSocketBGA2422
- UpgradeMethodSocketLGA1211
- UpgradeMethodSocketLGA2422
- UpgradeMethodSocketLGA5773
- UpgradeMethodSocketBGA5773
-)
-
-type CPUStatus int
-
-const (
- CPUStatusUnknown CPUStatus = iota
- CPUStatusEnabled
- CPUStatusDisabledByUser
- CPUStatusDisabledByBIOS
- CPUStatusIdle
- CPUStatusOther
-)
-
-type ConcreteJobState int
-
-const (
- ConcreteJobStateNew ConcreteJobState = 2
- ConcreteJobStateStarting ConcreteJobState = 3
- ConcreteJobStateRunning ConcreteJobState = 4
- ConcreteJobStateSuspended ConcreteJobState = 5
- ConcreteJobStateShuttingDown ConcreteJobState = 6
- ConcreteJobStateCompleted ConcreteJobState = 7
- ConcreteJobStateTerminated ConcreteJobState = 8
- ConcreteJobStateKilled ConcreteJobState = 9
- ConcreteJobStateException ConcreteJobState = 10
- ConcreteJobStateService ConcreteJobState = 11
- ConcreteJobStateQueryPending ConcreteJobState = 12
-)
-
-type CommunicationStatus int
-
-const (
- UnknownCS CommunicationStatus = iota
- NotAvailableCS
- CommunicationOK
- LostCommunication
- NoContact
-)
-
-type DetailedStatus int
-
-const (
- NotAvailableDS DetailedStatus = iota
- NoAdditionalInformation
- Stressed
- PredictiveFailure
- NonRecoverableError
- SupportingEntityInError
-)
-
-type OperatingStatus int
-
-const (
- UnknownOS OperatingStatus = iota
- NotAvailableOS
- Servicing
- Starting
- Stopping
- Stopped
- Aborted
- Dormant
- Completed
- Migrating
- Emigrating
- Immigrating
- Snapshotting
- ShuttingDown
- InTest
- Transitioning
- InService
-)
-
-type PrimaryStatus int
-
-const (
- UnknownPS PrimaryStatus = iota
- OK
- Degraded
- ErrorPS
-)
-
-type RunMonth int
-
-const (
- January RunMonth = iota
- February
- March
- April
- May
- June
- July
- August
- September
- October
- November
- December
-)
-
-type RunDayOfWeek int
-
-const (
- SaturdayNegative RunDayOfWeek = iota - 7
- FridayNegative
- ThursdayNegative
- WednesdayNegative
- TuesdayNegative
- MondayNegative
- SundayNegative
- ExactDayOfMonth
- Sunday
- Monday
- Tuesday
- Wednesday
- Thursday
- Friday
- Saturday
-)
-
-type RecoveryAction int
-
-const (
- UnknownRA RecoveryAction = iota
- Other
- DoNotContinue
- ContinueWithNextJob
- RerunJob
- RunRecoveryJob
-)
-
-type LocalOrUtcTime int
-
-const (
- LocalTime LocalOrUtcTime = iota + 1
- UTCTime
-)
-
-type LogicalDevicePowerManagementCapabilitiesValues int
-
-const (
- LogicalDevicePowerManagementCapabilitiesUnknown LogicalDevicePowerManagementCapabilitiesValues = iota
- LogicalDevicePowerManagementCapabilitiesNotSupported
- LogicalDevicePowerManagementCapabilitiesDisabled
- LogicalDevicePowerManagementCapabilitiesEnabled
- LogicalDevicePowerManagementCapabilitiesPowerSavingModesEnteredAutomatically
- LogicalDevicePowerManagementCapabilitiesPowerStateSettable
- LogicalDevicePowerManagementCapabilitiesPowerCyclingSupported
- LogicalDevicePowerManagementCapabilitiesTimedPowerOnSupported
-)
-
-type LogicalDeviceAvailabilityValues int
-
-const (
- LogicalDeviceAvailabilityOther LogicalDeviceAvailabilityValues = iota + 1
- LogicalDeviceAvailabilityUnknown
- LogicalDeviceAvailabilityRunningFullPower
- LogicalDeviceAvailabilityWarning
- LogicalDeviceAvailabilityInTest
- LogicalDeviceAvailabilityNotApplicable
- LogicalDeviceAvailabilityPowerOff
- LogicalDeviceAvailabilityOffLine
- LogicalDeviceAvailabilityOffDuty
- LogicalDeviceAvailabilityDegraded
- LogicalDeviceAvailabilityNotInstalled
- LogicalDeviceAvailabilityInstallError
- LogicalDeviceAvailabilityPowerSaveUnknown
- LogicalDeviceAvailabilityPowerSaveLowPowerMode
- LogicalDeviceAvailabilityPowerSaveStandby
- LogicalDeviceAvailabilityPowerCycle
- LogicalDeviceAvailabilityPowerSaveWarning
- LogicalDeviceAvailabilityPaused
- LogicalDeviceAvailabilityNotReady
- LogicalDeviceAvailabilityNotConfigured
- LogicalDeviceAvailabilityQuiesced
-)
-
-type LogicalDeviceStatusInfoValues int
-
-const (
- LogicalDeviceStatusInfoOther LogicalDeviceStatusInfoValues = iota + 1
- LogicalDeviceStatusInfoUnknown
- LogicalDeviceStatusInfoEnabled
- LogicalDeviceStatusInfoDisabled
- LogicalDeviceStatusInfoNotApplicable
-)
-
-type LogicalDeviceAdditionalAvailabilityValues int
-
-const (
- LogicalDeviceAdditionalAvailabilityOther LogicalDeviceAdditionalAvailabilityValues = iota + 1
- LogicalDeviceAdditionalAvailabilityUnknown
- LogicalDeviceAdditionalAvailabilityRunningFullPower
- LogicalDeviceAdditionalAvailabilityWarning
- LogicalDeviceAdditionalAvailabilityInTest
- LogicalDeviceAdditionalAvailabilityNotApplicable
- LogicalDeviceAdditionalAvailabilityPowerOff
- LogicalDeviceAdditionalAvailabilityOffLine
- LogicalDeviceAdditionalAvailabilityOffDuty
- LogicalDeviceAdditionalAvailabilityDegraded
- LogicalDeviceAdditionalAvailabilityNotInstalled
- LogicalDeviceAdditionalAvailabilityInstallError
- LogicalDeviceAdditionalAvailabilityPowerSaveUnknown
- LogicalDeviceAdditionalAvailabilityPowerSaveLowPowerMode
- LogicalDeviceAdditionalAvailabilityPowerSaveStandby
- LogicalDeviceAdditionalAvailabilityPowerCycle
- LogicalDeviceAdditionalAvailabilityPowerSaveWarning
- LogicalDeviceAdditionalAvailabilityPaused
- LogicalDeviceAdditionalAvailabilityNotReady
- LogicalDeviceAdditionalAvailabilityNotConfigured
- LogicalDeviceAdditionalAvailabilityQuiesced
-)
-
-type Credential struct {
- ManagedElement
- Issued time.Time // The date and time when the credential was issued. Default is current time
- Expires time.Time // The date and time when the credential expires (and is not appropriate for use for authentication/authorization). Default is '99991231235959.999999+999'
-}
-
-type CredentialContext struct {
- ElementInContext Credential
- ElementProvidingContext ManagedElement
-}
-
-type ManagedSystemElement struct {
- ManagedElement
- InstallDate time.Time
- Name string
- OperationalStatus ManagedSystemElementOperationalStatus
- StatusDescriptions []string
- Status string
- HealthState ManagedSystemElementHealthState
-}
-
-type ServiceAvailableToElement struct {
- ServiceProvided ServiceProvider
- UserOfService UserOfService
-}
-
-type AssociationReference struct {
- Address string
- ReferenceParameters ReferenceParmetersNoNamespace
-}
-
-type ReferenceParmetersNoNamespace struct {
- ResourceURI string
- SelectorSet []SelectorNoNamespace `xml:"SelectorSet>Selector,omitempty"`
-}
-
-func (rp *ReferenceParmetersNoNamespace) HasSelector(name string, value string) bool {
- for _, selector := range rp.SelectorSet {
- if selector.Name == name && selector.Value == value {
- return true
- }
- }
- return false
-}
-func (rp *ReferenceParmetersNoNamespace) GetSelectorValue(name string) string {
- for _, selector := range rp.SelectorSet {
- if selector.Name == name {
- return selector.Value
- }
- }
- return ""
-}
-
-type SelectorNoNamespace struct {
- //XMLName xml.Name `xml:"Selector,omitempty"`
- Name string `xml:"Name,attr"`
- Value string `xml:",chardata"`
-}
-
-type ServiceProvider struct {
- Address string
- ReferenceParameters ReferenceParameters
-}
-
-type UserOfService struct {
- Address string
- ReferenceParameters ReferenceParameters
-}
-
-type ReferenceParameters struct {
- ResourceURI string `xml:"w:ResourceURI,omitempty"`
- SelectorSet SelectorSet `xml:"w:SelectorSet,omitempty"`
-}
-
-type ReferenceParameters_OUTPUT struct {
- ResourceURI string `xml:"ResourceURI,omitempty"`
- SelectorSet SelectorSet_OUTPUT `xml:"SelectorSet,omitempty"`
-}
-type SelectorSet_OUTPUT struct {
- XMLName xml.Name `xml:"SelectorSet,omitempty"`
- Selector []message.Selector_OUTPUT
-}
-
-type SelectorSet struct {
- XMLName xml.Name `xml:"w:SelectorSet,omitempty"`
- Selector []message.Selector
-}
-
-type AssociatedPowerManagementService struct {
- ServiceAvailableToElement
- CIMAssociatedPowerManagementService CIMAssociatedPowerManagementServiceItem
-}
-
-type CIMAssociatedPowerManagementServiceItem struct {
- ServiceAvailableToElement
- AvailableRequestedPowerStates []string
- PowerState string
-}
-
-type SoftwareIdentity struct {
- LogicalElement
- CIMSoftwareIdentity []CIMSoftwareIdentityItem
-}
-
-type CIMSoftwareIdentityItem struct {
- LogicalElement
- InstanceID string
- VersionString string
- IsEntity bool
-}
-
-type Log struct {
- EnabledLogicalElement
- MaxNumberOfRecords int
- CurrentNumberOfRecords int
- OverwritePolicy TypesLogOverwritePolicy
- LogState TypesLogLogState
-}
-
-type MessageLog struct {
- Log
- CreationClassName string
- Capabilities []TypesMessageLogCapabilitiesValues
- CapabilitiesDescriptions []string
- MaxLogSize int
- SizeOfHeader int
- HeaderFormat string
- MaxRecordSize int
- SizeOfRecordHeader int
- RecordHeaderFormat string
- OtherPolicyDescription string
- TimeWhenOutdated time.Time
- PercentageNearFull int
- LastChange TypesMessageLogLastChange
- TimeOfLastChange time.Time
- RecordLastChanged int
- IsFrozen bool
- CharacterSet TypesMessageLogCharacterSet
-}
-
-type TypesLogOverwritePolicy int
-
-const (
- TypesLogOverwritePolicyUnknown TypesLogOverwritePolicy = 0
- TypesLogOverwritePolicyWrapsWhenFull TypesLogOverwritePolicy = 2
- TypesLogOverwritePolicyNeverOverwrites TypesLogOverwritePolicy = 7
-)
-
-type TypesLogLogState int
-
-const (
- TypesLogLogStateUnknown TypesLogLogState = 0
- TypesLogLogStateNormal TypesLogLogState = 2
- TypesLogLogStateErasing TypesLogLogState = 3
- TypesLogLogStateNotApplicable TypesLogLogState = 4
-)
-
-type TypesMessageLogCapabilitiesValues int
-
-const (
- TypesMessageLogCapabilitiesUnknown TypesMessageLogCapabilitiesValues = iota
- TypesMessageLogCapabilitiesOther
- TypesMessageLogCapabilitiesWriteRecordSupported
- TypesMessageLogCapabilitiesDeleteRecordSupported
- TypesMessageLogCapabilitiesCanMoveBackwardInLog
- TypesMessageLogCapabilitiesFreezeLogSupported
- TypesMessageLogCapabilitiesClearLogSupported
- TypesMessageLogCapabilitiesSupportsAddressingByOrdinalRecordNumber
- TypesMessageLogCapabilitiesVariableLengthRecordsSupported
- TypesMessageLogCapabilitiesVariableFormatsForRecords
- TypesMessageLogCapabilitiesCanFlagRecordsForOverwrite
-)
-
-type TypesMessageLogLastChange int
-
-const (
- TypesMessageLogLastChangeUnknown TypesMessageLogLastChange = iota
- TypesMessageLogLastChangeAdd
- TypesMessageLogLastChangeDelete
- TypesMessageLogLastChangeModify
- TypesMessageLogLastChangeLogCleared
-)
-
-type TypesMessageLogCharacterSet int
-
-const (
- TypesMessageLogCharacterSetUnknown TypesMessageLogCharacterSet = iota
- TypesMessageLogCharacterSetOther
- TypesMessageLogCharacterSetASCII
- TypesMessageLogCharacterSetUnicode
- TypesMessageLogCharacterSetISO2022
- TypesMessageLogCharacterSetISO8859
- TypesMessageLogCharacterSetExtendedUNIXCode
- TypesMessageLogCharacterSetUTF8
- TypesMessageLogCharacterSetUCS2
- TypesMessageLogCharacterSetBitmappedData
- TypesMessageLogCharacterSetOctetString
- TypesMessageLogCharacterSetDefinedByIndividualRecords
-)
-
-// Define the enums for the respective fields as types
-type ManagedSystemElementOperationalStatus int
-
-const (
- ManagedSystemElementOperationalStatusUnknown ManagedSystemElementOperationalStatus = iota
- ManagedSystemElementOperationalStatusOther
- ManagedSystemElementOperationalStatusOk
- ManagedSystemElementOperationalStatusDegraded
- ManagedSystemElementOperationalStatusStressed
- ManagedSystemElementOperationalStatusPredictiveFailure
- ManagedSystemElementOperationalStatusError
- ManagedSystemElementOperationalStatusNonRecoverableError
- ManagedSystemElementOperationalStatusStarting
- ManagedSystemElementOperationalStatusStopping
- ManagedSystemElementOperationalStatusStopped
- ManagedSystemElementOperationalStatusInService
- ManagedSystemElementOperationalStatusNoContact
- ManagedSystemElementOperationalStatusLostCommunication
- ManagedSystemElementOperationalStatusAborted
- ManagedSystemElementOperationalStatusDormant
- ManagedSystemElementOperationalStatusSupportingEntityInError
- ManagedSystemElementOperationalStatusCompleted
- ManagedSystemElementOperationalStatusPowerMode
- ManagedSystemElementOperationalStatusRelocating
-)
-
-type ManagedSystemElementHealthState int
-
-const (
- ManagedSystemElementHealthStateUnknown ManagedSystemElementHealthState = 0
- ManagedSystemElementHealthStateOk ManagedSystemElementHealthState = 5
- ManagedSystemElementHealthStateDegradedWarning ManagedSystemElementHealthState = 10
- ManagedSystemElementHealthStateMinorFailure ManagedSystemElementHealthState = 15
- ManagedSystemElementHealthStateMajorFailure ManagedSystemElementHealthState = 20
- ManagedSystemElementHealthStateCriticalFailure ManagedSystemElementHealthState = 25
- ManagedSystemElementHealthStateNonRecoverableFailure ManagedSystemElementHealthState = 30
-)
-
-// Define the enums for the respective fields as types
-type EnabledLogicalElementEnabledState int
-
-const (
- EnabledLogicalElementEnabledStateUnknown EnabledLogicalElementEnabledState = iota
- EnabledLogicalElementEnabledStateOther
- EnabledLogicalElementEnabledStateEnabled
- EnabledLogicalElementEnabledStateDisabled
- EnabledLogicalElementEnabledStateShuttingDown
- EnabledLogicalElementEnabledStateNotApplicable
- EnabledLogicalElementEnabledStateEnabledButOffline
- EnabledLogicalElementEnabledStateInTest
- EnabledLogicalElementEnabledStateDeferred
- EnabledLogicalElementEnabledStateQuiesce
- EnabledLogicalElementEnabledStateStarting
-)
-
-type EnabledLogicalElementRequestedState int
-
-const (
- EnabledLogicalElementRequestedStateUnknown EnabledLogicalElementRequestedState = iota
- _
- EnabledLogicalElementRequestedStateEnabled
- EnabledLogicalElementRequestedStateDisable
- EnabledLogicalElementRequestedStateShutDown
- EnabledLogicalElementRequestedStateNoChange
- EnabledLogicalElementRequestedStateOffline
- EnabledLogicalElementRequestedStateTest
- EnabledLogicalElementRequestedStateDeferred
- EnabledLogicalElementRequestedStateQuiesce
- EnabledLogicalElementRequestedStateReboot
- EnabledLogicalElementRequestedStateReset
- EnabledLogicalElementRequestedStateNotApplicable
-)
-
-type EnabledLogicalElementEnabledDefault int
-
-const (
- EnabledLogicalElementEnabledDefaultEnabled EnabledLogicalElementEnabledDefault = 2
- EnabledLogicalElementEnabledDefaultDisabled EnabledLogicalElementEnabledDefault = 3
- EnabledLogicalElementEnabledDefaultNotApplicable EnabledLogicalElementEnabledDefault = 5
- EnabledLogicalElementEnabledDefaultEnabledButOffline EnabledLogicalElementEnabledDefault = 6
- EnabledLogicalElementEnabledDefaultNoDefault EnabledLogicalElementEnabledDefault = 7
- EnabledLogicalElementEnabledDefaultQuiesce EnabledLogicalElementEnabledDefault = 9
-)
-
-type BSSType int
-type EncryptionMethod int
-type AuthenticationMethod int
-type BootConfigSettingInstanceID string
-type FailThroughSupported int
-type RemovalConditions int
-type MemoryType int
-type PackageType int
-type ServicePhilosophy int
-type SecurityBreach int
-type ChassisPackageType int
-type SoftwareElementState int
-type TargetOperatingSystem int
-
-// ServerCertificateNameComparison represents the ServerCertificateNameComparison type for IEEE8021xProfile.
-type ServerCertificateNameComparison int
-
-const (
- BSSType_Unknown BSSType = 0
- BSSType_Independent BSSType = 2
- BSSType_Infrastructure BSSType = 3
-
- EncryptionMethod_Other EncryptionMethod = 1
- EncryptionMethod_WEP EncryptionMethod = 2
- EncryptionMethod_TKIP EncryptionMethod = 3
- EncryptionMethod_CCMP EncryptionMethod = 4
- EncryptionMethod_None EncryptionMethod = 5
- EncryptionMethod_DMTFReserved EncryptionMethod = 6
-
- AuthenticationMethod_Other AuthenticationMethod = 1
- AuthenticationMethod_OpenSystem AuthenticationMethod = 2
- AuthenticationMethod_SharedKey AuthenticationMethod = 3
- AuthenticationMethod_WPA_PSK AuthenticationMethod = 4
- AuthenticationMethod_WPA_IEEE8021x AuthenticationMethod = 5
- AuthenticationMethod_WPA2_PSK AuthenticationMethod = 6
- AuthenticationMethod_WPA2_IEEE8021x AuthenticationMethod = 7
- AuthenticationMethod_DMTFReserved AuthenticationMethod = 8
- AuthenticationMethod_WPA3_SAE AuthenticationMethod = 32768
- AuthenticationMethod_WPA3_OWE AuthenticationMethod = 32769
- AuthenticationMethod_VendorReserved AuthenticationMethod = 32770
-)
-
-const (
- ForceHardDriveBoot BootConfigSettingInstanceID = "Intel(r) AMT: Force Hard-drive Boot"
- ForceCD_DVDBoot BootConfigSettingInstanceID = "Intel(r) AMT: Force CD/DVD Boot"
- ForcePXEBoot BootConfigSettingInstanceID = "Intel(r) AMT: Force PXE Boot"
- ForceOCRUEFIHTTPSBoot BootConfigSettingInstanceID = "Intel(r) AMT: Force OCR UEFI HTTPS Boot"
- ForceOCRUEFIBootOption1 BootConfigSettingInstanceID = "Intel(r) AMT: Force OCR UEFI Boot Option 1"
- ForceOCRUEFIBootOption2 BootConfigSettingInstanceID = "Intel(r) AMT: Force OCR UEFI Boot Option 2"
- ForceOCRUEFIBootOption3 BootConfigSettingInstanceID = "Intel(r) AMT: Force OCR UEFI Boot Option 3"
- ForceOCRUEFIBootOption4 BootConfigSettingInstanceID = "Intel(r) AMT: Force OCR UEFI Boot Option 4"
- ForceOCRUEFIBootOption5 BootConfigSettingInstanceID = "Intel(r) AMT: Force OCR UEFI Boot Option 5"
- ForceOCRUEFIBootOption6 BootConfigSettingInstanceID = "Intel(r) AMT: Force OCR UEFI Boot Option 6"
- ForceOCRUEFIBootOption7 BootConfigSettingInstanceID = "Intel(r) AMT: Force OCR UEFI Boot Option 7"
- ForceOCRUEFIBootOption8 BootConfigSettingInstanceID = "Intel(r) AMT: Force OCR UEFI Boot Option 8"
- ForceOCRUEFIBootOption9 BootConfigSettingInstanceID = "Intel(r) AMT: Force OCR UEFI Boot Option 9"
- ForceOCRUEFIBootOption10 BootConfigSettingInstanceID = "Intel(r) AMT: Force OCR UEFI Boot Option 10"
-)
-const (
- RemovalConditions_Unknown RemovalConditions = 0
- RemovalConditions_NotApplicable RemovalConditions = 2
- RemovalConditions_RemovableWhenOff RemovalConditions = 3
- RemovalConditions_RemovableWhenOnOrOff RemovalConditions = 4
-)
-
-const (
- FailThroughSupportedUnknown FailThroughSupported = iota
- IsSupported
- NotSupported
-)
-
-// PowerState represents the PowerState type in the PowerManagementService namespace.
diff --git a/pkg/cim/physical/card.go b/pkg/cim/physical/card.go
deleted file mode 100644
index b90f03bb..00000000
--- a/pkg/cim/physical/card.go
+++ /dev/null
@@ -1,38 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package physical
-
-import (
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
-)
-
-type Card struct {
- base message.Base
-}
-
-const CIM_Card = "CIM_Card"
-
-// NewCard returns a new instance of the Card struct.
-func NewCard(wsmanMessageCreator *message.WSManMessageCreator) Card {
- return Card{
- base: message.NewBase(wsmanMessageCreator, string(CIM_Card)),
- }
-}
-
-// Get retrieves the representation of the instance
-func (b Card) Get() string {
- return b.base.Get(nil)
-}
-
-// Enumerates the instances of this class
-func (b Card) Enumerate() string {
- return b.base.Enumerate()
-}
-
-// Pulls instances of this class, following an Enumerate operation
-func (b Card) Pull(enumerationContext string) string {
- return b.base.Pull(enumerationContext)
-}
diff --git a/pkg/cim/physical/card_test.go b/pkg/cim/physical/card_test.go
deleted file mode 100644
index cb7f651a..00000000
--- a/pkg/cim/physical/card_test.go
+++ /dev/null
@@ -1,50 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package physical
-
-import (
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestCard(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewCard(wsmanMessageCreator)
-
- t.Run("cim_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid cim_Card Get wsman message", "CIM_Card", wsmantesting.GET, "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid cim_Card Enumerate wsman message", "CIM_Card", wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid cim_Card Pull wsman message", "CIM_Card", wsmantesting.PULL, wsmantesting.PULL_BODY, func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-}
diff --git a/pkg/cim/physical/chassis.go b/pkg/cim/physical/chassis.go
deleted file mode 100644
index 011cd9b8..00000000
--- a/pkg/cim/physical/chassis.go
+++ /dev/null
@@ -1,38 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package physical
-
-import (
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
-)
-
-type Chassis struct {
- base message.Base
-}
-
-const CIM_Chassis = "CIM_Chassis"
-
-// NewChassis returns a new instance of the Chassis struct.
-func NewChassis(wsmanMessageCreator *message.WSManMessageCreator) Chassis {
- return Chassis{
- base: message.NewBase(wsmanMessageCreator, string(CIM_Chassis)),
- }
-}
-
-// Get retrieves the representation of the instance
-func (b Chassis) Get() string {
- return b.base.Get(nil)
-}
-
-// Enumerates the instances of this class
-func (b Chassis) Enumerate() string {
- return b.base.Enumerate()
-}
-
-// Pulls instances of this class, following an Enumerate operation
-func (b Chassis) Pull(enumerationContext string) string {
- return b.base.Pull(enumerationContext)
-}
diff --git a/pkg/cim/physical/chassis_test.go b/pkg/cim/physical/chassis_test.go
deleted file mode 100644
index 88f3205c..00000000
--- a/pkg/cim/physical/chassis_test.go
+++ /dev/null
@@ -1,50 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package physical
-
-import (
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestChassis(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewChassis(wsmanMessageCreator)
-
- t.Run("cim_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid cim_Chassis Get wsman message", "CIM_Chassis", wsmantesting.GET, "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid cim_Chassis Enumerate wsman message", "CIM_Chassis", wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid cim_Chassis Pull wsman message", "CIM_Chassis", wsmantesting.PULL, wsmantesting.PULL_BODY, func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-}
diff --git a/pkg/cim/physical/chip.go b/pkg/cim/physical/chip.go
deleted file mode 100644
index 870f7b94..00000000
--- a/pkg/cim/physical/chip.go
+++ /dev/null
@@ -1,38 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package physical
-
-import (
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
-)
-
-type Chip struct {
- base message.Base
-}
-
-const CIM_Chip = "CIM_Chip"
-
-// NewChip returns a new instance of the Chip struct.
-func NewChip(wsmanMessageCreator *message.WSManMessageCreator) Chip {
- return Chip{
- base: message.NewBase(wsmanMessageCreator, string(CIM_Chip)),
- }
-}
-
-// Get retrieves the representation of the instance
-func (b Chip) Get() string {
- return b.base.Get(nil)
-}
-
-// Enumerates the instances of this class
-func (b Chip) Enumerate() string {
- return b.base.Enumerate()
-}
-
-// Pulls instances of this class, following an Enumerate operation
-func (b Chip) Pull(enumerationContext string) string {
- return b.base.Pull(enumerationContext)
-}
diff --git a/pkg/cim/physical/chip_test.go b/pkg/cim/physical/chip_test.go
deleted file mode 100644
index 9d12e9ad..00000000
--- a/pkg/cim/physical/chip_test.go
+++ /dev/null
@@ -1,50 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package physical
-
-import (
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestChip(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewChip(wsmanMessageCreator)
-
- t.Run("cim_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid cim_Chip Get wsman message", "CIM_Chip", wsmantesting.GET, "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid cim_Chip Enumerate wsman message", "CIM_Chip", wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid cim_Chip Pull wsman message", "CIM_Chip", wsmantesting.PULL, wsmantesting.PULL_BODY, func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-}
diff --git a/pkg/cim/physical/memory.go b/pkg/cim/physical/memory.go
deleted file mode 100644
index d9c57620..00000000
--- a/pkg/cim/physical/memory.go
+++ /dev/null
@@ -1,38 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package physical
-
-import (
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
-)
-
-type Memory struct {
- base message.Base
-}
-
-const CIM_PhysicalMemory = "CIM_PhysicalMemory"
-
-// NewPhysicalMemory returns a new instance of the PhysicalMemory struct.
-func NewPhysicalMemory(wsmanMessageCreator *message.WSManMessageCreator) Memory {
- return Memory{
- base: message.NewBase(wsmanMessageCreator, string(CIM_PhysicalMemory)),
- }
-}
-
-// Get retrieves the representation of the instance
-func (b Memory) Get() string {
- return b.base.Get(nil)
-}
-
-// Enumerates the instances of this class
-func (b Memory) Enumerate() string {
- return b.base.Enumerate()
-}
-
-// Pulls instances of this class, following an Enumerate operation
-func (b Memory) Pull(enumerationContext string) string {
- return b.base.Pull(enumerationContext)
-}
diff --git a/pkg/cim/physical/memory_test.go b/pkg/cim/physical/memory_test.go
deleted file mode 100644
index 8d2c58d2..00000000
--- a/pkg/cim/physical/memory_test.go
+++ /dev/null
@@ -1,50 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package physical
-
-import (
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestMemory(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewPhysicalMemory(wsmanMessageCreator)
-
- t.Run("cim_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid cim_PhysicalMemory Get wsman message", "CIM_PhysicalMemory", wsmantesting.GET, "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid cim_PhysicalMemory Enumerate wsman message", "CIM_PhysicalMemory", wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid cim_PhysicalMemory Pull wsman message", "CIM_PhysicalMemory", wsmantesting.PULL, wsmantesting.PULL_BODY, func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-}
diff --git a/pkg/cim/physical/package.go b/pkg/cim/physical/package.go
deleted file mode 100644
index e4f4974f..00000000
--- a/pkg/cim/physical/package.go
+++ /dev/null
@@ -1,38 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package physical
-
-import (
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
-)
-
-type Package struct {
- base message.Base
-}
-
-const CIM_PhysicalPackage = "CIM_PhysicalPackage"
-
-// NewPhysicalPackage returns a new instance of the PhysicalPackage struct.
-func NewPhysicalPackage(wsmanMessageCreator *message.WSManMessageCreator) Package {
- return Package{
- base: message.NewBase(wsmanMessageCreator, string(CIM_PhysicalPackage)),
- }
-}
-
-// Get retrieves the representation of the instance
-func (b Package) Get() string {
- return b.base.Get(nil)
-}
-
-// Enumerates the instances of this class
-func (b Package) Enumerate() string {
- return b.base.Enumerate()
-}
-
-// Pulls instances of this class, following an Enumerate operation
-func (b Package) Pull(enumerationContext string) string {
- return b.base.Pull(enumerationContext)
-}
diff --git a/pkg/cim/physical/package_test.go b/pkg/cim/physical/package_test.go
deleted file mode 100644
index bce7920e..00000000
--- a/pkg/cim/physical/package_test.go
+++ /dev/null
@@ -1,50 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package physical
-
-import (
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestPackage(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewPhysicalPackage(wsmanMessageCreator)
-
- t.Run("cim_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid cim_PhysicalPackage Get wsman message", "CIM_PhysicalPackage", wsmantesting.GET, "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid cim_PhysicalPackage Enumerate wsman message", "CIM_PhysicalPackage", wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid cim_PhysicalPackage Pull wsman message", "CIM_PhysicalPackage", wsmantesting.PULL, wsmantesting.PULL_BODY, func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-}
diff --git a/pkg/cim/physical/processor.go b/pkg/cim/physical/processor.go
deleted file mode 100644
index 3a214ec2..00000000
--- a/pkg/cim/physical/processor.go
+++ /dev/null
@@ -1,38 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package physical
-
-import (
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
-)
-
-type Processor struct {
- base message.Base
-}
-
-const CIM_Processor = "CIM_Processor"
-
-// NewProcessor returns a new instance of the Processor struct.
-func NewProcessor(wsmanMessageCreator *message.WSManMessageCreator) Processor {
- return Processor{
- base: message.NewBase(wsmanMessageCreator, string(CIM_Processor)),
- }
-}
-
-// Get retrieves the representation of the instance
-func (b Processor) Get() string {
- return b.base.Get(nil)
-}
-
-// Enumerates the instances of this class
-func (b Processor) Enumerate() string {
- return b.base.Enumerate()
-}
-
-// Pulls instances of this class, following an Enumerate operation
-func (b Processor) Pull(enumerationContext string) string {
- return b.base.Pull(enumerationContext)
-}
diff --git a/pkg/cim/physical/processor_test.go b/pkg/cim/physical/processor_test.go
deleted file mode 100644
index 9db06beb..00000000
--- a/pkg/cim/physical/processor_test.go
+++ /dev/null
@@ -1,50 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package physical
-
-import (
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestProcessor(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewProcessor(wsmanMessageCreator)
-
- t.Run("cim_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid cim_Processor Get wsman message", "CIM_Processor", wsmantesting.GET, "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid cim_Processor Enumerate wsman message", "CIM_Processor", wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid cim_Processor Pull wsman message", "CIM_Processor", wsmantesting.PULL, wsmantesting.PULL_BODY, func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-}
diff --git a/pkg/cim/power/managementservice.go b/pkg/cim/power/managementservice.go
deleted file mode 100644
index 8c65ff48..00000000
--- a/pkg/cim/power/managementservice.go
+++ /dev/null
@@ -1,97 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package power
-
-import (
- "fmt"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/cim/actions"
-)
-
-type PowerState int
-
-const (
- // Power On
- PowerOn PowerState = 2 + iota
-
- // Sleep - Light
- SleepLight
-
- // Sleep - Deep
- SleepDeep
-
- // Power Cycle (Off Soft)
- PowerCycleOffSoft
-
- // Power Off - Hard
- PowerOffHard
-
- // Hibernate
- Hibernate
-
- // Power Off - Soft
- PowerOffSoft
-
- // Power Cycle (Off Hard)
- PowerCycleOffHard
-
- // Master Bus Reset
- MasterBusReset
-
- // Diagnostic Interrupt (NMI)
- DiagnosticInterruptNMI
-
- // Power Off - Soft Graceful
- PowerOffSoftGraceful
-
- // Power Off - Hard Graceful
- PowerOffHardGraceful
-
- // Master Bus Reset Graceful
- MasterBusResetGraceful
-
- // Power Cycle (Off - Soft Graceful)
- PowerCycleOffSoftGraceful
-
- // Power Cycle (Off - Hard Graceful)
- PowerCycleOffHardGraceful
-)
-
-type ManagementService struct {
- base message.Base
-}
-
-const CIM_PowerManagementService = "CIM_PowerManagementService"
-
-// NewPowerManagementService returns a new instance of the PowerManagementService struct.
-func NewPowerManagementService(wsmanMessageCreator *message.WSManMessageCreator) ManagementService {
- return ManagementService{
- base: message.NewBase(wsmanMessageCreator, string(CIM_PowerManagementService)),
- }
-}
-
-// RequestPowerStateChange defines the desired power state of the managed element, and when the element should be put into that state.
-func (p ManagementService) RequestPowerStateChange(powerState PowerState) string {
- header := p.base.WSManMessageCreator.CreateHeader(string(actions.RequestPowerStateChange), string(CIM_PowerManagementService), nil, "", "")
- body := fmt.Sprintf(`%dhttp://schemas.xmlsoap.org/ws/2004/08/addressinghttp://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ComputerSystemCIM_ComputerSystemManagedSystem`, powerState)
- return p.base.WSManMessageCreator.CreateXML(header, body)
-}
-
-// Get retrieves the representation of the instance
-func (b ManagementService) Get() string {
- return b.base.Get(nil)
-}
-
-// Enumerates the instances of this class
-func (b ManagementService) Enumerate() string {
- return b.base.Enumerate()
-}
-
-// Pulls instances of this class, following an Enumerate operation
-func (b ManagementService) Pull(enumerationContext string) string {
- return b.base.Pull(enumerationContext)
-}
diff --git a/pkg/cim/power/managementservice_test.go b/pkg/cim/power/managementservice_test.go
deleted file mode 100644
index 4506e713..00000000
--- a/pkg/cim/power/managementservice_test.go
+++ /dev/null
@@ -1,54 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package power
-
-import (
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestPowerManagementService(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewPowerManagementService(wsmanMessageCreator)
-
- t.Run("cim_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid cim_PowerManagementService Get wsman message", "CIM_PowerManagementService", wsmantesting.GET, "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid cim_PowerManagementService Enumerate wsman message", "CIM_PowerManagementService", wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid cim_PowerManagementService Pull wsman message", "CIM_PowerManagementService", wsmantesting.PULL, wsmantesting.PULL_BODY, func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- {"Should create a valid cim_PowerManagementService ChangeBootOrder wsman message", "CIM_PowerManagementService", "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_PowerManagementService/RequestPowerStateChange", "8http://schemas.xmlsoap.org/ws/2004/08/addressinghttp://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ComputerSystemCIM_ComputerSystemManagedSystem", func() string {
- var powerState PowerState = PowerOffSoft
- return elementUnderTest.RequestPowerStateChange(powerState)
- }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-}
diff --git a/pkg/cim/service/availabletoelement.go b/pkg/cim/service/availabletoelement.go
deleted file mode 100644
index f27c7f97..00000000
--- a/pkg/cim/service/availabletoelement.go
+++ /dev/null
@@ -1,36 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package service
-
-import "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
-
-type AvailableToElement struct {
- base message.Base
-}
-
-const CIM_ServiceAvailableToElement = "CIM_ServiceAvailableToElement"
-
-// NewServiceAvailableToElement returns a new instance of the ServiceAvailableToElement struct.
-func NewServiceAvailableToElement(wsmanMessageCreator *message.WSManMessageCreator) AvailableToElement {
- return AvailableToElement{
- base: message.NewBase(wsmanMessageCreator, string(CIM_ServiceAvailableToElement)),
- }
-}
-
-// Get retrieves the representation of the instance
-func (b AvailableToElement) Get() string {
- return b.base.Get(nil)
-}
-
-// Enumerates the instances of this class
-func (b AvailableToElement) Enumerate() string {
- return b.base.Enumerate()
-}
-
-// Pulls instances of this class, following an Enumerate operation
-func (b AvailableToElement) Pull(enumerationContext string) string {
- return b.base.Pull(enumerationContext)
-}
diff --git a/pkg/cim/service/availabletoelement_test.go b/pkg/cim/service/availabletoelement_test.go
deleted file mode 100644
index c65ccac9..00000000
--- a/pkg/cim/service/availabletoelement_test.go
+++ /dev/null
@@ -1,50 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package service
-
-import (
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestAvailableToElement(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewServiceAvailableToElement(wsmanMessageCreator)
-
- t.Run("cim_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid cim_ServiceAvailableToElement Get wsman message", "CIM_ServiceAvailableToElement", wsmantesting.GET, "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid cim_ServiceAvailableToElement Enumerate wsman message", "CIM_ServiceAvailableToElement", wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid cim_ServiceAvailableToElement Pull wsman message", "CIM_ServiceAvailableToElement", wsmantesting.PULL, wsmantesting.PULL_BODY, func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-}
diff --git a/pkg/cim/software/idenity_test.go b/pkg/cim/software/idenity_test.go
deleted file mode 100644
index f81c1b24..00000000
--- a/pkg/cim/software/idenity_test.go
+++ /dev/null
@@ -1,50 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package software
-
-import (
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestIdentity(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewSoftwareIdentity(wsmanMessageCreator)
-
- t.Run("cim_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid cim_SoftwareIdentity Get wsman message", "CIM_SoftwareIdentity", wsmantesting.GET, "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid cim_SoftwareIdentity Enumerate wsman message", "CIM_SoftwareIdentity", wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid cim_SoftwareIdentity Pull wsman message", "CIM_SoftwareIdentity", wsmantesting.PULL, wsmantesting.PULL_BODY, func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-}
diff --git a/pkg/cim/software/identity.go b/pkg/cim/software/identity.go
deleted file mode 100644
index f69ea61e..00000000
--- a/pkg/cim/software/identity.go
+++ /dev/null
@@ -1,36 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package software
-
-import "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
-
-type Identity struct {
- base message.Base
-}
-
-const CIM_SoftwareIdentity = "CIM_SoftwareIdentity"
-
-// NewSoftwareIdentity returns a new instance of the SoftwareIdentity struct.
-func NewSoftwareIdentity(wsmanMessageCreator *message.WSManMessageCreator) Identity {
- return Identity{
- base: message.NewBase(wsmanMessageCreator, string(CIM_SoftwareIdentity)),
- }
-}
-
-// Get retrieves the representation of the instance
-func (b Identity) Get() string {
- return b.base.Get(nil)
-}
-
-// Enumerates the instances of this class
-func (b Identity) Enumerate() string {
- return b.base.Enumerate()
-}
-
-// Pulls instances of this class, following an Enumerate operation
-func (b Identity) Pull(enumerationContext string) string {
- return b.base.Pull(enumerationContext)
-}
diff --git a/pkg/cim/system/packaging.go b/pkg/cim/system/packaging.go
deleted file mode 100644
index 14d4537c..00000000
--- a/pkg/cim/system/packaging.go
+++ /dev/null
@@ -1,36 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package system
-
-import "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
-
-type Packaging struct {
- base message.Base
-}
-
-const CIM_SystemPackaging = "CIM_SystemPackaging"
-
-// NewSystemPackaging returns a new instance of the SystemPackaging struct.
-func NewSystemPackaging(wsmanMessageCreator *message.WSManMessageCreator) Packaging {
- return Packaging{
- base: message.NewBase(wsmanMessageCreator, string(CIM_SystemPackaging)),
- }
-}
-
-// Get retrieves the representation of the instance
-func (b Packaging) Get() string {
- return b.base.Get(nil)
-}
-
-// Enumerates the instances of this class
-func (b Packaging) Enumerate() string {
- return b.base.Enumerate()
-}
-
-// Pulls instances of this class, following an Enumerate operation
-func (b Packaging) Pull(enumerationContext string) string {
- return b.base.Pull(enumerationContext)
-}
diff --git a/pkg/cim/system/packaging_test.go b/pkg/cim/system/packaging_test.go
deleted file mode 100644
index 67ee2045..00000000
--- a/pkg/cim/system/packaging_test.go
+++ /dev/null
@@ -1,50 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package system
-
-import (
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestSystemPackaging(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewSystemPackaging(wsmanMessageCreator)
-
- t.Run("cim_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid cim_SystemPackaging Get wsman message", "CIM_SystemPackaging", wsmantesting.GET, "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid cim_SystemPackaging Enumerate wsman message", "CIM_SystemPackaging", wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid cim_SystemPackaging Pull wsman message", "CIM_SystemPackaging", wsmantesting.PULL, wsmantesting.PULL_BODY, func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-}
diff --git a/pkg/cim/wifi/endpointsettings.go b/pkg/cim/wifi/endpointsettings.go
deleted file mode 100644
index 43bb765a..00000000
--- a/pkg/cim/wifi/endpointsettings.go
+++ /dev/null
@@ -1,72 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package wifi
-
-import (
- "encoding/xml"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
-)
-
-type EndpointSettings struct {
- base message.Base
-}
-
-type PullResponseEnvelope struct {
- XMLName xml.Name `xml:"Envelope"`
- Header message.Header
- Body PullResponseBody
-}
-
-type PullResponseBody struct {
- PullResponse PullResponse
-}
-
-type PullResponse struct {
- Items []CIMWiFiEndpointSettings `xml:"Items>CIM_WiFiEndpointSettings"`
- EndOfSequence string `xml:"EndOfSequence"`
-}
-
-type CIMWiFiEndpointSettings struct {
- AuthenticationMethod int
- BSSType int
- ElementName string
- EncryptionMethod int
- InstanceID string
- Priority int
- SSID string
-}
-
-const CIM_WiFiEndpoint = "CIM_WiFiEndpoint"
-const CIM_WiFiEndpointSettings = "CIM_WiFiEndpointSettings"
-
-// NewWiFiEndpointSettings returns a new instance of the WiFiEndpointSettings struct.
-func NewWiFiEndpointSettings(wsmanMessageCreator *message.WSManMessageCreator) EndpointSettings {
- return EndpointSettings{
- base: message.NewBase(wsmanMessageCreator, string(CIM_WiFiEndpointSettings)),
- }
-}
-
-// Get retrieves the representation of the instance
-func (b EndpointSettings) Get() string {
- return b.base.Get(nil)
-}
-
-// Enumerates the instances of this class
-func (b EndpointSettings) Enumerate() string {
- return b.base.Enumerate()
-}
-
-// Pulls instances of this class, following an Enumerate operation
-func (b EndpointSettings) Pull(enumerationContext string) string {
- return b.base.Pull(enumerationContext)
-}
-
-// Delete removes a the specified instance
-func (b EndpointSettings) Delete(handle string) string {
- selector := message.Selector{Name: "InstanceID", Value: handle}
- return b.base.Delete(selector)
-}
diff --git a/pkg/cim/wifi/endpointsettings_test.go b/pkg/cim/wifi/endpointsettings_test.go
deleted file mode 100644
index 8134a037..00000000
--- a/pkg/cim/wifi/endpointsettings_test.go
+++ /dev/null
@@ -1,51 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package wifi
-
-import (
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestWifiEndpointSettings(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewWiFiEndpointSettings(wsmanMessageCreator)
-
- t.Run("cim_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- extraHeader string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid cim_WiFiEndpointSettings Get wsman message", "CIM_WiFiEndpointSettings", wsmantesting.GET, "", "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid cim_WiFiEndpointSettings Enumerate wsman message", "CIM_WiFiEndpointSettings", wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, "", elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid cim_WiFiEndpointSettings Pull wsman message", "CIM_WiFiEndpointSettings", wsmantesting.PULL, wsmantesting.PULL_BODY, "", func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- //DELETE
- {"should create a valid cim_WiFiEndpointSettings Delete wsman message", "CIM_WiFiEndpointSettings", wsmantesting.DELETE, "", "instanceID123", func() string { return elementUnderTest.Delete("instanceID123") }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, test.extraHeader, test.body)
- messageID++
- response := test.responseFunc()
- assert.Equal(t, correctResponse, response)
- })
- }
- })
-}
diff --git a/pkg/cim/wifi/port.go b/pkg/cim/wifi/port.go
deleted file mode 100644
index 42fe9dc9..00000000
--- a/pkg/cim/wifi/port.go
+++ /dev/null
@@ -1,59 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package wifi
-
-import (
- "encoding/xml"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/cim/actions"
-)
-
-type Port struct {
- base message.Base
-}
-type RequestStateChangeResponse struct {
- XMLName xml.Name `xml:"Envelope"`
- Header message.Header `xml:"Header"`
- Body RequestStateChangeBody `xml:"Body"`
-}
-type RequestStateChangeBody struct {
- XMLName xml.Name `xml:"Body"`
- RequestStateChange_OUTPUT RequestStateChange_OUTPUT `xml:"RequestStateChange_OUTPUT"`
-}
-type RequestStateChange_OUTPUT struct {
- XMLName xml.Name `xml:"RequestStateChange_OUTPUT"`
- ReturnValue int
-}
-
-const CIM_WiFiPort = "CIM_WiFiPort"
-
-// NewWiFiPort returns a new instance of the WiFiPort struct.
-func NewWiFiPort(wsmanMessageCreator *message.WSManMessageCreator) Port {
- return Port{
- base: message.NewBase(wsmanMessageCreator, string(CIM_WiFiPort)),
- }
-}
-
-// RequestStateChange requests that the state of the element be changed to the value specified in the RequestedState parameter . . .
-func (w Port) RequestStateChange(requestedState int) string {
- return w.base.RequestStateChange(actions.RequestStateChange(string(CIM_WiFiPort)), requestedState)
-}
-
-// Get retrieves the representation of the instance
-func (b Port) Get() string {
- return b.base.Get(nil)
-}
-
-// Enumerates the instances of this class
-func (b Port) Enumerate() string {
- return b.base.Enumerate()
-}
-
-// Pulls instances of this class, following an Enumerate operation
-func (b Port) Pull(enumerationContext string) string {
- return b.base.Pull(enumerationContext)
-}
diff --git a/pkg/cim/wifi/port_test.go b/pkg/cim/wifi/port_test.go
deleted file mode 100644
index 7409afb5..00000000
--- a/pkg/cim/wifi/port_test.go
+++ /dev/null
@@ -1,51 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package wifi
-
-import (
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestWifiPort(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewWiFiPort(wsmanMessageCreator)
-
- t.Run("cim_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid cim_WiFiPort Get wsman message", "CIM_WiFiPort", wsmantesting.GET, "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid cim_WiFiPort Enumerate wsman message", "CIM_WiFiPort", wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid cim_WiFiPort Pull wsman message", "CIM_WiFiPort", wsmantesting.PULL, wsmantesting.PULL_BODY, func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- {"should create a valid cim_WiFiPort Request State Change wsman message", "CIM_WiFiPort", "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_WiFiPort/RequestStateChange", "3", func() string { return elementUnderTest.RequestStateChange(3) }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-}
diff --git a/pkg/common/messages.go b/pkg/common/messages.go
deleted file mode 100644
index 189b2580..00000000
--- a/pkg/common/messages.go
+++ /dev/null
@@ -1,21 +0,0 @@
-package common
-
-import (
- "encoding/xml"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
-)
-
-type EnumerationResponse struct {
- XMLName xml.Name `xml:"Envelope"`
- Header message.Header
- Body EnumerationBody
-}
-
-type EnumerationBody struct {
- EnumerateResponse EnumerateResponse
-}
-
-type EnumerateResponse struct {
- EnumerationContext string
-}
diff --git a/pkg/ips/actions/constants.go b/pkg/ips/actions/constants.go
deleted file mode 100644
index e615cbe9..00000000
--- a/pkg/ips/actions/constants.go
+++ /dev/null
@@ -1,24 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package actions
-
-type Actions string
-
-const (
- Enumerate Actions = "http://schemas.xmlsoap.org/ws/2004/09/enumeration/Enumerate"
- Pull Actions = "http://schemas.xmlsoap.org/ws/2004/09/enumeration/Pull"
- Get Actions = "http://schemas.xmlsoap.org/ws/2004/09/transfer/Get"
- Put Actions = "http://schemas.xmlsoap.org/ws/2004/09/transfer/Put"
- Delete Actions = "http://schemas.xmlsoap.org/ws/2004/09/transfeeleteete"
- Setup Actions = "http://intel.com/wbem/wscim/1/ips-schema/1/IPS_HostBasedSetupService/Setup"
- AdminSetup Actions = "http://intel.com/wbem/wscim/1/ips-schema/1/IPS_HostBasedSetupService/AdminSetup"
- AddNextCertInChain Actions = "http://intel.com/wbem/wscim/1/ips-schema/1/IPS_HostBasedSetupService/AddNextCertInChain"
- UpgradeClientToAdmin Actions = "http://intel.com/wbem/wscim/1/ips-schema/1/IPS_HostBasedSetupService/UpgradeClientToAdmin"
- StartOptIn Actions = "http://intel.com/wbem/wscim/1/ips-schema/1/IPS_OptInService/StartOptIn"
- CancelOptIn Actions = "http://intel.com/wbem/wscim/1/ips-schema/1/IPS_OptInService/CancelOptIn"
- SendOptInCode Actions = "http://intel.com/wbem/wscim/1/ips-schema/1/IPS_OptInService/SendOptInCode"
- SetCertificates Actions = "http://intel.com/wbem/wscim/1/ips-schema/1/IPS_IEEE8021xSettings/SetCertificates"
-)
diff --git a/pkg/ips/alarmclock/occurrence.go b/pkg/ips/alarmclock/occurrence.go
deleted file mode 100644
index a807ca44..00000000
--- a/pkg/ips/alarmclock/occurrence.go
+++ /dev/null
@@ -1,42 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package alarmclock
-
-import "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
-
-type Occurrence struct {
- base message.Base
-}
-
-const IPS_AlarmClockOccurrence = "IPS_AlarmClockOccurrence"
-
-// NewAlarmClockOccurrence returns a new instance of the AlarmClockOccurrence struct.
-func NewAlarmClockOccurrence(wsmanMessageCreator *message.WSManMessageCreator) Occurrence {
- return Occurrence{
- base: message.NewBase(wsmanMessageCreator, IPS_AlarmClockOccurrence),
- }
-}
-
-// Get retrieves the representation of the instance
-func (a Occurrence) Get() string {
- return a.base.Get(nil)
-}
-
-// Delete removes a the specified instance
-func (a Occurrence) Delete(handle string) string {
- selector := message.Selector{Name: "Name", Value: handle}
- return a.base.Delete(selector)
-}
-
-// Enumerates the instances of this class
-func (a Occurrence) Enumerate() string {
- return a.base.Enumerate()
-}
-
-// Pulls instances of this class, following an Enumerate operation
-func (a Occurrence) Pull(enumerationContext string) string {
- return a.base.Pull(enumerationContext)
-}
diff --git a/pkg/ips/alarmclock/occurrence_test.go b/pkg/ips/alarmclock/occurrence_test.go
deleted file mode 100644
index 8827641c..00000000
--- a/pkg/ips/alarmclock/occurrence_test.go
+++ /dev/null
@@ -1,55 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package alarmclock
-
-import (
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestIPS_AlarmClockOccurrence(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://intel.com/wbem/wscim/1/ips-schema/1/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewAlarmClockOccurrence(wsmanMessageCreator)
-
- t.Run("amt_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- extraHeader string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid ips_AlarmClockOccurrence Get wsman message", "IPS_AlarmClockOccurrence", wsmantesting.GET, "", "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid IPS_AlarmClockOccurrence Enumerate wsman message", "IPS_AlarmClockOccurrence", wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, "", elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid IPS_AlarmClockOccurrence Pull wsman message", "IPS_AlarmClockOccurrence", wsmantesting.PULL, wsmantesting.PULL_BODY, "", func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- // DELETE
- {"should create a valid ips_AlarmClockOccurrence Delete wsman message", "IPS_AlarmClockOccurrence", wsmantesting.DELETE, "", "Instance", func() string {
- return elementUnderTest.Delete("Instance")
- }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, test.extraHeader, test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-}
diff --git a/pkg/ips/hostbasedsetup/service.go b/pkg/ips/hostbasedsetup/service.go
deleted file mode 100644
index 8b44c6d0..00000000
--- a/pkg/ips/hostbasedsetup/service.go
+++ /dev/null
@@ -1,190 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package hostbasedsetup
-
-import (
- "crypto/md5"
- "encoding/xml"
- "fmt"
- "io"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/ips/actions"
-)
-
-type Response struct {
- XMLName xml.Name `xml:"Envelope"`
- Header message.Header `xml:"Header"`
- Body Body `xml:"Body"`
-}
-
-type Body struct {
- XMLName xml.Name `xml:"Body"`
- Setup_OUTPUT Setup_OUTPUT `xml:"Setup_OUTPUT"`
- AdminSetup_OUTPUT AdminSetup_OUTPUT `xml:"AdminSetup_OUTPUT"`
- AddNextCertInChain_OUTPUT AddNextCertInChain_OUTPUT `xml:"AddNextCertInChain_OUTPUT"`
- IPS_HostBasedSetupService HostBasedSetupService `xml:"IPS_HostBasedSetupService"`
-}
-
-type HostBasedSetupService struct {
- XMLName xml.Name `xml:"IPS_HostBasedSetupService"`
- ElementName string
- SystemCreationClassName string
- SystemName string
- CreationClassName string
- Name string
- CurrentControlMode int
- AllowedControlModes int
- ConfigurationNonce string
- CertChainStatus int
-}
-
-type AdminPassEncryptionType int
-
-const (
- AdminPassEncryptionTypeNone AdminPassEncryptionType = iota
- AdminPassEncryptionTypeOther
- AdminPassEncryptionTypeHTTPDigestMD5A1
-)
-
-type SigningAlgorithm int
-
-const (
- SigningAlgorithmNone SigningAlgorithm = iota
- SigningAlgorithmOther
- SigningAlgorithmRSASHA2256
-)
-
-type Service struct {
- base message.Base
-}
-
-const IPS_HostBasedSetupService = "IPS_HostBasedSetupService"
-
-// NewHostBasedSetupService returns a new instance of the HostBasedSetupService struct.
-func NewHostBasedSetupService(wsmanMessageCreator *message.WSManMessageCreator) Service {
- return Service{
- base: message.NewBase(wsmanMessageCreator, string(IPS_HostBasedSetupService)),
- }
-}
-
-// Get retrieves the representation of the instance
-func (b Service) Get() string {
- return b.base.Get(nil)
-}
-
-// Enumerates the instances of this class
-func (b Service) Enumerate() string {
- return b.base.Enumerate()
-}
-
-// Pulls instances of this class, following an Enumerate operation
-func (b Service) Pull(enumerationContext string) string {
- return b.base.Pull(enumerationContext)
-}
-
-type AddNextCertInChain struct {
- XMLName xml.Name `xml:"h:AddNextCertInChain_INPUT"`
- H string `xml:"xmlns:h,attr"`
- NextCertificate string `xml:"h:NextCertificate"`
- IsLeafCertificate bool `xml:"h:IsLeafCertificate"`
- IsRootCertificate bool `xml:"h:IsRootCertificate"`
-}
-
-type AddNextCertInChain_OUTPUT struct {
- ReturnValue int
-}
-
-// Add a certificate to the provisioning certificate chain, to be used by AdminSetup or UpgradeClientToAdmin methods.
-func (b Service) AddNextCertInChain(cert string, isLeaf bool, isRoot bool) string {
- header := b.base.WSManMessageCreator.CreateHeader(string(actions.AddNextCertInChain), string(IPS_HostBasedSetupService), nil, "", "")
- body := b.base.WSManMessageCreator.CreateBody("AddNextCertInChain_INPUT", string(IPS_HostBasedSetupService), AddNextCertInChain{
- H: "http://intel.com/wbem/wscim/1/ips-schema/1/IPS_HostBasedSetupService",
- NextCertificate: cert,
- IsLeafCertificate: isLeaf,
- IsRootCertificate: isRoot,
- })
- return b.base.WSManMessageCreator.CreateXML(header, body)
-}
-
-type AdminSetup struct {
- XMLName xml.Name `xml:"h:AdminSetup_INPUT"`
- H string `xml:"xmlns:h,attr"`
- NetAdminPassEncryptionType int `xml:"h:NetAdminPassEncryptionType"`
- NetworkAdminPassword string `xml:"h:NetworkAdminPassword"`
- McNonce string `xml:"h:McNonce"`
- SigningAlgorithm int `xml:"h:SigningAlgorithm"`
- DigitalSignature string `xml:"h:DigitalSignature"`
-}
-
-type AdminSetup_OUTPUT struct {
- ReturnValue int
-}
-
-// Setup Intel(R) AMT from the local host, resulting in Admin Setup Mode. Requires OS administrator rights, and moves Intel(R) AMT from "Pre Provisioned" state to "Post Provisioned" state. The control mode after this method is run will be "Admin".
-func (b Service) AdminSetup(adminPassEncryptionType AdminPassEncryptionType, digestRealm string, adminPassword string, mcNonce string, signingAlgorithm SigningAlgorithm, digitalSignature string) string {
- hashInHex := createMD5Hash(adminPassword, digestRealm)
- header := b.base.WSManMessageCreator.CreateHeader(string(actions.AdminSetup), string(IPS_HostBasedSetupService), nil, "", "")
- body := b.base.WSManMessageCreator.CreateBody("AdminSetup_INPUT", string(IPS_HostBasedSetupService), AdminSetup{
- H: "http://intel.com/wbem/wscim/1/ips-schema/1/IPS_HostBasedSetupService",
- NetAdminPassEncryptionType: int(adminPassEncryptionType),
- NetworkAdminPassword: string(hashInHex),
- McNonce: mcNonce,
- SigningAlgorithm: int(signingAlgorithm),
- DigitalSignature: digitalSignature,
- })
- return b.base.WSManMessageCreator.CreateXML(header, body)
-}
-
-type Setup struct {
- XMLName xml.Name `xml:"h:Setup_INPUT"`
- H string `xml:"xmlns:h,attr"`
- NetAdminPassEncryptionType int `xml:"h:NetAdminPassEncryptionType"`
- NetworkAdminPassword string `xml:"h:NetworkAdminPassword"`
-}
-type Setup_OUTPUT struct {
- ReturnValue int
-}
-
-func (b Service) Setup(adminPassEncryptionType AdminPassEncryptionType, digestRealm, adminPassword string) string {
- hashInHex := createMD5Hash(adminPassword, digestRealm)
- header := b.base.WSManMessageCreator.CreateHeader(string(actions.Setup), string(IPS_HostBasedSetupService), nil, "", "")
- body := b.base.WSManMessageCreator.CreateBody("Setup_INPUT", string(IPS_HostBasedSetupService), Setup{
- H: "http://intel.com/wbem/wscim/1/ips-schema/1/IPS_HostBasedSetupService",
- NetAdminPassEncryptionType: int(adminPassEncryptionType),
- NetworkAdminPassword: string(hashInHex),
- })
- return b.base.WSManMessageCreator.CreateXML(header, body)
-}
-
-func createMD5Hash(adminPassword string, digestRealm string) string {
- // Create an md5 hash.
- setupPassword := "admin:" + digestRealm + ":" + adminPassword
- hash := md5.New()
- _, _ = io.WriteString(hash, setupPassword)
- hashInHex := fmt.Sprintf("%x", hash.Sum(nil))
- return hashInHex
-}
-
-type UpgradeClientToAdmin struct {
- XMLName xml.Name `xml:"h:UpgradeClientToAdmin_INPUT"`
- H string `xml:"xmlns:h,attr"`
- McNonce string `xml:"h:McNonce"`
- SigningAlgorithm int `xml:"h:SigningAlgorithm"`
- DigitalSignature string `xml:"h:DigitalSignature"`
-}
-
-// Upgrade Intel(R) AMT from Client to Admin Control Mode.
-func (b Service) UpgradeClientToAdmin(mcNonce string, signingAlgorithm SigningAlgorithm, digitalSignature string) string {
- header := b.base.WSManMessageCreator.CreateHeader(string(actions.UpgradeClientToAdmin), string(IPS_HostBasedSetupService), nil, "", "")
- body := b.base.WSManMessageCreator.CreateBody("UpgradeClientToAdmin_INPUT", string(IPS_HostBasedSetupService), UpgradeClientToAdmin{
- H: "http://intel.com/wbem/wscim/1/ips-schema/1/IPS_HostBasedSetupService",
- McNonce: mcNonce,
- SigningAlgorithm: int(signingAlgorithm),
- DigitalSignature: digitalSignature,
- })
- return b.base.WSManMessageCreator.CreateXML(header, body)
-}
diff --git a/pkg/ips/hostbasedsetup/service_test.go b/pkg/ips/hostbasedsetup/service_test.go
deleted file mode 100644
index 7bf8632d..00000000
--- a/pkg/ips/hostbasedsetup/service_test.go
+++ /dev/null
@@ -1,88 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package hostbasedsetup
-
-import (
- "fmt"
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestIPS_HostBasedSetupService(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://intel.com/wbem/wscim/1/ips-schema/1/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewHostBasedSetupService(wsmanMessageCreator)
-
- t.Run("amt_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid IPS_HostBasedSetupService Get wsman message", "IPS_HostBasedSetupService", wsmantesting.GET, "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid IPS_HostBasedSetupService Enumerate wsman message", "IPS_HostBasedSetupService", wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid IPS_HostBasedSetupService Pull wsman message", "IPS_HostBasedSetupService", wsmantesting.PULL, wsmantesting.PULL_BODY, func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
-
- // ADD NEXT CERT IN CHAIN
- {"should create a valid IPS_HostBasedSetupService AddNextCertInChain wsman message", "IPS_HostBasedSetupService", wsmantesting.ADD_NEXT_CERT_IN_CHAIN, fmt.Sprintf(`%struefalse`, wsmantesting.ClientCertificate), func() string {
- return elementUnderTest.AddNextCertInChain(wsmantesting.ClientCertificate, true, false)
- }},
-
- // AdminSetup
- {"should create a valid IPS_HostBasedSetupService AdminSetup wsman message", "IPS_HostBasedSetupService", wsmantesting.ADMIN_SETUP, fmt.Sprintf(`%d%s%s%d%s`, wsmantesting.AdminPassEncryptionType, "f73b2c17b1ecbd7a235ec37d66cbed71", wsmantesting.MCNonce, wsmantesting.SigningAlgorithm, wsmantesting.DigitalSignature), func() string {
- return elementUnderTest.AdminSetup(wsmantesting.AdminPassEncryptionType, wsmantesting.DigestRealm, wsmantesting.AdminPassword, wsmantesting.MCNonce, wsmantesting.SigningAlgorithm, wsmantesting.DigitalSignature)
- }},
-
- // UpgradeToAdminSetup
- {"should create a valid IPS_HostBasedSetupService UpgradeToAdminSetup wsman message", "IPS_HostBasedSetupService", wsmantesting.UPGRADE_CLIENT_TO_ADMIN, fmt.Sprintf(`%s%d%s`, wsmantesting.MCNonce, wsmantesting.SigningAlgorithm, wsmantesting.DigitalSignature), func() string {
- return elementUnderTest.UpgradeClientToAdmin(wsmantesting.MCNonce, wsmantesting.SigningAlgorithm, wsmantesting.DigitalSignature)
- }},
-
- //Setup
- {"should create a valid IPS_HostBasedSetupService Setup wsman message", "IPS_HostBasedSetupService", wsmantesting.SETUP, fmt.Sprintf(`%d%s`, wsmantesting.AdminPassEncryptionType, "f73b2c17b1ecbd7a235ec37d66cbed71"), func() string {
- return elementUnderTest.Setup(wsmantesting.AdminPassEncryptionType, wsmantesting.DigestRealm, wsmantesting.AdminPassword)
- }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-}
-
-func TestCreateMD5Hash(t *testing.T) {
- tests := []struct {
- adminPassword string
- digestRealm string
- expected string
- }{
- {"adminPassword1", "digestRealm1", "7eab95087308c968d56947a05e916d6b"},
- {"adminPassword2", "digestRealm2", "b404159c55fafd0b4a8e7d64833c7f26"},
- }
- for _, test := range tests {
- t.Run(test.digestRealm, func(t *testing.T) {
- result := createMD5Hash(test.adminPassword, test.digestRealm)
- assert.Equal(t, test.expected, result)
- })
- }
-}
diff --git a/pkg/ips/ieee8021x/credentialcontext.go b/pkg/ips/ieee8021x/credentialcontext.go
deleted file mode 100644
index 786e302f..00000000
--- a/pkg/ips/ieee8021x/credentialcontext.go
+++ /dev/null
@@ -1,38 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package ieee8021x
-
-import (
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
-)
-
-type CredentialContext struct {
- base message.Base
-}
-
-const IPS_8021xCredentialContext = "IPS_8021xCredentialContext"
-
-// NewIEEE8021xCredentialContext returns a new instance of the IPS_8021xCredentialContext struct.
-func NewIEEE8021xCredentialContext(wsmanMessageCreator *message.WSManMessageCreator) CredentialContext {
- return CredentialContext{
- base: message.NewBase(wsmanMessageCreator, IPS_8021xCredentialContext),
- }
-}
-
-// Get retrieves the representation of the instance
-func (b CredentialContext) Get() string {
- return b.base.Get(nil)
-}
-
-// Enumerates the instances of this class
-func (b CredentialContext) Enumerate() string {
- return b.base.Enumerate()
-}
-
-// Pulls instances of this class, following an Enumerate operation
-func (b CredentialContext) Pull(enumerationContext string) string {
- return b.base.Pull(enumerationContext)
-}
diff --git a/pkg/ips/ieee8021x/credentialcontext_test.go b/pkg/ips/ieee8021x/credentialcontext_test.go
deleted file mode 100644
index f6ac2cbe..00000000
--- a/pkg/ips/ieee8021x/credentialcontext_test.go
+++ /dev/null
@@ -1,50 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package ieee8021x
-
-import (
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestIPS_8021xCredentialContext(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://intel.com/wbem/wscim/1/ips-schema/1/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewIEEE8021xCredentialContext(wsmanMessageCreator)
-
- t.Run("amt_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid IPS_8021xCredentialContext Get wsman message", "IPS_8021xCredentialContext", wsmantesting.GET, "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid IPS_8021xCredentialContext Enumerate wsman message", "IPS_8021xCredentialContext", wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid IPS_8021xCredentialContext Pull wsman message", "IPS_8021xCredentialContext", wsmantesting.PULL, wsmantesting.PULL_BODY, func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-}
diff --git a/pkg/ips/ieee8021x/settings.go b/pkg/ips/ieee8021x/settings.go
deleted file mode 100644
index 758a4b5f..00000000
--- a/pkg/ips/ieee8021x/settings.go
+++ /dev/null
@@ -1,82 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package ieee8021x
-
-import (
- "encoding/xml"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/cim/models"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/ips/actions"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/ips/methods"
-)
-
-type IEEE8021xSettings struct {
- models.IEEE8021xSettings
- Enabled IEEE8021xSettingsEnabled `json:"Enabled,omitempty"`
- PxeTimeout int `json:"PxeTimeout,omitempty"`
- AvailableInS0 bool `json:"AvailableInS0,omitempty"`
-}
-
-type IEEE8021xSettingsEnabled int
-
-const (
- EnabledWithCertificates IEEE8021xSettingsEnabled = 2
- Disabled IEEE8021xSettingsEnabled = 3
- EnabledWithoutCertificates IEEE8021xSettingsEnabled = 6
-)
-
-type Settings struct {
- base message.Base
-}
-type Certificate struct {
- XMLName xml.Name `xml:"h:SetCertificates_INPUT"`
- H string `xml:"xmlns:h,attr"`
- ServerCertificateIssuer string `xml:"h:ServerCertificateIssuer"`
- ClientCertificate string `xml:"h:ClientCertificate"`
-}
-
-const IPS_IEEE8021xSettings = "IPS_IEEE8021xSettings"
-
-// NewIEEE8021xSettings returns a new instance of the IEEE8021xSettings struct.
-func NewIEEE8021xSettings(wsmanMessageCreator *message.WSManMessageCreator) Settings {
- return Settings{
- base: message.NewBase(wsmanMessageCreator, IPS_IEEE8021xSettings),
- }
-}
-
-// Get retrieves the representation of the instance
-func (b Settings) Get() string {
- return b.base.Get(nil)
-}
-
-// Enumerates the instances of this class
-func (b Settings) Enumerate() string {
- return b.base.Enumerate()
-}
-
-// Pulls instances of this class, following an Enumerate operation
-func (b Settings) Pull(enumerationContext string) string {
- return b.base.Pull(enumerationContext)
-}
-
-// Put will change properties of the selected instance
-func (b Settings) Put(ieee8021xSettings IEEE8021xSettings) string {
-
- return b.base.Put(ieee8021xSettings, false, nil)
-}
-
-func (b Settings) SetCertificates(serverCertificateIssuer, clientCertificate string) string {
- header := b.base.WSManMessageCreator.CreateHeader(string(actions.SetCertificates), string(IPS_IEEE8021xSettings), nil, "", "")
- body := b.base.WSManMessageCreator.CreateBody(string(methods.SetCertificates_INPUT), string(IPS_IEEE8021xSettings),
- Certificate{
- H: "http://intel.com/wbem/wscim/1/ips-schema/1/IPS_IEEE8021xSettings",
- ServerCertificateIssuer: serverCertificateIssuer,
- ClientCertificate: clientCertificate,
- },
- )
- return b.base.WSManMessageCreator.CreateXML(header, body)
-}
diff --git a/pkg/ips/ieee8021x/settings_test.go b/pkg/ips/ieee8021x/settings_test.go
deleted file mode 100644
index af2ada24..00000000
--- a/pkg/ips/ieee8021x/settings_test.go
+++ /dev/null
@@ -1,55 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package ieee8021x
-
-import (
- "fmt"
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestIPS_IEEE8021xSettings(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://intel.com/wbem/wscim/1/ips-schema/1/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewIEEE8021xSettings(wsmanMessageCreator)
-
- t.Run("amt_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid IPS_IEEE8021xSettings Get wsman message", "IPS_IEEE8021xSettings", wsmantesting.GET, "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid IPS_IEEE8021xSettings Enumerate wsman message", "IPS_IEEE8021xSettings", wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid IPS_IEEE8021xSettings Pull wsman message", "IPS_IEEE8021xSettings", wsmantesting.PULL, wsmantesting.PULL_BODY, func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
- // SET CERTIFICATES
- {"should create a valid ips_IEEE8021xSettings set certificates wsman message", "IPS_IEEE8021xSettings", wsmantesting.SET_CERTIFICATES, fmt.Sprintf(`%s%s`, wsmantesting.ServerCertificateIssuer, wsmantesting.ClientCertificate), func() string {
- return elementUnderTest.SetCertificates(wsmantesting.ServerCertificateIssuer, wsmantesting.ClientCertificate)
- }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-}
diff --git a/pkg/ips/methods/constants.go b/pkg/ips/methods/constants.go
deleted file mode 100644
index 2d7d5809..00000000
--- a/pkg/ips/methods/constants.go
+++ /dev/null
@@ -1,26 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package methods
-
-type Methods string
-
-const (
- Get Methods = "Get"
- Pull Methods = "Pull"
- Enumerate Methods = "Enumerate"
- Put Methods = "Put"
- Delete Methods = "Delete"
- Setup Methods = "Setup"
- AdminSetup Methods = "AdminSetup"
- StartOptIn Methods = "StartOptIn"
- CancelOptIn Methods = "CancelOptIn"
- SendOptInCode Methods = "SendOptInCode"
- RequestPowerStateChange Methods = "RequestPowerStateChange"
- AddNextCertInChain Methods = "AddNextCertInChain"
- SetCertificates Methods = "SetCertificates"
- SetCertificates_INPUT Methods = "SetCertificates_INPUT"
- UpgradeClientToAdmin Methods = "UpgradeClientToAdmin"
-)
diff --git a/pkg/ips/models/types.go b/pkg/ips/models/types.go
deleted file mode 100644
index 4c23a578..00000000
--- a/pkg/ips/models/types.go
+++ /dev/null
@@ -1,85 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package models
-
-import (
- base "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- cim "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/cim/models"
-)
-
-type CurrentControlMode int
-
-const (
- NotProvisioned CurrentControlMode = 0
- Client CurrentControlMode = 1
- Admin CurrentControlMode = 2
-)
-
-type CertChainStatus int
-
-const (
- CertChainStatusNotStarted CertChainStatus = 0
- CertChainStatusChainInProgress CertChainStatus = 1
- CertChainStatusChainComplete CertChainStatus = 2
-)
-
-type OptInRequired int
-
-const (
- None OptInRequired = 0
- KVM OptInRequired = 1
- All OptInRequired = 4294967295
-)
-
-type OptInState int
-
-const (
- NotStarted OptInState = 0
- Requested OptInState = 1
- Displayed OptInState = 2
- Received OptInState = 3
- InSession OptInState = 4
-)
-
-type CanModifyOptInPolicy int
-
-const (
- FALSE CanModifyOptInPolicy = 0
- TRUE CanModifyOptInPolicy = 1
-)
-
-type HostBasedSetupService struct {
- cim.SecurityService
- CurrentControlMode CurrentControlMode `json:"currentControlMode,omitempty"`
- AllowedControlModes []int `json:"allowedControlModes,omitempty"`
- ConfigurationNonce []int `json:"configurationNonce,omitempty"`
- CertChainStatus CertChainStatus `json:"certChainStatus,omitempty"`
-}
-
-type OptInService struct {
- cim.Service
- OptInCodeTimeout int `json:"optInCodeTimeout,omitempty"`
- OptInRequired OptInRequired `json:"optInRequired,omitempty"`
- OptInState OptInState `json:"optInState,omitempty"`
- CanModifyOptInPolicy CanModifyOptInPolicy `json:"canModifyOptInPolicy,omitempty"`
- OptInDisplayTimeout int `json:"optInDisplayTimeout,omitempty"`
-}
-
-type OptInServiceResponse struct {
- IPS_OptInService OptInService `json:"IPS_OptInService"`
-}
-
-type StartOptIn_OUTPUT struct {
- StartOptIn_OUTPUT base.ReturnValue `json:"StartOptIn_OUTPUT"`
-}
-
-type CancelOptIn_OUTPUT struct {
- CancelOptIn_OUTPUT base.ReturnValue `json:"CancelOptIn_OUTPUT"`
-}
-
-type SendOptInCode_OUTPUT struct {
- SendOptInCode_OUTPUT base.ReturnValue `json:"SendOptInCode_OUTPUT"`
-}
diff --git a/pkg/ips/optin/service.go b/pkg/ips/optin/service.go
deleted file mode 100644
index bddc410f..00000000
--- a/pkg/ips/optin/service.go
+++ /dev/null
@@ -1,71 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package optin
-
-import (
- "encoding/xml"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/ips/actions"
-)
-
-type Service struct {
- base message.Base
-}
-
-const IPS_OptInService = "IPS_OptInService"
-
-// NewOptInService returns a new instance of the OptInService struct.
-func NewOptInService(wsmanMessageCreator *message.WSManMessageCreator) Service {
- return Service{
- base: message.NewBase(wsmanMessageCreator, string(IPS_OptInService)),
- }
-}
-
-// Gets the representation of OptInService.
-func (b Service) Get() string {
- return b.base.Get(nil)
-}
-
-// Enumerates the instances of this class
-func (b Service) Enumerate() string {
- return b.base.Enumerate()
-}
-
-// Pulls instances of this class, following an Enumerate operation
-func (b Service) Pull(enumerationContext string) string {
- return b.base.Pull(enumerationContext)
-}
-
-type OptInCode struct {
- XMLName xml.Name `xml:"h:SendOptInCode_INPUT"`
- H string `xml:"xmlns:h,attr"`
- OptInCode int `xml:"h:OptInCode"`
-}
-
-// Send the opt-in code to Intel(R) AMT.
-func (b Service) SendOptInCode(optInCode int) string {
- header := b.base.WSManMessageCreator.CreateHeader(string(actions.SendOptInCode), string(IPS_OptInService), nil, "", "")
- body := b.base.WSManMessageCreator.CreateBody("SendOptInCode_INPUT", string(IPS_OptInService), OptInCode{
- H: "http://intel.com/wbem/wscim/1/ips-schema/1/IPS_OptInService",
- OptInCode: optInCode,
- })
- return b.base.WSManMessageCreator.CreateXML(header, body)
-}
-
-// Request an opt-in code.
-func (b Service) StartOptIn() string {
- header := b.base.WSManMessageCreator.CreateHeader(string(actions.StartOptIn), string(IPS_OptInService), nil, "", "")
- body := b.base.WSManMessageCreator.CreateBody("StartOptIn_INPUT", string(IPS_OptInService), nil)
- return b.base.WSManMessageCreator.CreateXML(header, body)
-}
-
-// Cancel a previous opt-in code request.
-func (b Service) CancelOptIn() string {
- header := b.base.WSManMessageCreator.CreateHeader(string(actions.CancelOptIn), string(IPS_OptInService), nil, "", "")
- body := b.base.WSManMessageCreator.CreateBody("CancelOptIn_INPUT", string(IPS_OptInService), nil)
- return b.base.WSManMessageCreator.CreateXML(header, body)
-}
diff --git a/pkg/ips/optin/service_test.go b/pkg/ips/optin/service_test.go
deleted file mode 100644
index 5e136810..00000000
--- a/pkg/ips/optin/service_test.go
+++ /dev/null
@@ -1,65 +0,0 @@
-/*********************************************************************
- * Copyright (c) Intel Corporation 2023
- * SPDX-License-Identifier: Apache-2.0
- **********************************************************************/
-
-package optin
-
-import (
- "testing"
-
- "github.com/stretchr/testify/assert"
-
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/internal/message"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/wsmantesting"
-)
-
-func TestIPS_OptInService(t *testing.T) {
- messageID := 0
- resourceUriBase := "http://intel.com/wbem/wscim/1/ips-schema/1/"
- wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
- elementUnderTest := NewOptInService(wsmanMessageCreator)
-
- t.Run("amt_* Tests", func(t *testing.T) {
- tests := []struct {
- name string
- method string
- action string
- body string
- responseFunc func() string
- }{
- //GETS
- {"should create a valid IPS_OptInService Get wsman message", "IPS_OptInService", wsmantesting.GET, "", elementUnderTest.Get},
- //ENUMERATES
- {"should create a valid IPS_OptInService Enumerate wsman message", "IPS_OptInService", wsmantesting.ENUMERATE, wsmantesting.ENUMERATE_BODY, elementUnderTest.Enumerate},
- //PULLS
- {"should create a valid IPS_OptInService Pull wsman message", "IPS_OptInService", wsmantesting.PULL, wsmantesting.PULL_BODY, func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
-
- // SEND_OPT_IN_CODE
- {"should create a valid IPS_OptInService send opt in code wsman message", "IPS_OptInService", wsmantesting.SEND_OPT_IN_CODE, `1`, func() string {
- return elementUnderTest.SendOptInCode(1)
- }},
-
- // START_OPT_IN
- {"should create a valid IPS_OptInService start opt in code wsman message", "IPS_OptInService", wsmantesting.START_OPT_IN, ``, func() string {
- return elementUnderTest.StartOptIn()
- }},
-
- // CANCEL_OPT_IN
- {"should create a valid IPS_OptInService cancel opt in code wsman message", "IPS_OptInService", wsmantesting.CANCEL_OPT_IN, ``, func() string {
- return elementUnderTest.CancelOptIn()
- }},
- }
-
- for _, test := range tests {
- t.Run(test.name, func(t *testing.T) {
- correctResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
- messageID++
- response := test.responseFunc()
- if response != correctResponse {
- assert.Equal(t, correctResponse, response)
- }
- })
- }
- })
-}
diff --git a/pkg/wsman/amt/alarmclock/constants.go b/pkg/wsman/amt/alarmclock/constants.go
new file mode 100644
index 00000000..c82a1772
--- /dev/null
+++ b/pkg/wsman/amt/alarmclock/constants.go
@@ -0,0 +1,11 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package alarmclock
+
+const (
+ AMT_AlarmClockService string = "AMT_AlarmClockService"
+ AddAlarm string = "AddAlarm"
+)
diff --git a/pkg/wsman/amt/alarmclock/marshal.go b/pkg/wsman/amt/alarmclock/marshal.go
new file mode 100644
index 00000000..9c82df6e
--- /dev/null
+++ b/pkg/wsman/amt/alarmclock/marshal.go
@@ -0,0 +1,30 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package alarmclock
+
+import (
+ "encoding/json"
+
+ "gopkg.in/yaml.v3"
+)
+
+// JSON marshals the type into JSON format
+func (r *Response) JSON() string {
+ jsonOutput, err := json.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(jsonOutput)
+}
+
+// YAML marshals the type into YAML format
+func (r *Response) YAML() string {
+ yamlOutput, err := yaml.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(yamlOutput)
+}
diff --git a/pkg/wsman/amt/alarmclock/service.go b/pkg/wsman/amt/alarmclock/service.go
new file mode 100644
index 00000000..8f8b4f8b
--- /dev/null
+++ b/pkg/wsman/amt/alarmclock/service.go
@@ -0,0 +1,151 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+// Package alarmclock facilitates communication with Intel® AMT devices to set an alarm time to turn the host computer system on. Setting an alarm time is done by calling "AddAlarm" method.
+package alarmclock
+
+import (
+ "encoding/xml"
+ "strconv"
+ "strings"
+ "time"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/methods"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+)
+
+// NewServiceWithClient instantiates a new Alarm Clock service
+func NewServiceWithClient(wsmanMessageCreator *message.WSManMessageCreator, client client.WSMan) Service {
+ return Service{
+ base: message.NewBaseWithClient(wsmanMessageCreator, AMT_AlarmClockService, client),
+ }
+}
+
+// Get retrieves the representation of the instance
+func (acs Service) Get() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: acs.base.Get(nil),
+ },
+ }
+
+ // send the message to AMT
+ err = acs.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+
+ return
+}
+
+// Enumerate returns an enumeration context which is used in a subsequent Pull call
+func (acs Service) Enumerate() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: acs.base.Enumerate(),
+ },
+ }
+ // send the message to AMT
+ err = acs.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+
+ return
+}
+
+// Pull returns the instances of this class. An enumeration context provided by the Enumerate call is used as input.
+func (acs Service) Pull(enumerationContext string) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: acs.base.Pull(enumerationContext),
+ },
+ }
+ // send the message to AMT
+ err = acs.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+
+ return
+}
+
+// AddAlarm creates an alarm that would wake the system at a given time. The method receives as input an embedded instance of type IPS_AlarmClockOccurrence, with the following fields set: StartTime, Interval, InstanceID, DeleteOnCompletion. Upon success, the method creates an instance of IPS_AlarmClockOccurrence which is associated with AlarmClockService. The method would fail if 5 instances or more of IPS_AlarmClockOccurrence already exist in the system.
+func (acs Service) AddAlarm(alarmClockOccurrence AlarmClockOccurrence) (response Response, err error) {
+ header := acs.base.WSManMessageCreator.CreateHeader(methods.GenerateAction(AMT_AlarmClockService, AddAlarm), AMT_AlarmClockService, nil, "", "")
+ startTime := alarmClockOccurrence.StartTime.UTC().Format(time.RFC3339Nano)
+ startTime = strings.Split(startTime, ".")[0]
+
+ var body strings.Builder
+ body.WriteString(``)
+ body.WriteString(alarmClockOccurrence.InstanceID)
+ body.WriteString(``)
+
+ if alarmClockOccurrence.ElementName != "" {
+ body.WriteString(``)
+ body.WriteString(alarmClockOccurrence.ElementName)
+ body.WriteString(``)
+ }
+
+ body.WriteString(``)
+ body.WriteString(startTime)
+ body.WriteString(``)
+
+ minutes := alarmClockOccurrence.Interval % 60
+ hours := (alarmClockOccurrence.Interval / 60) % 24
+ days := alarmClockOccurrence.Interval / 1440
+
+ body.WriteString(`P`)
+ body.WriteString(strconv.Itoa(days))
+ body.WriteString("DT")
+ body.WriteString(strconv.Itoa(hours))
+ body.WriteString("H")
+ body.WriteString(strconv.Itoa(minutes))
+ body.WriteString(`M`)
+
+ body.WriteString(``)
+ body.WriteString(strconv.FormatBool(alarmClockOccurrence.DeleteOnCompletion))
+ body.WriteString(``)
+
+ response = Response{
+ Message: &client.Message{
+ XMLInput: acs.base.WSManMessageCreator.CreateXML(header, body.String()),
+ },
+ }
+ // send the message to AMT
+ err = acs.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+
+ return
+}
diff --git a/pkg/wsman/amt/alarmclock/service_test.go b/pkg/wsman/amt/alarmclock/service_test.go
new file mode 100644
index 00000000..93e1b864
--- /dev/null
+++ b/pkg/wsman/amt/alarmclock/service_test.go
@@ -0,0 +1,296 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package alarmclock
+
+import (
+ "encoding/xml"
+ "testing"
+ "time"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/methods"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/models"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
+ "github.com/stretchr/testify/assert"
+)
+
+const (
+ EnvelopeResponse = `http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous0`
+ GetBody = `AMT_AlarmClockServiceIntel(r) AMT Alarm Clock ServiceIntel(r) AMT Alarm Clock ServiceCIM_ComputerSystemManagedSystem`
+)
+
+func TestPositiveAMT_AlarmClockService(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/alarmclock",
+ }
+ elementUnderTest := NewServiceWithClient(wsmanMessageCreator, &client)
+ t.Run("amt_AlarmClockService Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {"should create and parse valid AMT_AlarmClockService Get call",
+ AMT_AlarmClockService,
+ wsmantesting.GET,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Get"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GetResponse: AlarmClockService{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AlarmClockService", Local: "AMT_AlarmClockService"},
+ CreationClassName: AMT_AlarmClockService,
+ ElementName: "Intel(r) AMT Alarm Clock Service",
+ Name: "Intel(r) AMT Alarm Clock Service",
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "ManagedSystem",
+ },
+ },
+ },
+ //ENUMERATES
+ {"should create and parse valid AMT_AlarmClockService Enumerate call",
+ AMT_AlarmClockService,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Enumerate"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "8A000000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {"should create and parse valid AMT_AlarmClockService Pull call",
+ AMT_AlarmClockService,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Pull"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ AlarmClockServiceItems: []AlarmClockService{
+ {
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AlarmClockService", Local: "AMT_AlarmClockService"},
+ Name: "Intel(r) AMT Alarm Clock Service",
+ CreationClassName: AMT_AlarmClockService,
+ SystemName: "ManagedSystem",
+ SystemCreationClassName: "CIM_ComputerSystem",
+ ElementName: "Intel(r) AMT Alarm Clock Service",
+ },
+ },
+ },
+ },
+ },
+ //AddAlarm
+ {
+ "should create and parse valid AMT_AlarmClockService AddAlarm call",
+ AMT_AlarmClockService,
+ methods.GenerateAction(AMT_AlarmClockService, AddAlarm),
+ `InstanceAlarm instance name2022-12-31T23:59:00ZP1DT23H59Mtrue`,
+ func() (Response, error) {
+ client.CurrentMessage = "AddAlarm"
+ startTime := "2022-12-31T23:59:00Z"
+ minutes := 59
+ hours := 23
+ days := 1
+ interval := minutes + hours*60 + days*1440
+
+ startTimeFormatted, _ := time.Parse(time.RFC3339, startTime)
+ return elementUnderTest.AddAlarm(AlarmClockOccurrence{
+ InstanceID: "Instance",
+ StartTime: startTimeFormatted,
+ ElementName: "Alarm instance name",
+ Interval: interval,
+ DeleteOnCompletion: true,
+ })
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ AddAlarmOutput: AddAlarmOutput{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AlarmClockService", Local: "AddAlarm_OUTPUT"},
+ AlarmClock: AlarmClock{
+ Address: "default",
+ ReferenceParameters: models.ReferenceParameters_OUTPUT{
+ ResourceURI: "",
+ SelectorSet: models.SelectorSet_OUTPUT{
+ XMLName: xml.Name{
+ Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd",
+ Local: "SelectorSet",
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.NoError(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.Equal(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
+
+func TestNegativeAMT_AlarmClockService(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/alarmclock",
+ }
+ elementUnderTest := NewServiceWithClient(wsmanMessageCreator, &client)
+ t.Run("amt_AlarmClockService Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {"should create and parse valid AMT_AlarmClockService Get call",
+ AMT_AlarmClockService,
+ wsmantesting.GET,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GetResponse: AlarmClockService{
+ CreationClassName: AMT_AlarmClockService,
+ ElementName: "Intel(r) AMT Alarm Clock Service",
+ Name: "Intel(r) AMT Alarm Clock Service",
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "ManagedSystem",
+ },
+ },
+ },
+ //ENUMERATES
+ {"should create and parse valid AMT_AlarmClockService Enumerate call",
+ AMT_AlarmClockService,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "8A000000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {"should create and parse valid AMT_AlarmClockService Pull call",
+ AMT_AlarmClockService,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ AlarmClockServiceItems: []AlarmClockService{
+ {
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AlarmClockService", Local: "AMT_AlarmClockService"},
+ Name: "Intel(r) AMT Alarm Clock Service",
+ CreationClassName: AMT_AlarmClockService,
+ SystemName: "ManagedSystem",
+ SystemCreationClassName: "CIM_ComputerSystem",
+ ElementName: "Intel(r) AMT Alarm Clock Service",
+ },
+ },
+ },
+ },
+ },
+ //AddAlarm
+ {"should create and parse valid AMT_AlarmClockService AddAlarm call",
+ AMT_AlarmClockService,
+ methods.GenerateAction(AMT_AlarmClockService, AddAlarm),
+ `InstanceAlarm instance name2022-12-31T23:59:00ZP1DT23H59Mtrue`,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ startTime := "2022-12-31T23:59:00Z"
+ minutes := 59
+ hours := 23
+ days := 1
+ interval := minutes + hours*60 + days*1440
+
+ startTimeFormatted, _ := time.Parse(time.RFC3339, startTime)
+ return elementUnderTest.AddAlarm(AlarmClockOccurrence{
+ InstanceID: "Instance",
+ StartTime: startTimeFormatted,
+ ElementName: "Alarm instance name",
+ Interval: interval,
+ DeleteOnCompletion: true,
+ })
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ AddAlarmOutput: AddAlarmOutput{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AlarmClockService", Local: "AddAlarm_OUTPUT"},
+ AlarmClock: AlarmClock{
+ Address: "default",
+ ReferenceParameters: models.ReferenceParameters_OUTPUT{
+ ResourceURI: "",
+ SelectorSet: models.SelectorSet_OUTPUT{
+ XMLName: xml.Name{
+ Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd",
+ Local: "SelectorSet",
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.Error(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.NotEqual(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
diff --git a/pkg/wsman/amt/alarmclock/types.go b/pkg/wsman/amt/alarmclock/types.go
new file mode 100644
index 00000000..d79428fd
--- /dev/null
+++ b/pkg/wsman/amt/alarmclock/types.go
@@ -0,0 +1,72 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package alarmclock
+
+import (
+ "encoding/xml"
+ "time"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/models"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+)
+
+type Service struct {
+ base message.Base
+}
+
+// INPUTS
+// AlarmClockOccurrence represents a single alarm clock setting
+type AlarmClockOccurrence struct {
+ ElementName string `json:"ElementName"` // Elementname is a user-friendly name for the object
+ InstanceID string `json:"InstanceID"` // InstanceID is the instance key, set by the caller of AMT_AlarmClockService.AddAlarm.
+ StartTime time.Time `json:"StartTime"` // StartTime is the next time when the alarm is scheduled to be set.
+ Interval int `json:"Interval"` // Interval between occurrences of the alarm (0 if the alarm is scheduled to run once).
+ DeleteOnCompletion bool `json:"DeleteOnCompletion"` // DeleteOnComplete if set to TRUE, the instance will be deleted by the FW when the alarm is completed
+}
+
+// OUTPUTS
+// Response Types
+type (
+ Response struct {
+ *client.Message
+ XMLName xml.Name `xml:"Envelope"`
+ Header message.Header `xml:"Header"`
+ Body Body `xml:"Body"`
+ }
+ Body struct {
+ XMLName xml.Name `xml:"Body"`
+ GetResponse AlarmClockService `xml:"AMT_AlarmClockService"`
+ EnumerateResponse common.EnumerateResponse
+ AddAlarmOutput AddAlarmOutput `xml:"AddAlarm_OUTPUT"`
+ PullResponse PullResponse
+ }
+ PullResponse struct {
+ XMLName xml.Name `xml:"PullResponse"`
+ AlarmClockServiceItems []AlarmClockService `xml:"Items>AMT_AlarmClockService"`
+ }
+ AlarmClockService struct {
+ XMLName xml.Name `xml:"AMT_AlarmClockService"`
+ Name string // The Name property uniquely identifies the Service and provides an indication of the functionality that is managed
+ CreationClassName string // CreationClassName indicates the name of the class or the subclass that is used in the creation of an instance
+ SystemName string // The Name of the scoping System.
+ SystemCreationClassName string // The CreationClassName of the scoping System.
+ ElementName string // A user-friendly name for the object
+ NextAMTAlarmTime string // Specifies the next AMT alarm time
+ AMTAlarmClockInterval string // Specifies the alarm time interval
+ }
+ AddAlarmOutput struct {
+ XMLName xml.Name `xml:"AddAlarm_OUTPUT"`
+ AlarmClock AlarmClock // A reference to the created instance of IPS_AlarmClockOccurrence.
+ ReturnValue int // Return code. 0 indicates success
+ }
+ AlarmClock struct {
+ // Reference address to the created instance of IPS_AlarmClockOccurrence
+ Address string
+ ReferenceParameters models.ReferenceParameters_OUTPUT
+ }
+)
diff --git a/pkg/wsman/amt/auditlog/constants.go b/pkg/wsman/amt/auditlog/constants.go
new file mode 100644
index 00000000..16ac90c7
--- /dev/null
+++ b/pkg/wsman/amt/auditlog/constants.go
@@ -0,0 +1,53 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package auditlog
+
+const (
+ AMT_AuditLog string = "AMT_AuditLog"
+ ReadRecords string = "ReadRecords"
+)
+
+const (
+ OverwritePolicyUnknown OverwritePolicy = 0
+ OverwritePolicyWrapsWhenFull OverwritePolicy = 2
+ OverwritePolicyNeverOverwrites OverwritePolicy = 7
+ OverwritePolicyPartialRestrictedRollover OverwritePolicy = 32768
+)
+
+const (
+ EnabledStateUnknown EnabledState = iota
+ EnabledStateOther
+ EnabledStateEnabled
+ EnabledStateDisabled
+ EnabledStateShuttingDown
+ EnabledStateNotApplicable
+ EnabledStateEnabledbutOffline
+ EnabledStateInTest
+ EnabledStateDeferred
+ EnabledStateQuiesce
+ EnabledStateStarting
+)
+
+const (
+ RequestedStateUnknown RequestedState = 0
+ RequestedStateEnabled RequestedState = 2
+ RequestedStateDisabled RequestedState = 3
+ RequestedStateShutDown RequestedState = 4
+ RequestedStateNoChange RequestedState = 5
+ RequestedStateOffline RequestedState = 6
+ RequestedStateTest RequestedState = 7
+ RequestedStateDeferred RequestedState = 8
+ RequestedStateQuiesce RequestedState = 9
+ RequestedStateReboot RequestedState = 10
+ RequestedStateReset RequestedState = 11
+ RequestedStateNotApplicable RequestedState = 12
+)
+
+const (
+ StoragePolicyNoRollOver StoragePolicy = iota
+ StoragePolicyRollOver
+ StoragePolicyRestrictedRollOver
+)
diff --git a/pkg/wsman/amt/auditlog/marshal.go b/pkg/wsman/amt/auditlog/marshal.go
new file mode 100644
index 00000000..825197e5
--- /dev/null
+++ b/pkg/wsman/amt/auditlog/marshal.go
@@ -0,0 +1,30 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package auditlog
+
+import (
+ "encoding/json"
+
+ "gopkg.in/yaml.v3"
+)
+
+// JSON marshals the type into JSON format
+func (r *Response) JSON() string {
+ jsonOutput, err := json.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(jsonOutput)
+}
+
+// YAML marshals the type into YAML format
+func (r *Response) YAML() string {
+ yamlOutput, err := yaml.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(yamlOutput)
+}
diff --git a/pkg/wsman/amt/auditlog/message.go b/pkg/wsman/amt/auditlog/message.go
new file mode 100644
index 00000000..8b489b3c
--- /dev/null
+++ b/pkg/wsman/amt/auditlog/message.go
@@ -0,0 +1,104 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+// Package auditlog facilitates communication with Intel® AMT devices to read the audit log records
+package auditlog
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/methods"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+)
+
+// NewAuditLogWithClient instantiates a new Audit Log service
+func NewAuditLogWithClient(wsmanMessageCreator *message.WSManMessageCreator, client client.WSMan) Service {
+ return Service{
+ base: message.NewBaseWithClient(wsmanMessageCreator, AMT_AuditLog, client),
+ }
+}
+
+// Get retrieves the representation of the instance
+func (service Service) Get() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: service.base.Get(nil),
+ },
+ }
+
+ err = service.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Enumerate returns an enumeration context which is used in a subsequent Pull call
+func (service Service) Enumerate() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: service.base.Enumerate(),
+ },
+ }
+ err = service.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Pull returns the instances of this class. An enumeration context provided by the Enumerate call is used as input.
+func (service Service) Pull(enumerationContext string) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: service.base.Pull(enumerationContext),
+ },
+ }
+ err = service.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// ReadRecords returns a list of consecutive audit log records in chronological order:
+// The first record in the returned array is the oldest record stored in the log.
+// startIndex Identifies the position of the first record to retrieve. An index of 1 indicates the first record in the log.
+func (service Service) ReadRecords(startIndex int) (response Response, err error) {
+ if startIndex < 1 {
+ startIndex = 0
+ }
+ header := service.base.WSManMessageCreator.CreateHeader(methods.GenerateAction(AMT_AuditLog, ReadRecords), AMT_AuditLog, nil, "", "")
+ body := service.base.WSManMessageCreator.CreateBody(methods.GenerateInputMethod(ReadRecords), AMT_AuditLog, &readRecords_INPUT{StartIndex: startIndex})
+ response = Response{
+ Message: &client.Message{
+ XMLInput: service.base.WSManMessageCreator.CreateXML(header, body),
+ },
+ }
+ err = service.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
diff --git a/pkg/wsman/amt/auditlog/message_test.go b/pkg/wsman/amt/auditlog/message_test.go
new file mode 100644
index 00000000..9f290b11
--- /dev/null
+++ b/pkg/wsman/amt/auditlog/message_test.go
@@ -0,0 +1,292 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package auditlog
+
+import (
+ "encoding/xml"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
+)
+
+func TestPositiveAMT_AuditLog(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/auditlog",
+ }
+ elementUnderTest := NewAuditLogWithClient(wsmanMessageCreator, &client)
+
+ t.Run("amt_AuditLog Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create a valid AMT_AuditLog Get wsman message",
+ AMT_AuditLog,
+ wsmantesting.GET,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Get"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GetResponse: AuditLog{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AuditLog", Local: "AMT_AuditLog"},
+ OverwritePolicy: OverwritePolicyWrapsWhenFull,
+ CurrentNumberOfRecords: 161,
+ MaxNumberOfRecords: 0,
+ ElementName: "Intel(r) AMT Audit Log",
+ EnabledState: EnabledStateEnabled,
+ RequestedState: RequestedStateEnabled,
+ PercentageFree: 92,
+ Name: "Intel(r) AMT:Audit Log",
+ TimeOfLastRecord: Datetime{
+ Datetime: "2024-01-03T00:44:35Z",
+ },
+ AuditState: 16,
+ MaxAllowedAuditors: 1,
+ StoragePolicy: StoragePolicyRollOver,
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create a valid AMT_AuditLog Enumerate wsman message",
+ AMT_AuditLog,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Enumerate"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "92070000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid AMT_AuditLog Pull wsman message",
+ AMT_AuditLog,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Pull"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ AuditLogItems: []AuditLog{
+ {
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AuditLog", Local: "AMT_AuditLog"},
+ OverwritePolicy: OverwritePolicyWrapsWhenFull,
+ CurrentNumberOfRecords: 162,
+ MaxNumberOfRecords: 0,
+ ElementName: "Intel(r) AMT Audit Log",
+ EnabledState: EnabledStateEnabled,
+ RequestedState: RequestedStateEnabled,
+ PercentageFree: 92,
+ Name: "Intel(r) AMT:Audit Log",
+ TimeOfLastRecord: Datetime{
+ Datetime: "2024-01-03T00:45:41Z",
+ },
+ AuditState: 16,
+ MaxAllowedAuditors: 1,
+ StoragePolicy: StoragePolicyRollOver,
+ },
+ },
+ },
+ },
+ },
+ //READ RECORDS
+ {
+ "should create a valid AMT_AuditLog Read Records wsman message",
+ AMT_AuditLog,
+ `http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AuditLog/ReadRecords`,
+ `1`,
+ func() (Response, error) {
+ client.CurrentMessage = "ReadRecords"
+ return elementUnderTest.ReadRecords(1)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ ReadRecordsResponse: ReadRecords_OUTPUT{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AuditLog", Local: "ReadRecords_OUTPUT"},
+ TotalRecordCount: 2,
+ RecordsReturned: 2,
+ EventRecords: []string{"ABMAAAI/9M1uAgAQAAwAAAAoBZkADAAAACQFlA==", "ABMAAAI/9M1vAgAQAAwAAAAoBZkADAAAACQFlA=="},
+ ReturnValue: 0,
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.NoError(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.Equal(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
+func TestNegativeAMT_AuditLog(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/auditlog",
+ }
+ elementUnderTest := NewAuditLogWithClient(wsmanMessageCreator, &client)
+
+ t.Run("amt_AuditLog Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create a valid AMT_AuditLog Get wsman message",
+ AMT_AuditLog,
+ wsmantesting.GET,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GetResponse: AuditLog{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AuditLog", Local: "AMT_AuditLog"},
+ OverwritePolicy: OverwritePolicyWrapsWhenFull,
+ CurrentNumberOfRecords: 161,
+ MaxNumberOfRecords: 0,
+ ElementName: "Intel(r) AMT Audit Log",
+ EnabledState: EnabledStateEnabled,
+ RequestedState: RequestedStateEnabled,
+ PercentageFree: 92,
+ Name: "Intel(r) AMT:Audit Log",
+ TimeOfLastRecord: Datetime{
+ Datetime: "2024-01-03T00:44:35Z",
+ },
+ AuditState: 16,
+ MaxAllowedAuditors: 1,
+ StoragePolicy: StoragePolicyRollOver,
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create a valid AMT_AuditLog Enumerate wsman message",
+ AMT_AuditLog,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "92070000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid AMT_AuditLog Pull wsman message",
+ AMT_AuditLog,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ AuditLogItems: []AuditLog{
+ {
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AuditLog", Local: "AMT_AuditLog"},
+ OverwritePolicy: OverwritePolicyWrapsWhenFull,
+ CurrentNumberOfRecords: 162,
+ MaxNumberOfRecords: 0,
+ ElementName: "Intel(r) AMT Audit Log",
+ EnabledState: EnabledStateEnabled,
+ RequestedState: RequestedStateEnabled,
+ PercentageFree: 92,
+ Name: "Intel(r) AMT:Audit Log",
+ TimeOfLastRecord: Datetime{
+ Datetime: "2024-01-03T00:45:41Z",
+ },
+ AuditState: 16,
+ MaxAllowedAuditors: 1,
+ StoragePolicy: StoragePolicyRollOver,
+ },
+ },
+ },
+ },
+ },
+ //READ RECORDS
+ {
+ "should create a valid AMT_AuditLog Read Records wsman message",
+ AMT_AuditLog,
+ `http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AuditLog/ReadRecords`,
+ `1`,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.ReadRecords(1)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ ReadRecordsResponse: ReadRecords_OUTPUT{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AuditLog", Local: "ReadRecords_OUTPUT"},
+ TotalRecordCount: 2,
+ RecordsReturned: 2,
+ EventRecords: []string{"ABMAAAI/9M1uAgAQAAwAAAAoBZkADAAAACQFlA==", "ABMAAAI/9M1vAgAQAAwAAAAoBZkADAAAACQFlA=="},
+ ReturnValue: 0,
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.Error(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.NotEqual(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
diff --git a/pkg/wsman/amt/auditlog/types.go b/pkg/wsman/amt/auditlog/types.go
new file mode 100644
index 00000000..073ac4a3
--- /dev/null
+++ b/pkg/wsman/amt/auditlog/types.go
@@ -0,0 +1,146 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package auditlog
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+)
+
+type Service struct {
+ base message.Base
+}
+
+// INPUTS
+// Request Types
+type readRecords_INPUT struct {
+ XMLName xml.Name `xml:"h:ReadRecords_INPUT"`
+ H string `xml:"xmlns:h,attr"`
+ StartIndex int `xml:"h:StartIndex" json:"StartIndex"`
+}
+
+// OUTPUTS
+// Response Types
+type (
+ Response struct {
+ *client.Message
+ XMLName xml.Name `xml:"Envelope"`
+ Header message.Header `xml:"Header"`
+ Body Body `xml:"Body"`
+ }
+ Body struct {
+ XMLName xml.Name `xml:"Body"`
+ EnumerateResponse common.EnumerateResponse
+ GetResponse AuditLog
+ PullResponse PullResponse
+ ReadRecordsResponse ReadRecords_OUTPUT
+ }
+ PullResponse struct {
+ XMLName xml.Name `xml:"PullResponse"`
+ AuditLogItems []AuditLog `xml:"Items>AMT_AuditLog"`
+ }
+
+ AuditLog struct {
+ XMLName xml.Name `xml:"AMT_AuditLog"`
+ OverwritePolicy OverwritePolicy `xml:"OverwritePolicy,omitempty"` // OverwritePolicy is an integer enumeration that indicates whether the log, represented by the CIM_Log subclasses, can overwrite its entries.Unknown (0) indicates the log's overwrite policy is unknown
+ CurrentNumberOfRecords int `xml:"CurrentNumberOfRecords,omitempty"` // Current number of records in the Log
+ MaxNumberOfRecords int `xml:"MaxNumberOfRecords,omitempty"` // Maximum number of records that can be captured in the Log
+ ElementName string `xml:"ElementName,omitempty"` // A user-friendly name for the object
+ EnabledState EnabledState `xml:"EnabledState,omitempty"` // EnabledState is an integer enumeration that indicates the enabled and disabled states of an element
+ RequestedState RequestedState `xml:"RequestedState,omitempty"` // RequestedState is an integer enumeration that indicates the last requested or desired state for the element, irrespective of the mechanism through which it was requested
+ PercentageFree int `xml:"PercentageFree,omitempty"` // Indicates the percentage of free space in the storage dedicated to the audit log
+ Name string `xml:"Name,omitempty"` // The Name property uniquely identifies the Service and provides an indication of the functionality that is managed
+ TimeOfLastRecord Datetime `xml:"TimeOfLastRecord"` // Time stamp of the most recent entry in the log if such an entry exists
+ AuditState int `xml:"AuditState,omitempty"` // State of log
+ MaxAllowedAuditors int `xml:"MaxAllowedAuditors,omitempty"` // Maximum number of auditors allowed
+ StoragePolicy StoragePolicy `xml:"StoragePolicy,omitempty"` // AuditLog storage policy
+ MinDaysToKeep int `xml:"MinDaysToKeep,omitempty"` // Minimum number of days to keep records in the AuditLog
+ }
+
+ Datetime struct {
+ Datetime string `xml:"Datetime,omitempty"`
+ }
+
+ ReadRecords_OUTPUT struct {
+ XMLName xml.Name `xml:"ReadRecords_OUTPUT,omitempty"`
+ TotalRecordCount int `xml:"TotalRecordCount,omitempty"` // The total number of records in the log.
+ RecordsReturned int `xml:"RecordsReturned,omitempty"` // The number of records returned + content of 10 records from the start index.
+ EventRecords []string `xml:"EventRecords,omitempty"` // Notice: the values of this array are actually base64 encoded values. A list of event records.
+ ReturnValue int `xml:"ReturnValue,omitempty"` // ValueMap={0, 1, 2, 35} Values={PT_STATUS_SUCCESS, PT_STATUS_INTERNAL_ERROR, PT_STATUS_NOT_READY, PT_STATUS_INVALID_INDEX}
+ }
+)
+
+type (
+ // OverwritePolicy is an integer enumeration that indicates whether the log, represented by the CIM_Log subclasses, can overwrite its entries.
+ //
+ // Unknown (0) indicates the log's overwrite policy is unknown.
+ //
+ // Wraps when Full (2) indicates that the log overwrites its entries with new entries when the log has reached its maximum capacity.
+ //
+ // Never Overwrites (7) indicates that the log never overwrites its entries by the new entries.
+ //
+ // Value of 32768 means "Parital (restricted) rollover" - only old events (under certain threshold, which can be set using SetStoragePolicy) will be overwritten.
+ //
+ // This is a read-only property.
+ //
+ // ValueMap={0, 2, 7, .., 32768..65535}
+ //
+ // Values={Unknown, Wraps When Full, Never Overwrites, DMTF Reserved, Vendor Reserved}
+ OverwritePolicy int
+ // EnabledState is an integer enumeration that indicates the enabled and disabled states of an element. It can also indicate the transitions between these requested states. For example, shutting down (value=4) and starting (value=10) are transient states between enabled and disabled.
+ //
+ // The following text briefly summarizes the various enabled and disabled states:
+ //
+ // Enabled (2) indicates that the element is or could be executing commands, will process any queued commands, and queues new requests.
+ //
+ // Disabled (3) indicates that the element will not execute commands and will drop any new requests.
+ //
+ // Shutting Down (4) indicates that the element is in the process of going to a Disabled state.
+ //
+ // Not Applicable (5) indicates the element does not support being enabled or disabled.
+ //
+ // Enabled but Offline (6) indicates that the element might be completing commands, and will drop any new requests.
+ //
+ // Test (7) indicates that the element is in a test state.
+ //
+ // Deferred (8) indicates that the element might be completing commands, but will queue any new requests.
+ //
+ // Quiesce (9) indicates that the element is enabled but in a restricted mode.
+ //
+ // Starting (10) indicates that the element is in the process of going to an Enabled state. New requests are queued.
+ //
+ // Value 6 ("Enabled but Offline") can be recieved also if the Audit Log is in locked state.
+ //
+ // ValueMap={0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11..32767, 32768..65535}
+ //
+ // Values={Unknown, Other, Enabled, Disabled, Shutting Down, Not Applicable, Enabled but Offline, In Test, Deferred, Quiesce, Starting, DMTF Reserved, Vendor Reserved}
+ EnabledState int
+ // RequestedState is an integer enumeration that indicates the last requested or desired state for the element, irrespective of the mechanism through which it was requested. The actual state of the element is represented by EnabledState. This property is provided to compare the last requested and current enabled or disabled states. Note that when EnabledState is set to 5 ("Not Applicable"), then this property has no meaning. Refer to the EnabledState property description for explanations of the values in the RequestedState enumeration.
+ //
+ // "Unknown" (0) indicates the last requested state for the element is unknown.
+ //
+ // Note that the value "No Change" (5) has been deprecated in lieu of indicating the last requested state is "Unknown" (0). If the last requested or desired state is unknown, RequestedState should have the value "Unknown" (0), but may have the value "No Change" (5).Offline (6) indicates that the element has been requested to transition to the Enabled but Offline EnabledState. It should be noted that there are two new values in RequestedState that build on the statuses of EnabledState. These are "Reboot" (10) and "Reset" (11). Reboot refers to doing a "Shut Down" and then moving to an "Enabled" state. Reset indicates that the element is first "Disabled" and then "Enabled". The distinction between requesting "Shut Down" and "Disabled" should also be noted. Shut Down requests an orderly transition to the Disabled state, and might involve removing power, to completely erase any existing state. The Disabled state requests an immediate disabling of the element, such that it will not execute or accept any commands or processing requests.
+ //
+ // This property is set as the result of a method invocation (such as Start or StopService on CIM_Service), or can be overridden and defined as WRITEable in a subclass. The method approach is considered superior to a WRITEable property, because it allows an explicit invocation of the operation and the return of a result code.
+ //
+ // If knowledge of the last RequestedState is not supported for the EnabledLogicalElement, the property shall be NULL or have the value 12 "Not Applicable".
+ //
+ // ValueMap={0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, .., 32768..65535}
+ //
+ // Values={Unknown, Enabled, Disabled, Shut Down, No Change, Offline, Test, Deferred, Quiesce, Reboot, Reset, Not Applicable, DMTF Reserved, Vendor Reserved}
+ RequestedState int
+ // AuditLog storage policy. The available policies are: "NO_ROLL_OVER" - No roll-over in storage. Old events will not be overwritten. "ROLL_OVER" - Full rollover. Any old record will be overwritten. "RESTRICTED_ROLL_OVER" - Parital (restricted) rollover. Only old events (under certain threshold, which can be set using SetStoragePolicy) will be overwritten. If not specified default is "ROLL_OVER" unless FW was upgraded from AMT 5.0 and then "NO_ROLL_OVER" will be used as default.
+ //
+ // Additional Notes: 'StoragePolicy' is only supported in Intel AMT Release 5.1 and later releases.
+ //
+ // ValueMap={0, 1, 2}
+ //
+ // Values={NO_ROLL_OVER, ROLL_OVER, RESTRICTED_ROLL_OVER}
+ StoragePolicy int
+)
diff --git a/pkg/wsman/amt/authorization/constants.go b/pkg/wsman/amt/authorization/constants.go
new file mode 100644
index 00000000..1eb59772
--- /dev/null
+++ b/pkg/wsman/amt/authorization/constants.go
@@ -0,0 +1,100 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package authorization
+
+const (
+ AMT_AuthorizationService string = "AMT_AuthorizationService"
+ EnumerateUserAclEntries string = "EnumerateUserAclEntries"
+ GetUserAclEntryEx string = "GetUserAclEntryEx"
+ UpdateUserAclEntryEx string = "UpdateUserAclEntryEx"
+ RemoveUserAclEntry string = "RemoveUserAclEntry"
+ GetAdminAclEntry string = "GetAdminAclEntry"
+ GetAdminAclEntryStatus string = "GetAdminAclEntryStatus"
+ GetAdminNetAclEntryStatus string = "GetAdminNetAclEntryStatus"
+ SetAclEnabledState string = "SetAclEnabledState"
+ GetAclEnabledState string = "GetAclEnabledState"
+ SetAdminAclEntryEx string = "SetAdminAclEntryEx"
+ AddUserAclEntryEx string = "AddUserAclEntryEx"
+)
+
+const (
+ PTStatusSuccess PTStatus = 0
+ PTStatusInternalError PTStatus = 1
+ PTStatusInvalidName PTStatus = 12
+ PTStatusNotPermitted PTStatus = 16
+ PTStatusMaxLimitReached PTStatus = 23
+ PTStatusInvalidIndex PTStatus = 35
+ PTStatusFlashWriteLimitExceeded PTStatus = 38
+ PTStatusInvalidHandle PTStatus = 2053
+ PTStatusInvalidPassword PTStatus = 2054
+ PTStatusInvalidRealm PTStatus = 2055
+ AMTStatusDuplicate PTStatus = 2058
+ PTStatusMaxKerbDomainReached PTStatus = 2065
+ PTStatusAuditFail PTStatus = 2075
+)
+
+const (
+ LocalAccessOnly AccessPermission = iota
+ NetworkAccessOnly
+ LocalAndNetworkAccess
+)
+
+const (
+ InvalidRealm RealmValues = iota
+ ReservedRealm0
+ RedirectionRealm
+ PTAdministrationRealm
+ HardwareAssetRealm
+ RemoteControlRealm
+ StorageRealm
+ EventManagerRealm
+ StorageAdminRealm
+ AgentPresenceLocalRealm
+ AgentPresenceRemoteRealm
+ CircuitBreakerRealm
+ NetworkTimeRealm
+ GeneralInfoRealm
+ FirmwareUpdateRealm
+ EITRealm
+ LocalUN
+ EndpointAccessControlRealm
+ EndpointAccessControlAdminRealm
+ EventLogReaderRealm
+ AuditLogRealm
+ ACLRealm
+ ReservedRealm1
+ ReservedRealm2
+ LocalSystemRealm
+)
+
+const (
+ EnabledStateUnknown EnabledState = iota
+ EnabledStateOther
+ EnabledStateEnabled
+ EnabledStateDisabled
+ EnabledStateShuttingDown
+ EnabledStateNotApplicable
+ EnabledStateEnabledbutOffline
+ EnabledStateInTest
+ EnabledStateDeferred
+ EnabledStateQuiesce
+ EnabledStateStarting
+)
+
+const (
+ RequestedStateUnknown RequestedState = 0
+ RequestedStateEnabled RequestedState = 2
+ RequestedStateDisabled RequestedState = 3
+ RequestedStateShutDown RequestedState = 4
+ RequestedStateNoChange RequestedState = 5
+ RequestedStateOffline RequestedState = 6
+ RequestedStateTest RequestedState = 7
+ RequestedStateDeferred RequestedState = 8
+ RequestedStateQuiesce RequestedState = 9
+ RequestedStateReboot RequestedState = 10
+ RequestedStateReset RequestedState = 11
+ RequestedStateNotApplicable RequestedState = 12
+)
diff --git a/pkg/wsman/amt/authorization/marshal.go b/pkg/wsman/amt/authorization/marshal.go
new file mode 100644
index 00000000..6ce48582
--- /dev/null
+++ b/pkg/wsman/amt/authorization/marshal.go
@@ -0,0 +1,30 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package authorization
+
+import (
+ "encoding/json"
+
+ "gopkg.in/yaml.v3"
+)
+
+// JSON marshals the type into JSON format
+func (r *Response) JSON() string {
+ jsonOutput, err := json.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(jsonOutput)
+}
+
+// YAML marshals the type into YAML format
+func (r *Response) YAML() string {
+ yamlOutput, err := yaml.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(yamlOutput)
+}
diff --git a/pkg/wsman/amt/authorization/service.go b/pkg/wsman/amt/authorization/service.go
new file mode 100644
index 00000000..e15d9b1d
--- /dev/null
+++ b/pkg/wsman/amt/authorization/service.go
@@ -0,0 +1,291 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+// Package authorization facilitates communication with Intel® AMT devices to manage access control list (ACL) entries.
+//
+// Additional Notes:
+//
+// 1) Realms 'AuditLogRealm' (20) and 'ACLRealm' (21) are supported only in Intel AMT Release 4.0 and later releases.
+//
+// 2) Realm 'DTRealm' (23) is supported only in 'ME 5.1' and Intel AMT Release 5.1 and later releases.
+//
+// 3) All the methods of 'AMT_AuthorizationService' except for 'Get' are not supported in Remote Connectivity Service provisioning mode
+package authorization
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/methods"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+)
+
+// Instantiates a new Authorization service
+func NewServiceWithClient(wsmanMessageCreator *message.WSManMessageCreator, client client.WSMan) AuthorizationService {
+ return AuthorizationService{
+ base: message.NewBaseWithClient(wsmanMessageCreator, AMT_AuthorizationService, client),
+ }
+}
+
+// Get retrieves the representation of the instance
+func (as AuthorizationService) Get() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: as.base.Get(nil),
+ },
+ }
+ // send the message to AMT
+ err = as.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Enumerate returns an enumeration context which is used in a subsequent Pull call
+func (as AuthorizationService) Enumerate() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: as.base.Enumerate(),
+ },
+ }
+ // send the message to AMT
+ err = as.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Pull returns the instances of this class. An enumeration context provided by the Enumerate call is used as input.
+func (as AuthorizationService) Pull(enumerationContext string) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: as.base.Pull(enumerationContext),
+ },
+ }
+ // send the message to AMT
+ err = as.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// EnumerateUserAclEntries enumerates entries in the User Access Control List (ACL).
+func (as AuthorizationService) EnumerateUserAclEntries(startIndex int) (response Response, err error) {
+ if startIndex == 0 {
+ startIndex = 1
+ }
+ header := as.base.WSManMessageCreator.CreateHeader(methods.GenerateAction(AMT_AuthorizationService, EnumerateUserAclEntries), AMT_AuthorizationService, nil, "", "")
+ body := as.base.WSManMessageCreator.CreateBody(methods.GenerateInputMethod(EnumerateUserAclEntries), AMT_AuthorizationService, &EnumerateUserAclEntries_INPUT{StartIndex: startIndex})
+ response = Response{
+ Message: &client.Message{
+ XMLInput: as.base.WSManMessageCreator.CreateXML(header, body),
+ },
+ }
+ err = as.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Gets the state of a user ACL entry (enabled/disabled)
+func (as AuthorizationService) GetAclEnabledState(handle int) (response Response, err error) {
+ header := as.base.WSManMessageCreator.CreateHeader(methods.GenerateAction(AMT_AuthorizationService, GetAclEnabledState), AMT_AuthorizationService, nil, "", "")
+ body := as.base.WSManMessageCreator.CreateBody(methods.GenerateInputMethod(GetAclEnabledState), AMT_AuthorizationService, &GetAclEnabledState_INPUT{Handle: handle})
+ response = Response{
+ Message: &client.Message{
+ XMLInput: as.base.WSManMessageCreator.CreateXML(header, body),
+ },
+ }
+ err = as.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Returns the username attribute of the Admin ACL
+func (as AuthorizationService) GetAdminAclEntry() (response Response, err error) {
+ header := as.base.WSManMessageCreator.CreateHeader(methods.GenerateAction(AMT_AuthorizationService, GetAdminAclEntry), AMT_AuthorizationService, nil, "", "")
+ body := as.base.WSManMessageCreator.CreateBody(methods.GenerateInputMethod(GetAdminAclEntry), AMT_AuthorizationService, nil)
+ response = Response{
+ Message: &client.Message{
+ XMLInput: as.base.WSManMessageCreator.CreateXML(header, body),
+ },
+ }
+ err = as.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Reads the Admin ACL Entry status from Intel® AMT. The return state changes as a function of the admin password.
+func (as AuthorizationService) GetAdminAclEntryStatus() (response Response, err error) {
+ header := as.base.WSManMessageCreator.CreateHeader(methods.GenerateAction(AMT_AuthorizationService, GetAdminAclEntryStatus), AMT_AuthorizationService, nil, "", "")
+ body := as.base.WSManMessageCreator.CreateBody(methods.GenerateInputMethod(GetAdminAclEntryStatus), AMT_AuthorizationService, nil)
+ response = Response{
+ Message: &client.Message{
+ XMLInput: as.base.WSManMessageCreator.CreateXML(header, body),
+ },
+ }
+ err = as.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Reads the remote Admin ACL Entry status from Intel® AMT. The return state changes as a function of the remote admin password.
+func (as AuthorizationService) GetAdminNetAclEntryStatus() (response Response, err error) {
+ header := as.base.WSManMessageCreator.CreateHeader(methods.GenerateAction(AMT_AuthorizationService, GetAdminNetAclEntryStatus), AMT_AuthorizationService, nil, "", "")
+ body := as.base.WSManMessageCreator.CreateBody(methods.GenerateInputMethod(GetAdminNetAclEntryStatus), AMT_AuthorizationService, nil)
+ response = Response{
+ Message: &client.Message{
+ XMLInput: as.base.WSManMessageCreator.CreateXML(header, body),
+ },
+ }
+ err = as.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Reads a user entry from the Intel® AMT device. Note: confidential information, such as password (hash) is omitted or zeroed in the response.
+func (as AuthorizationService) GetUserAclEntryEx(handle int) (response Response, err error) {
+ header := as.base.WSManMessageCreator.CreateHeader(methods.GenerateAction(AMT_AuthorizationService, GetUserAclEntryEx), AMT_AuthorizationService, nil, "", "")
+ body := as.base.WSManMessageCreator.CreateBody(methods.GenerateInputMethod(GetUserAclEntryEx), AMT_AuthorizationService, &GetUserAclEntryEx_INPUT{Handle: handle})
+ response = Response{
+ Message: &client.Message{
+ XMLInput: as.base.WSManMessageCreator.CreateXML(header, body),
+ },
+ }
+ err = as.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Removes an entry from the User Access Control List (ACL), given a handle.
+func (as AuthorizationService) RemoveUserAclEntry(handle int) (response Response, err error) {
+ header := as.base.WSManMessageCreator.CreateHeader(methods.GenerateAction(AMT_AuthorizationService, RemoveUserAclEntry), AMT_AuthorizationService, nil, "", "")
+ body := as.base.WSManMessageCreator.CreateBody(methods.GenerateInputMethod(RemoveUserAclEntry), AMT_AuthorizationService, &RemoveUserAclEntry_INPUT{Handle: handle})
+ response = Response{
+ Message: &client.Message{
+ XMLInput: as.base.WSManMessageCreator.CreateXML(header, body),
+ },
+ }
+ err = as.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Enables or disables a user ACL entry. Disabling ACL entries is useful when accounts that cannot be removed (system accounts - starting with $$) are required to be disabled.
+func (as AuthorizationService) SetAclEnabledState(handle int, enabled bool) (response Response, err error) {
+ header := as.base.WSManMessageCreator.CreateHeader(methods.GenerateAction(AMT_AuthorizationService, SetAclEnabledState), AMT_AuthorizationService, nil, "", "")
+ body := as.base.WSManMessageCreator.CreateBody(methods.GenerateInputMethod(SetAclEnabledState), AMT_AuthorizationService, &SetAclEnabledState_INPUT{Handle: handle, Enabled: enabled})
+ response = Response{
+ Message: &client.Message{
+ XMLInput: as.base.WSManMessageCreator.CreateXML(header, body),
+ },
+ }
+ err = as.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Updates an Admin entry in the Intel® AMT device.
+func (as AuthorizationService) SetAdminACLEntryEx(username, digestPassword string) (response Response, err error) {
+ header := as.base.WSManMessageCreator.CreateHeader(methods.GenerateAction(AMT_AuthorizationService, SetAdminAclEntryEx), AMT_AuthorizationService, nil, "", "")
+ body := as.base.WSManMessageCreator.CreateBody(methods.GenerateInputMethod(SetAdminAclEntryEx), AMT_AuthorizationService, &SetAdminACLEntryEx_INPUT{Username: username, DigestPassword: digestPassword})
+ response = Response{
+ Message: &client.Message{
+ XMLInput: as.base.WSManMessageCreator.CreateXML(header, body),
+ },
+ }
+ err = as.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
diff --git a/pkg/wsman/amt/authorization/service_test.go b/pkg/wsman/amt/authorization/service_test.go
new file mode 100644
index 00000000..2039e158
--- /dev/null
+++ b/pkg/wsman/amt/authorization/service_test.go
@@ -0,0 +1,264 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package authorization
+
+import (
+ "encoding/xml"
+ "testing"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
+ "github.com/stretchr/testify/assert"
+)
+
+func TestPositiveAMT_AuthorizationService(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/authorization",
+ }
+ elementUnderTest := NewServiceWithClient(wsmanMessageCreator, &client)
+ t.Run("amt_AuthorizationService Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {"should create a valid AMT_AuthorizationService Get wsman message",
+ AMT_AuthorizationService,
+ wsmantesting.GET,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Get"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GetResponse: AuthorizationOccurrence{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AuthorizationService", Local: "AMT_AuthorizationService"},
+ AllowHttpQopAuthOnly: 1,
+ CreationClassName: AMT_AuthorizationService,
+ ElementName: "Intel(r) AMT Authorization Service",
+ EnabledState: 5,
+ Name: "Intel(r) AMT Authorization Service",
+ RequestedState: 12,
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "Intel(r) AMT",
+ },
+ },
+ },
+ //ENUMERATES
+ {"should create a valid AMT_AuthorizationService Enumerate wsman message",
+ AMT_AuthorizationService,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Enumerate"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "5C000000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid AMT_AuthorizationService Pull wsman message",
+ AMT_AuthorizationService,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Pull"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ AuthorizationOccurrenceItems: []AuthorizationOccurrence{
+ {
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AuthorizationService", Local: "AMT_AuthorizationService"},
+ AllowHttpQopAuthOnly: 1,
+ CreationClassName: AMT_AuthorizationService,
+ ElementName: "Intel(r) AMT Authorization Service",
+ EnabledState: 5,
+ Name: "Intel(r) AMT Authorization Service",
+ RequestedState: 12,
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "Intel(r) AMT",
+ },
+ },
+ },
+ },
+ },
+ // // AUTHORIZATION SERVICE
+
+ // // ADD USER ACL ENTRY EX
+ // // Verify with Matt - Typescript is referring to wrong realm values
+ // // {"should return a valid amt_AuthorizationService ADD_USER_ACL_ENTRY_EX wsman message using digest", AMT_AuthorizationService, ADD_USER_ACL_ENTRY_EX, fmt.Sprintf(`%s%s%d%d`, "test", "P@ssw0rd", 2, 3), func() string {
+ // // return elementUnderTest.AddUserAclEntryEx(authorization.AccessPermissionLocalAndNetworkAccess, []authorization.RealmValues{authorization.RedirectionRealm}, "test", "P@ssw0rd", "")
+ // // }},
+ // // {"should return a valid amt_AuthorizationService ADD_USER_ACL_ENTRY_EX wsman message using kerberos", AMT_AuthorizationService, ADD_USER_ACL_ENTRY_EX, fmt.Sprintf(`%d%d%d3`, 64, 2, 3), func() string {
+ // // return elementUnderTest.AddUserAclEntryEx(authorization.AccessPermissionLocalAndNetworkAccess, []authorization.RealmValues{authorization.RedirectionRealm}, "", "", "64")
+ // // }},
+ // // // Check how to verify for exceptions
+ // // // {"should throw an error if the digestUsername is longer than 16 when calling AddUserAclEntryEx", "", "", "", func() string {
+ // // // return elementUnderTest.AddUserAclEntryEx(2, []models.RealmValues{models.RedirectionRealm}, "thisusernameistoolong", "test", "")
+ // // // }},
+ // // ENUMERATE USER ACL ENTRIES
+ // {"should return a valid amt_AuthorizationService EnumerateUserAclEntries wsman message when startIndex is undefined", AMT_AuthorizationService, `http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AuthorizationService/EnumerateUserAclEntries`, fmt.Sprintf(`%d`, 1), func() string {
+ // var index int
+ // return elementUnderTest.EnumerateUserAclEntries(index)
+ // }},
+ // {"should return a valid amt_AuthorizationService EnumerateUserAclEntries wsman message when startIndex is not 1", AMT_AuthorizationService, `http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AuthorizationService/EnumerateUserAclEntries`, fmt.Sprintf(`%d`, 50), func() string {
+ // return elementUnderTest.EnumerateUserAclEntries(50)
+ // }},
+ // // GET USER ACL ENTRY EX
+ // {"should return a valid amt_AuthorizationService GetUserAclEntryEx wsman message", AMT_AuthorizationService, `http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AuthorizationService/GetUserAclEntryEx`, `1`, func() string {
+ // return elementUnderTest.GetUserAclEntryEx(1)
+ // }},
+ // // UPDATE USER ACL ENTRY EX
+ // // {"should return a valid amt_AuthorizationService UpdateUserAclEntryEx wsman message using digest", AMT_AuthorizationService, `http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AuthorizationService/UpdateUserAclEntryEx`, `1`, func() string {
+ // // return elementUnderTest.UpdateUserAclEntryEx(1, 2, []authorization.RealmValues{authorization.RedirectionRealm}, "test", "test123!", "")
+ // // }},
+ // // {"should return a valid amt_AuthorizationService UpdateUserAclEntryEx wsman message using kerberos", AMT_AuthorizationService, `http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AuthorizationService/UpdateUserAclEntryEx`, `16423`, func() string {
+ // // return elementUnderTest.UpdateUserAclEntryEx(1, 2, []authorization.RealmValues{authorization.RedirectionRealm}, "", "", "64")
+ // // }},
+ // // // should throw an error if digest or kerberos credentials are not provided to UpdateUserAclEntryEx
+ // // // should throw an error if the digestUsername is longer than 16 when calling UpdateUserAclEntryEx
+
+ // // REMOVE USER ACL ENTRY
+ // {"should return a valid amt_AuthorizationService RemoveUserAclEntry wsman message", AMT_AuthorizationService, `http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AuthorizationService/RemoveUserAclEntry`, `1`, func() string {
+ // return elementUnderTest.RemoveUserAclEntry(1)
+ // }},
+
+ // // GET ADMIN ACL ENTRY
+ // {"should return a valid amt_AuthorizationService GetAdminAclEntry wsman message", AMT_AuthorizationService, `http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AuthorizationService/GetAdminAclEntry`, ``, func() string {
+ // return elementUnderTest.GetAdminAclEntry()
+ // }},
+
+ // // GET ADMIN ACL ENTRY STATUS
+ // {"should return a valid amt_AuthorizationService GetAdminAclEntry wsman message", AMT_AuthorizationService, `http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AuthorizationService/GetAdminAclEntryStatus`, ``, func() string {
+ // return elementUnderTest.GetAdminAclEntryStatus()
+ // }},
+
+ // // GET ADMIN NET ACL ENTRY STATUS
+ // {"should return a valid amt_AuthorizationService GetAdminNetAclEntryStatus wsman message", AMT_AuthorizationService, `http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AuthorizationService/GetAdminNetAclEntryStatus`, ``, func() string {
+ // return elementUnderTest.GetAdminNetAclEntryStatus()
+ // }},
+
+ // // GET ACL ENABLED STATE
+ // {"should return a valid amt_AuthorizationService GetAclEnabledState wsman message", AMT_AuthorizationService, `http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AuthorizationService/GetAclEnabledState`, `1`, func() string {
+ // return elementUnderTest.GetAclEnabledState(1)
+ // }},
+ }
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.NoError(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.Equal(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
+func TestNegativeAMT_AuthorizationService(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/authorization",
+ }
+ elementUnderTest := NewServiceWithClient(wsmanMessageCreator, &client)
+ t.Run("amt_AuthorizationService Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ extraHeader string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ {
+ "should create an invalid AMT_EthernetPortSettings Get wsman message",
+ "AMT_EthernetPortSettings",
+ wsmantesting.GET,
+ "",
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GetResponse: AuthorizationOccurrence{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AuthorizationService", Local: "AMT_AuthorizationService"},
+ AllowHttpQopAuthOnly: 1,
+ CreationClassName: AMT_AuthorizationService,
+ ElementName: "Intel(r) AMT Authorization Service",
+ EnabledState: 5,
+ Name: "Intel(r) AMT Authorization Service",
+ RequestedState: 12,
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "Intel(r) AMT",
+ },
+ },
+ },
+ {
+ "should create an invalid AMT_EthernetPortSettings Pull wsman message",
+ "AMT_EthernetPortSettings",
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Pull("")
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ AuthorizationOccurrenceItems: []AuthorizationOccurrence{
+ {
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_AuthorizationService", Local: "AMT_AuthorizationService"},
+ AllowHttpQopAuthOnly: 1,
+ CreationClassName: AMT_AuthorizationService,
+ ElementName: "Intel(r) AMT Authorization Service",
+ EnabledState: 5,
+ Name: "Intel(r) AMT Authorization Service",
+ RequestedState: 12,
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "Intel(r) AMT",
+ },
+ },
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, test.extraHeader, test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.Error(t, err)
+ assert.NotEqual(t, expectedXMLInput, response.XMLInput)
+ assert.NotEqual(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
diff --git a/pkg/wsman/amt/authorization/types.go b/pkg/wsman/amt/authorization/types.go
new file mode 100644
index 00000000..ef78b275
--- /dev/null
+++ b/pkg/wsman/amt/authorization/types.go
@@ -0,0 +1,170 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package authorization
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+)
+
+type AuthorizationService struct {
+ base message.Base
+}
+
+// OUTPUTS
+// Response Types
+type (
+ Response struct {
+ *client.Message
+ XMLName xml.Name `xml:"Envelope"`
+ Header message.Header `xml:"Header"`
+ Body Body `xml:"Body"`
+ }
+ Body struct {
+ XMLName xml.Name `xml:"Body"`
+ GetResponse AuthorizationOccurrence
+ EnumerateResponse common.EnumerateResponse
+ PullResponse PullResponse
+ }
+
+ AuthorizationOccurrence struct {
+ XMLName xml.Name `xml:"AMT_AuthorizationService"`
+ AllowHttpQopAuthOnly int `xml:"AllowHttpQopAuthOnly"` // Indicates whether using the http "quality of protection" (qop) directive with value auth is allowed
+ CreationClassName string `xml:"CreationClassName"` // CreationClassName indicates the name of the class or the subclass that is used in the creation of an instance. When used with the other key properties of this class, this property allows all instances of this class and its subclasses to be uniquely identified. In Intel AMT Release 6.0 and later releases value is 'AMT_AuthorizationService'
+ ElementName string `xml:"ElementName"` // A user-friendly name for the object. This property allows each instance to define a user-friendly name in addition to its key properties, identity data, and description information. Note that the Name property of ManagedSystemElement is also defined as a user-friendly name. But, it is often subclassed to be a Key. It is not reasonable that the same property can convey both identity and a user-friendly name, without inconsistencies. Where Name exists and is not a Key (such as for instances of LogicalDevice), the same information can be present in both the Name and ElementName properties. Note that if there is an associated instance of CIM_EnabledLogicalElementCapabilities, restrictions on this properties may exist as defined in ElementNameMask and MaxElementNameLen properties defined in that class.
+ EnabledState EnabledState `xml:"EnabledState"` // EnabledState is an integer enumeration that indicates the enabled and disabled states of an element.
+ Name string `xml:"Name"` // The Name property uniquely identifies the Service and provides an indication of the functionality that is managed. This functionality is described in more detail in the Description property of the object. In Intel AMT Release 6.0 and later releases value is 'Intel® AMT Authorization Service'
+ RequestedState RequestedState `xml:"RequestedState"` // RequestedState is an integer enumeration that indicates the last requested or desired state for the element, irrespective of the mechanism through which it was requested.
+ SystemCreationClassName string `xml:"SystemCreationClassName"` // The CreationClassName of the scoping System. In Intel AMT Release 6.0 and later releases value is 'CIM_ComputerSystem'
+ SystemName string `xml:"SystemName"` // The Name of the scoping System. In Intel AMT Release 6.0 and later releases value is 'Intel® AMT'
+ }
+ PullResponse struct {
+ XMLName xml.Name `xml:"PullResponse"`
+ AuthorizationOccurrenceItems []AuthorizationOccurrence `xml:"Items>AMT_AuthorizationService"`
+ }
+)
+type AddUserAclEntry struct {
+ XMLName xml.Name `xml:"h:AddUserAclEntryEx_INPUT"`
+ H string `xml:"xmlns:h,attr"`
+ Handle int `xml:"h:Handle,omitempty"` // Contains a creation handle.
+ DigestUsername string `xml:"h:DigestUsername"` // Username for access control. Contains 7-bit ASCII characters. String length is limited to 16 characters. Username cannot be an empty string.
+ DigestPassword string `xml:"h:DigestPassword"` // An MD5 Hash of these parameters concatenated together (Username + ":" + DigestRealm + ":" + Password). The DigestRealm is a field in AMT_GeneralSettings
+ AccessPermission AccessPermission `xml:"h:AccessPermission"` // Indicates whether the User is allowed to access Intel® AMT from the Network or Local Interfaces. Note: this definition is restricted by the Default Interface Access Permissions of each Realm.
+ Realms []RealmValues `xml:"h:Realms>h:RealmValue,omitempty"` // Array of interface names the ACL entry is allowed to access.
+ KerberosUserSid string `xml:"h:KerberosUserSid"` // Descriptor for user (SID) which is authenticated using the Kerberos Authentication. Byte array, specifying the Security Identifier (SID) according to the Kerberos specification. Current requirements imply that SID should be not smaller than 1 byte length and no longer than 28 bytes. SID length should also be a multiplicand of 4.
+}
+type UpdateUserAclEntry struct {
+ XMLName xml.Name `xml:"h:UpdateUserAclEntry_INPUT"`
+ H string `xml:"xmlns:h,attr"`
+ Handle int `xml:"h:Handle,omitempty"` // Contains a creation handle.
+ DigestUsername string `xml:"h:DigestUsername"` // Username for access control. Contains 7-bit ASCII characters. String length is limited to 16 characters. Username cannot be an empty string.
+ DigestPassword string `xml:"h:DigestPassword"` // An MD5 Hash of these parameters concatenated together (Username + ":" + DigestRealm + ":" + Password). The DigestRealm is a field in AMT_GeneralSettings
+ AccessPermission AccessPermission `xml:"h:AccessPermission"` // Indicates whether the User is allowed to access Intel® AMT from the Network or Local Interfaces. Note: this definition is restricted by the Default Interface Access Permissions of each Realm.
+ Realms []RealmValues `xml:"h:Realms>h:RealmValue,omitempty"` // Array of interface names the ACL entry is allowed to access.
+ KerberosUserSid string `xml:"h:KerberosUserSid"` // Descriptor for user (SID) which is authenticated using the Kerberos Authentication. Byte array, specifying the Security Identifier (SID) according to the Kerberos specification. Current requirements imply that SID should be not smaller than 1 byte length and no longer than 28 bytes. SID length should also be a multiplicand of 4.
+}
+
+// ValueMap={0, 1, 2}
+//
+// Values={LocalAccessPermission, NetworkAccessPermission, AnyAccessPermission}
+type AccessPermission int
+
+// ValueMap={0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, ..}
+//
+// Values={InvalidRealm, ReservedRealm0, RedirectionRealm, PTAdministrationRealm, HardwareAssetRealm, RemoteControlRealm, StorageRealm, EventManagerRealm, StorageAdminRealm, AgentPresenceLocalRealm, AgentPresenceRemoteRealm, CircuitBreakerRealm, NetworkTimeRealm, GeneralInfoRealm, FirmwareUpdateRealm, EITRealm, LocalUN, EndpointAccessControlRealm, EndpointAccessControlAdminRealm, EventLogReaderRealm, AuditLogRealm, ACLRealm, ReservedRealm1, ReservedRealm2, LocalSystemRealm, Reserved}
+type RealmValues int
+
+// EnabledState is an integer enumeration that indicates the enabled and disabled states of an element. It can also indicate the transitions between these requested states. For example, shutting down (value=4) and starting (value=10) are transient states between enabled and disabled.
+//
+// The following text briefly summarizes the various enabled and disabled states:
+//
+// Enabled (2) indicates that the element is or could be executing commands, will process any queued commands, and queues new requests.
+//
+// Disabled (3) indicates that the element will not execute commands and will drop any new requests.
+//
+// Shutting Down (4) indicates that the element is in the process of going to a Disabled state.
+//
+// Not Applicable (5) indicates the element does not support being enabled or disabled.
+//
+// Enabled but Offline (6) indicates that the element might be completing commands, and will drop any new requests.
+//
+// Test (7) indicates that the element is in a test state.
+//
+// Deferred (8) indicates that the element might be completing commands, but will queue any new requests.
+//
+// Quiesce (9) indicates that the element is enabled but in a restricted mode.
+//
+// Starting (10) indicates that the element is in the process of going to an Enabled state. New requests are queued.
+//
+// Value 6 ("Enabled but Offline") can be recieved also if the Audit Log is in locked state.
+//
+// ValueMap={0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11..32767, 32768..65535}
+//
+// Values={Unknown, Other, Enabled, Disabled, Shutting Down, Not Applicable, Enabled but Offline, In Test, Deferred, Quiesce, Starting, DMTF Reserved, Vendor Reserved}
+type EnabledState int
+
+// RequestedState is an integer enumeration that indicates the last requested or desired state for the element, irrespective of the mechanism through which it was requested. The actual state of the element is represented by EnabledState. This property is provided to compare the last requested and current enabled or disabled states. Note that when EnabledState is set to 5 ("Not Applicable"), then this property has no meaning. Refer to the EnabledState property description for explanations of the values in the RequestedState enumeration.
+//
+// "Unknown" (0) indicates the last requested state for the element is unknown.
+//
+// Note that the value "No Change" (5) has been deprecated in lieu of indicating the last requested state is "Unknown" (0). If the last requested or desired state is unknown, RequestedState should have the value "Unknown" (0), but may have the value "No Change" (5).Offline (6) indicates that the element has been requested to transition to the Enabled but Offline EnabledState. It should be noted that there are two new values in RequestedState that build on the statuses of EnabledState. These are "Reboot" (10) and "Reset" (11). Reboot refers to doing a "Shut Down" and then moving to an "Enabled" state. Reset indicates that the element is first "Disabled" and then "Enabled". The distinction between requesting "Shut Down" and "Disabled" should also be noted. Shut Down requests an orderly transition to the Disabled state, and might involve removing power, to completely erase any existing state. The Disabled state requests an immediate disabling of the element, such that it will not execute or accept any commands or processing requests.
+//
+// This property is set as the result of a method invocation (such as Start or StopService on CIM_Service), or can be overridden and defined as WRITEable in a subclass. The method approach is considered superior to a WRITEable property, because it allows an explicit invocation of the operation and the return of a result code.
+//
+// If knowledge of the last RequestedState is not supported for the EnabledLogicalElement, the property shall be NULL or have the value 12 "Not Applicable".
+//
+// ValueMap={0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, .., 32768..65535}
+//
+// Values={Unknown, Enabled, Disabled, Shut Down, No Change, Offline, Test, Deferred, Quiesce, Reboot, Reset, Not Applicable, DMTF Reserved, Vendor Reserved}
+type RequestedState int
+
+// ValueMap={0, 1, 12, 16, 23, 38, 2054, 2055, 2058, 2065, 2075}
+//
+// Values={PT_STATUS_SUCCESS, PT_STATUS_INTERNAL_ERROR, PT_STATUS_INVALID_NAME, PT_STATUS_NOT_PERMITTED, PT_STATUS_MAX_LIMIT_REACHED, PT_STATUS_FLASH_WRITE_LIMIT_EXCEEDED, PT_STATUS_INVALID_PASSWORD, PT_STATUS_INVALID_REALM, AMT_STATUS_DUPLICATE, PT_STATUS_MAX_KERB_DOMAIN_REACHED, PT_STATUS_AUDIT_FAIL}
+type PTStatus int
+
+// INPUTS
+// Request Types
+type (
+ EnumerateUserAclEntries_INPUT struct {
+ XMLName xml.Name `xml:"h:EnumerateUserAclEntries_INPUT"`
+ H string `xml:"xmlns:h,attr"`
+ StartIndex int `xml:"h:StartIndex"` // Indicates the first ACL entry to retrieve. To enumerate the entire list, an application sends this message with StartIndex set to 1.
+ }
+
+ GetAclEnabledState_INPUT struct {
+ XMLName xml.Name `xml:"h:GetAclEnabledState_INPUT"`
+ H string `xml:"xmlns:h,attr"`
+ Handle int `xml:"h:Handle"` // Specifies the ACL entry to fetch.
+ }
+ GetUserAclEntryEx_INPUT struct {
+ XMLName xml.Name `xml:"h:GetUserAclEntryEx_INPUT"`
+ H string `xml:"xmlns:h,attr"`
+ Handle int `xml:"h:Handle"` // Specifies the ACL entry to fetch.
+ }
+ RemoveUserAclEntry_INPUT struct {
+ XMLName xml.Name `xml:"h:RemoveUserAclEntry_INPUT"`
+ H string `xml:"xmlns:h,attr"`
+ Handle int `xml:"h:Handle"` // Specifies the ACL entry to be removed.
+ }
+
+ SetAclEnabledState_INPUT struct {
+ XMLName xml.Name `xml:"h:SetAclEnabledState_INPUT"`
+ H string `xml:"xmlns:h,attr"`
+ Handle int `xml:"h:Handle"` // Specifies the ACL entry to update
+ Enabled bool `xml:"h:Enabled"` // Specifies the state of the ACL entry
+ }
+
+ SetAdminACLEntryEx_INPUT struct {
+ XMLName xml.Name `xml:"h:SetAdminACLEntryEx_INPUT"`
+ H string `xml:"xmlns:h,attr"`
+ Username string `xml:"h:Username"` // Username for access control. Contains 7-bit ASCII characters. String length is limited to 16 characters. Username cannot be an empty string.
+ DigestPassword string `xml:"h:DigestPassword"` // An MD5 Hash of these parameters concatenated together (Username + ":" + DigestRealm + ":" + Password). The DigestRealm is a field in AMT_GeneralSettings
+ }
+)
diff --git a/pkg/wsman/amt/boot/capabilities.go b/pkg/wsman/amt/boot/capabilities.go
new file mode 100644
index 00000000..6f3eb282
--- /dev/null
+++ b/pkg/wsman/amt/boot/capabilities.go
@@ -0,0 +1,85 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+// Package boot facilitates communication with Intel® AMT devices to access the boot capabilities and boot setting data.
+//
+// Capabilities reports what boot options that the Intel® AMT device supports.
+//
+// SettingData provides configuration-related and operational parameters for the boot service in the Intel® AMT device. In order to activate these settings use [pkg/github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/power] RequestPowerStateChange(). Notice that you can't set certain values while others are enabled (for example: You can't set UseIDER or UseSOL if a CIM_BootSourceSetting is chosen).
+package boot
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+)
+
+// NewBootCapabilitiesWithClient instantiates a new Boot Capabilities service
+func NewBootCapabilitiesWithClient(wsmanMessageCreator *message.WSManMessageCreator, client client.WSMan) Capabilities {
+ return Capabilities{
+ base: message.NewBaseWithClient(wsmanMessageCreator, AMT_BootCapabilities, client),
+ }
+}
+
+// Get retrieves the representation of the instance
+func (bootCapabilities Capabilities) Get() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: bootCapabilities.base.Get(nil),
+ },
+ }
+ // send the message to AMT
+ err = bootCapabilities.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Enumerate returns an enumeration context which is used in a subsequent Pull call
+func (bootCapabilities Capabilities) Enumerate() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: bootCapabilities.base.Enumerate(),
+ },
+ }
+ // send the message to AMT
+ err = bootCapabilities.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Pull returns the instances of this class. An enumeration context provided by the Enumerate call is used as input.
+func (bootCapabilities Capabilities) Pull(enumerationContext string) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: bootCapabilities.base.Pull(enumerationContext),
+ },
+ }
+ // send the message to AMT
+ err = bootCapabilities.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
diff --git a/pkg/wsman/amt/boot/capabilities_test.go b/pkg/wsman/amt/boot/capabilities_test.go
new file mode 100644
index 00000000..cf3300b1
--- /dev/null
+++ b/pkg/wsman/amt/boot/capabilities_test.go
@@ -0,0 +1,303 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package boot
+
+import (
+ "encoding/xml"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
+)
+
+func TestPositiveAMT_BootCapabilities(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/boot/capabilities",
+ }
+ elementUnderTest := NewBootCapabilitiesWithClient(wsmanMessageCreator, &client)
+
+ t.Run("amt_BootCapabilities Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create a valid AMT_BootCapabilities Get wsman message",
+ AMT_BootCapabilities,
+ wsmantesting.GET,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Get"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ BootCapabilitiesGetResponse: BootCapabilitiesResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_BootCapabilities", Local: "AMT_BootCapabilities"},
+ BIOSPause: false,
+ BIOSReflash: true,
+ BIOSSecureBoot: true,
+ BIOSSetup: true,
+ ConfigurationDataReset: false,
+ ElementName: "Intel(r) AMT: Boot Capabilities",
+ ForceCDorDVDBoot: true,
+ ForceDiagnosticBoot: false,
+ ForceHardDriveBoot: true,
+ ForceHardDriveSafeModeBoot: false,
+ ForcePXEBoot: true,
+ ForcedProgressEvents: true,
+ IDER: true,
+ InstanceID: "Intel(r) AMT:BootCapabilities 0",
+ KeyboardLock: true,
+ PowerButtonLock: false,
+ ResetButtonLock: false,
+ SOL: true,
+ SecureErase: false,
+ SleepButtonLock: false,
+ UserPasswordBypass: true,
+ VerbosityQuiet: false,
+ VerbosityScreenBlank: false,
+ VerbosityVerbose: false,
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create a valid AMT_BootCapabilities Enumerate wsman message",
+ AMT_BootCapabilities,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Enumerate"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "E6070000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid AMT_BootCapabilities Pull wsman message",
+ AMT_BootCapabilities,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Pull"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ BootCapabilitiesItems: []BootCapabilitiesResponse{
+ {
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_BootCapabilities", Local: "AMT_BootCapabilities"},
+ BIOSPause: false,
+ BIOSReflash: true,
+ BIOSSecureBoot: true,
+ BIOSSetup: true,
+ ConfigurationDataReset: false,
+ ElementName: "Intel(r) AMT: Boot Capabilities",
+ ForceCDorDVDBoot: true,
+ ForceDiagnosticBoot: false,
+ ForceHardDriveBoot: true,
+ ForceHardDriveSafeModeBoot: false,
+ ForcePXEBoot: true,
+ ForcedProgressEvents: true,
+ IDER: true,
+ InstanceID: "Intel(r) AMT:BootCapabilities 0",
+ KeyboardLock: true,
+ PowerButtonLock: false,
+ ResetButtonLock: false,
+ SOL: true,
+ SecureErase: false,
+ SleepButtonLock: false,
+ UserPasswordBypass: true,
+ VerbosityQuiet: false,
+ VerbosityScreenBlank: false,
+ VerbosityVerbose: false,
+ },
+ },
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.NoError(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.Equal(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
+
+func TestNegativeAMT_BootCapabilities(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/boot/capabilities",
+ }
+ elementUnderTest := NewBootCapabilitiesWithClient(wsmanMessageCreator, &client)
+
+ t.Run("amt_BootCapabilities Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create a valid AMT_BootCapabilities Get wsman message",
+ AMT_BootCapabilities,
+ wsmantesting.GET,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ BootCapabilitiesGetResponse: BootCapabilitiesResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_BootCapabilities", Local: "AMT_BootCapabilities"},
+ InstanceID: "t",
+ ElementName: "t",
+ IDER: false,
+ SOL: false,
+ BIOSReflash: false,
+ BIOSSetup: false,
+ BIOSPause: false,
+ ForcePXEBoot: false,
+ ForceHardDriveBoot: false,
+ ForceHardDriveSafeModeBoot: false,
+ ForceDiagnosticBoot: false,
+ ForceCDorDVDBoot: false,
+ VerbosityScreenBlank: false,
+ PowerButtonLock: false,
+ ResetButtonLock: false,
+ KeyboardLock: false,
+ SleepButtonLock: false,
+ UserPasswordBypass: false,
+ ForcedProgressEvents: false,
+ VerbosityVerbose: false,
+ VerbosityQuiet: false,
+ ConfigurationDataReset: false,
+ BIOSSecureBoot: false,
+ SecureErase: false,
+ ForceWinREBoot: false,
+ ForceUEFILocalPBABoot: false,
+ ForceUEFIHTTPSBoot: false,
+ AMTSecureBootControl: false,
+ UEFIWiFiCoExistenceAndProfileShare: false,
+ PlatformErase: 0,
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create a valid AMT_BootCapabilities Enumerate wsman message",
+ AMT_BootCapabilities,
+ wsmantesting.ENUMERATE,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "error",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid AMT_BootCapabilities Pull wsman message",
+ AMT_BootCapabilities,
+ wsmantesting.PULL,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ BootCapabilitiesItems: []BootCapabilitiesResponse{
+ {
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_BootCapabilities", Local: "AMT_BootCapabilities"},
+ InstanceID: "t",
+ ElementName: "t",
+ IDER: false,
+ SOL: false,
+ BIOSReflash: false,
+ BIOSSetup: false,
+ BIOSPause: false,
+ ForcePXEBoot: false,
+ ForceHardDriveBoot: false,
+ ForceHardDriveSafeModeBoot: false,
+ ForceDiagnosticBoot: false,
+ ForceCDorDVDBoot: false,
+ VerbosityScreenBlank: false,
+ PowerButtonLock: false,
+ ResetButtonLock: false,
+ KeyboardLock: false,
+ SleepButtonLock: false,
+ UserPasswordBypass: false,
+ ForcedProgressEvents: false,
+ VerbosityVerbose: false,
+ VerbosityQuiet: false,
+ ConfigurationDataReset: false,
+ BIOSSecureBoot: false,
+ SecureErase: false,
+ ForceWinREBoot: false,
+ ForceUEFILocalPBABoot: false,
+ ForceUEFIHTTPSBoot: false,
+ AMTSecureBootControl: false,
+ UEFIWiFiCoExistenceAndProfileShare: false,
+ PlatformErase: 0,
+ },
+ },
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.Error(t, err)
+ assert.NotEqual(t, expectedXMLInput, response.XMLInput)
+ assert.NotEqual(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
diff --git a/pkg/wsman/amt/boot/constants.go b/pkg/wsman/amt/boot/constants.go
new file mode 100644
index 00000000..8a29c052
--- /dev/null
+++ b/pkg/wsman/amt/boot/constants.go
@@ -0,0 +1,23 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package boot
+
+const (
+ AMT_BootSettingData string = "AMT_BootSettingData"
+ AMT_BootCapabilities string = "AMT_BootCapabilities"
+)
+
+const (
+ SystemDefault FirmwareVerbosity = iota
+ QuietMinimal
+ VerboseAll
+ ScreenBlank
+)
+
+const (
+ FloppyBoot IDERBootDevice = iota
+ CDBoot
+)
diff --git a/pkg/wsman/amt/boot/marshal.go b/pkg/wsman/amt/boot/marshal.go
new file mode 100644
index 00000000..8b27da02
--- /dev/null
+++ b/pkg/wsman/amt/boot/marshal.go
@@ -0,0 +1,30 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package boot
+
+import (
+ "encoding/json"
+
+ "gopkg.in/yaml.v3"
+)
+
+// JSON marshals the type into JSON format
+func (r *Response) JSON() string {
+ jsonOutput, err := json.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(jsonOutput)
+}
+
+// YAML marshals the type into YAML format
+func (r *Response) YAML() string {
+ yamlOutput, err := yaml.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(yamlOutput)
+}
diff --git a/pkg/wsman/amt/boot/settingdata.go b/pkg/wsman/amt/boot/settingdata.go
new file mode 100644
index 00000000..600d12cc
--- /dev/null
+++ b/pkg/wsman/amt/boot/settingdata.go
@@ -0,0 +1,102 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package boot
+
+import (
+ "encoding/xml"
+ "fmt"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+)
+
+// Instantiates a new Boot Setting Data service
+func NewBootSettingDataWithClient(wsmanMessageCreator *message.WSManMessageCreator, client client.WSMan) SettingData {
+ return SettingData{
+ base: message.NewBaseWithClient(wsmanMessageCreator, AMT_BootSettingData, client),
+ }
+}
+
+// Get retrieves the representation of the instance
+func (settingData SettingData) Get() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: settingData.base.Get(nil),
+ },
+ }
+ // send the message to AMT
+ err = settingData.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Enumerate returns an enumeration context which is used in a subsequent Pull call
+func (settingData SettingData) Enumerate() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: settingData.base.Enumerate(),
+ },
+ }
+ // send the message to AMT
+ err = settingData.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Pull returns the instances of this class. An enumeration context provided by the Enumerate call is used as input.
+func (settingData SettingData) Pull(enumerationContext string) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: settingData.base.Pull(enumerationContext),
+ },
+ }
+ // send the message to AMT
+ err = settingData.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Put will change properties of the selected instance
+func (settingData SettingData) Put(bootSettingData BootSettingDataRequest) (response Response, err error) {
+ bootSettingData.H = fmt.Sprintf("%s%s", message.AMTSchema, AMT_BootSettingData)
+ response = Response{
+ Message: &client.Message{
+ XMLInput: settingData.base.Put(bootSettingData, false, nil),
+ },
+ }
+ // send the message to AMT
+ err = settingData.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
diff --git a/pkg/wsman/amt/boot/settingdata_test.go b/pkg/wsman/amt/boot/settingdata_test.go
new file mode 100644
index 00000000..aa27e377
--- /dev/null
+++ b/pkg/wsman/amt/boot/settingdata_test.go
@@ -0,0 +1,308 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package boot
+
+import (
+ "encoding/xml"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
+)
+
+func TestPositiveAMT_BootSettingData(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/boot/settingdata",
+ }
+ elementUnderTest := NewBootSettingDataWithClient(wsmanMessageCreator, &client)
+
+ t.Run("amt_BootSettingData Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create a valid AMT_BootSettingData Get wsman message",
+ AMT_BootSettingData,
+ wsmantesting.GET,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Get"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ BootSettingDataGetResponse: BootSettingDataResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_BootSettingData", Local: "AMT_BootSettingData"},
+ InstanceID: "Intel(r) AMT:BootSettingData 0",
+ ElementName: "Intel(r) AMT Boot Configuration Settings",
+ OwningEntity: "Intel(r) AMT",
+ UseSOL: false,
+ UseSafeMode: false,
+ ReflashBIOS: false,
+ BIOSSetup: false,
+ BIOSPause: false,
+ LockPowerButton: false,
+ LockResetButton: false,
+ LockKeyboard: false,
+ LockSleepButton: false,
+ UserPasswordBypass: false,
+ ForcedProgressEvents: false,
+ FirmwareVerbosity: 0,
+ ConfigurationDataReset: false,
+ IDERBootDevice: 0,
+ UseIDER: false,
+ EnforceSecureBoot: false,
+ BootMediaIndex: 0,
+ SecureErase: false,
+ RSEPassword: "",
+ OptionsCleared: false,
+ BIOSLastStatus: []int{2, 0},
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create a valid AMT_BootSettingData Enumerate wsman message",
+ AMT_BootSettingData,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Enumerate"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "DD070000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid AMT_BootSettingData Pull wsman message",
+ AMT_BootSettingData,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Pull"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ BootSettingDataItems: []BootSettingDataResponse{
+ {
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_BootSettingData", Local: "AMT_BootSettingData"},
+ InstanceID: "Intel(r) AMT:BootSettingData 0",
+ ElementName: "Intel(r) AMT Boot Configuration Settings",
+ OwningEntity: "Intel(r) AMT",
+ UseSOL: false,
+ UseSafeMode: false,
+ ReflashBIOS: false,
+ BIOSSetup: false,
+ BIOSPause: false,
+ LockPowerButton: false,
+ LockResetButton: false,
+ LockKeyboard: false,
+ LockSleepButton: false,
+ UserPasswordBypass: false,
+ ForcedProgressEvents: false,
+ FirmwareVerbosity: 0,
+ ConfigurationDataReset: false,
+ IDERBootDevice: 0,
+ UseIDER: false,
+ EnforceSecureBoot: false,
+ BootMediaIndex: 0,
+ SecureErase: false,
+ RSEPassword: "",
+ OptionsCleared: false,
+ BIOSLastStatus: []int{2, 0},
+ },
+ },
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.NoError(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.Equal(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
+
+func TestNegativeAMT_BootSettingData(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/boot/settingdata",
+ }
+ elementUnderTest := NewBootSettingDataWithClient(wsmanMessageCreator, &client)
+
+ t.Run("amt_BootSettingData Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create a valid AMT_BootSettingData Get wsman message",
+ AMT_BootSettingData,
+ wsmantesting.GET,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ BootSettingDataGetResponse: BootSettingDataResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_BootSettingData", Local: "AMT_BootSettingData"},
+ InstanceID: "t",
+ ElementName: "t",
+ OwningEntity: "t",
+ UseSOL: false,
+ UseSafeMode: false,
+ ReflashBIOS: false,
+ BIOSSetup: false,
+ BIOSPause: false,
+ LockPowerButton: false,
+ LockResetButton: false,
+ LockKeyboard: false,
+ LockSleepButton: false,
+ UserPasswordBypass: false,
+ ForcedProgressEvents: false,
+ FirmwareVerbosity: 0,
+ ConfigurationDataReset: false,
+ IDERBootDevice: 1,
+ UseIDER: false,
+ EnforceSecureBoot: false,
+ BootMediaIndex: 0,
+ SecureErase: false,
+ RSEPassword: "",
+ OptionsCleared: false,
+ WinREBootEnabled: false,
+ UEFILocalPBABootEnabled: false,
+ UEFIHTTPSBootEnabled: false,
+ SecureBootControlEnabled: false,
+ BootguardStatus: false,
+ BIOSLastStatus: []int{0, 0},
+ UEFIBootParametersArray: []int{0},
+ UEFIBootNumberOfParams: []int{0},
+ RPEEnabled: false,
+ PlatformErase: false,
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create a valid AMT_BootSettingData Enumerate wsman message",
+ AMT_BootSettingData,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "5C000000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid AMT_BootSettingData Pull wsman message",
+ AMT_BootSettingData,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ BootSettingDataItems: []BootSettingDataResponse{
+ {
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_BootSettingData", Local: "AMT_BootSettingData"},
+ InstanceID: "t",
+ ElementName: "t",
+ OwningEntity: "t",
+ UseSOL: false,
+ UseSafeMode: false,
+ ReflashBIOS: false,
+ BIOSSetup: false,
+ BIOSPause: false,
+ LockPowerButton: false,
+ LockResetButton: false,
+ LockKeyboard: false,
+ LockSleepButton: false,
+ UserPasswordBypass: false,
+ ForcedProgressEvents: false,
+ FirmwareVerbosity: 0,
+ ConfigurationDataReset: false,
+ IDERBootDevice: 1,
+ UseIDER: false,
+ EnforceSecureBoot: false,
+ BootMediaIndex: 0,
+ SecureErase: false,
+ RSEPassword: "",
+ OptionsCleared: false,
+ WinREBootEnabled: false,
+ UEFILocalPBABootEnabled: false,
+ UEFIHTTPSBootEnabled: false,
+ SecureBootControlEnabled: false,
+ BootguardStatus: false,
+ BIOSLastStatus: []int{0, 0},
+ UEFIBootParametersArray: []int{0},
+ UEFIBootNumberOfParams: []int{0},
+ RPEEnabled: false,
+ PlatformErase: false},
+ },
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.Error(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.NotEqual(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
diff --git a/pkg/wsman/amt/boot/types.go b/pkg/wsman/amt/boot/types.go
new file mode 100644
index 00000000..c1d108e4
--- /dev/null
+++ b/pkg/wsman/amt/boot/types.go
@@ -0,0 +1,170 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package boot
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+)
+
+type SettingData struct {
+ base message.Base
+}
+
+type Capabilities struct {
+ base message.Base
+}
+
+// OUTPUTS
+// Response Types
+type (
+ Response struct {
+ *client.Message
+ XMLName xml.Name `xml:"Envelope"`
+ Header message.Header `xml:"Header"`
+ Body Body `xml:"Body"`
+ }
+
+ Body struct {
+ XMLName xml.Name `xml:"Body"`
+ BootSettingDataGetResponse BootSettingDataResponse
+ BootCapabilitiesGetResponse BootCapabilitiesResponse
+ EnumerateResponse common.EnumerateResponse
+ PullResponse PullResponse
+ }
+ PullResponse struct {
+ XMLName xml.Name `xml:"PullResponse"`
+ BootSettingDataItems []BootSettingDataResponse `xml:"Items>AMT_BootSettingData"`
+ BootCapabilitiesItems []BootCapabilitiesResponse `xml:"Items>AMT_BootCapabilities"`
+ }
+ BootSettingDataResponse struct {
+ XMLName xml.Name `xml:"AMT_BootSettingData"`
+ InstanceID string `xml:"InstanceID,omitempty"` // Within the scope of the instantiating Namespace, InstanceID opaquely and uniquely identifies an instance of this class. To ensure uniqueness within the NameSpace, the value of InstanceID should be constructed using the following "preferred" algorithm: : Where and are separated by a colon (:), and where must include a copyrighted, trademarked, or otherwise unique name that is owned by the business entity that is creating or defining the InstanceID or that is a registered ID assigned to the business entity by a recognized global authority. (This requirement is similar to the _ structure of Schema class names.) In addition, to ensure uniqueness, must not contain a colon (:). When using this algorithm, the first colon to appear in InstanceID must appear between and . is chosen by the business entity and should not be reused to identify different underlying (real-world) elements. If the above "preferred" algorithm is not used, the defining entity must assure that the resulting InstanceID is not reused across any InstanceIDs produced by this or other providers for the NameSpace of this instance. For DMTF-defined instances, the "preferred" algorithm must be used with the set to CIM.
+ ElementName string `xml:"ElementName,omitempty"` // The user-friendly name for this instance of SettingData. In addition, the user-friendly name can be used as an index property for a search or query. (Note: The name does not have to be unique within a namespace.)
+ OwningEntity string `xml:"OwningEntity,omitempty"` // OwningEntity identifies the vendor or organization that defines the contained boot settings.
+ UseSOL bool `xml:"UseSOL,omitempty"` // When True, Serial over LAN is used on the next boot cycle.
+ UseSafeMode bool `xml:"UseSafeMode,omitempty"` // When a Hard-drive boot source is chosen (using CIM_BootConfigSetting) and this property is set to True, the Intel® AMT firmware will boot in safe mode.
+ ReflashBIOS bool `xml:"ReflashBIOS,omitempty"` // When True, the Intel® AMT firmware reflashes the BIOS on the next boot cycle. This property can be set to true only when a boot source isn't set (using CIM_BootConfigSetting.ChangeBootOrder method).
+ BIOSSetup bool `xml:"BIOSSetup,omitempty"` // When True, the Intel® AMT firmware enters the CMOS Setup screen on the next boot cycle. This property can be set to true only when a boot source isn't set (using CIM_BootConfigSetting.ChangeBootOrder method).
+ BIOSPause bool `xml:"BIOSPause,omitempty"` // When True, the BIOS pauses for user input on the next boot cycle. This property can be set to true only when a boot source isn't set (using CIM_BootConfigSetting.ChangeBootOrder method).
+ LockPowerButton bool `xml:"LockPowerButton,omitempty"` // When True, the Intel® AMT firmware disables the power button operation for the system, normally until the next boot cycle.
+ LockResetButton bool `xml:"LockResetButton,omitempty"` // When True, the Intel® AMT firmware disables the reset button operation for the system, normally until the next boot cycle.
+ LockKeyboard bool `xml:"LockKeyboard,omitempty"` // When True, the Intel® AMT firmware disallows keyboard activity during its boot process.
+ LockSleepButton bool `xml:"LockSleepButton,omitempty"` // When True, the Intel® AMT firmware disables the sleep button operation for the system, normally until the next boot cycle.
+ UserPasswordBypass bool `xml:"UserPasswordBypass,omitempty"` // When True, the Intel® AMT firmware boots the system and bypasses any user or boot password that might be set in the system.
+ ForcedProgressEvents bool `xml:"ForcedProgressEvents,omitempty"` // When True, the Intel® AMT firmware transmits all progress PET events to the alert-sending device.
+ FirmwareVerbosity FirmwareVerbosity `xml:"FirmwareVerbosity,omitempty"` // When set to a non-zero value, controls the amount of information the managed system writes to its local display.
+ ConfigurationDataReset bool `xml:"ConfigurationDataReset,omitempty"` // When True, the Intel® AMT firmware resets its non-volatile configuration data to the managed system's Setup defaults prior to booting the system.
+ IDERBootDevice IDERBootDevice `xml:"IDERBootDevice,omitempty"` // Specifies the device to use when UseIder is set. 0 - Floppy Boot, 1- CD Boot.
+ UseIDER bool `xml:"UseIDER,omitempty"` // When True, IDER is used on the next boot cycle.
+ EnforceSecureBoot bool `xml:"EnforceSecureBoot,omitempty"` // When True, Secure boot over IDER is enforced on the next boot cycle, if IDER boot is used. This field is also used in One-Click Recovery.
+ BootMediaIndex int `xml:"BootMediaIndex,omitempty"` // This property identifies the boot-media index for the managed client (when a boot source is set using the CIM_BootConfigSetting.ChangeBootOrder method). For Hard-Drive or CD/DVD boot - when the parameter value is 0, the default boot-media is booted. When the parameter value is 1, the primary boot-media is booted; when the value is 2, the secondary boot-media is booted; and so on. For PXE or diagnostics boot this property must be 0.
+ SecureErase bool `xml:"SecureErase,omitempty"` // When True, the BIOS performs secure erase operation. Note: Customers are recommended to use Secure Remote Platform Erase which is newer and more advanced than this function.
+ RSEPassword string `xml:"RSEPassword,omitempty"` // SSD password for Remote Secure Erase operation. This is a write-only field, an empty string is returned when instance is read. When writing, an empty string or lack of field will be ignored. The password length is limited to 32 ASCII characters. Note: Customers are recommended to use Secure Remote Platform Erase which is newer and more advanced than Remote Secure Erase.
+ OptionsCleared bool `xml:"OptionsCleared,omitempty"` // Indicates whether the boot options have been cleared by BIOS or not. This property is read only.
+ WinREBootEnabled bool `xml:"WinREBootEnabled,omitempty"` // Indicates whether ForceWinREBoot is enabled in BIOS. This property is read only.
+ UEFILocalPBABootEnabled bool `xml:"UEFILocalPBABootEnabled,omitempty"` // Indicates whether ForceUEFILocalPBABoot is enabled in BIOS. This property is read only.
+ UEFIHTTPSBootEnabled bool `xml:"UEFIHTTPSBootEnabled,omitempty"` // Indicates whether ForceUEFIHTTPSBoot is enabled in BIOS. This property is read only.
+ SecureBootControlEnabled bool `xml:"SecureBootControlEnabled,omitempty"` // Determines whether Intel AMT is privileged by BIOS to disable secure boot for an AMT triggered boot option. If not, BIOSSecureBoot must be set to TRUE. This property is read only.
+ BootguardStatus bool `xml:"BootguardStatus,omitempty"` // Enables the console to discover the security level of the BIOS boot flow. This property is read only.
+ BIOSLastStatus []int `xml:"BIOSLastStatus,omitempty"` // Last boot status reported by BIOS. The first 16-bit word contains the general BIOS status (0 - Success, 1 - In Progress, 2 - Not Updated, 0xFFFF - Failed). The second word contains the detailed error status (0 - Success/In Progress, 1 - General Drive Failure, 2 - Drive Password/Authentication Failure, 3 - Feature is not supported). This property is read-only.
+ UEFIBootParametersArray []int `xml:"UEFIBootParametersArray,omitempty"` // TLV parameters array encoded with base64 for configuring boot parameters for One-Click Recovery and Secure Remote Platform Erase.
+ UEFIBootNumberOfParams []int `xml:"UEFIBootNumberOfParams,omitempty"` // Number of parameters in UefiBootParametersArray
+ RPEEnabled bool `xml:"RPEEnabled,omitempty"` // Indicates whether Secure Remote Platform Erase is enabled by the BIOS. Note: This command needs to execute over TLS.
+ PlatformErase bool `xml:"PlatformErase,omitempty"` // When set to True, sets the boot option to trigger Secure Remote Platform Erase in the next boot. Note: This command needs to execute over TLS.
+ }
+
+ BootCapabilitiesResponse struct {
+ XMLName xml.Name `xml:"AMT_BootCapabilities"`
+ InstanceID string `xml:"InstanceID,omitempty"` // Within the scope of the instantiating Namespace, InstanceID opaquely and uniquely identifies an instance of this class. In order to ensure uniqueness within the NameSpace, the value of InstanceID SHOULD be constructed using the following 'preferred' algorithm: : Where and are separated by a colon ':', and where MUST include a copyrighted, trademarked or otherwise unique name that is owned by the business entity creating/defining the InstanceID, or is a registered ID that is assigned to the business entity by a recognized global authority (This is similar to the _ structure of Schema class names.) In addition, to ensure uniqueness MUST NOT contain a colon (':'). When using this algorithm, the first colon to appear in InstanceID MUST appear between and . is chosen by the business entity and SHOULD not be re-used to identify different underlying (real-world) elements. If the above 'preferred' algorithm is not used, the defining entity MUST assure that the resultant InstanceID is not re-used across any InstanceIDs produced by this or other providers for this instance's NameSpace. For DMTF defined instances, the 'preferred' algorithm MUST be used with the set to 'CIM'.
+ ElementName string `xml:"ElementName,omitempty"` // The user friendly name for this instance of Capabilities. In addition, the user friendly name can be used as a index property for a search of query. (Note: Name does not have to be unique within a namespace.)
+ IDER bool `xml:"IDER,omitempty"` // Indicates whether Intel® AMT device supports 'IDE Redirection'
+ SOL bool `xml:"SOL,omitempty"` // Indicates whether Intel® AMT device supports 'Serial Over Lan'
+ BIOSReflash bool `xml:"BIOSReflash,omitempty"` // Indicates whether Intel® AMT device supports 'BIOS Reflash'
+ BIOSSetup bool `xml:"BIOSSetup,omitempty"` // Indicates whether Intel® AMT device supports 'BIOS Setup'
+ BIOSPause bool `xml:"BIOSPause,omitempty"` // Indicates whether Intel® AMT device supports 'BIOS Pause'
+ ForcePXEBoot bool `xml:"ForcePXEBoot,omitempty"` // Indicates whether Intel® AMT device supports 'Force PXE Boot'
+ ForceHardDriveBoot bool `xml:"ForceHardDriveBoot,omitempty"` // Indicates whether Intel® AMT device supports 'Force Hard Drive Boot'
+ ForceHardDriveSafeModeBoot bool `xml:"ForceHardDriveSafeModeBoot,omitempty"` // Indicates whether Intel® AMT device supports 'Force Hard Drive Safe Mode Boot'
+ ForceDiagnosticBoot bool `xml:"ForceDiagnosticBoot,omitempty"` // Indicates whether Intel® AMT device supports 'Force Diagnostic Boot'
+ ForceCDorDVDBoot bool `xml:"ForceCDorDVDBoot,omitempty"` // Indicates whether Intel® AMT device supports 'Force CD or DVD Boot'
+ VerbosityScreenBlank bool `xml:"VerbosityScreenBlank,omitempty"` // Indicates whether Intel® AMT device supports 'Verbosity Screen Blank'
+ PowerButtonLock bool `xml:"PowerButtonLock,omitempty"` // Indicates whether Intel® AMT device supports 'Power Button Lock'
+ ResetButtonLock bool `xml:"ResetButtonLock,omitempty"` // Indicates whether Intel® AMT device supports 'Reset Button Lock'
+ KeyboardLock bool `xml:"KeyboardLock,omitempty"` // Indicates whether Intel® AMT device supports 'Keyboard Lock'
+ SleepButtonLock bool `xml:"SleepButtonLock,omitempty"` // Indicates whether Intel® AMT device supports 'Sleep Button Lock'
+ UserPasswordBypass bool `xml:"UserPasswordBypass,omitempty"` // Indicates whether Intel® AMT device supports 'User Password Bypass'
+ ForcedProgressEvents bool `xml:"ForcedProgressEvents,omitempty"` // Indicates whether Intel® AMT device supports 'Forced Progress Events'
+ VerbosityVerbose bool `xml:"VerbosityVerbose,omitempty"` // Indicates whether Intel® AMT device supports 'Verbosity/Verbose'
+ VerbosityQuiet bool `xml:"VerbosityQuiet,omitempty"` // Indicates whether Intel® AMT device supports 'Verbosity/Quiet'
+ ConfigurationDataReset bool `xml:"ConfigurationDataReset,omitempty"` // Indicates whether Intel® AMT device supports 'Configuration Data Reset'
+ BIOSSecureBoot bool `xml:"BIOSSecureBoot,omitempty"` // Indicates whether Intel® AMT device supports 'BIOS Secure Boot'
+ SecureErase bool `xml:"SecureErase,omitempty"` // Indicates whether Intel® AMT device supports 'Secure Erase'
+ ForceWinREBoot bool `xml:"ForceWinREBoot,omitempty"` // Supports Intel AMT invoking boot to WinRE
+ ForceUEFILocalPBABoot bool `xml:"ForceUEFILocalPBABoot,omitempty"` // Supports booting to an ISV’s PBA
+ ForceUEFIHTTPSBoot bool `xml:"ForceUEFIHTTPSBoot,omitempty"` // Supports Intel AMT invoking HTTPS boot
+ AMTSecureBootControl bool `xml:"AMTSecureBootControl,omitempty"` // Determines whether Intel AMT is privileged by BIOS to disable secure boot for an AMT triggered boot option. If true, the BIOS allows Intel AMT to control the secure boot (i.e., to disable secure boot in recovery from HTTPS under certain conditions).
+ UEFIWiFiCoExistenceAndProfileShare bool `xml:"UEFIWiFiCoExistenceAndProfileShare,omitempty"` // Read-only field, determines whether UEFI BIOS and Intel AMT WiFi profile share is supported. The feature is available from Intel® CSME 16.0.
+ PlatformErase int `xml:"PlatformErase,omitempty"` // Indicates whether the Intel AMT device supports Intel Remote Platform Erase (i.e., whether the OEM's BIOS includes support for the feature), and shows the devices that can be erased. The feature is available from Intel® CSME 16.0.
+ }
+)
+
+// INPUTS
+// Request Types
+type BootSettingDataRequest struct {
+ XMLName xml.Name `xml:"h:AMT_BootSettingData"`
+ H string `xml:"xmlns:h,attr"`
+ InstanceID string `xml:"h:InstanceID"` // Within the scope of the instantiating Namespace, InstanceID opaquely and uniquely identifies an instance of this class. To ensure uniqueness within the NameSpace, the value of InstanceID should be constructed using the following "preferred" algorithm: : Where and are separated by a colon (:), and where must include a copyrighted, trademarked, or otherwise unique name that is owned by the business entity that is creating or defining the InstanceID or that is a registered ID assigned to the business entity by a recognized global authority. (This requirement is similar to the _ structure of Schema class names.) In addition, to ensure uniqueness, must not contain a colon (:). When using this algorithm, the first colon to appear in InstanceID must appear between and . is chosen by the business entity and should not be reused to identify different underlying (real-world) elements. If the above "preferred" algorithm is not used, the defining entity must assure that the resulting InstanceID is not reused across any InstanceIDs produced by this or other providers for the NameSpace of this instance. For DMTF-defined instances, the "preferred" algorithm must be used with the set to CIM.
+ ElementName string `xml:"h:ElementName"` // Required. The user-friendly name for this instance of SettingData. In addition, the user-friendly name can be used as an index property for a search or query. (Note: The name does not have to be unique within a namespace.)
+ OwningEntity string `xml:"h:OwningEntity"` // OwningEntity identifies the vendor or organization that defines the contained boot settings.
+ UseSOL bool `xml:"h:UseSOL"` // Required. When True, Serial over LAN is used on the next boot cycle.
+ UseSafeMode bool `xml:"h:UseSafeMode"` // Required. When a Hard-drive boot source is chosen (using CIM_BootConfigSetting) and this property is set to True, the Intel® AMT firmware will boot in safe mode.
+ ReflashBIOS bool `xml:"h:ReflashBIOS"` // Required. When True, the Intel® AMT firmware reflashes the BIOS on the next boot cycle. This property can be set to true only when a boot source isn't set (using CIM_BootConfigSetting.ChangeBootOrder method).
+ BIOSSetup bool `xml:"h:BIOSSetup"` // Required. When True, the Intel® AMT firmware enters the CMOS Setup screen on the next boot cycle. This property can be set to true only when a boot source isn't set (using CIM_BootConfigSetting.ChangeBootOrder method).
+ BIOSPause bool `xml:"h:BIOSPause"` // Required. When True, the BIOS pauses for user input on the next boot cycle. This property can be set to true only when a boot source isn't set (using CIM_BootConfigSetting.ChangeBootOrder method).
+ LockPowerButton bool `xml:"h:LockPowerButton"` // Required. When True, the Intel® AMT firmware disables the power button operation for the system, normally until the next boot cycle.
+ LockResetButton bool `xml:"h:LockResetButton"` // Required. When True, the Intel® AMT firmware disables the reset button operation for the system, normally until the next boot cycle.
+ LockKeyboard bool `xml:"h:LockKeyboard"` // Required. When True, the Intel® AMT firmware disallows keyboard activity during its boot process.
+ LockSleepButton bool `xml:"h:LockSleepButton"` // Required. When True, the Intel® AMT firmware disables the sleep button operation for the system, normally until the next boot cycle.
+ UserPasswordBypass bool `xml:"h:UserPasswordBypass"` // Required. When True, the Intel® AMT firmware boots the system and bypasses any user or boot password that might be set in the system.
+ ForcedProgressEvents bool `xml:"h:ForcedProgressEvents"` // Required. When True, the Intel® AMT firmware transmits all progress PET events to the alert-sending device.
+ FirmwareVerbosity FirmwareVerbosity `xml:"h:FirmwareVerbosity"` // Required. When set to a non-zero value, controls the amount of information the managed system writes to its local display.
+ ConfigurationDataReset bool `xml:"h:ConfigurationDataReset"` // Required. When True, the Intel® AMT firmware resets its non-volatile configuration data to the managed system's Setup defaults prior to booting the system.
+ IDERBootDevice IDERBootDevice `xml:"h:IDERBootDevice"` // Required. Specifies the device to use when UseIder is set. 0 - Floppy Boot, 1- CD Boot.
+ UseIDER bool `xml:"h:UseIDER"` // Required. When True, IDER is used on the next boot cycle.
+ EnforceSecureBoot bool `xml:"h:EnforceSecureBoot"` // When True, Secure boot over IDER is enforced on the next boot cycle, if IDER boot is used. This field is also used in One-Click Recovery.
+ BootMediaIndex int `xml:"h:BootMediaIndex"` // Required. This property identifies the boot-media index for the managed client (when a boot source is set using the CIM_BootConfigSetting.ChangeBootOrder method). For Hard-Drive or CD/DVD boot - when the parameter value is 0, the default boot-media is booted. When the parameter value is 1, the primary boot-media is booted; when the value is 2, the secondary boot-media is booted; and so on. For PXE or diagnostics boot this property must be 0.
+ SecureErase bool `xml:"h:SecureErase"` // Required. When True, the BIOS performs secure erase operation. Note: Customers are recommended to use Secure Remote Platform Erase which is newer and more advanced than this function.
+ RSEPassword string `xml:"h:RSEPassword"` // SSD password for Remote Secure Erase operation. This is a write-only field, an empty string is returned when instance is read. When writing, an empty string or lack of field will be ignored. The password length is limited to 32 ASCII characters. Note: Customers are recommended to use Secure Remote Platform Erase which is newer and more advanced than Remote Secure Erase.
+ OptionsCleared bool `xml:"h:OptionsCleared"` // Indicates whether the boot options have been cleared by BIOS or not. This property is read only.
+ WinREBootEnabled bool `xml:"h:WinREBootEnabled"` // Indicates whether ForceWinREBoot is enabled in BIOS. This property is read only.
+ UEFILocalPBABootEnabled bool `xml:"h:UEFILocalPBABootEnabled"` // Indicates whether ForceUEFILocalPBABoot is enabled in BIOS. This property is read only.
+ UEFIHTTPSBootEnabled bool `xml:"h:UEFIHTTPSBootEnabled"` // Indicates whether ForceUEFIHTTPSBoot is enabled in BIOS. This property is read only.
+ SecureBootControlEnabled bool `xml:"h:SecureBootControlEnabled"` // Determines whether Intel AMT is privileged by BIOS to disable secure boot for an AMT triggered boot option. If not, BIOSSecureBoot must be set to TRUE. This property is read only.
+ BootguardStatus bool `xml:"h:BootguardStatus"` // Enables the console to discover the security level of the BIOS boot flow. This property is read only.
+ BIOSLastStatus []int `xml:"h:BIOSLastStatus"` // Last boot status reported by BIOS. The first 16-bit word contains the general BIOS status (0 - Success, 1 - In Progress, 2 - Not Updated, 0xFFFF - Failed). The second word contains the detailed error status (0 - Success/In Progress, 1 - General Drive Failure, 2 - Drive Password/Authentication Failure, 3 - Feature is not supported). This property is read-only.
+ UEFIBootParametersArray []int `xml:"h:UEFIBootParametersArray"` // TLV parameters array encoded with base64 for configuring boot parameters for One-Click Recovery and Secure Remote Platform Erase.
+ UEFIBootNumberOfParams []int `xml:"h:UEFIBootNumberOfParams"` // Number of parameters in UefiBootParametersArray
+ RPEEnabled bool `xml:"h:RPEEnabled"` // Indicates whether Secure Remote Platform Erase is enabled by the BIOS. Note: This command needs to execute over TLS.
+ PlatformErase bool `xml:"h:PlatformErase"` // When set to True, sets the boot option to trigger Secure Remote Platform Erase in the next boot. Note: This command needs to execute over TLS.
+}
+
+// When set to a non-zero value, controls the amount of information the managed system writes to its local display.
+//
+// ValueMap={0, 1, 2, 3}
+//
+// Values={System default, Quiet - minimal screen activity, Verbose - all messages appear on the screen, Screen blank - no messages appear on the screen}
+type FirmwareVerbosity int
+
+// Specifies the device to use when UseIder is set. 0 - Floppy Boot, 1- CD Boot.
+//
+// ValueMap={0, 1}
+//
+// Values={Floppy Boot, CD Boot}
+type IDERBootDevice int
diff --git a/pkg/wsman/amt/constants.go b/pkg/wsman/amt/constants.go
new file mode 100644
index 00000000..0f34220a
--- /dev/null
+++ b/pkg/wsman/amt/constants.go
@@ -0,0 +1,30 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package amt
+
+// Realms represents a set of enumerated constants for managing various aspects of the system.
+type Realms int
+
+const (
+ ADMINISTRATION Realms = 3 // ADMINISTRATION manages security control data, power saving options, Intel AMT setup and configuration, and local network options.(
+ AGENT_PRESENCE_LOCAL Realms = 9 // AGENT_PRESENCE_LOCAL is used by an application designed to run on the local platform to report that it is running and to send heartbeats periodically.(
+ AGENT_PRESENCE_REMOTE Realms = 10 // AGENT_PRESENCE_REMOTE is used to register Local Agent applications and to specify the behavior of Intel AMT when an application is running or stops running unexpectedly.(
+ AUDIT_LOG Realms = 20 // AUDIT_LOG configures the Audit Log.(
+ CIRCUIT_BREAKER Realms = 11 // CIRCUIT_BREAKER is used to define filters, counters, and policies to monitor incoming and outgoing network traffic and to block traffic when a suspicious condition is detected.(
+ ENDPOINT_ACCESS_CONTROL Realms = 17 // ENDPOINT_ACCESS_CONTROL is deprecated and not supported starting CSME release 18.0. Returns settings associated with NAC/NAP posture.(
+ ENDPOINT_ACCESS_CONTROL_ADMIN Realms = 18 // ENDPOINT_ACCESS_CONTROL_ADMIN is deprecated and not supported starting CSME release 18.0. Configures and enables the NAC/NAP posture.(
+ EVENT_LOG_READER Realms = 19 // EVENT_LOG_READER controls access for reading the Intel AMT event log.(
+ EVENT_MANAGER Realms = 7 // EVENT_MANAGER allows configuring hardware and software events to generate alerts and to send them to a remote console and/or log them locally.(
+ GENERAL_INFO Realms = 13 // GENERAL_INFO returns general setting and status information.(
+ HARDWARE_ASSET Realms = 4 // HARDWARE_ASSET is used to retrieve information about the hardware inventory of the platform.(
+ LOCAL_APPS Realms = 24 // LOCAL_APPS provides alerts to a user on the local interface.(
+ NETWORK_TIME Realms = 12 // NETWORK_TIME is used to set the clock in the Intel AMT device and synchronize it to network time.(
+ REDIRECTION Realms = 2 // REDIRECTION enables and disables the redirection capability and retrieves the redirection log.(
+ REMOTE_CONTROL Realms = 5 // REMOTE_CONTROL enables powering a platform up or down remotely.(
+ STORAGE Realms = 6 // STORAGE is used to access, configure, manage, write to and read from non-volatile user storage.(
+ STORAGE_ADMIN Realms = 8 // STORAGE_ADMIN is used to configure the global parameters that govern the allocation and use of non-volatile storage.(
+ USER_ACCESS_CONTROL Realms = 21 // USER_ACCESS_CONTROL allows users to control the properties of their own ACL entries.
+)
diff --git a/pkg/wsman/amt/environmentdetection/constants.go b/pkg/wsman/amt/environmentdetection/constants.go
new file mode 100644
index 00000000..ad6cbfe4
--- /dev/null
+++ b/pkg/wsman/amt/environmentdetection/constants.go
@@ -0,0 +1,15 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package environmentdetection
+
+const (
+ AMT_EnvironmentDetectionSettingData string = "AMT_EnvironmentDetectionSettingData"
+)
+
+const (
+ LocalDomains DetectionAlgorithm = iota
+ RemoteURLs
+)
diff --git a/pkg/wsman/amt/environmentdetection/marshal.go b/pkg/wsman/amt/environmentdetection/marshal.go
new file mode 100644
index 00000000..49c4102b
--- /dev/null
+++ b/pkg/wsman/amt/environmentdetection/marshal.go
@@ -0,0 +1,30 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package environmentdetection
+
+import (
+ "encoding/json"
+
+ "gopkg.in/yaml.v3"
+)
+
+// JSON marshals the type into JSON format
+func (r *Response) JSON() string {
+ jsonOutput, err := json.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(jsonOutput)
+}
+
+// YAML marshals the type into YAML format
+func (r *Response) YAML() string {
+ yamlOutput, err := yaml.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(yamlOutput)
+}
diff --git a/pkg/wsman/amt/environmentdetection/settingdata.go b/pkg/wsman/amt/environmentdetection/settingdata.go
new file mode 100644
index 00000000..79286648
--- /dev/null
+++ b/pkg/wsman/amt/environmentdetection/settingdata.go
@@ -0,0 +1,107 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+// Package environmentdetection facilitates communication with Intel® AMT device configuration-related and operational parameters for the Environment Detection service in Intel® AMT.
+package environmentdetection
+
+import (
+ "encoding/xml"
+ "fmt"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+)
+
+// NewEnvironmentDetectionSettingDataWithClient instantiates a new Environment Detection Setting Data service
+func NewEnvironmentDetectionSettingDataWithClient(wsmanMessageCreator *message.WSManMessageCreator, client client.WSMan) SettingData {
+ return SettingData{
+ base: message.NewBaseWithClient(wsmanMessageCreator, AMT_EnvironmentDetectionSettingData, client),
+ }
+}
+
+// Get retrieves the representation of the instance
+func (sd SettingData) Get() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: sd.base.Get(nil),
+ },
+ }
+ // send the message to AMT
+ err = sd.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Enumerate returns an enumeration context which is used in a subsequent Pull call
+func (sd SettingData) Enumerate() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: sd.base.Enumerate(),
+ },
+ }
+ // send the message to AMT
+ err = sd.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Pull returns the instances of this class. An enumeration context provided by the Enumerate call is used as input.
+func (sd SettingData) Pull(enumerationContext string) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: sd.base.Pull(enumerationContext),
+ },
+ }
+ // send the message to AMT
+ err = sd.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Put will change properties of the selected instance
+func (sd SettingData) Put(environmentDetectionSettingData EnvironmentDetectionSettingDataRequest) (response Response, err error) {
+ environmentDetectionSettingData.H = fmt.Sprintf("%s%s", message.AMTSchema, AMT_EnvironmentDetectionSettingData)
+ selector := message.Selector{
+ Name: "InstanceID",
+ Value: "Intel(r) AMT Environment Detection Settings",
+ }
+ response = Response{
+ Message: &client.Message{
+ XMLInput: sd.base.Put(environmentDetectionSettingData, true, &selector),
+ },
+ }
+ // send the message to AMT
+ err = sd.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
diff --git a/pkg/wsman/amt/environmentdetection/settingdata_test.go b/pkg/wsman/amt/environmentdetection/settingdata_test.go
new file mode 100644
index 00000000..0290dd9e
--- /dev/null
+++ b/pkg/wsman/amt/environmentdetection/settingdata_test.go
@@ -0,0 +1,277 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package environmentdetection
+
+import (
+ "encoding/xml"
+ "testing"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
+ "github.com/stretchr/testify/assert"
+)
+
+func TestPositiveAMT_EnvironmentDetectionSettingData(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/environmentdetection",
+ }
+ elementUnderTest := NewEnvironmentDetectionSettingDataWithClient(wsmanMessageCreator, &client)
+ t.Run("amt_EnvironmentDetectionSettingData Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ extraHeader string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create a valid AMT_EnvironmentDetectionSettingData Get wsman message",
+ AMT_EnvironmentDetectionSettingData,
+ wsmantesting.GET,
+ "",
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Get"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GetAndPutResponse: EnvironmentDetectionSettingDataResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_EnvironmentDetectionSettingData", Local: "AMT_EnvironmentDetectionSettingData"},
+ DetectionStrings: []string{"b332bb28-ef3a-43b0-b998-342285ac1e26.com", "test.com"},
+ DetectionAlgorithm: 0,
+ ElementName: "Intel(r) AMT Environment Detection Settings",
+ InstanceID: "Intel(r) AMT Environment Detection Settings",
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create a valid AMT_EnvironmentDetectionSettingData Enumerate wsman message",
+ AMT_EnvironmentDetectionSettingData,
+ wsmantesting.ENUMERATE,
+ "",
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Enumerate"
+ if elementUnderTest.base.WSManMessageCreator == nil {
+ print("Error")
+ }
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "61000000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid AMT_EnvironmentDetectionSettingData Pull wsman message",
+ AMT_EnvironmentDetectionSettingData,
+ wsmantesting.PULL,
+ "",
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Pull"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ EnvironmentDetectionSettingDataItems: []EnvironmentDetectionSettingDataResponse{
+ {
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_EnvironmentDetectionSettingData", Local: "AMT_EnvironmentDetectionSettingData"},
+ DetectionAlgorithm: 0,
+ DetectionStrings: []string{"00d032fb-4341-42a5-a353-aaf83ff9d410.com"},
+ ElementName: "Intel(r) AMT Environment Detection Settings",
+ InstanceID: "Intel(r) AMT Environment Detection Settings",
+ },
+ },
+ },
+ },
+ },
+ //PUT
+ {
+ "should create a valid AMT_EnvironmentDetectionSettingData Put wsman message",
+ AMT_EnvironmentDetectionSettingData,
+ wsmantesting.PUT,
+ "Intel(r) AMT Environment Detection Settings",
+ "Intel(r) AMT Environment Detection SettingsIntel(r) AMT Environment Detection Settings02b14eacc-7f20-4a11-99bc-fdc6a162160b.com",
+ func() (Response, error) {
+ client.CurrentMessage = "Put"
+ edsd := EnvironmentDetectionSettingDataRequest{
+ H: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_EnvironmentDetectionSettingData",
+ ElementName: "Intel(r) AMT Environment Detection Settings",
+ InstanceID: "Intel(r) AMT Environment Detection Settings",
+ DetectionAlgorithm: 0,
+ DetectionStrings: []string{"2b14eacc-7f20-4a11-99bc-fdc6a162160b.com"},
+ }
+ return elementUnderTest.Put(edsd)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GetAndPutResponse: EnvironmentDetectionSettingDataResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_EnvironmentDetectionSettingData", Local: "AMT_EnvironmentDetectionSettingData"},
+ DetectionStrings: []string{"2b14eacc-7f20-4a11-99bc-fdc6a162160b.com"},
+ DetectionAlgorithm: 0,
+ ElementName: "Intel(r) AMT Environment Detection Settings",
+ InstanceID: "Intel(r) AMT Environment Detection Settings",
+ },
+ },
+ },
+ }
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, test.extraHeader, test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.NoError(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.Equal(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
+func TestNegativeAMT_EnvironmentDetectionSettingData(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/environmentdetection",
+ }
+ elementUnderTest := NewEnvironmentDetectionSettingDataWithClient(wsmanMessageCreator, &client)
+ t.Run("amt_EnvironmentDetectionSettingData Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ extraHeader string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create a valid AMT_EnvironmentDetectionSettingData Get wsman message",
+ AMT_EnvironmentDetectionSettingData,
+ wsmantesting.GET,
+ "",
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GetAndPutResponse: EnvironmentDetectionSettingDataResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_EnvironmentDetectionSettingData", Local: "AMT_EnvironmentDetectionSettingData"},
+ DetectionStrings: []string{"b332bb28-ef3a-43b0-b998-342285ac1e26.com", "test.com"},
+ DetectionAlgorithm: 0,
+ ElementName: "Intel(r) AMT Environment Detection Settings",
+ InstanceID: "Intel(r) AMT Environment Detection Settings",
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create a valid AMT_EnvironmentDetectionSettingData Enumerate wsman message",
+ AMT_EnvironmentDetectionSettingData,
+ wsmantesting.ENUMERATE,
+ "",
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ if elementUnderTest.base.WSManMessageCreator == nil {
+ print("Error")
+ }
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "61000000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid AMT_EnvironmentDetectionSettingData Pull wsman message",
+ AMT_EnvironmentDetectionSettingData,
+ wsmantesting.PULL,
+ "",
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ EnvironmentDetectionSettingDataItems: []EnvironmentDetectionSettingDataResponse{
+ {
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_EnvironmentDetectionSettingData", Local: "AMT_EnvironmentDetectionSettingData"},
+ DetectionAlgorithm: 0,
+ DetectionStrings: []string{"00d032fb-4341-42a5-a353-aaf83ff9d410.com"},
+ ElementName: "Intel(r) AMT Environment Detection Settings",
+ InstanceID: "Intel(r) AMT Environment Detection Settings",
+ },
+ },
+ },
+ },
+ },
+ //PUT
+ {
+ "should create a valid AMT_EnvironmentDetectionSettingData Put wsman message",
+ AMT_EnvironmentDetectionSettingData,
+ wsmantesting.PUT,
+ "Intel(r) AMT Environment Detection Settings",
+ "Intel(r) AMT Environment Detection SettingsIntel(r) AMT Environment Detection Settings02b14eacc-7f20-4a11-99bc-fdc6a162160b.com",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ edsd := EnvironmentDetectionSettingDataRequest{
+ H: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_EnvironmentDetectionSettingData",
+ ElementName: "Intel(r) AMT Environment Detection Settings",
+ InstanceID: "Intel(r) AMT Environment Detection Settings",
+ DetectionAlgorithm: 0,
+ DetectionStrings: []string{"2b14eacc-7f20-4a11-99bc-fdc6a162160b.com"},
+ }
+ return elementUnderTest.Put(edsd)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GetAndPutResponse: EnvironmentDetectionSettingDataResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_EnvironmentDetectionSettingData", Local: "AMT_EnvironmentDetectionSettingData"},
+ DetectionStrings: []string{"2b14eacc-7f20-4a11-99bc-fdc6a162160b.com"},
+ DetectionAlgorithm: 0,
+ ElementName: "Intel(r) AMT Environment Detection Settings",
+ InstanceID: "Intel(r) AMT Environment Detection Settings",
+ },
+ },
+ },
+ }
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, test.extraHeader, test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.Error(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.NotEqual(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
diff --git a/pkg/wsman/amt/environmentdetection/types.go b/pkg/wsman/amt/environmentdetection/types.go
new file mode 100644
index 00000000..29f60a9d
--- /dev/null
+++ b/pkg/wsman/amt/environmentdetection/types.go
@@ -0,0 +1,69 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package environmentdetection
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+)
+
+type SettingData struct {
+ base message.Base
+}
+
+// OUTPUTS
+// Response Types
+type (
+ Response struct {
+ *client.Message
+ XMLName xml.Name `xml:"Envelope"`
+ Header message.Header `xml:"Header"`
+ Body Body `xml:"Body"`
+ }
+
+ Body struct {
+ XMLName xml.Name `xml:"Body"`
+ GetAndPutResponse EnvironmentDetectionSettingDataResponse
+ EnumerateResponse common.EnumerateResponse
+ PullResponse PullResponse
+ }
+ EnvironmentDetectionSettingDataResponse struct {
+ XMLName xml.Name `xml:"AMT_EnvironmentDetectionSettingData"`
+ ElementName string `xml:"ElementName,omitempty"` // The user-friendly name for this instance of SettingData. In addition, the user-friendly name can be used as an index property for a search or query. (Note: The name does not have to be unique within a namespace.)
+ InstanceID string `xml:"InstanceID,omitempty"` // Within the scope of the instantiating Namespace, InstanceID opaquely and uniquely identifies an instance of this class. To ensure uniqueness within the NameSpace, the value of InstanceID should be constructed using the following "preferred" algorithm: : Where and are separated by a colon (:), and where must include a copyrighted, trademarked, or otherwise unique name that is owned by the business entity that is creating or defining the InstanceID or that is a registered ID assigned to the business entity by a recognized global authority. (This requirement is similar to the _ structure of Schema class names.) In addition, to ensure uniqueness, must not contain a colon (:). When using this algorithm, the first colon to appear in InstanceID must appear between and . is chosen by the business entity and should not be reused to identify different underlying (real-world) elements. If the above "preferred" algorithm is not used, the defining entity must assure that the resulting InstanceID is not reused across any InstanceIDs produced by this or other providers for the NameSpace of this instance. For DMTF-defined instances, the "preferred" algorithm must be used with the set to CIM.
+ DetectionAlgorithm DetectionAlgorithm `xml:"DetectionAlgorithm,omitempty"` // Specifies which algorithm is used to determine whether the system is in its intranet environment or in the Internet environment. Currently, AMT supports only the "Local Domains" type.
+ DetectionStrings []string `xml:"DetectionStrings,omitempty"` // An array of strings used in the environment detection algorithm. If DetectionAlgorithm is "Local Domains", DetectionStrings contains a set of local domain strings. If DetectionAlgorithm is "Remote URLs", then DetectionStrings contains a set of remote URLs.
+ DetectionIPv6LocalPrefixes []string `xml:"DetectionIPv6LocalPrefixes,omitempty"` // Can be used for environment detection in IPv6 networks that do not configure the DNS suffix via DHCP. The format is: "XXXX:XXXX:XXXX:XXXX/Y" where Y is the prefix length, the XXXX:XXXX:XXXX:XXXX part can include zeros compression (e.g. 0:0:0 or ::) formats.
+ }
+ PullResponse struct {
+ XMLName xml.Name `xml:"PullResponse"`
+ EnvironmentDetectionSettingDataItems []EnvironmentDetectionSettingDataResponse `xml:"Items>AMT_EnvironmentDetectionSettingData"`
+ }
+)
+
+// INPUTS
+// Request Types
+type EnvironmentDetectionSettingDataRequest struct {
+ XMLName xml.Name `xml:"h:AMT_EnvironmentDetectionSettingData"`
+ H string `xml:"xmlns:h,attr"`
+ ElementName string `xml:"h:ElementName"` // Required. The user-friendly name for this instance of SettingData. In addition, the user-friendly name can be used as an index property for a search or query. (Note: The name does not have to be unique within a namespace.)
+ InstanceID string `xml:"h:InstanceID"` // Within the scope of the instantiating Namespace, InstanceID opaquely and uniquely identifies an instance of this class. To ensure uniqueness within the NameSpace, the value of InstanceID should be constructed using the following "preferred" algorithm: : Where and are separated by a colon (:), and where must include a copyrighted, trademarked, or otherwise unique name that is owned by the business entity that is creating or defining the InstanceID or that is a registered ID assigned to the business entity by a recognized global authority. (This requirement is similar to the _ structure of Schema class names.) In addition, to ensure uniqueness, must not contain a colon (:). When using this algorithm, the first colon to appear in InstanceID must appear between and . is chosen by the business entity and should not be reused to identify different underlying (real-world) elements. If the above "preferred" algorithm is not used, the defining entity must assure that the resulting InstanceID is not reused across any InstanceIDs produced by this or other providers for the NameSpace of this instance. For DMTF-defined instances, the "preferred" algorithm must be used with the set to CIM.
+ DetectionAlgorithm DetectionAlgorithm `xml:"h:DetectionAlgorithm"` // Required. Specifies which algorithm is used to determine whether the system is in its intranet environment or in the Internet environment. Currently, AMT supports only the "Local Domains" type.
+ DetectionStrings []string `xml:"h:DetectionStrings,omitempty"` // An array of strings used in the environment detection algorithm. If DetectionAlgorithm is "Local Domains", DetectionStrings contains a set of local domain strings. If DetectionAlgorithm is "Remote URLs", then DetectionStrings contains a set of remote URLs.
+ DetectionIPv6LocalPrefixes []string `xml:"h:DetectionIPv6LocalPrefixes,omitempty"` // Can be used for environment detection in IPv6 networks that do not configure the DNS suffix via DHCP. The format is: "XXXX:XXXX:XXXX:XXXX/Y" where Y is the prefix length, the XXXX:XXXX:XXXX:XXXX part can include zeros compression (e.g. 0:0:0 or ::) formats.
+}
+
+// Specifies which algorithm is used to determine whether the system is in its intranet environment or in the Internet environment.
+//
+// Currently, AMT supports only the "Local Domains" type.
+//
+// ValueMap={0, 1}
+//
+// Values={Local Domains, Remote URLs}
+type DetectionAlgorithm int
diff --git a/pkg/wsman/amt/ethernetport/constants.go b/pkg/wsman/amt/ethernetport/constants.go
new file mode 100644
index 00000000..5bee78c4
--- /dev/null
+++ b/pkg/wsman/amt/ethernetport/constants.go
@@ -0,0 +1,52 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package ethernetport
+
+const (
+ AMT_EthernetPortSettings string = "AMT_EthernetPortSettings"
+)
+
+const (
+ S0AC LinkPolicy = 1 // available on S0 AC
+ SxAC LinkPolicy = 14 // available on Sx AC
+ S0DC LinkPolicy = 16 // available on S0 DC
+ SxDC LinkPolicy = 224 // available on Sx DC
+)
+
+const (
+ LinkPreferenceME LinkPreference = iota + 1
+ LinkPreferenceHOST
+)
+
+const (
+ LinkControlME LinkControl = iota + 1
+ LinkControlHOST
+)
+
+const (
+ ConsoleTcpMaxRetransmissions5 ConsoleTcpMaxRetransmissions = iota + 5
+ ConsoleTcpMaxRetransmissions6
+ ConsoleTcpMaxRetransmissions7
+)
+
+const (
+ OVERRIDE WLANLinkProtectionLevel = iota
+ NONE
+ PASSIVE
+ HIGH
+)
+
+const (
+ IntegratedLANNIC PhysicalConnectionType = iota
+ DiscreteLANNIC
+ LANviaThunderboldDock
+ WirelessLAN
+)
+
+const (
+ SMBUS PhysicalNicMedium = iota
+ PCIe
+)
diff --git a/pkg/wsman/amt/ethernetport/marshal.go b/pkg/wsman/amt/ethernetport/marshal.go
new file mode 100644
index 00000000..4024a40f
--- /dev/null
+++ b/pkg/wsman/amt/ethernetport/marshal.go
@@ -0,0 +1,30 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package ethernetport
+
+import (
+ "encoding/json"
+
+ "gopkg.in/yaml.v3"
+)
+
+// JSON marshals the type into JSON format
+func (r *Response) JSON() string {
+ jsonOutput, err := json.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(jsonOutput)
+}
+
+// YAML marshals the type into YAML format
+func (r *Response) YAML() string {
+ yamlOutput, err := yaml.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(yamlOutput)
+}
diff --git a/pkg/wsman/amt/ethernetport/settings.go b/pkg/wsman/amt/ethernetport/settings.go
new file mode 100644
index 00000000..934dd5ad
--- /dev/null
+++ b/pkg/wsman/amt/ethernetport/settings.go
@@ -0,0 +1,114 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+// Package ethernetport facilitates communication with Intel® AMT devices to configure all Intel® AMT network specific settings (IP, DHCP, VLAN).
+//
+// Intel® AMT devices support a single wired and a single wireless network adapter. If an Intel® AMT device has multiple wired or wireless network adapters only one of each will be connected to AMT.
+package ethernetport
+
+import (
+ "encoding/xml"
+ "fmt"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+)
+
+// NewEthernetPortSettingsWithClient instantiates a new Ethernet Port Settings service
+func NewEthernetPortSettingsWithClient(wsmanMessageCreator *message.WSManMessageCreator, client client.WSMan) Settings {
+ return Settings{
+ base: message.NewBaseWithClient(wsmanMessageCreator, AMT_EthernetPortSettings, client),
+ }
+}
+
+// Get retrieves the representation of the instance
+func (s Settings) Get(instanceId int) (response Response, err error) {
+ selector := message.Selector{
+ Name: "InstanceID",
+ Value: fmt.Sprintf("Intel(r) AMT Ethernet Port Settings %d", instanceId),
+ }
+ response = Response{
+ Message: &client.Message{
+ XMLInput: s.base.Get(&selector),
+ },
+ }
+ // send the message to AMT
+ err = s.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Enumerate returns an enumeration context which is used in a subsequent Pull call
+func (s Settings) Enumerate() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: s.base.Enumerate(),
+ },
+ }
+ // send the message to AMT
+ err = s.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// // Pull returns the instances of this class. An enumeration context provided by the Enumerate call is used as input.
+func (s Settings) Pull(enumerationContext string) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: s.base.Pull(enumerationContext),
+ },
+ }
+ // send the message to AMT
+ err = s.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Put will change properties of the selected instance
+func (s Settings) Put(ethernetPortSettings SettingsRequest, instanceId int) (response Response, err error) {
+ ethernetPortSettings.H = fmt.Sprintf("%s%s", message.AMTSchema, AMT_EthernetPortSettings)
+ selector := message.Selector{
+ Name: "InstanceID",
+ Value: fmt.Sprintf("Intel(r) AMT Ethernet Port Settings %d", instanceId),
+ }
+ response = Response{
+ Message: &client.Message{
+ XMLInput: s.base.Put(ethernetPortSettings, true, &selector),
+ },
+ }
+ // send the message to AMT
+ err = s.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
diff --git a/pkg/wsman/amt/ethernetport/settings_test.go b/pkg/wsman/amt/ethernetport/settings_test.go
new file mode 100644
index 00000000..0c79b742
--- /dev/null
+++ b/pkg/wsman/amt/ethernetport/settings_test.go
@@ -0,0 +1,376 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package ethernetport
+
+import (
+ "encoding/xml"
+ "testing"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
+ "github.com/stretchr/testify/assert"
+)
+
+func TestPositiveAMT_EthernetPortSettings(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/ethernetport",
+ }
+ elementUnderTest := NewEthernetPortSettingsWithClient(wsmanMessageCreator, &client)
+ t.Run("amt_EthernetPortSettings Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ extraHeader string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create a valid AMT_EthernetPortSettings Get wsman message",
+ AMT_EthernetPortSettings,
+ wsmantesting.GET,
+ "",
+ "Intel(r) AMT Ethernet Port Settings 0",
+ func() (Response, error) {
+ client.CurrentMessage = "Get"
+ return elementUnderTest.Get(0)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GetAndPutResponse: SettingsResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_EthernetPortSettings", Local: "AMT_EthernetPortSettings"},
+ ElementName: "Intel(r) AMT Ethernet Port Settings",
+ InstanceID: "Intel(r) AMT Ethernet Port Settings 0",
+ SharedMAC: true,
+ MACAddress: "c8-d9-d2-7a-1e-33",
+ LinkIsUp: true,
+ LinkPolicy: []LinkPolicy{1, 14},
+ SharedStaticIp: false,
+ SharedDynamicIP: true,
+ IpSyncEnabled: true,
+ DHCPEnabled: true,
+ SubnetMask: "255.255.255.0",
+ DefaultGateway: "192.168.0.1",
+ PrimaryDNS: "68.105.28.11",
+ SecondaryDNS: "68.105.29.11",
+ PhysicalConnectionType: 0,
+ },
+ },
+ },
+
+ //ENUMERATES
+ {
+ "should create a valid AMT_EthernetPortSettings Enumerate wsman message",
+ AMT_EthernetPortSettings,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Enumerate"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "7700000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid AMT_EthernetPortSettings Pull wsman message",
+ AMT_EthernetPortSettings,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Pull"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ EthernetPortItems: []SettingsResponse{
+ {
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_EthernetPortSettings", Local: "AMT_EthernetPortSettings"},
+ ElementName: "Intel(r) AMT Ethernet Port Settings",
+ InstanceID: "Intel(r) AMT Ethernet Port Settings 0",
+ VLANTag: 0,
+ SharedMAC: true,
+ MACAddress: "00-be-43-d8-22-a4",
+ LinkIsUp: true,
+ LinkPolicy: []LinkPolicy{1, 14},
+ SharedStaticIp: false,
+ SharedDynamicIP: true,
+ IpSyncEnabled: true,
+ DHCPEnabled: true,
+ SubnetMask: "255.255.255.0",
+ DefaultGateway: "192.168.6.1",
+ PrimaryDNS: "192.168.6.1",
+ PhysicalConnectionType: 0,
+ },
+ {
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_EthernetPortSettings", Local: "AMT_EthernetPortSettings"},
+ ElementName: "Intel(r) AMT Ethernet Port Settings",
+ InstanceID: "Intel(r) AMT Ethernet Port Settings 1",
+ SharedMAC: true,
+ MACAddress: "00-00-00-00-00-00",
+ LinkIsUp: false,
+ LinkPreference: 2,
+ LinkControl: 2,
+ DHCPEnabled: true,
+ ConsoleTcpMaxRetransmissions: 5,
+ WLANLinkProtectionLevel: 1,
+ PhysicalConnectionType: 3,
+ },
+ },
+ },
+ },
+ },
+ //PUTS
+ {
+ "should create a valid AMT_EthernetPortSettings Put wsman message",
+ AMT_EthernetPortSettings,
+ wsmantesting.PUT,
+ "Intel(r) AMT Ethernet Port SettingsIntel(r) AMT Ethernet Port Settings 0truefalsetruetruetrue",
+ "Intel(r) AMT Ethernet Port Settings 0",
+ func() (Response, error) {
+ ethernetPortSettings := SettingsRequest{
+ H: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_EthernetPortSettings",
+ DHCPEnabled: true,
+ ElementName: "Intel(r) AMT Ethernet Port Settings",
+ InstanceID: "Intel(r) AMT Ethernet Port Settings 0",
+ IpSyncEnabled: true,
+ SharedMAC: true,
+ SharedStaticIp: true,
+ }
+ client.CurrentMessage = "Put"
+ return elementUnderTest.Put(ethernetPortSettings, 0)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GetAndPutResponse: SettingsResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_EthernetPortSettings", Local: "AMT_EthernetPortSettings"},
+ DHCPEnabled: true,
+ DefaultGateway: "192.168.0.1",
+ ElementName: "Intel(r) AMT Ethernet Port Settings",
+ IPAddress: "192.168.0.24",
+ InstanceID: "Intel(r) AMT Ethernet Port Settings 0",
+ IpSyncEnabled: true,
+ LinkIsUp: true,
+ LinkPolicy: []LinkPolicy{1, 14, 16},
+ MACAddress: "a4-ae-11-1e-46-53",
+ PhysicalConnectionType: 0,
+ PrimaryDNS: "68.105.28.11",
+ SecondaryDNS: "68.105.29.11",
+ SharedDynamicIP: true,
+ SharedMAC: true,
+ SharedStaticIp: true,
+ SubnetMask: "255.255.255.0",
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, test.extraHeader, test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.NoError(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.Equal(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
+
+func TestNegativeAMT_EthernetPortSettings(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/ethernetport",
+ }
+ elementUnderTest := NewEthernetPortSettingsWithClient(wsmanMessageCreator, &client)
+ t.Run("amt_EthernetPortSettings Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ extraHeader string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create a valid AMT_EthernetPortSettings Get wsman message",
+ AMT_EthernetPortSettings,
+ wsmantesting.GET,
+ "",
+ "Intel(r) AMT Ethernet Port Settings 0",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Get(0)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GetAndPutResponse: SettingsResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_EthernetPortSettings", Local: "AMT_EthernetPortSettings"},
+ ElementName: "Intel(r) AMT Ethernet Port Settings",
+ InstanceID: "Intel(r) AMT Ethernet Port Settings 0",
+ SharedMAC: true,
+ MACAddress: "c8-d9-d2-7a-1e-33",
+ LinkIsUp: true,
+ LinkPolicy: []LinkPolicy{1, 14},
+ SharedStaticIp: false,
+ SharedDynamicIP: true,
+ IpSyncEnabled: true,
+ DHCPEnabled: true,
+ SubnetMask: "255.255.255.0",
+ DefaultGateway: "192.168.0.1",
+ PrimaryDNS: "68.105.28.11",
+ SecondaryDNS: "68.105.29.11",
+ PhysicalConnectionType: 0,
+ },
+ },
+ },
+
+ //ENUMERATES
+ {
+ "should create a valid AMT_EthernetPortSettings Enumerate wsman message",
+ AMT_EthernetPortSettings,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "7700000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid AMT_EthernetPortSettings Pull wsman message",
+ AMT_EthernetPortSettings,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ EthernetPortItems: []SettingsResponse{
+ {
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_EthernetPortSettings", Local: "AMT_EthernetPortSettings"},
+ ElementName: "Intel(r) AMT Ethernet Port Settings",
+ InstanceID: "Intel(r) AMT Ethernet Port Settings 0",
+ VLANTag: 0,
+ SharedMAC: true,
+ MACAddress: "00-be-43-d8-22-a4",
+ LinkIsUp: true,
+ LinkPolicy: []LinkPolicy{1, 14},
+ SharedStaticIp: false,
+ SharedDynamicIP: true,
+ IpSyncEnabled: true,
+ DHCPEnabled: true,
+ SubnetMask: "255.255.255.0",
+ DefaultGateway: "192.168.6.1",
+ PrimaryDNS: "192.168.6.1",
+ PhysicalConnectionType: 0,
+ },
+ {
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_EthernetPortSettings", Local: "AMT_EthernetPortSettings"},
+ ElementName: "Intel(r) AMT Ethernet Port Settings",
+ InstanceID: "Intel(r) AMT Ethernet Port Settings 1",
+ SharedMAC: true,
+ MACAddress: "00-00-00-00-00-00",
+ LinkIsUp: false,
+ LinkPreference: 2,
+ LinkControl: 2,
+ DHCPEnabled: true,
+ ConsoleTcpMaxRetransmissions: 5,
+ WLANLinkProtectionLevel: 1,
+ PhysicalConnectionType: 3,
+ },
+ },
+ },
+ },
+ },
+ //PUTS
+ {
+ "should create a valid AMT_EthernetPortSettings Put wsman message",
+ AMT_EthernetPortSettings,
+ wsmantesting.PUT,
+ "Intel(r) AMT Ethernet Port SettingsIntel(r) AMT Ethernet Port Settings 0truefalsetruetruetrue",
+ "Intel(r) AMT Ethernet Port Settings 0",
+ func() (Response, error) {
+ ethernetPortSettings := SettingsRequest{
+ H: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_EthernetPortSettings",
+ DHCPEnabled: true,
+ ElementName: "Intel(r) AMT Ethernet Port Settings",
+ InstanceID: "Intel(r) AMT Ethernet Port Settings 0",
+ IpSyncEnabled: true,
+ SharedMAC: true,
+ SharedStaticIp: true,
+ }
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Put(ethernetPortSettings, 0)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GetAndPutResponse: SettingsResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_EthernetPortSettings", Local: "AMT_EthernetPortSettings"},
+ DHCPEnabled: true,
+ DefaultGateway: "192.168.0.1",
+ ElementName: "Intel(r) AMT Ethernet Port Settings",
+ IPAddress: "192.168.0.24",
+ InstanceID: "Intel(r) AMT Ethernet Port Settings 0",
+ IpSyncEnabled: true,
+ LinkIsUp: true,
+ LinkPolicy: []LinkPolicy{1, 14, 16},
+ MACAddress: "a4-ae-11-1e-46-53",
+ PhysicalConnectionType: 0,
+ PrimaryDNS: "68.105.28.11",
+ SecondaryDNS: "68.105.29.11",
+ SharedDynamicIP: true,
+ SharedMAC: true,
+ SharedStaticIp: true,
+ SubnetMask: "255.255.255.0",
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, test.extraHeader, test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.Error(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.NotEqual(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
diff --git a/pkg/wsman/amt/ethernetport/types.go b/pkg/wsman/amt/ethernetport/types.go
new file mode 100644
index 00000000..317b29ce
--- /dev/null
+++ b/pkg/wsman/amt/ethernetport/types.go
@@ -0,0 +1,147 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package ethernetport
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+)
+
+type Settings struct {
+ base message.Base
+}
+
+// OUTPUTS
+// Response Types
+type (
+ Response struct {
+ *client.Message
+ XMLName xml.Name `xml:"Envelope"`
+ Header message.Header `xml:"Header"`
+ Body Body `xml:"Body"`
+ }
+
+ Body struct {
+ XMLName xml.Name `xml:"Body"`
+ GetAndPutResponse SettingsResponse
+ EnumerateResponse common.EnumerateResponse
+ PullResponse PullResponse
+ }
+
+ PullResponse struct {
+ XMLName xml.Name `xml:"PullResponse"`
+ EthernetPortItems []SettingsResponse `xml:"Items>AMT_EthernetPortSettings"`
+ }
+
+ SettingsResponse struct {
+ XMLName xml.Name `xml:"AMT_EthernetPortSettings"`
+ ElementName string `xml:"ElementName,omitempty"` // The user-friendly name for this instance of SettingData. In addition, the user-friendly name can be used as an index property for a search or query. (Note: The name does not have to be unique within a namespace.)
+ InstanceID string `xml:"InstanceID,omitempty"` // Within the scope of the instantiating Namespace, InstanceID opaquely and uniquely identifies an instance of this class.
+ VLANTag int `xml:"VLANTag,omitempty"` // Indicates whether VLAN is in use and what is the VLAN tag when used.
+ SharedMAC bool `xml:"SharedMAC,omitempty"` // Indicates whether Intel® AMT shares it's MAC address with the host system.
+ MACAddress string `xml:"MACAddress,omitempty"` // The MAC address used by Intel® AMT in a string format. For Example: 01-02-3f-b0-99-99. (This property can only be read and can't be changed.)
+ LinkIsUp bool `xml:"LinkIsUp,omitempty"` // Indicates whether the network link is up
+ LinkPolicy []LinkPolicy `xml:"LinkPolicy,omitempty"` // Enumeration values for link policy restrictions for better power consumption. If Intel® AMT will not be able to determine the exact power state, the more restrictive closest configuration applies.
+ LinkPreference LinkPreference `xml:"LinkPreference,omitempty"` // Determines whether the link is preferred to be owned by ME or host
+ LinkControl LinkControl `xml:"LinkControl,omitempty"` // Determines whether the link is owned by ME or host. Additional Notes: This property is read-only.
+ SharedStaticIp bool `xml:"SharedStaticIp,omitempty"` // Indicates whether the static host IP is shared with ME.
+ SharedDynamicIP bool `xml:"SharedDynamicIP,omitempty"` // Indicates whether the dynamic host IP is shared with ME. This property is read only.
+ IpSyncEnabled bool `xml:"IpSyncEnabled,omitempty"` // Indicates whether the IP synchronization between host and ME is enabled.
+ DHCPEnabled bool `xml:"DHCPEnabled,omitempty"` // Indicates whether DHCP is in use. Additional Notes: 'DHCPEnabled' is a required field for the Put command.
+ IPAddress string `xml:"IPAddress,omitempty"` // String representation of IP address. Get operation - reports the acquired IP address (whether in static or DHCP mode). Put operation - sets the IP address (in static mode only).
+ SubnetMask string `xml:"SubnetMask,omitempty"` // Subnet mask in a string format.For example: 255.255.0.0
+ DefaultGateway string `xml:"DefaultGateway,omitempty"` // Default Gateway in a string format. For example: 10.12.232.1
+ PrimaryDNS string `xml:"PrimaryDNS,omitempty"` // Primary DNS in a string format. For example: 10.12.232.1
+ SecondaryDNS string `xml:"SecondaryDNS,omitempty"` // Secondary DNS in a string format. For example: 10.12.232.1
+ ConsoleTcpMaxRetransmissions ConsoleTcpMaxRetransmissions `xml:"ConsoleTcpMaxRetransmissions,omitempty"` // Indicates the number of retransmissions host TCP SW tries ifno ack is accepted
+ WLANLinkProtectionLevel WLANLinkProtectionLevel `xml:"WLANLinkProtectionLevel,omitempty"` // Defines the level of the link protection feature activation. Read only property.
+ PhysicalConnectionType PhysicalConnectionType `xml:"PhysicalConnectionType,omitempty"` // Indicates the physical connection type of this network interface. Note: Applicable in Intel AMT 15.0 and later.
+ PhysicalNicMedium PhysicalNicMedium `xml:"PhysicalNicMedium,omitempty"` // Indicates which medium is currently used by Intel® AMT to communicate with the NIC. Note: Applicable in Intel AMT 15.0 and later.
+ }
+)
+
+// INPUTS
+// Request Types
+type SettingsRequest struct {
+ XMLName xml.Name `xml:"h:AMT_EthernetPortSettings"`
+ H string `xml:"xmlns:h,attr"`
+ ElementName string `xml:"h:ElementName,omitempty"` // The user-friendly name for this instance of SettingData. In addition, the user-friendly name can be used as an index property for a search or query. (Note: The name does not have to be unique within a namespace.)
+ InstanceID string `xml:"h:InstanceID,omitempty"` // Within the scope of the instantiating Namespace, InstanceID opaquely and uniquely identifies an instance of this class.
+ VLANTag int `xml:"h:VLANTag,omitempty"` // Indicates whether VLAN is in use and what is the VLAN tag when used.
+ SharedMAC bool `xml:"h:SharedMAC"` // Indicates whether Intel® AMT shares it's MAC address with the host system.
+ MACAddress string `xml:"h:MACAddress,omitempty"` // The MAC address used by Intel® AMT in a string format. For Example: 01-02-3f-b0-99-99. (This property can only be read and can't be changed.)
+ LinkIsUp bool `xml:"h:LinkIsUp"` // Indicates whether the network link is up
+ LinkPolicy []LinkPolicy `xml:"h:LinkPolicy,omitempty"` // Enumeration values for link policy restrictions for better power consumption. If Intel® AMT will not be able to determine the exact power state, the more restrictive closest configuration applies.
+ LinkPreference LinkPreference `xml:"h:LinkPreference,omitempty"` // Determines whether the link is preferred to be owned by ME or host
+ LinkControl LinkControl `xml:"h:LinkControl,omitempty"` // Determines whether the link is owned by ME or host. Additional Notes: This property is read-only.
+ SharedStaticIp bool `xml:"h:SharedStaticIp"` // Indicates whether the static host IP is shared with ME.
+ SharedDynamicIP bool `xml:"h:SharedDynamicIP,omitempty"` // Indicates whether the dynamic host IP is shared with ME. This property is read only.
+ IpSyncEnabled bool `xml:"h:IpSyncEnabled"` // Indicates whether the IP synchronization between host and ME is enabled.
+ DHCPEnabled bool `xml:"h:DHCPEnabled"` // Indicates whether DHCP is in use. Additional Notes: 'DHCPEnabled' is a required field for the Put command.
+ IPAddress string `xml:"h:IPAddress,omitempty"` // String representation of IP address. Get operation - reports the acquired IP address (whether in static or DHCP mode). Put operation - sets the IP address (in static mode only).
+ SubnetMask string `xml:"h:SubnetMask,omitempty"` // Subnet mask in a string format.For example: 255.255.0.0
+ DefaultGateway string `xml:"h:DefaultGateway,omitempty"` // Default Gateway in a string format. For example: 10.12.232.1
+ PrimaryDNS string `xml:"h:PrimaryDNS,omitempty"` // Primary DNS in a string format. For example: 10.12.232.1
+ SecondaryDNS string `xml:"h:SecondaryDNS,omitempty"` // Secondary DNS in a string format. For example: 10.12.232.1
+ ConsoleTcpMaxRetransmissions ConsoleTcpMaxRetransmissions `xml:"h:ConsoleTcpMaxRetransmissions,omitempty"` // Indicates the number of retransmissions host TCP SW tries ifno ack is accepted
+ WLANLinkProtectionLevel WLANLinkProtectionLevel `xml:"h:WLANLinkProtectionLevel,omitempty"` // Defines the level of the link protection feature activation. Read only property.
+ PhysicalConnectionType PhysicalConnectionType `xml:"h:PhysicalConnectionType,omitempty"` // Indicates the physical connection type of this network interface. Note: Applicable in Intel AMT 15.0 and later.
+ PhysicalNicMedium PhysicalNicMedium `xml:"h:PhysicalNicMedium,omitempty"` // Indicates which medium is currently used by Intel® AMT to communicate with the NIC. Note: Applicable in Intel AMT 15.0 and later.
+}
+
+type Selector message.Selector
+
+// Enumeration values for link policy restrictions for better power consumption. If Intel® AMT will not be able to determine the exact power state, the more restrictive closest configuration applies.
+//
+// ValueMap={1, 14, 16, 224}
+//
+// Values={available on S0 AC, available on Sx AC, available on S0 DC, available on Sx DC}
+type LinkPolicy int
+
+// Indicates the number of retransmissions host TCP SW tries ifno ack is accepted
+//
+// MinValue=5
+//
+// MaxValue=7
+type ConsoleTcpMaxRetransmissions int
+
+// Determines whether the link is preferred to be owned by ME or host
+//
+// ValueMap={1, 2, 3..}
+//
+// Values={ME, HOST, Reserved}
+type LinkPreference int
+
+// Determines whether the link is owned by ME or host. Additional Notes: This property is read-only.
+//
+// ValueMap={1, 2, 3..}
+//
+// Values={ME, HOST, Reserved}
+type LinkControl int
+
+// Defines the level of the link protection feature activation. Read only property.
+//
+// ValueMap={0, 1, 2, 3, 4..}
+//
+// Values={OVERRIDE, NONE, PASSIVE, HIGH, RESERVED}
+type WLANLinkProtectionLevel int
+
+// Indicates the physical connection type of this network interface. Note: Applicable in Intel AMT 15.0 and later.
+//
+// ValueMap={"0", "1", "2", "3", "4.."}
+//
+// Values={"Integrated LAN NIC", "Discrete LAN NIC", "LAN via a Thunderbolt dock", "Wireless LAN", "Reserved"}
+type PhysicalConnectionType int
+
+// Indicates which medium is currently used by Intel® AMT to communicate with the NIC. Note: Applicable in Intel AMT 15.0 and later.
+//
+// ValueMap={"0", "1", "2.."}
+//
+// Values={"SMBUS", "PCIe", "Reserved"}
+type PhysicalNicMedium int
diff --git a/pkg/wsman/amt/general/constants.go b/pkg/wsman/amt/general/constants.go
new file mode 100644
index 00000000..d70148c8
--- /dev/null
+++ b/pkg/wsman/amt/general/constants.go
@@ -0,0 +1,31 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package general
+
+const (
+ AMT_GeneralSettings string = "AMT_GeneralSettings"
+)
+
+const (
+ IPv4 PreferredAddressFamily = iota
+ IPv6
+)
+
+const (
+ PrivacyLevelDefault PrivacyLevel = iota
+ PrivacyLevelEnhanced
+ PrivacyLevelExtreme
+)
+
+const (
+ AC PowerSource = iota
+ DC
+)
+
+const (
+ Disabled FeatureEnabled = iota
+ Enabled
+)
diff --git a/pkg/wsman/amt/general/marshal.go b/pkg/wsman/amt/general/marshal.go
new file mode 100644
index 00000000..84d46376
--- /dev/null
+++ b/pkg/wsman/amt/general/marshal.go
@@ -0,0 +1,30 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package general
+
+import (
+ "encoding/json"
+
+ "gopkg.in/yaml.v3"
+)
+
+// JSON marshals the type into JSON format
+func (r *Response) JSON() string {
+ jsonOutput, err := json.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(jsonOutput)
+}
+
+// YAML marshals the type into YAML format
+func (r *Response) YAML() string {
+ yamlOutput, err := yaml.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(yamlOutput)
+}
diff --git a/pkg/wsman/amt/general/settings.go b/pkg/wsman/amt/general/settings.go
new file mode 100644
index 00000000..6c03dfd8
--- /dev/null
+++ b/pkg/wsman/amt/general/settings.go
@@ -0,0 +1,106 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+// Package general facilitates communication with Intel® AMT to read and configure the device's Intel® AMT general settings.
+package general
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+)
+
+// NewGeneralSettingsWithClient instantiates a new General Settings service
+func NewGeneralSettingsWithClient(wsmanMessageCreator *message.WSManMessageCreator, client client.WSMan) Settings {
+ return Settings{
+ base: message.NewBaseWithClient(wsmanMessageCreator, AMT_GeneralSettings, client),
+ }
+}
+
+// Get retrieves the representation of the instance
+func (GeneralSettings Settings) Get() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: GeneralSettings.base.Get(nil),
+ },
+ }
+ // send the message to AMT
+ err = GeneralSettings.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Enumerate returns an enumeration context which is used in a subsequent Pull call
+func (GeneralSettings Settings) Enumerate() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: GeneralSettings.base.Enumerate(),
+ },
+ }
+ // send the message to AMT
+ err = GeneralSettings.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+
+ return
+}
+
+// Pull returns the instances of this class. An enumeration context provided by the Enumerate call is used as input.
+func (GeneralSettings Settings) Pull(enumerationContext string) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: GeneralSettings.base.Pull(enumerationContext),
+ },
+ }
+ // send the message to AMT
+ err = GeneralSettings.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+
+ return
+}
+
+// Put will change properties of the selected instance
+func (GeneralSettings Settings) Put(generalSettings GeneralSettingsResponse) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: GeneralSettings.base.Put(generalSettings, false, nil),
+ },
+ }
+ // send the message to AMT
+ err = GeneralSettings.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
diff --git a/pkg/wsman/amt/general/settings_test.go b/pkg/wsman/amt/general/settings_test.go
new file mode 100644
index 00000000..7d636388
--- /dev/null
+++ b/pkg/wsman/amt/general/settings_test.go
@@ -0,0 +1,281 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package general
+
+import (
+ "encoding/xml"
+ "testing"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
+ "github.com/stretchr/testify/assert"
+)
+
+func TestPositiveAMT_GeneralSettings(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/general",
+ }
+ elementUnderTest := NewGeneralSettingsWithClient(wsmanMessageCreator, &client)
+ t.Run("amt_* Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create a valid AMT_GeneralSettings Get wsman message",
+ AMT_GeneralSettings,
+ wsmantesting.GET,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Get"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GetResponse: GeneralSettingsResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_GeneralSettings", Local: AMT_GeneralSettings},
+ ElementName: "Intel(r) AMT: General Settings",
+ InstanceID: "Intel(r) AMT: General Settings",
+ AMTNetworkEnabled: 1,
+ DDNSPeriodicUpdateInterval: 1440,
+ DDNSTTL: 900,
+ DDNSUpdateByDHCPServerEnabled: true,
+ DDNSUpdateEnabled: false,
+ DHCPSyncRequiresHostname: 1, //Intel SDK documentation missing
+ DHCPv6ConfigurationTimeout: 0,
+ DigestRealm: "Digest:F3EB554784E729164447A89F60B641C5",
+ DomainName: "Test Domain Name",
+ HostName: "Test Host Name",
+ HostOSFQDN: "Test Host OS FQDN",
+ IdleWakeTimeout: 1,
+ NetworkInterfaceEnabled: true,
+ PingResponseEnabled: true,
+ PowerSource: 0,
+ PreferredAddressFamily: 0,
+ PresenceNotificationInterval: 0,
+ PrivacyLevel: 0,
+ RmcpPingResponseEnabled: true,
+ SharedFQDN: true,
+ ThunderboltDockEnabled: 0,
+ WsmanOnlyMode: false,
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create a valid AMT_GeneralSettings Enumerate wsman message",
+ AMT_GeneralSettings,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Enumerate"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "14000000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid AMT_GeneralSettings Pull wsman message",
+ AMT_GeneralSettings,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Pull"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ GeneralSettingsItems: []GeneralSettingsResponse{
+ {
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_GeneralSettings", Local: AMT_GeneralSettings},
+ ElementName: "Intel(r) AMT: General Settings",
+ InstanceID: "Intel(r) AMT: General Settings",
+ AMTNetworkEnabled: 1,
+ DDNSPeriodicUpdateInterval: 1440,
+ DDNSTTL: 900,
+ DDNSUpdateByDHCPServerEnabled: true,
+ DDNSUpdateEnabled: false,
+ DHCPv6ConfigurationTimeout: 0,
+ DigestRealm: "Digest:6EE8C61BA74893E059F032EA919D699E",
+ DomainName: "",
+ HostOSFQDN: "",
+ IdleWakeTimeout: 65535,
+ NetworkInterfaceEnabled: true,
+ PingResponseEnabled: true,
+ PowerSource: 0,
+ PreferredAddressFamily: 0,
+ PresenceNotificationInterval: 0,
+ PrivacyLevel: 0,
+ RmcpPingResponseEnabled: true,
+ SharedFQDN: true,
+ WsmanOnlyMode: false,
+ },
+ },
+ },
+ },
+ },
+ }
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.NoError(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.Equal(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
+func TestNegativeAMT_GeneralSettings(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/general",
+ }
+ elementUnderTest := NewGeneralSettingsWithClient(wsmanMessageCreator, &client)
+ t.Run("amt_* Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create a valid AMT_GeneralSettings Get wsman message",
+ AMT_GeneralSettings,
+ wsmantesting.GET,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GetResponse: GeneralSettingsResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_GeneralSettings", Local: AMT_GeneralSettings},
+ ElementName: "Intel(r) AMT: General Settings",
+ InstanceID: "Intel(r) AMT: General Settings",
+ AMTNetworkEnabled: 1,
+ DDNSPeriodicUpdateInterval: 1440,
+ DDNSTTL: 900,
+ DDNSUpdateByDHCPServerEnabled: true,
+ DDNSUpdateEnabled: false,
+ DHCPSyncRequiresHostname: 1, //Intel SDK documentation missing
+ DHCPv6ConfigurationTimeout: 0,
+ DigestRealm: "Digest:F3EB554784E729164447A89F60B641C5",
+ DomainName: "Test Domain Name",
+ HostName: "Test Host Name",
+ HostOSFQDN: "Test Host OS FQDN",
+ IdleWakeTimeout: 1,
+ NetworkInterfaceEnabled: true,
+ PingResponseEnabled: true,
+ PowerSource: 0,
+ PreferredAddressFamily: 0,
+ PresenceNotificationInterval: 0,
+ PrivacyLevel: 0,
+ RmcpPingResponseEnabled: true,
+ SharedFQDN: true,
+ ThunderboltDockEnabled: 0,
+ WsmanOnlyMode: false,
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create a valid AMT_GeneralSettings Enumerate wsman message",
+ AMT_GeneralSettings,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "14000000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid AMT_GeneralSettings Pull wsman message",
+ AMT_GeneralSettings,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ GeneralSettingsItems: []GeneralSettingsResponse{
+ {
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_GeneralSettings", Local: AMT_GeneralSettings},
+ ElementName: "Intel(r) AMT: General Settings",
+ InstanceID: "Intel(r) AMT: General Settings",
+ AMTNetworkEnabled: 1,
+ DDNSPeriodicUpdateInterval: 1440,
+ DDNSTTL: 900,
+ DDNSUpdateByDHCPServerEnabled: true,
+ DDNSUpdateEnabled: false,
+ DHCPv6ConfigurationTimeout: 0,
+ DigestRealm: "Digest:6EE8C61BA74893E059F032EA919D699E",
+ DomainName: "",
+ HostOSFQDN: "",
+ IdleWakeTimeout: 65535,
+ NetworkInterfaceEnabled: true,
+ PingResponseEnabled: true,
+ PowerSource: 0,
+ PreferredAddressFamily: 0,
+ PresenceNotificationInterval: 0,
+ PrivacyLevel: 0,
+ RmcpPingResponseEnabled: true,
+ SharedFQDN: true,
+ WsmanOnlyMode: false,
+ },
+ },
+ },
+ },
+ },
+ }
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.Error(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.NotEqual(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
diff --git a/pkg/wsman/amt/general/types.go b/pkg/wsman/amt/general/types.go
new file mode 100644
index 00000000..1fd0b5ab
--- /dev/null
+++ b/pkg/wsman/amt/general/types.go
@@ -0,0 +1,149 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package general
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+)
+
+type Settings struct {
+ base message.Base
+}
+
+// OUTPUTS
+// Response Types
+type (
+ Response struct {
+ *client.Message
+ XMLName xml.Name `xml:"Envelope"`
+ Header message.Header `xml:"Header"`
+ Body Body `xml:"Body"`
+ }
+
+ Body struct {
+ XMLName xml.Name `xml:"Body"`
+ GetResponse GeneralSettingsResponse
+ EnumerateResponse common.EnumerateResponse
+ PullResponse PullResponse
+ PutResponse PutResponse
+ }
+
+ PullResponse struct {
+ XMLName xml.Name `xml:"PullResponse"`
+ GeneralSettingsItems []GeneralSettingsResponse `xml:"Items>AMT_GeneralSettings"`
+ }
+ GeneralSettingsResponse struct {
+ XMLName xml.Name `xml:"AMT_GeneralSettings"`
+ ElementName string `xml:"ElementName,omitempty"` // The user-friendly name for this instance of SettingData. In addition, the user-friendly name can be used as an index property for a search or query. (Note: The name does not have to be unique within a namespace.)
+ InstanceID string `xml:"InstanceID,omitempty"` // Within the scope of the instantiating Namespace, InstanceID opaquely and uniquely identifies an instance of this class. This is a read-only property.
+ NetworkInterfaceEnabled bool `xml:"NetworkInterfaceEnabled,omitempty"` // Indicates whether the network interface is enabled. This is a read-only property.
+ DigestRealm string `xml:"DigestRealm,omitempty"` // The Intel® AMT device Digest Authentication Realm parameter as defined by RFC 2617. This is a read-only property.
+ IdleWakeTimeout int `xml:"IdleWakeTimeout,omitempty"` // Defines the minimum time value, in minutes, that Intel® AMT will be powered after waking up from a sleep power state, or after the host enters sleep or off state.This timer value will be reloaded whenever Intel® AMT is servicing requests. Note: this setting may not be applicable under some power package definitions. The minimum value for this property is 1, maximum is 65535
+ HostName string `xml:"HostName,omitempty"` // Intel® AMT host setting. In Intel AMT Release 6.0 and later releases, maximum length is 63 characters. Starting from Intel CSME 18.0, the hostname can contain Unicode characters, where each character is encoded as an html entity number, for example U+003C is represented by the ASCII string < or <. Maximum length of the string remains 63 bytes when encoded in UTF-8.
+ DomainName string `xml:"DomainName,omitempty"` // Intel® AMT domain name setting. In Intel AMT Release 6.0 and later releases, maximum length is 191 characters.
+ PingResponseEnabled bool `xml:"PingResponseEnabled,omitempty"` // Indicates whether Intel® AMT should respond to ping Echo Request messages. Additional Notes: 'PingResponseEnabled' is a required field for the Put command.
+ WsmanOnlyMode bool `xml:"WsmanOnlyMode,omitempty"` // Indicates whether Intel® AMT should block network interfaces other than WS-Management. By default AMT enables both WS-Management and legacy interfaces. If set to true, only WS-Management will be enabled. Additional Notes: 'WsmanOnlyMode' is a required field for the Put command.
+ PreferredAddressFamily PreferredAddressFamily `xml:"PreferredAddressFamily,omitempty"` // Preferred Address Family (IPv4/IPv6). Preferred Address Family (IPv4/IPv6) used for controlling outbound traffic such as events and user initiated traffic. For such traffic, the preferred addressing family will be attempted first, but other considerations also apply, depending on the traffic and the destination.
+ DHCPv6ConfigurationTimeout int `xml:"DHCPv6ConfigurationTimeout,omitempty"` // Defines the Maximum Duration (DHCPv6 MRD for the Solicit Message) in seconds during which the Intel® ME FW tries to locate a DHCPv6 server. 0 - means try forever. The default value for this property is 0.
+ DDNSUpdateEnabled bool `xml:"DDNSUpdateEnabled,omitempty"` // Defines whether the Dynamic DNS Update Client in FW is enabled or not. (The default value for this property is disabled)
+ DDNSUpdateByDHCPServerEnabled bool `xml:"DDNSUpdateByDHCPServerEnabled,omitempty"` // If the DDNS Update client in FW is disabled then this property will define whether DDNS Update should be requested from the DHCP Server for the shared IPv4 address and shared FQDN. (The default value for this property is enabled)
+ SharedFQDN bool `xml:"SharedFQDN,omitempty"` // Defines Whether the FQDN (HostName.DomainName) is shared with the Host or dedicated to ME. (The default value for this property is shared - TRUE).
+ HostOSFQDN string `xml:"HostOSFQDN,omitempty"` // Intel® AMT host OS FQDN. This value of host FQDN is needed for the case that FW is set with a dedicated FQDN - this allows the SW to correlate the FW name with the Host name.
+ DDNSTTL int `xml:"DDNSTTL,omitempty"` // Defines the Time To Live value (cachable time) of RRs registered by the FW DDNSUpdateClient. Units are seconds. (The default value for this property is 15 minutes). Maximum value is 2147483647 (2^31-1) - according to RFC2181
+ AMTNetworkEnabled AMTNetworkEnabled `xml:"AMTNetworkEnabled,omitempty"` // When set to Disabled, the AMT OOB network interfaces (LAN and WLAN) are disabled including AMT user initiated applications, Environment Detection and RMCPPing. Since OOB networking is disabled, there will not be an option to enable it back remotely.
+ RmcpPingResponseEnabled bool `xml:"RmcpPingResponseEnabled,omitempty"` // Indicates whether Intel® AMT should respond to RMCP ping Echo Request messages.
+ DDNSPeriodicUpdateInterval int `xml:"DDNSPeriodicUpdateInterval,omitempty"` // Defines the interval at which the FW DDNS Update client will send periodic updates for all the RRs registered by FW. Should be set according to corporate DNS scavenging policy. Units are minutes. Can be : either 0, or 20 and over. A value of 0 disables periodic update. (The default value for this property is 24 hours - 1440 minutes).
+ PresenceNotificationInterval int `xml:"PresenceNotificationInterval,omitempty"` // Defines the interval at which the FW will send periodic WS-management events notifications (for the subscribed clients) whenever network settings are changed. Units are minutes. A value of 0 disables periodic events. The default value for this property is 0 (notifications are disabled). The minimal allowed value is 15 minutes.
+ PrivacyLevel PrivacyLevel `xml:"PrivacyLevel,omitempty"` // Defines the Privacy and Security Level setting. This is a read-only property.
+ PowerSource PowerSource `xml:"PowerSource,omitempty"` // The system current power source. This is a read-only property.
+ ThunderboltDockEnabled ThunderboltDockEnabled `xml:"ThunderboltDockEnabled,omitempty"` // When set to Disabled, a management console cannot communicate with Intel AMT via a Thunderbolt dock. Available in Release 15.0 and later releases.
+ OemID int `xml:"OemID,omitempty"` // The OEM's vendor ID as listed in the Peripheral Component Interconnect Special Interest Group (PCI-SIG) list of member companies. Available in Release 16.1 and later releases.
+ DHCPSyncRequiresHostname int `xml:"DHCPSyncRequiresHostname,omitempty"` // AMT SDK Documentation Missing
+ }
+
+ PutResponse struct {
+ }
+)
+
+// INPUTS
+// Request Types
+type (
+ GeneralSettingsRequest struct {
+ XMLName xml.Name `xml:"h:AMT_GeneralSettings"`
+ H string `xml:"h:xmlns:h,attr"`
+ ElementName string `xml:"h:ElementName,omitempty"` // The user-friendly name for this instance of SettingData. In addition, the user-friendly name can be used as an index property for a search or query. (Note: The name does not have to be unique within a namespace.)
+ InstanceID string `xml:"h:InstanceID,omitempty"` // Within the scope of the instantiating Namespace, InstanceID opaquely and uniquely identifies an instance of this class. This is a read-only property.
+ NetworkInterfaceEnabled bool `xml:"h:NetworkInterfaceEnabled,omitempty"` // Indicates whether the network interface is enabled. This is a read-only property.
+ DigestRealm string `xml:"h:DigestRealm,omitempty"` // The Intel® AMT device Digest Authentication Realm parameter as defined by RFC 2617. This is a read-only property.
+ IdleWakeTimeout int `xml:"h:IdleWakeTimeout,omitempty"` // Defines the minimum time value, in minutes, that Intel® AMT will be powered after waking up from a sleep power state, or after the host enters sleep or off state.This timer value will be reloaded whenever Intel® AMT is servicing requests. Note: this setting may not be applicable under some power package definitions. The minimum value for this property is 1, maximum is 65535
+ HostName string `xml:"h:HostName,omitempty"` // Intel® AMT host setting. In Intel AMT Release 6.0 and later releases, maximum length is 63 characters. Starting from Intel CSME 18.0, the hostname can contain Unicode characters, where each character is encoded as an html entity number, for example U+003C is represented by the ASCII string < or <. Maximum length of the string remains 63 bytes when encoded in UTF-8.
+ DomainName string `xml:"h:DomainName,omitempty"` // Intel® AMT domain name setting. In Intel AMT Release 6.0 and later releases, maximum length is 191 characters.
+ PingResponseEnabled bool `xml:"h:PingResponseEnabled,omitempty"` // Indicates whether Intel® AMT should respond to ping Echo Request messages. Additional Notes: 'PingResponseEnabled' is a required field for the Put command.
+ WsmanOnlyMode bool `xml:"h:WsmanOnlyMode,omitempty"` // Indicates whether Intel® AMT should block network interfaces other than WS-Management. By default AMT enables both WS-Management and legacy interfaces. If set to true, only WS-Management will be enabled. Additional Notes: 'WsmanOnlyMode' is a required field for the Put command.
+ PreferredAddressFamily PreferredAddressFamily `xml:"h:PreferredAddressFamily,omitempty"` // Preferred Address Family (IPv4/IPv6). Preferred Address Family (IPv4/IPv6) used for controlling outbound traffic such as events and user initiated traffic. For such traffic, the preferred addressing family will be attempted first, but other considerations also apply, depending on the traffic and the destination.
+ DHCPv6ConfigurationTimeout int `xml:"h:DHCPv6ConfigurationTimeout,omitempty"` // Defines the Maximum Duration (DHCPv6 MRD for the Solicit Message) in seconds during which the Intel® ME FW tries to locate a DHCPv6 server. 0 - means try forever. The default value for this property is 0.
+ DDNSUpdateEnabled bool `xml:"h:DDNSUpdateEnabled,omitempty"` // Defines whether the Dynamic DNS Update Client in FW is enabled or not. (The default value for this property is disabled)
+ DDNSUpdateByDHCPServerEnabled bool `xml:"h:DDNSUpdateByDHCPServerEnabled,omitempty"` // If the DDNS Update client in FW is disabled then this property will define whether DDNS Update should be requested from the DHCP Server for the shared IPv4 address and shared FQDN. (The default value for this property is enabled)
+ SharedFQDN bool `xml:"h:SharedFQDN,omitempty"` // Defines Whether the FQDN (HostName.DomainName) is shared with the Host or dedicated to ME. (The default value for this property is shared - TRUE).
+ HostOSFQDN string `xml:"h:HostOSFQDN,omitempty"` // Intel® AMT host OS FQDN. This value of host FQDN is needed for the case that FW is set with a dedicated FQDN - this allows the SW to correlate the FW name with the Host name.
+ DDNSTTL int `xml:"h:DDNSTTL,omitempty"` // Defines the Time To Live value (cachable time) of RRs registered by the FW DDNSUpdateClient. Units are seconds. (The default value for this property is 15 minutes). Maximum value is 2147483647 (2^31-1) - according to RFC2181
+ AMTNetworkEnabled AMTNetworkEnabled `xml:"h:AMTNetworkEnabled,omitempty"` // When set to Disabled, the AMT OOB network interfaces (LAN and WLAN) are disabled including AMT user initiated applications, Environment Detection and RMCPPing. Since OOB networking is disabled, there will not be an option to enable it back remotely.
+ RmcpPingResponseEnabled bool `xml:"h:RmcpPingResponseEnabled,omitempty"` // Indicates whether Intel® AMT should respond to RMCP ping Echo Request messages.
+ DDNSPeriodicUpdateInterval int `xml:"h:DDNSPeriodicUpdateInterval,omitempty"` // Defines the interval at which the FW DDNS Update client will send periodic updates for all the RRs registered by FW. Should be set according to corporate DNS scavenging policy. Units are minutes. Can be : either 0, or 20 and over. A value of 0 disables periodic update. (The default value for this property is 24 hours - 1440 minutes).
+ PresenceNotificationInterval int `xml:"h:PresenceNotificationInterval,omitempty"` // Defines the interval at which the FW will send periodic WS-management events notifications (for the subscribed clients) whenever network settings are changed. Units are minutes. A value of 0 disables periodic events. The default value for this property is 0 (notifications are disabled). The minimal allowed value is 15 minutes.
+ PrivacyLevel PrivacyLevel `xml:"h:PrivacyLevel,omitempty"` // Defines the Privacy and Security Level setting. This is a read-only property.
+ PowerSource PowerSource `xml:"h:PowerSource,omitempty"` // The system current power source. This is a read-only property.
+ ThunderboltDockEnabled ThunderboltDockEnabled `xml:"h:ThunderboltDockEnabled,omitempty"` // When set to Disabled, a management console cannot communicate with Intel AMT via a Thunderbolt dock. Available in Release 15.0 and later releases.
+ OemID int `xml:"h:OemID,omitempty"` // The OEM's vendor ID as listed in the Peripheral Component Interconnect Special Interest Group (PCI-SIG) list of member companies. Available in Release 16.1 and later releases.
+ DHCPSyncRequiresHostname int `xml:"h:DHCPSyncRequiresHostname,omitempty"` // AMT SDK Documentation Missing
+ }
+)
+
+// Preferred Address Family (IPv4/IPv6). Preferred Address Family (IPv4/IPv6) used for controlling outbound traffic such as events and user initiated traffic. For such traffic, the preferred addressing family will be attempted first, but other considerations also apply, depending on the traffic and the destination.
+//
+// ValueMap={0, 1, 2..}
+//
+// Values={IPv4, IPv6, Reserved}
+type PreferredAddressFamily int
+
+// Defines the Privacy and Security Level setting. Privacy Level defines the values for privacy/security-related parameters by default and upon ME-unconfigure event. The setting can have the following values:
+//
+// Default: SOL enabled = true, IDER enabled = true, KVM enabled = true, Opt-in can be disabled = true, opt-in configurable remotely = true. From Intel ME 8: Also Client Control Mode allowed=true and RCFG enabled=true.
+//
+// Enhanced: SOL enabled = true, IDER enabled = true, KVM enabled = true, Opt-in can be disabled = false, opt-in configurable remotely = true. From Intel ME 8: Also Client Control Mode allowed=true and RCFG enabled=true.
+//
+// Extreme: SOL enabled = false, IDER enabled = false, KVM enabled = false, Opt-in can be disabled = false, opt-in configurable remotely = false. From Intel ME 8: Also Client Control Mode allowed=false and RCFG enabled = false.
+//
+// This is a read-only property.
+//
+// ValueMap={0, 1, 2, 3..}
+//
+// Values={Default, Enhanced, Extreme, Reserved}
+type PrivacyLevel int
+
+// The system current power source. This is a read-only property.
+//
+// ValueMap={0, 1, 2..}
+//
+// Values={AC, DC, Reserved}
+type PowerSource int
+
+// When set to Disabled, the AMT OOB network interfaces (LAN and WLAN) are disabled including AMT user initiated applications, Environment Detection and RMCPPing. Since OOB networking is disabled, there will not be an option to enable it back remotely.
+//
+// ValueMap={0, 1, 2..}
+//
+// Values={Disabled, Enabled, Reserved}
+type AMTNetworkEnabled FeatureEnabled
+
+// When set to Disabled, a management console cannot communicate with Intel AMT via a Thunderbolt dock. Available in Release 15.0 and later releases.
+//
+// Values: 0=Disabled, 1=Enabled. Default: Enabled.
+type ThunderboltDockEnabled FeatureEnabled
+type FeatureEnabled int
diff --git a/pkg/wsman/amt/ieee8021x/constants.go b/pkg/wsman/amt/ieee8021x/constants.go
new file mode 100644
index 00000000..d351bdcd
--- /dev/null
+++ b/pkg/wsman/amt/ieee8021x/constants.go
@@ -0,0 +1,26 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package ieee8021x
+
+const (
+ AMT_IEEE8021xCredentialContext string = "AMT_8021xCredentialContext"
+ AMT_IEEE8021xProfile string = "AMT_8021XProfile"
+)
+
+const (
+ TLS AuthenticationProtocol = iota
+ TTLS_MSCHAPv2
+ PEAP_MSCHAPv2
+ EAP_GTC
+ EAPFAST_MSCHAPv2
+ EAPFAST_GTC
+ EAPFAST_TLS
+)
+
+const (
+ FullName ServerCertificateNameComparison = iota
+ DomainSuffix
+)
diff --git a/pkg/wsman/amt/ieee8021x/credentialcontext.go b/pkg/wsman/amt/ieee8021x/credentialcontext.go
new file mode 100644
index 00000000..4eb5c521
--- /dev/null
+++ b/pkg/wsman/amt/ieee8021x/credentialcontext.go
@@ -0,0 +1,72 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+// Package ieee8021x facilitiates communication with Intel® AMT devices to access the ieee8021x credential context and profile settings
+//
+// CredentialContext gets the association between an instance of AMT_8021XProfile and an instance of AMT_PublicKeyCertificate that it uses.
+//
+// Profile represents a 802.1X profile in the Intel® AMT system.
+package ieee8021x
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+)
+
+type CredentialContext struct {
+ base message.Base
+}
+
+// NewIEEE8021xCredentialContextWithClient instantiates a new CredentialContext service.
+func NewIEEE8021xCredentialContextWithClient(wsmanMessageCreator *message.WSManMessageCreator, client client.WSMan) CredentialContext {
+ return CredentialContext{
+ base: message.NewBaseWithClient(wsmanMessageCreator, AMT_IEEE8021xCredentialContext, client),
+ }
+}
+
+// TODO: Handle GET input
+// Get retrieves the representation of the instance
+
+// Enumerate returns an enumeration context which is used in a subsequent Pull call
+func (credentialContext CredentialContext) Enumerate() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: credentialContext.base.Enumerate(),
+ },
+ }
+ // send the message to AMT
+ err = credentialContext.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Pull returns the instances of this class. An enumeration context provided by the Enumerate call is used as input.
+func (credentialContext CredentialContext) Pull(enumerationContext string) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: credentialContext.base.Pull(enumerationContext),
+ },
+ }
+ // send the message to AMT
+ err = credentialContext.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
diff --git a/pkg/wsman/amt/ieee8021x/credentialcontext_test.go b/pkg/wsman/amt/ieee8021x/credentialcontext_test.go
new file mode 100644
index 00000000..a54c7181
--- /dev/null
+++ b/pkg/wsman/amt/ieee8021x/credentialcontext_test.go
@@ -0,0 +1,149 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package ieee8021x
+
+import (
+ "encoding/xml"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
+)
+
+func TestPositiveAMT_8021xCredentialContext(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/ieee8021x/credentialcontext",
+ }
+ elementUnderTest := NewIEEE8021xCredentialContextWithClient(wsmanMessageCreator, &client)
+
+ t.Run("amt_8021xCredentialContext Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //ENUMERATES
+ {
+ "should create a valid AMT_8021xCredentialContext Enumerate wsman message",
+ AMT_IEEE8021xCredentialContext,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Enumerate"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "02080000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid AMT_8021xCredentialContext Pull wsman message",
+ AMT_IEEE8021xCredentialContext,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Pull"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ },
+ },
+ },
+ }
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.NoError(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.Equal(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
+
+func TestNegativeAMT_8021xCredentialContext(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/ieee8021x/credentialcontext",
+ }
+ elementUnderTest := NewIEEE8021xCredentialContextWithClient(wsmanMessageCreator, &client)
+
+ t.Run("amt_8021xCredentialContext Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //ENUMERATES
+ {
+ "should create a valid AMT_8021xCredentialContext Enumerate wsman message",
+ AMT_IEEE8021xCredentialContext,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "02080000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid AMT_8021xCredentialContext Pull wsman message",
+ AMT_IEEE8021xCredentialContext,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ },
+ },
+ },
+ }
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.Error(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.NotEqual(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
diff --git a/pkg/wsman/amt/ieee8021x/marshal.go b/pkg/wsman/amt/ieee8021x/marshal.go
new file mode 100644
index 00000000..e23c3e2d
--- /dev/null
+++ b/pkg/wsman/amt/ieee8021x/marshal.go
@@ -0,0 +1,30 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package ieee8021x
+
+import (
+ "encoding/json"
+
+ "gopkg.in/yaml.v3"
+)
+
+// JSON marshals the type into JSON format
+func (r *Response) JSON() string {
+ jsonOutput, err := json.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(jsonOutput)
+}
+
+// YAML marshals the type into YAML format
+func (r *Response) YAML() string {
+ yamlOutput, err := yaml.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(yamlOutput)
+}
diff --git a/pkg/wsman/amt/ieee8021x/profile.go b/pkg/wsman/amt/ieee8021x/profile.go
new file mode 100644
index 00000000..d05f4520
--- /dev/null
+++ b/pkg/wsman/amt/ieee8021x/profile.go
@@ -0,0 +1,106 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package ieee8021x
+
+import (
+ "encoding/xml"
+ "fmt"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+)
+
+type Profile struct {
+ base message.Base
+}
+
+// NewIEEE8021xProfileWithClient instantiates a new Profile service
+func NewIEEE8021xProfileWithClient(wsmanMessageCreator *message.WSManMessageCreator, client client.WSMan) Profile {
+ return Profile{
+ base: message.NewBaseWithClient(wsmanMessageCreator, AMT_IEEE8021xProfile, client),
+ }
+}
+
+// Get retrieves the representation of the instance
+func (profile Profile) Get() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: profile.base.Get(nil),
+ },
+ }
+ // send the message to AMT
+ err = profile.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Enumerate returns an enumeration context which is used in a subsequent Pull call
+func (profile Profile) Enumerate() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: profile.base.Enumerate(),
+ },
+ }
+ // send the message to AMT
+ err = profile.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Pull returns the instances of this class. An enumeration context provided by the Enumerate call is used as input.
+func (profile Profile) Pull(enumerationContext string) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: profile.base.Pull(enumerationContext),
+ },
+ }
+ // send the message to AMT
+ err = profile.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Put will change properties of the selected instance
+func (profile Profile) Put(ieee8021xProfile ProfileRequest) (response Response, err error) {
+ ieee8021xProfile.H = fmt.Sprintf("%s%s", message.AMTSchema, AMT_IEEE8021xProfile)
+ response = Response{
+ Message: &client.Message{
+ XMLInput: profile.base.Put(ieee8021xProfile, false, nil),
+ },
+ }
+ // send the message to AMT
+ err = profile.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
diff --git a/pkg/wsman/amt/ieee8021x/profile_test.go b/pkg/wsman/amt/ieee8021x/profile_test.go
new file mode 100644
index 00000000..b8507bc9
--- /dev/null
+++ b/pkg/wsman/amt/ieee8021x/profile_test.go
@@ -0,0 +1,270 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package ieee8021x
+
+import (
+ "encoding/xml"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
+)
+
+func TestPositiveAMT_8021XProfile(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/ieee8021x/profile",
+ }
+ elementUnderTest := NewIEEE8021xProfileWithClient(wsmanMessageCreator, &client)
+
+ t.Run("amt_8021XProfile Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create a valid AMT_8021XProfile Get wsman message",
+ AMT_IEEE8021xProfile,
+ wsmantesting.GET,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Get"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ ProfileGetAndPutResponse: ProfileResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_8021XProfile", Local: "AMT_8021XProfile"},
+ ElementName: "Intel(r) AMT 802.1x Profile",
+ InstanceID: "Intel(r) AMT 802.1x Profile 0",
+ Enabled: false,
+ ActiveInS0: true,
+ PxeTimeout: 0,
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create a valid AMT_8021XProfile Enumerate wsman message",
+ AMT_IEEE8021xProfile,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Enumerate"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "04080000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid AMT_8021XProfile Pull wsman message",
+ AMT_IEEE8021xProfile,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Pull"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ ProfileItems: []ProfileResponse{
+ {
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_8021XProfile", Local: "AMT_8021XProfile"},
+ ElementName: "Intel(r) AMT 802.1x Profile",
+ InstanceID: "Intel(r) AMT 802.1x Profile 0",
+ Enabled: false,
+ ActiveInS0: true,
+ PxeTimeout: 0,
+ },
+ },
+ },
+ },
+ },
+ //PUTS
+ {
+ "should create a valid AMT_8021XProfile Put wsman message",
+ AMT_IEEE8021xProfile,
+ wsmantesting.PUT,
+ "Intel(r) AMT 802.1x ProfileIntel(r) AMT 802.1x Profile 0falsefalse00",
+ func() (Response, error) {
+ profileRequest := ProfileRequest{
+ H: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_8021XProfile",
+ ActiveInS0: false,
+ ElementName: "Intel(r) AMT 802.1x Profile",
+ Enabled: false,
+ InstanceID: "Intel(r) AMT 802.1x Profile 0",
+ }
+ client.CurrentMessage = "Put"
+ return elementUnderTest.Put(profileRequest)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ ProfileGetAndPutResponse: ProfileResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_8021XProfile", Local: "AMT_8021XProfile"},
+ ElementName: "Intel(r) AMT 802.1x Profile",
+ InstanceID: "Intel(r) AMT 802.1x Profile 0",
+ Enabled: false,
+ ActiveInS0: false,
+ PxeTimeout: 120,
+ },
+ },
+ },
+ }
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.NoError(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.Equal(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
+func TestNegativeAMT_8021XProfile(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/ieee8021x/profile",
+ }
+ elementUnderTest := NewIEEE8021xProfileWithClient(wsmanMessageCreator, &client)
+
+ t.Run("amt_8021XProfile Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create a valid AMT_8021XProfile Get wsman message",
+ AMT_IEEE8021xProfile,
+ wsmantesting.GET,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ ProfileGetAndPutResponse: ProfileResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_8021XProfile", Local: "AMT_8021XProfile"},
+ ElementName: "Intel(r) AMT 802.1x Profile",
+ InstanceID: "Intel(r) AMT 802.1x Profile 0",
+ Enabled: false,
+ ActiveInS0: true,
+ PxeTimeout: 0,
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create a valid AMT_8021XProfile Enumerate wsman message",
+ AMT_IEEE8021xProfile,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "04080000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid AMT_8021XProfile Pull wsman message",
+ AMT_IEEE8021xProfile,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ ProfileItems: []ProfileResponse{
+ {
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_8021XProfile", Local: "AMT_8021XProfile"},
+ ElementName: "Intel(r) AMT 802.1x Profile",
+ InstanceID: "Intel(r) AMT 802.1x Profile 0",
+ Enabled: false,
+ ActiveInS0: true,
+ PxeTimeout: 0,
+ },
+ },
+ },
+ },
+ },
+ //PUTS
+ {
+ "should create a valid AMT_8021XProfile Put wsman message",
+ AMT_IEEE8021xProfile,
+ wsmantesting.PUT,
+ "Intel(r) AMT 802.1x ProfileIntel(r) AMT 802.1x Profile 0falsefalse00",
+ func() (Response, error) {
+ profileRequest := ProfileRequest{
+ H: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_8021XProfile",
+ ActiveInS0: false,
+ ElementName: "Intel(r) AMT 802.1x Profile",
+ Enabled: false,
+ InstanceID: "Intel(r) AMT 802.1x Profile 0",
+ }
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Put(profileRequest)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ ProfileGetAndPutResponse: ProfileResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_8021XProfile", Local: "AMT_8021XProfile"},
+ ElementName: "Intel(r) AMT 802.1x Profile",
+ InstanceID: "Intel(r) AMT 802.1x Profile 0",
+ Enabled: false,
+ ActiveInS0: false,
+ PxeTimeout: 120,
+ },
+ },
+ },
+ }
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.Error(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.NotEqual(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
diff --git a/pkg/wsman/amt/ieee8021x/types.go b/pkg/wsman/amt/ieee8021x/types.go
new file mode 100644
index 00000000..22b1bdb4
--- /dev/null
+++ b/pkg/wsman/amt/ieee8021x/types.go
@@ -0,0 +1,98 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package ieee8021x
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+)
+
+// OUTPUTS
+// Response Types
+type (
+ Response struct {
+ *client.Message
+ XMLName xml.Name `xml:"Envelope"`
+ Header message.Header `xml:"Header"`
+ Body Body `xml:"Body"`
+ }
+
+ Body struct {
+ XMLName xml.Name `xml:"Body"`
+ ProfileGetAndPutResponse ProfileResponse
+ CredentialContextGetResponse CredentialContextResponse
+ EnumerateResponse common.EnumerateResponse
+ PullResponse PullResponse
+ }
+
+ PullResponse struct {
+ XMLName xml.Name `xml:"PullResponse"`
+ ProfileItems []ProfileResponse `xml:"Items>AMT_8021XProfile"`
+ CredentialContextItems []CredentialContextResponse `xml:"Items>AMT_8021xCredentialContext"`
+ }
+
+ ProfileResponse struct {
+ XMLName xml.Name `xml:"AMT_8021XProfile"`
+ ElementName string `xml:"ElementName,omitempty"` // The user-friendly name for this instance of SettingData. In addition, the user-friendly name can be used as an index property for a search or query. (Note: The name does not have to be unique within a namespace.)
+ InstanceID string `xml:"InstanceID,omitempty"` // Within the scope of the instantiating Namespace, InstanceID opaquely and uniquely identifies an instance of this class. To ensure uniqueness within the NameSpace, the value of InstanceID should be constructed using the following "preferred" algorithm: : Where and are separated by a colon (:), and where must include a copyrighted, trademarked, or otherwise unique name that is owned by the business entity that is creating or defining the InstanceID or that is a registered ID assigned to the business entity by a recognized global authority. (This requirement is similar to the _ structure of Schema class names.) In addition, to ensure uniqueness, must not contain a colon (:). When using this algorithm, the first colon to appear in InstanceID must appear between and . is chosen by the business entity and should not be reused to identify different underlying (real-world) elements. If the above "preferred" algorithm is not used, the defining entity must assure that the resulting InstanceID is not reused across any InstanceIDs produced by this or other providers for the NameSpace of this instance. For DMTF-defined instances, the "preferred" algorithm must be used with the set to CIM.
+ Enabled bool `xml:"Enabled,omitempty"` // Indicates whether the 802.1x profile is enabled.
+ ActiveInS0 bool `xml:"ActiveInS0,omitempty"` // Indicates the activity setting of the 802.1X module in H0 state when the LAN driver is active. The default value for this property is 'true'. If the LAN driver is down, this property is not relevant. Functionality: when FALSE, AMT is not accessible (over 802.1x enabled port) in case the host is in S0 but fails to authenticate to the server. When TRUE, AMT handles the authentication in this case (but the host still can't be accessed until it authenticates successfully). If 802.1X is not configured, this API may still succeed as the setting may be stored for future use. The default factory setting is TRUE.
+ AuthenticationProtocol AuthenticationProtocol `xml:"AuthenticationProtocol,omitempty"` // Identifies the authentication protocol used to authenticate the access requestor to the AAA server.
+ RoamingIdentity string `xml:"RoamingIdentity,omitempty"` // A string presented to the authentication server in 802.1x protocol exchange. The AAA server determines the format of this string. Formats supported by AAA servers include: username@domain.
+ ServerCertificateName string `xml:"ServerCertificateName,omitempty"` // The name compared against the subject name field in the certificate provided by the AAA server. This name is either the full name of the AAA server, in which case ServerCertificateNameComparison is set to "FullName", or it is the domain suffix of the AAA server, in which case ServerCertificateNameComparison is set to "DomainSuffix"
+ ServerCertificateNameComparison ServerCertificateNameComparison `xml:"ServerCertificateNameComparison,omitempty"` // Determines the comparison algorithm used between the ServerCertificateName value and the subject name field of the certificate presented by the AAA server. This field is mandatory if ServerCertificateName is defined.
+ Username string `xml:"Username,omitempty"` // Within the domain specified by Domain, Identifies the user that is requesting access to the network. MaxLen=128
+ Password string `xml:"Password,omitempty"` // The password associated with the user identified by Username and Domain. MaxLen=32
+ Domain string `xml:"Domain,omitempty"` // The domain within which Username is unique. The Domain string shouldn't contain the suffix, so the user name (Domain\user) will be correct. If the Domain string contains a suffix (e.g. Domain = intel.com), the user trying to authenticate will be of the form intel.com\user (instead of intel\user) and thus authentication will fail. MaxLen=128
+ ProtectedAccessCredential []int `xml:"ProtectedAccessCredential,omitempty"` // A credential used by the supplicant and AAA server to establish a mutually authenticated encrypted tunnel for confidential user authentication. This field is relevant for EAP-FAST only. It is not required if the server is configured for "PAC provisioning".
+ PACPassword string `xml:"PACPassword,omitempty"` // Optional password to extract the PAC (Protected Access Credential)information from the PAC data. MaxLen=256
+ ClientCertificate string `xml:"ClientCertificate,omitempty"` // The client certificate that should be used by the profile. The client certificate should be specified in the Put request while configuring the profile. This will delete the existing instance of AMT_8021xCredentialContext that represents the client certificate, and create a new instance if a client certificate EPR is provided. This property will never be returned in Get response.
+ ServerCertificateIssue string `xml:"ServerCertificateIssue,omitempty"` // The trusted root CA that should be used while verifying the server certificate. The root certificate should be specified in the Put request while configuring the profile. This will delete the existing instance of AMT_8021xCredentialContext that represents the trusted root certificate, and create a new instance if a trusted root certificate EPR is provided. This property will never be returned in Get response. This field is optional. If not defined, AMT looks for a matching root certidicate in its repository.
+ PxeTimeout int `xml:"PxeTimeout,omitempty"` // Timeout in seconds, in which the Intel® AMT will hold an authenticated 802.1X session. During the defined period, Intel® AMT manages the 802.1X negotiation while a PXE boot takes place. After the timeout, control of the negotiation passes to the host. The maximum value is 86400 seconds (one day). A value of 0 disables the feature. If you do not set a profile, the value of PxeTimeout is 0. If you set a profile without specifying a value for PxeTimeout, the firmware sets it to 120.
+ }
+
+ CredentialContextResponse struct {
+ XMLName xml.Name `xml:"AMT_8021XCredentialContext"`
+ }
+)
+
+type ProfileRequest struct {
+ XMLName xml.Name `xml:"h:AMT_8021XProfile"`
+ H string `xml:"xmlns:h,attr"`
+ ElementName string `xml:"h:ElementName"` // Required. The user-friendly name for this instance of SettingData. In addition, the user-friendly name can be used as an index property for a search or query. (Note: The name does not have to be unique within a namespace.)
+ InstanceID string `xml:"h:InstanceID,omitempty"` // Within the scope of the instantiating Namespace, InstanceID opaquely and uniquely identifies an instance of this class. To ensure uniqueness within the NameSpace, the value of InstanceID should be constructed using the following "preferred" algorithm: : Where and are separated by a colon (:), and where must include a copyrighted, trademarked, or otherwise unique name that is owned by the business entity that is creating or defining the InstanceID or that is a registered ID assigned to the business entity by a recognized global authority. (This requirement is similar to the _ structure of Schema class names.) In addition, to ensure uniqueness, must not contain a colon (:). When using this algorithm, the first colon to appear in InstanceID must appear between and . is chosen by the business entity and should not be reused to identify different underlying (real-world) elements. If the above "preferred" algorithm is not used, the defining entity must assure that the resulting InstanceID is not reused across any InstanceIDs produced by this or other providers for the NameSpace of this instance. For DMTF-defined instances, the "preferred" algorithm must be used with the set to CIM.
+ Enabled bool `xml:"h:Enabled"` // Required. Indicates whether the 802.1x profile is enabled.
+ ActiveInS0 bool `xml:"h:ActiveInS0"` // Indicates the activity setting of the 802.1X module in H0 state when the LAN driver is active. The default value for this property is 'true'. If the LAN driver is down, this property is not relevant. Functionality: when FALSE, AMT is not accessible (over 802.1x enabled port) in case the host is in S0 but fails to authenticate to the server. When TRUE, AMT handles the authentication in this case (but the host still can't be accessed until it authenticates successfully). If 802.1X is not configured, this API may still succeed as the setting may be stored for future use. The default factory setting is TRUE.
+ AuthenticationProtocol AuthenticationProtocol `xml:"h:AuthenticationProtocol"` // Identifies the authentication protocol used to authenticate the access requestor to the AAA server.
+ RoamingIdentity string `xml:"h:RoamingIdentity,omitempty"` // A string presented to the authentication server in 802.1x protocol exchange. The AAA server determines the format of this string. Formats supported by AAA servers include: username@domain.
+ ServerCertificateName string `xml:"h:ServerCertificateName,omitempty"` // The name compared against the subject name field in the certificate provided by the AAA server. This name is either the full name of the AAA server, in which case ServerCertificateNameComparison is set to "FullName", or it is the domain suffix of the AAA server, in which case ServerCertificateNameComparison is set to "DomainSuffix"
+ ServerCertificateNameComparison ServerCertificateNameComparison `xml:"h:ServerCertificateNameComparison"` // Determines the comparison algorithm used between the ServerCertificateName value and the subject name field of the certificate presented by the AAA server. This field is mandatory if ServerCertificateName is defined.
+ Username string `xml:"h:Username,omitempty"` // Within the domain specified by Domain, Identifies the user that is requesting access to the network. MaxLen=128
+ Password string `xml:"h:Password,omitempty"` // The password associated with the user identified by Username and Domain. MaxLen=32
+ Domain string `xml:"h:Domain,omitempty"` // The domain within which Username is unique. The Domain string shouldn't contain the suffix, so the user name (Domain\user) will be correct. If the Domain string contains a suffix (e.g. Domain = intel.com), the user trying to authenticate will be of the form intel.com\user (instead of intel\user) and thus authentication will fail. MaxLen=128
+ ProtectedAccessCredential []int `xml:"h:ProtectedAccessCredential,omitempty"` // A credential used by the supplicant and AAA server to establish a mutually authenticated encrypted tunnel for confidential user authentication. This field is relevant for EAP-FAST only. It is not required if the server is configured for "PAC provisioning".
+ PACPassword string `xml:"h:PACPassword,omitempty"` // Optional password to extract the PAC (Protected Access Credential)information from the PAC data. MaxLen=256
+ ClientCertificate string `xml:"h:ClientCertificate,omitempty"` // The client certificate that should be used by the profile. The client certificate should be specified in the Put request while configuring the profile. This will delete the existing instance of AMT_8021xCredentialContext that represents the client certificate, and create a new instance if a client certificate EPR is provided. This property will never be returned in Get response.
+ ServerCertificateIssue string `xml:"h:ServerCertificateIssue,omitempty"` // The trusted root CA that should be used while verifying the server certificate. The root certificate should be specified in the Put request while configuring the profile. This will delete the existing instance of AMT_8021xCredentialContext that represents the trusted root certificate, and create a new instance if a trusted root certificate EPR is provided. This property will never be returned in Get response. This field is optional. If not defined, AMT looks for a matching root certidicate in its repository.
+ PxeTimeout int `xml:"h:PxeTimeout,omitempty"` // Timeout in seconds, in which the Intel® AMT will hold an authenticated 802.1X session. During the defined period, Intel® AMT manages the 802.1X negotiation while a PXE boot takes place. After the timeout, control of the negotiation passes to the host. The maximum value is 86400 seconds (one day). A value of 0 disables the feature. If you do not set a profile, the value of PxeTimeout is 0. If you set a profile without specifying a value for PxeTimeout, the firmware sets it to 120.
+}
+
+// Identifies the authentication protocol used to authenticate the access requestor to the AAA server.
+//
+// ValueMap={0, 1, 2, 3, 4, 5, 6}
+//
+// Values={TLS, TTLS_MSCHAPv2, PEAP_MSCHAPv2, EAP_GTC, EAPFAST_MSCHAPv2, EAPFAST_GTC, EAPFAST_TLS}
+type AuthenticationProtocol int
+
+// Determines the comparison algorithm used between the ServerCertificateName value and the subject name field of the certificate presented by the AAA server. This field is mandatory if ServerCertificateName is defined.
+//
+// ValueMap={0, 1}
+//
+// Values={FullName, DomainSuffix}
+type ServerCertificateNameComparison int
diff --git a/pkg/wsman/amt/kerberos/constants.go b/pkg/wsman/amt/kerberos/constants.go
new file mode 100644
index 00000000..92bcbe8d
--- /dev/null
+++ b/pkg/wsman/amt/kerberos/constants.go
@@ -0,0 +1,35 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package kerberos
+
+const (
+ AMT_KerberosSettingData string = "AMT_KerberosSettingData"
+ SetCredentialCacheState string = "SetCredentialCacheState"
+ GetCredentialCacheState string = "GetCredentialCacheState"
+)
+
+const (
+ ServicePrincipalProtocolHTTPProtocoldefinition ServicePrincipalProtocol = iota
+ ServicePrincipalProtocolHTTPSProtocoldefinition
+ ServicePrincipalProtocolSOLAndIDERprotocoldefinition
+ ServicePrincipalProtocolSOLAndIDERprotocoldefinitionUsingSSL
+)
+
+const (
+ EncryptionAlgorithmRC4EncryptionAndHMACAuthentication EncryptionAlgorithm = iota
+)
+
+const (
+ SupportedEncryptionAlgorithmsRC4HMAC SupportedEncryptionAlgorithms = iota
+ SupportedEncryptionAlgorithmsAES128CTSHMACSHA196
+ SupportedEncryptionAlgorithmsAES256CTSHMACSHA196
+)
+
+const (
+ ConfiguredEncryptionAlgorithmsRC4HMAC SupportedEncryptionAlgorithms = iota
+ ConfiguredEncryptionAlgorithmsAES128CTSHMACSHA196
+ ConfiguredEncryptionAlgorithmsAES256CTSHMACSHA196
+)
diff --git a/pkg/wsman/amt/kerberos/marshal.go b/pkg/wsman/amt/kerberos/marshal.go
new file mode 100644
index 00000000..8a0798eb
--- /dev/null
+++ b/pkg/wsman/amt/kerberos/marshal.go
@@ -0,0 +1,30 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package kerberos
+
+import (
+ "encoding/json"
+
+ "gopkg.in/yaml.v3"
+)
+
+// JSON marshals the type into JSON format
+func (r *Response) JSON() string {
+ jsonOutput, err := json.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(jsonOutput)
+}
+
+// YAML marshals the type into YAML format
+func (r *Response) YAML() string {
+ yamlOutput, err := yaml.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(yamlOutput)
+}
diff --git a/pkg/wsman/amt/kerberos/settingdata.go b/pkg/wsman/amt/kerberos/settingdata.go
new file mode 100644
index 00000000..f215ada0
--- /dev/null
+++ b/pkg/wsman/amt/kerberos/settingdata.go
@@ -0,0 +1,134 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+// Package kerberos facilitiates communication with Intel® AMT devices to access the configuration-related and operational parameters for the kerberos service in the Intel® AMT.
+package kerberos
+
+import (
+ "encoding/xml"
+ "fmt"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/methods"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+)
+
+// NewKerberosSettingDataWithClient instantiates a new kerberos SettingData
+func NewKerberosSettingDataWithClient(wsmanMessageCreator *message.WSManMessageCreator, client client.WSMan) SettingData {
+ return SettingData{
+ base: message.NewBaseWithClient(wsmanMessageCreator, AMT_KerberosSettingData, client),
+ }
+}
+
+// Get retrieves the representation of the instance
+func (settingData SettingData) Get() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: settingData.base.Get(nil),
+ },
+ }
+ // send the message to AMT
+ err = settingData.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Enumerate returns an enumeration context which is used in a subsequent Pull call
+func (settingData SettingData) Enumerate() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: settingData.base.Enumerate(),
+ },
+ }
+ // send the message to AMT
+ err = settingData.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Pull returns the instances of this class. An enumeration context provided by the Enumerate call is used as input.
+func (settingData SettingData) Pull(enumerationContext string) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: settingData.base.Pull(enumerationContext),
+ },
+ }
+ // send the message to AMT
+ err = settingData.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// GetCredentialCacheState gets the current state of the credential caching functionality
+func (settingData SettingData) GetCredentialCacheState() (response Response, err error) {
+ header := settingData.base.WSManMessageCreator.CreateHeader(methods.GenerateAction(AMT_KerberosSettingData, GetCredentialCacheState), AMT_KerberosSettingData, nil, "", "")
+ body := settingData.base.WSManMessageCreator.CreateBody(methods.GenerateInputMethod(GetCredentialCacheState), AMT_KerberosSettingData, nil)
+
+ response = Response{
+ Message: &client.Message{
+ XMLInput: settingData.base.WSManMessageCreator.CreateXML(header, body),
+ },
+ }
+ // send the message to AMT
+ err = settingData.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// SetCredentialCacheState enables/disables the credential caching functionality
+// TODO: Current gets SOAP schema violation from AMT
+func (settingData SettingData) SetCredentialCacheState(enabled bool) (response Response, err error) {
+ credentialCasheState := SetCredentialCacheState_INPUT{
+ H: fmt.Sprintf("%s%s", message.AMTSchema, AMT_KerberosSettingData),
+ Enabled: enabled,
+ }
+ header := settingData.base.WSManMessageCreator.CreateHeader(methods.GenerateAction(AMT_KerberosSettingData, SetCredentialCacheState), AMT_KerberosSettingData, nil, "", "")
+ body := settingData.base.WSManMessageCreator.CreateBody(methods.GenerateInputMethod(SetCredentialCacheState), AMT_KerberosSettingData, credentialCasheState)
+
+ response = Response{
+ Message: &client.Message{
+ XMLInput: settingData.base.WSManMessageCreator.CreateXML(header, body),
+ },
+ }
+ // send the message to AMT
+ err = settingData.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
diff --git a/pkg/wsman/amt/kerberos/settingdata_test.go b/pkg/wsman/amt/kerberos/settingdata_test.go
new file mode 100644
index 00000000..25b59803
--- /dev/null
+++ b/pkg/wsman/amt/kerberos/settingdata_test.go
@@ -0,0 +1,277 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package kerberos
+
+import (
+ "encoding/xml"
+ "fmt"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
+)
+
+func TestPositiveAMT_KerberosSettingData(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/kerberos",
+ }
+ elementUnderTest := NewKerberosSettingDataWithClient(wsmanMessageCreator, &client)
+
+ t.Run("amt_KerberosSettingData Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create a valid AMT_KerberosSettingData Get wsman message",
+ AMT_KerberosSettingData,
+ wsmantesting.GET,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Get"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GetResponse: KerberosSettingDataResponse{
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_KerberosSettingData), Local: AMT_KerberosSettingData},
+ ElementName: "Intel(r) AMT: Kerberos Settings",
+ InstanceID: "Intel (r) AMT: Kerberos Settings",
+ KrbEnabled: false,
+ SupportedEncryptionAlgorithms: []SupportedEncryptionAlgorithms{0, 1, 2},
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create a valid AMT_KerberosSettingData Enumerate wsman message",
+ AMT_KerberosSettingData,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Enumerate"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "61080000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid AMT_KerberosSettingData Pull wsman message",
+ AMT_KerberosSettingData,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Pull"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: message.XMLPullResponseSpace, Local: "PullResponse"},
+ KerberosSettingDataItems: []KerberosSettingDataResponse{
+ {
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_KerberosSettingData), Local: AMT_KerberosSettingData},
+ ElementName: "Intel(r) AMT: Kerberos Settings",
+ InstanceID: "Intel (r) AMT: Kerberos Settings",
+ KrbEnabled: false,
+ SupportedEncryptionAlgorithms: []SupportedEncryptionAlgorithms{0, 1, 2},
+ },
+ },
+ },
+ },
+ },
+ // GET CREDENTIAL CACHE STATE
+ {
+ "should return a valid amt_KerberosSettingData GetCredentialCacheState wsman message",
+ AMT_KerberosSettingData,
+ fmt.Sprintf("%s%s/%s", message.AMTSchema, AMT_KerberosSettingData, "GetCredentialCacheState"),
+ ``,
+ func() (Response, error) {
+ client.CurrentMessage = "GetCredentialCacheState"
+ return elementUnderTest.GetCredentialCacheState()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GetCredentialCacheState_OUTPUT: GetCredentialCacheState_OUTPUT{
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_KerberosSettingData), Local: "GetCredentialCacheState_OUTPUT"},
+ Enabled: false,
+ ReturnValue: 0,
+ },
+ },
+ },
+
+ // SET CREDENTIAL CACHE STATE
+ // {
+ // "should return a valid amt_KerberosSettingData SetCredentialCacheState wsman message",
+ // AMT_KerberosSettingData,
+ // fmt.Sprintf("%s%s/%s", message.AMTSchema, AMT_KerberosSettingData, "SetCredentialCacheState"),
+ // ``,
+ // func() (Response, error) {
+ // client.CurrentMessage = "SetCredentialCacheState"
+ // return elementUnderTest.SetCredentialCacheState(true)
+ // },
+ // Body{},
+ // },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.NoError(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.Equal(t, test.expectedResponse, response.Body)
+
+ })
+ }
+ })
+}
+func TestNegativeAMT_KerberosSettingData(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/kerberos",
+ }
+ elementUnderTest := NewKerberosSettingDataWithClient(wsmanMessageCreator, &client)
+
+ t.Run("amt_KerberosSettingData Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create a valid AMT_KerberosSettingData Get wsman message",
+ AMT_KerberosSettingData,
+ wsmantesting.GET,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GetResponse: KerberosSettingDataResponse{
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_KerberosSettingData), Local: AMT_KerberosSettingData},
+ ElementName: "Intel(r) AMT: Kerberos Settings",
+ InstanceID: "Intel (r) AMT: Kerberos Settings",
+ KrbEnabled: false,
+ SupportedEncryptionAlgorithms: []SupportedEncryptionAlgorithms{0, 1, 2},
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create a valid AMT_KerberosSettingData Enumerate wsman message",
+ AMT_KerberosSettingData,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "61080000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid AMT_KerberosSettingData Pull wsman message",
+ AMT_KerberosSettingData,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: message.XMLPullResponseSpace, Local: "PullResponse"},
+ KerberosSettingDataItems: []KerberosSettingDataResponse{
+ {
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_KerberosSettingData), Local: AMT_KerberosSettingData},
+ ElementName: "Intel(r) AMT: Kerberos Settings",
+ InstanceID: "Intel (r) AMT: Kerberos Settings",
+ KrbEnabled: false,
+ SupportedEncryptionAlgorithms: []SupportedEncryptionAlgorithms{0, 1, 2},
+ },
+ },
+ },
+ },
+ },
+ // GET CREDENTIAL CACHE STATE
+ {
+ "should return a valid amt_KerberosSettingData GetCredentialCacheState wsman message",
+ AMT_KerberosSettingData,
+ fmt.Sprintf("%s%s/%s", message.AMTSchema, AMT_KerberosSettingData, "GetCredentialCacheState"),
+ ``,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.GetCredentialCacheState()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GetCredentialCacheState_OUTPUT: GetCredentialCacheState_OUTPUT{
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_KerberosSettingData), Local: "GetCredentialCacheState_OUTPUT"},
+ Enabled: false,
+ ReturnValue: 0,
+ },
+ },
+ },
+
+ // SET CREDENTIAL CACHE STATE
+ // {
+ // "should return a valid amt_KerberosSettingData SetCredentialCacheState wsman message",
+ // AMT_KerberosSettingData,
+ // fmt.Sprintf("%s%s/%s", message.AMTSchema, AMT_KerberosSettingData, "SetCredentialCacheState"),
+ // ``,
+ // func() (Response, error) {
+ // client.CurrentMessage = "SetCredentialCacheState"
+ // return elementUnderTest.SetCredentialCacheState(true)
+ // },
+ // Body{},
+ // },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.Error(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.NotEqual(t, test.expectedResponse, response.Body)
+
+ })
+ }
+ })
+}
diff --git a/pkg/wsman/amt/kerberos/types.go b/pkg/wsman/amt/kerberos/types.go
new file mode 100644
index 00000000..72a5c1c9
--- /dev/null
+++ b/pkg/wsman/amt/kerberos/types.go
@@ -0,0 +1,103 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package kerberos
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+)
+
+type SettingData struct {
+ base message.Base
+}
+
+// OUTPUTS
+// Response Types
+type (
+ Response struct {
+ *client.Message
+ XMLName xml.Name `xml:"Envelope"`
+ Header message.Header `xml:"Header"`
+ Body Body `xml:"Body"`
+ }
+
+ Body struct {
+ XMLName xml.Name `xml:"Body"`
+ GetResponse KerberosSettingDataResponse
+ EnumerateResponse common.EnumerateResponse
+ PullResponse PullResponse
+ GetCredentialCacheState_OUTPUT GetCredentialCacheState_OUTPUT
+ }
+
+ PullResponse struct {
+ XMLName xml.Name `xml:"PullResponse"`
+ KerberosSettingDataItems []KerberosSettingDataResponse `xml:"Items>AMT_KerberosSettingData"`
+ }
+ KerberosSettingDataResponse struct {
+ XMLName xml.Name `xml:"AMT_KerberosSettingData"`
+ ElementName string `xml:"ElementName,omitempty"` // The user-friendly name for this instance of SettingData. In addition, the user-friendly name can be used as an index property for a search or query. (Note: The name does not have to be unique within a namespace.)
+ InstanceID string `xml:"InstanceID,omitempty"` // Within the scope of the instantiating Namespace, InstanceID opaquely and uniquely identifies an instance of this class. To ensure uniqueness within the NameSpace, the value of InstanceID should be constructed using the following "preferred" algorithm: : Where and are separated by a colon (:), and where must include a copyrighted, trademarked, or otherwise unique name that is owned by the business entity that is creating or defining the InstanceID or that is a registered ID assigned to the business entity by a recognized global authority. (This requirement is similar to the _ structure of Schema class names.) In addition, to ensure uniqueness, must not contain a colon (:). When using this algorithm, the first colon to appear in InstanceID must appear between and . is chosen by the business entity and should not be reused to identify different underlying (real-world) elements. If the above "preferred" algorithm is not used, the defining entity must assure that the resulting InstanceID is not reused across any InstanceIDs produced by this or other providers for the NameSpace of this instance. For DMTF-defined instances, the "preferred" algorithm must be used with the set to CIM.
+ RealmName string `xml:"RealmName,omitempty"` // Kerberos Realm name.
+ ServicePrincipalName []string `xml:"ServicePrincipalName,omitempty"` // An array of strings, each of which names a distinct service principal.
+ ServicePrincipalProtocol []ServicePrincipalProtocol `xml:"ServicePrincipalProtocol"` // An array of 16-bit enumeration values, each of which corresponds to the string in the same position of ServicePrincipalName.
+ KeyVersion int `xml:"KeyVersion,omitempty"` // Key version number. User can update the value each time the master key is changed.
+ EncryptionAlgorithm EncryptionAlgorithm `xml:"EncryptionAlgorithm,omitempty"` // A 16-bit enumeration value that identifiers the encryption algorithm used in Kerberos authentication.
+ MasterKey []int `xml:"MasterKey"` // A 128-bit binary key value. MasterKey cannot be used if the key generation method is used (using the Passphrase property)
+ MaximumClockTolerance int `xml:"MaximumClockTolerance,omitempty"` // The number of minutes by which the clocks of the Intel® AMT device and the client and KDC can be out of sync - typically 5 minutes.
+ KrbEnabled bool `xml:"KrbEnabled"` // Indicates whether Kerberos authentication is enabled or disable.
+ Passphrase string `xml:"Passphrase,omitempty"` // Used when the key generation method is chosen (RFC 3961,3962). Salt and IterationCount must be supplied also.
+ Salt string `xml:"Salt,omitempty"` // Used when the key generation method is chosen (RFC 3961,3962)
+ IterationCount int `xml:"IterationCount,omitempty"` // Can be used when the key generation method is chosen (RFC 3961,3962)
+ SupportedEncryptionAlgorithms []SupportedEncryptionAlgorithms `xml:"SupportedEncryptionAlgorithms"` // A 16-bit enumeration values that identifier the supported encryption algorithms used in Kerberos authentication.
+ ConfiguredEncryptionAlgorithms []ConfiguredEncryptionAlgorithms `xml:"ConfiguredEncryptionAlgorithms"` // A 16-bit enumeration values that identifier the configured encryption algorithms used in Kerberos authentication.
+ }
+ GetCredentialCacheState_OUTPUT struct {
+ XMLName xml.Name `xml:"GetCredentialCacheState_OUTPUT"`
+ Enabled bool `xml:"Enabled"`
+ ReturnValue int `xml:"ReturnValue"`
+ }
+)
+
+// INPUTS
+// Request Types
+type (
+ SetCredentialCacheState_INPUT struct {
+ XMLName xml.Name `xml:"h:SetCredentialCacheState_INPUT"`
+ H string `xml:"xmlns:h,attr"`
+ Enabled bool `xml:"h:Enabled"`
+ }
+)
+
+// An array of 16-bit enumeration values, each of which corresponds to the string in the same position of ServicePrincipalName. In Intel AMT Release 6.0 and later releases this field is not in use and has no impact
+//
+// ValueMap={0, 1, 2, 3}
+//
+// Values={HTTP Protocol definition, HTTPS Protocol definition, SOL&IDER protocol definition, SOL&IDER protocol definition (using SSL)}
+type ServicePrincipalProtocol int
+
+// A 16-bit enumeration values that identifier the supported encryption algorithms used in Kerberos authentication. Note: While RC4-HMAC is supported, Intel recommends using AES256-CTS-HMAC-SHA1-96.
+//
+// ValueMap={0, 1, 2, ..}
+//
+// Values={RC4-HMAC, AES128-CTS-HMAC-SHA1-96, AES256-CTS-HMAC-SHA1-96, Reserved}
+type SupportedEncryptionAlgorithms int
+
+// A 16-bit enumeration values that identifier the configured encryption algorithms used in Kerberos authentication. Note: While RC4-HMAC is supported, Intel recommends using AES256-CTS-HMAC-SHA1-96. Note: Intel AMT does not choose the encryption algorithm to configure based on the values specified by the user. Intel AMT attempts to enable RC4. If a Passphrase and Salt are provided, the AES suites are also configured.
+//
+// ValueMap={0, 1, 2, ..}
+//
+// Values={RC4-HMAC, AES128-CTS-HMAC-SHA1-96, AES256-CTS-HMAC-SHA1-96, Reserved}
+type ConfiguredEncryptionAlgorithms int
+
+// A 16-bit enumeration value that identifiers the encryption algorithm used in Kerberos authentication.
+//
+// ValueMap={0}
+//
+// Values={RC4 encryption and HMAC authentication}
+type EncryptionAlgorithm int
diff --git a/pkg/wsman/amt/managementpresence/constants.go b/pkg/wsman/amt/managementpresence/constants.go
new file mode 100644
index 00000000..38a5c4ba
--- /dev/null
+++ b/pkg/wsman/amt/managementpresence/constants.go
@@ -0,0 +1,38 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package managementpresence
+
+const (
+ AMT_ManagementPresenceRemoteSAP string = "AMT_ManagementPresenceRemoteSAP"
+)
+
+const (
+ InfoFormatOther InfoFormat = 1
+ InfoFormatHostName InfoFormat = 2
+ InfoFormatIPv4Address InfoFormat = 3
+ InfoFormatIPv6Address InfoFormat = 4
+ InfoFormatIPXAddress InfoFormat = 5
+ InfoFormatDECnetAddress InfoFormat = 6
+ InfoFormatSNAAddress InfoFormat = 7
+ InfoFormatAutonomousSystemNumber InfoFormat = 8
+ InfoFormatMPLSLabel InfoFormat = 9
+ InfoFormatIPv4SubnetAddress InfoFormat = 10
+ InfoFormatIPv6SubnetAddress InfoFormat = 11
+ InfoFormatIPv4AddressRange InfoFormat = 12
+ InfoFormatIPv6AddressRange InfoFormat = 13
+ InfoFormatDialString InfoFormat = 100
+ InfoFormatEthernetAddress InfoFormat = 101
+ InfoFormatTokenRingAddress InfoFormat = 102
+ InfoFormatATMAddress InfoFormat = 103
+ InfoFormatFrameRelayAddress InfoFormat = 104
+ InfoFormatURL InfoFormat = 200
+ InfoFormatFQDN InfoFormat = 201
+ InfoFormatUserFQDN InfoFormat = 202
+ InfoFormatDERASN1DN InfoFormat = 203
+ InfoFormatDERASN1GN InfoFormat = 204
+ InfoFormatKeyID InfoFormat = 205
+ InfoFormatParameterizedURL InfoFormat = 206
+)
diff --git a/pkg/wsman/amt/managementpresence/marshal.go b/pkg/wsman/amt/managementpresence/marshal.go
new file mode 100644
index 00000000..edb5196a
--- /dev/null
+++ b/pkg/wsman/amt/managementpresence/marshal.go
@@ -0,0 +1,30 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package managementpresence
+
+import (
+ "encoding/json"
+
+ "gopkg.in/yaml.v3"
+)
+
+// JSON marshals the type into JSON format
+func (r *Response) JSON() string {
+ jsonOutput, err := json.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(jsonOutput)
+}
+
+// YAML marshals the type into YAML format
+func (r *Response) YAML() string {
+ yamlOutput, err := yaml.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(yamlOutput)
+}
diff --git a/pkg/wsman/amt/managementpresence/remotesap.go b/pkg/wsman/amt/managementpresence/remotesap.go
new file mode 100644
index 00000000..fe4cecaa
--- /dev/null
+++ b/pkg/wsman/amt/managementpresence/remotesap.go
@@ -0,0 +1,102 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+// Package managementpresence facilitiates communication with Intel® AMT devices to configure Management Presence Remote Service Access Points (or an MPS) to be accessed by the Intel® AMT subsystem from remote.
+package managementpresence
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+)
+
+// NewManagementPresenceRemoteSAPWithClient instantiates a new RemoteSAP
+func NewManagementPresenceRemoteSAPWithClient(wsmanMessageCreator *message.WSManMessageCreator, client client.WSMan) RemoteSAP {
+ return RemoteSAP{
+ base: message.NewBaseWithClient(wsmanMessageCreator, AMT_ManagementPresenceRemoteSAP, client),
+ }
+}
+
+// Get retrieves the representation of the instance
+func (remoteSAP RemoteSAP) Get() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: remoteSAP.base.Get(nil),
+ },
+ }
+ // send the message to AMT
+ err = remoteSAP.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Enumerate returns an enumeration context which is used in a subsequent Pull call
+func (remoteSAP RemoteSAP) Enumerate() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: remoteSAP.base.Enumerate(),
+ },
+ }
+ // send the message to AMT
+ err = remoteSAP.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Pull returns the instances of this class. An enumeration context provided by the Enumerate call is used as input.
+func (remoteSAP RemoteSAP) Pull(enumerationContext string) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: remoteSAP.base.Pull(enumerationContext),
+ },
+ }
+ // send the message to AMT
+ err = remoteSAP.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Delete removes a the specified instance
+func (remoteSAP RemoteSAP) Delete(handle string) (response Response, err error) {
+ selector := message.Selector{Name: "Name", Value: handle}
+ response = Response{
+ Message: &client.Message{
+ XMLInput: remoteSAP.base.Delete(selector),
+ },
+ }
+ // send the message to AMT
+ err = remoteSAP.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
diff --git a/pkg/wsman/amt/managementpresence/remotesap_test.go b/pkg/wsman/amt/managementpresence/remotesap_test.go
new file mode 100644
index 00000000..caa05796
--- /dev/null
+++ b/pkg/wsman/amt/managementpresence/remotesap_test.go
@@ -0,0 +1,265 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package managementpresence
+
+import (
+ "encoding/xml"
+ "testing"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
+ "github.com/stretchr/testify/assert"
+)
+
+func TestPositiveAMT_ManagementPresenceRemoteSAP(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/managementpresence",
+ }
+ elementUnderTest := NewManagementPresenceRemoteSAPWithClient(wsmanMessageCreator, &client)
+ t.Run("amt_ManagementPresenceRemoteSAP Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ extraHeader string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create a valid AMT_ManagementPresenceRemoteSAP Get wsman message",
+ AMT_ManagementPresenceRemoteSAP,
+ wsmantesting.GET,
+ "",
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Get"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GetResponse: ManagementRemoteResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_ManagementPresenceRemoteSAP", Local: "AMT_ManagementPresenceRemoteSAP"},
+ AccessInfo: "192.168.0.208",
+ CN: "192.168.0.208",
+ CreationClassName: "AMT_ManagementPresenceRemoteSAP",
+ ElementName: "Intel(r) AMT:Management Presence Server",
+ InfoFormat: 3,
+ Name: "Intel(r) AMT:Management Presence Server 0",
+ Port: 4433,
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "Intel(r) AMT",
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create a valid AMT_ManagementPresenceRemoteSAP Enumerate wsman message",
+ AMT_ManagementPresenceRemoteSAP,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Enumerate"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "C9000000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid AMT_ManagementPresenceRemoteSAP Pull wsman message",
+ AMT_ManagementPresenceRemoteSAP,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Pull"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ ManagementRemoteItems: []ManagementRemoteResponse{
+ {
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_ManagementPresenceRemoteSAP", Local: "AMT_ManagementPresenceRemoteSAP"},
+ AccessInfo: "192.168.10.196",
+ CN: "192.168.10.196",
+ CreationClassName: "AMT_ManagementPresenceRemoteSAP",
+ ElementName: "Intel(r) AMT:Management Presence Server",
+ InfoFormat: 3,
+ Name: "Intel(r) AMT:Management Presence Server 0",
+ Port: 4433,
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "Intel(r) AMT",
+ },
+ },
+ },
+ },
+ },
+ //DELETE
+ {
+ "should create a valid AMT_ManagementPresenceRemoteSAP Delete wsman message",
+ AMT_ManagementPresenceRemoteSAP,
+ wsmantesting.DELETE,
+ "",
+ "instanceID123",
+ func() (Response, error) {
+ client.CurrentMessage = "Delete"
+ return elementUnderTest.Delete("instanceID123")
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, test.extraHeader, test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.NoError(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.Equal(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
+func TestNegativeAMT_ManagementPresenceRemoteSAP(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/managementpresence",
+ }
+ elementUnderTest := NewManagementPresenceRemoteSAPWithClient(wsmanMessageCreator, &client)
+ t.Run("amt_ManagementPresenceRemoteSAP Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ extraHeader string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create a valid AMT_ManagementPresenceRemoteSAP Get wsman message",
+ AMT_ManagementPresenceRemoteSAP,
+ wsmantesting.GET,
+ "",
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GetResponse: ManagementRemoteResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_ManagementPresenceRemoteSAP", Local: "AMT_ManagementPresenceRemoteSAP"},
+ AccessInfo: "192.168.0.208",
+ CN: "192.168.0.208",
+ CreationClassName: "AMT_ManagementPresenceRemoteSAP",
+ ElementName: "Intel(r) AMT:Management Presence Server",
+ InfoFormat: 3,
+ Name: "Intel(r) AMT:Management Presence Server 0",
+ Port: 4433,
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "Intel(r) AMT",
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create a valid AMT_ManagementPresenceRemoteSAP Enumerate wsman message",
+ AMT_ManagementPresenceRemoteSAP,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "C9000000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid AMT_ManagementPresenceRemoteSAP Pull wsman message",
+ AMT_ManagementPresenceRemoteSAP,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ ManagementRemoteItems: []ManagementRemoteResponse{
+ {
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_ManagementPresenceRemoteSAP", Local: "AMT_ManagementPresenceRemoteSAP"},
+ AccessInfo: "192.168.10.196",
+ CN: "192.168.10.196",
+ CreationClassName: "AMT_ManagementPresenceRemoteSAP",
+ ElementName: "Intel(r) AMT:Management Presence Server",
+ InfoFormat: 3,
+ Name: "Intel(r) AMT:Management Presence Server 0",
+ Port: 4433,
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "Intel(r) AMT",
+ },
+ },
+ },
+ },
+ },
+ //DELETE
+ {
+ "should create a valid AMT_ManagementPresenceRemoteSAP Delete wsman message",
+ AMT_ManagementPresenceRemoteSAP,
+ wsmantesting.DELETE,
+ "",
+ "instanceID123",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Delete("instanceID123")
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, test.extraHeader, test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.Error(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.NotEqual(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
diff --git a/pkg/wsman/amt/managementpresence/types.go b/pkg/wsman/amt/managementpresence/types.go
new file mode 100644
index 00000000..29d6f621
--- /dev/null
+++ b/pkg/wsman/amt/managementpresence/types.go
@@ -0,0 +1,63 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package managementpresence
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+)
+
+type RemoteSAP struct {
+ base message.Base
+}
+
+// OUTPUTS
+// Response Types
+type (
+ Response struct {
+ *client.Message
+ XMLName xml.Name `xml:"Envelope"`
+ Header message.Header `xml:"Header"`
+ Body Body `xml:"Body"`
+ }
+
+ Body struct {
+ XMLName xml.Name `xml:"Body"`
+ GetResponse ManagementRemoteResponse
+ EnumerateResponse common.EnumerateResponse
+ PullResponse PullResponse
+ }
+
+ PullResponse struct {
+ XMLName xml.Name `xml:"PullResponse"`
+ ManagementRemoteItems []ManagementRemoteResponse `xml:"Items>AMT_ManagementPresenceRemoteSAP"`
+ }
+
+ ManagementRemoteResponse struct {
+ XMLName xml.Name `xml:"AMT_ManagementPresenceRemoteSAP"`
+ AccessInfo string `xml:"AccessInfo,omitempty"` // Access or addressing information or a combination of this information for a remote connection. This information can be a host name, network address, or similar information.
+ CN string `xml:"CN,omitempty"` // A common name used when AccessInfo is an IP address.
+ CreationClassName string `xml:"CreationClassName,omitempty"` // CreationClassName indicates the name of the class or the subclass used in the creation of an instance. When used with the other key properties of this class, this property allows all instances of this class and its subclasses to be uniquely identified.
+ ElementName string `xml:"ElementName,omitempty"` // A user-friendly name for the object. This property allows each instance to define a user-friendly name in addition to its key properties, identity data, and description information. Note that the Name property of ManagedSystemElement is also defined as a user-friendly name. But, it is often subclassed to be a Key. It is not reasonable that the same property can convey both identity and a user-friendly name, without inconsistencies. Where Name exists and is not a Key (such as for instances of LogicalDevice), the same information can be present in both the Name and ElementName properties. Note that if there is an associated instance of CIM_EnabledLogicalElementCapabilities, restrictions on this properties may exist as defined in ElementNameMask and MaxElementNameLen properties defined in that class.
+ InfoFormat InfoFormat `xml:"InfoFormat,omitempty"` // An enumerated integer that describes the format and interpretation of the AccessInfo property.
+ Name string `xml:"Name,omitempty"` // The Name property uniquely identifies the ServiceAccessPoint and provides an indication of the functionality that is managed. This functionality is described in more detail in the Description property of the object.
+ Port int `xml:"Port,omitempty"` // The port to be used to establish a tunnel with the MPS.
+ SystemCreationClassName string `xml:"SystemCreationClassName,omitempty"` // The CreationClassName of the scoping System.
+ SystemName string `xml:"SystemName,omitempty"` // The Name of the scoping System.
+ }
+
+ // An enumerated integer that describes the format and interpretation of the AccessInfo property. 206'Parameterized URL'- a URL containing ${parameterName} strings. Those strings are intended to be replaced in their entirety by the value of the named parameter. The interpretation of such parameters is not defined by this subclass. As an example use: If a parameter named 'CompanyURL' has a value of 'www.DMTF.org' and the value of AccessInfo was 'http:\${CompanyURL}', then the resultant URL is intended to be 'http:\www.dmtf.org'.
+ //
+ // The supported values are 3 (IPv4 address), 4 (IPv6 address) ,201 (FQDN).
+ //
+ // ValueMap={1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 100, 101, 102, 103, 104, 200, 201, 202, 203, 204, 205, 206, .., 32768..65535}
+ //
+ // Values={Other, Host Name, IPv4 Address, IPv6 Address, IPX Address, DECnet Address, SNA Address, Autonomous System Number, MPLS Label, IPv4 Subnet Address, IPv6 Subnet Address, IPv4 Address Range, IPv6 Address Range, Dial String, Ethernet Address, Token Ring Address, ATM Address, Frame Relay Address, URL, FQDN, User FQDN, DER ASN1 DN, DER ASN1 GN, Key ID, Parameterized URL, DMTF Reserved, Vendor Reserved}
+ InfoFormat int
+)
diff --git a/pkg/wsman/amt/messagelog/constants.go b/pkg/wsman/amt/messagelog/constants.go
new file mode 100644
index 00000000..44fdbd3a
--- /dev/null
+++ b/pkg/wsman/amt/messagelog/constants.go
@@ -0,0 +1,138 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package messagelog
+
+const (
+ AMT_MessageLog string = "AMT_MessageLog"
+ GetRecords string = "GetRecords"
+ PositionToFirstRecord string = "PositionToFirstRecord"
+)
+
+const (
+ CharacterSetUnknown CharacterSet = iota
+ CharacterSetOther
+ CharacterSetASCII
+ CharacterSetUnicode
+ CharacterSetISO2022
+ CharacterSetISO8859
+ CharacterSetExtendedUNIXCode
+ CharacterSetUTF8
+ CharacterSetUCS2
+ CharacterSetBitmappedData
+ CharacterSetOctetString
+ CharacterSetDefinedbyIndividualRecords
+)
+
+const (
+ LastChangeUnknown LastChange = iota
+ LastChangeAdd
+ LastChangeDelete
+ LastChangeModify
+ LastChangeLogCleared
+)
+
+const (
+ OverwritePolicyUnknown OverwritePolicy = iota
+ OverwritePolicyOther
+ OverwritePolicyWrapsWhenFull
+ OverwritePolicyClearWhenNearFull
+ OverwritePolicyOverwriteOutdatedWhenNeeded
+ OverwritePolicyRemoveOutdatedRecords
+ OverwritePolicyOverwriteSpecificRecords
+ OverwritePolicyNeverOverwrite
+)
+
+const (
+ CapabilitiesUnknown Capabilities = iota
+ CapabilitiesOther
+ CapabilitiesWriteRecordSupported
+ CapabilitiesDeleteRecordSupported
+ CapabilitiesCanMoveBackwardinLog
+ CapabilitiesFreezeLogSupported
+ CapabilitiesClearLogSupported
+ CapabilitiesSupportsAddressingbyOrdinalRecordNumber
+ CapabilitiesVariableLengthRecordsSupported
+ CapabilitiesVariableFormatsforRecords
+ CapabilitiesCanFlagRecordsforOverwrite
+)
+
+const (
+ LogStateUnknown LogState = 0
+ LogStateNormal LogState = 2
+ LogStateErasing LogState = 3
+ LogStateNotApplicable LogState = 4
+)
+
+const (
+ EnabledDefaultEnabled EnabledDefault = 2
+ EnabledDefaultDisabled EnabledDefault = 3
+ EnabledDefaultNotApplicable EnabledDefault = 5
+ EnabledDefaultEnabledbutOffline EnabledDefault = 6
+ EnabledDefaultNoDefault EnabledDefault = 7
+ EnabledDefaultQuiesce EnabledDefault = 9
+)
+
+const (
+ EnabledStateUnknown EnabledState = iota
+ EnabledStateOther
+ EnabledStateEnabled
+ EnabledStateDisabled
+ EnabledStateShuttingDown
+ EnabledStateNotApplicable
+ EnabledStateEnabledbutOffline
+ EnabledStateInTest
+ EnabledStateDeferred
+ EnabledStateQuiesce
+ EnabledStateStarting
+)
+
+const (
+ HealthStateUnknown HealthState = 0
+ HealthStateOK HealthState = 5
+ HealthStateDegradedWarning HealthState = 10
+ HealthStateMinorFailure HealthState = 15
+ HealthStateMajorFailure HealthState = 20
+ HealthStateCriticalFailure HealthState = 25
+ HealthStateNonRecoverableError HealthState = 30
+)
+
+const (
+ OperationalStatusUnknown OperationalStatus = iota
+ OperationalStatusOther
+ OperationalStatusOK
+ OperationalStatusDegraded
+ OperationalStatusStressed
+ OperationalStatusPredictiveFailure
+ OperationalStatusError
+ OperationalStatusNonRecoverableError
+ OperationalStatusStarting
+ OperationalStatusStopping
+ OperationalStatusStopped
+ OperationalStatusInService
+ OperationalStatusNoContact
+ OperationalStatusLostCommunication
+ OperationalStatusAborted
+ OperationalStatusDormant
+ OperationalStatusSupportingEntityinError
+ OperationalStatusCompleted
+ OperationalStatusPowerMode
+ OperationalStatusRelocating
+)
+
+const (
+ RequestedStateEnabled RequestedState = iota + 2
+ RequestedStateDisabled
+ RequestedStateShutDown
+ RequestedStateNoChange
+ RequestedStateOffline
+ RequestedStateTest
+ RequestedStateDeferred
+ RequestedStateQuiesce
+ RequestedStateReboot
+ RequestedStateReset
+ RequestedStateNotApplicable
+ RequestedStateUnknown RequestedState = 0
+)
diff --git a/pkg/wsman/amt/messagelog/log.go b/pkg/wsman/amt/messagelog/log.go
new file mode 100644
index 00000000..324148e3
--- /dev/null
+++ b/pkg/wsman/amt/messagelog/log.go
@@ -0,0 +1,156 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+// Package messagelog facilitiates communication with Intel® AMT devices to provide access to the AMT event log.
+// Client should read the record time parameter in order to determine which record is newer.
+// In most implementations, log entries are stored backwards, i.e. the newest record is the first record and the oldest record is the last (index based).
+//
+// Records have no header and the record data is combined of 21 binary bytes which could be read as:
+//
+// struct {
+// UINT32 TimeStamp; // little endian
+// UINT8 DeviceAddress;
+// UINT8 EventSensorType;
+// UINT8 EventType;
+// UINT8 EventOffset;
+// UINT8 EventSourceType;
+// UINT8 EventSeverity;
+// UINT8 SensorNumber;
+// UINT8 Entity;
+// UINT8 EntityInstance;
+// UINT8 EventData[8];
+// } EVENT_DATA;
+package messagelog
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/methods"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+)
+
+// NewMessageLogWithClient instantiates a new MessageLog
+func NewMessageLogWithClient(wsmanMessageCreator *message.WSManMessageCreator, client client.WSMan) MessageLog {
+ return MessageLog{
+ base: message.NewBaseWithClient(wsmanMessageCreator, AMT_MessageLog, client),
+ }
+}
+
+// Get retrieves the representation of the instance
+func (messageLog MessageLog) Get() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: messageLog.base.Get(nil),
+ },
+ }
+ // send the message to AMT
+ err = messageLog.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Enumerate returns an enumeration context which is used in a subsequent Pull call
+func (messageLog MessageLog) Enumerate() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: messageLog.base.Enumerate(),
+ },
+ }
+ // send the message to AMT
+ err = messageLog.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Pull returns the instances of this class. An enumeration context provided by the Enumerate call is used as input.
+func (messageLog MessageLog) Pull(enumerationContext string) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: messageLog.base.Pull(enumerationContext),
+ },
+ }
+ // send the message to AMT
+ err = messageLog.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// GetRecords retrieves multiple records from event log.
+// The IterationIdentifier input parameter is a numeric value (starting at 1) which is the position of the first record in the log that should be extracted.
+// MaxReadRecords is set to 390. If NoMoreRecords returns false, call this again setting the identifier to the start of the next IterationIdentifier
+func (messageLog MessageLog) GetRecords(identifier int) (response Response, err error) {
+ if identifier < 1 {
+ identifier = 1
+ }
+
+ header := messageLog.base.WSManMessageCreator.CreateHeader(methods.GenerateAction(AMT_MessageLog, GetRecords), AMT_MessageLog, nil, "", "")
+ body := messageLog.base.WSManMessageCreator.CreateBody(methods.GenerateInputMethod(GetRecords), AMT_MessageLog, &GetRecords_INPUT{
+ IterationIdentifier: identifier,
+ MaxReadRecords: 390,
+ })
+
+ response = Response{
+ Message: &client.Message{
+ XMLInput: messageLog.base.WSManMessageCreator.CreateXML(header, body),
+ },
+ }
+ // send the message to AMT
+ err = messageLog.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Requests that an iteration of the MessageLog be established and that the iterator be set to the first entry in the Log. An identifier for the iterator is returned as an output parameter of the method. Regarding iteration, you have 2 choices: 1) Embed iteration data in the method call, and allow implementations to track/ store this data manually; or, 2) Iterate using a separate object (for example, class ActiveIterator) as an iteration agent. The first approach is used here for interoperability. The second requires an instance of the Iterator object for EACH iteration in progress. 2's functionality could be implemented underneath 1.
+//
+// Product Specific Usage: In current implementation this method doesn't have any affect. In order to get the events from the log user should just call GetRecord or GetRecords.
+func (messageLog MessageLog) PositionToFirstRecord() (response Response, err error) {
+ header := messageLog.base.WSManMessageCreator.CreateHeader(methods.GenerateAction(AMT_MessageLog, PositionToFirstRecord), AMT_MessageLog, nil, "", "")
+ body := messageLog.base.WSManMessageCreator.CreateBody(methods.GenerateInputMethod(PositionToFirstRecord), AMT_MessageLog, nil)
+ response = Response{
+ Message: &client.Message{
+ XMLInput: messageLog.base.WSManMessageCreator.CreateXML(header, body),
+ },
+ }
+ // send the message to AMT
+ err = messageLog.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
diff --git a/pkg/wsman/amt/messagelog/log_test.go b/pkg/wsman/amt/messagelog/log_test.go
new file mode 100644
index 00000000..f0188641
--- /dev/null
+++ b/pkg/wsman/amt/messagelog/log_test.go
@@ -0,0 +1,360 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package messagelog
+
+import (
+ "encoding/xml"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
+)
+
+func TestPositiveAMT_MessageLog(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/messagelog",
+ }
+ elementUnderTest := NewMessageLogWithClient(wsmanMessageCreator, &client)
+
+ t.Run("amt_MessageLog Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create a valid AMT_MessageLog Get wsman message",
+ AMT_MessageLog, wsmantesting.GET,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Get"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GetResponse: MessageLogResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_MessageLog", Local: "AMT_MessageLog"},
+ Capabilities: []Capabilities{5, 6, 8, 7},
+ CharacterSet: 10,
+ CreationClassName: "AMT_MessageLog",
+ CurrentNumberOfRecords: 390,
+ ElementName: "Intel(r) AMT:MessageLog 1",
+ EnabledDefault: 2,
+ EnabledState: 2,
+ HealthState: 5,
+ IsFrozen: false,
+ LastChange: 0,
+ LogState: 4,
+ MaxLogSize: 0,
+ MaxNumberOfRecords: 390,
+ MaxRecordSize: 21,
+ Name: "Intel(r) AMT:MessageLog 1",
+ OperationalStatus: []OperationalStatus{2},
+ OverwritePolicy: 2,
+ PercentageNearFull: 100,
+ RequestedState: 12,
+ SizeOfHeader: 0,
+ SizeOfRecordHeader: 0,
+ Status: "OK",
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create a valid AMT_MessageLog Enumerate wsman message",
+ AMT_MessageLog,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Enumerate"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "16080000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid AMT_MessageLog Pull wsman message",
+ AMT_MessageLog,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Pull"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ MessageLogItems: []MessageLogResponse{
+ {
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_MessageLog", Local: "AMT_MessageLog"},
+ Capabilities: []Capabilities{5, 6, 8, 7},
+ CharacterSet: 10,
+ CreationClassName: "AMT_MessageLog",
+ CurrentNumberOfRecords: 390,
+ ElementName: "Intel(r) AMT:MessageLog 1",
+ EnabledDefault: 2,
+ EnabledState: 2,
+ HealthState: 5,
+ IsFrozen: false,
+ LastChange: 0,
+ LogState: 4,
+ MaxLogSize: 0,
+ MaxNumberOfRecords: 390,
+ MaxRecordSize: 21,
+ Name: "Intel(r) AMT:MessageLog 1",
+ OperationalStatus: []OperationalStatus{2},
+ OverwritePolicy: 2,
+ PercentageNearFull: 100,
+ RequestedState: 12,
+ SizeOfHeader: 0,
+ SizeOfRecordHeader: 0,
+ Status: "OK",
+ },
+ },
+ },
+ },
+ },
+ // POSITION TO FIRST RECORD
+ {
+ "should return a valid amt_MessageLog PositionToFirstRecords wsman message",
+ AMT_MessageLog,
+ `http://intel.com/wbem/wscim/1/amt-schema/1/AMT_MessageLog/PositionToFirstRecord`,
+ ``,
+ func() (Response, error) {
+ client.CurrentMessage = "PositionToFirstRecord"
+ return elementUnderTest.PositionToFirstRecord()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PositionToFirstRecordResponse: PositionToFirstRecordResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_MessageLog", Local: "PositionToFirstRecord_OUTPUT"},
+ IterationIdentifier: 1,
+ ReturnValue: 0,
+ },
+ },
+ },
+ // GET RECORDS
+ {
+ "should return a valid amt_MessageLog GetRecords wsman message",
+ AMT_MessageLog,
+ `http://intel.com/wbem/wscim/1/amt-schema/1/AMT_MessageLog/GetRecords`,
+ `1390`,
+ func() (Response, error) {
+ client.CurrentMessage = "GetRecords"
+ return elementUnderTest.GetRecords(1)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GetRecordsResponse: GetRecordsResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_MessageLog", Local: "GetRecords_OUTPUT"},
+ IterationIdentifier: 3,
+ NoMoreRecords: true,
+ RecordArray: []string{"Y8iYZf8GbwVoEP8mYaoKAAAAAAAA", "IgYBZf8PbwJoAf8iAEAHAAAAAAAA", "IgYBZf8PbwJoAf8iAEAHAAAAAAAA"},
+ ReturnValue: 0,
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.NoError(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.Equal(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
+func TestNegativeAMT_MessageLog(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/messagelog",
+ }
+ elementUnderTest := NewMessageLogWithClient(wsmanMessageCreator, &client)
+
+ t.Run("amt_MessageLog Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create a valid AMT_MessageLog Get wsman message",
+ AMT_MessageLog, wsmantesting.GET,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GetResponse: MessageLogResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_MessageLog", Local: "AMT_MessageLog"},
+ Capabilities: []Capabilities{5, 6, 8, 7},
+ CharacterSet: 10,
+ CreationClassName: "AMT_MessageLog",
+ CurrentNumberOfRecords: 390,
+ ElementName: "Intel(r) AMT:MessageLog 1",
+ EnabledDefault: 2,
+ EnabledState: 2,
+ HealthState: 5,
+ IsFrozen: false,
+ LastChange: 0,
+ LogState: 4,
+ MaxLogSize: 0,
+ MaxNumberOfRecords: 390,
+ MaxRecordSize: 21,
+ Name: "Intel(r) AMT:MessageLog 1",
+ OperationalStatus: []OperationalStatus{2},
+ OverwritePolicy: 2,
+ PercentageNearFull: 100,
+ RequestedState: 12,
+ SizeOfHeader: 0,
+ SizeOfRecordHeader: 0,
+ Status: "OK",
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create a valid AMT_MessageLog Enumerate wsman message",
+ AMT_MessageLog,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "16080000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid AMT_MessageLog Pull wsman message",
+ AMT_MessageLog,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ MessageLogItems: []MessageLogResponse{
+ {
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_MessageLog", Local: "AMT_MessageLog"},
+ Capabilities: []Capabilities{5, 6, 8, 7},
+ CharacterSet: 10,
+ CreationClassName: "AMT_MessageLog",
+ CurrentNumberOfRecords: 390,
+ ElementName: "Intel(r) AMT:MessageLog 1",
+ EnabledDefault: 2,
+ EnabledState: 2,
+ HealthState: 5,
+ IsFrozen: false,
+ LastChange: 0,
+ LogState: 4,
+ MaxLogSize: 0,
+ MaxNumberOfRecords: 390,
+ MaxRecordSize: 21,
+ Name: "Intel(r) AMT:MessageLog 1",
+ OperationalStatus: []OperationalStatus{2},
+ OverwritePolicy: 2,
+ PercentageNearFull: 100,
+ RequestedState: 12,
+ SizeOfHeader: 0,
+ SizeOfRecordHeader: 0,
+ Status: "OK",
+ },
+ },
+ },
+ },
+ },
+ // POSITION TO FIRST RECORD
+ {
+ "should return a valid amt_MessageLog PositionToFirstRecords wsman message",
+ AMT_MessageLog,
+ `http://intel.com/wbem/wscim/1/amt-schema/1/AMT_MessageLog/PositionToFirstRecord`,
+ ``,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.PositionToFirstRecord()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PositionToFirstRecordResponse: PositionToFirstRecordResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_MessageLog", Local: "PositionToFirstRecord_OUTPUT"},
+ IterationIdentifier: 1,
+ ReturnValue: 0,
+ },
+ },
+ },
+ // GET RECORDS
+ {
+ "should return a valid amt_MessageLog GetRecords wsman message",
+ AMT_MessageLog,
+ `http://intel.com/wbem/wscim/1/amt-schema/1/AMT_MessageLog/GetRecords`,
+ `1390`,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.GetRecords(1)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GetRecordsResponse: GetRecordsResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_MessageLog", Local: "GetRecords_OUTPUT"},
+ IterationIdentifier: 3,
+ NoMoreRecords: true,
+ RecordArray: []string{"Y8iYZf8GbwVoEP8mYaoKAAAAAAAA", "IgYBZf8PbwJoAf8iAEAHAAAAAAAA", "IgYBZf8PbwJoAf8iAEAHAAAAAAAA"},
+ ReturnValue: 0,
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.Error(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.NotEqual(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
diff --git a/pkg/wsman/amt/messagelog/marshal.go b/pkg/wsman/amt/messagelog/marshal.go
new file mode 100644
index 00000000..587e4920
--- /dev/null
+++ b/pkg/wsman/amt/messagelog/marshal.go
@@ -0,0 +1,30 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package messagelog
+
+import (
+ "encoding/json"
+
+ "gopkg.in/yaml.v3"
+)
+
+// JSON marshals the type into JSON format
+func (r *Response) JSON() string {
+ jsonOutput, err := json.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(jsonOutput)
+}
+
+// YAML marshals the type into YAML format
+func (r *Response) YAML() string {
+ yamlOutput, err := yaml.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(yamlOutput)
+}
diff --git a/pkg/wsman/amt/messagelog/types.go b/pkg/wsman/amt/messagelog/types.go
new file mode 100644
index 00000000..e0dac4a8
--- /dev/null
+++ b/pkg/wsman/amt/messagelog/types.go
@@ -0,0 +1,247 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package messagelog
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+)
+
+type MessageLog struct {
+ base message.Base
+}
+
+// OUTPUTS
+// Response Types
+type (
+ Response struct {
+ *client.Message
+ XMLName xml.Name `xml:"Envelope"`
+ Header message.Header `xml:"Header"`
+ Body Body `xml:"Body"`
+ }
+
+ Body struct {
+ XMLName xml.Name `xml:"Body"`
+ GetResponse MessageLogResponse
+ EnumerateResponse common.EnumerateResponse
+ PullResponse PullResponse
+ GetRecordsResponse GetRecordsResponse
+ PositionToFirstRecordResponse PositionToFirstRecordResponse
+ }
+
+ PullResponse struct {
+ XMLName xml.Name `xml:"PullResponse"`
+ MessageLogItems []MessageLogResponse `xml:"Items>AMT_MessageLog"`
+ }
+
+ MessageLogResponse struct {
+ XMLName xml.Name `xml:"AMT_MessageLog"`
+ Capabilities []Capabilities `xml:"Capabilities"` // An array of integers indicating the Log capabilities. Information such as "Write Record Supported" (value= 2) or "Variable Length Records Supported" (8) is specified in this property.
+ CharacterSet CharacterSet `xml:"CharacterSet"` // An enumeration describing the character set used to record data in the individual Log entries. For example, the Log records may contain ASCII data (value=2), or be raw octet strings (value=10).
+ CreationClassName string `xml:"CreationClassName"` // CreationClassName indicates the name of the class or the subclass used in the creation of an instance. When used with the other key properties of this class, this property allows all instances of this class and its subclasses to be uniquely identified.
+ CurrentNumberOfRecords int `xml:"CurrentNumberOfRecords"` // Current number of records in the Log.
+ ElementName string `xml:"ElementName"` // A user-friendly name for the object. This property allows each instance to define a user-friendly name in addition to its key properties, identity data, and description information. Note that the Name property of ManagedSystemElement is also defined as a user-friendly name. But, it is often subclassed to be a Key. It is not reasonable that the same property can convey both identity and a user-friendly name, without inconsistencies. Where Name exists and is not a Key (such as for instances of LogicalDevice), the same information can be present in both the Name and ElementName properties. Note that if there is an associated instance of CIM_EnabledLogicalElementCapabilities, restrictions on this properties may exist as defined in ElementNameMask and MaxElementNameLen properties defined in that class.
+ EnabledDefault EnabledDefault `xml:"EnabledDefault"` // An enumerated value indicating an administrator's default or startup configuration for the Enabled State of an element. By default, the element is "Enabled" (value=2).
+ EnabledState EnabledState `xml:"EnabledState"` // EnabledState is an integer enumeration that indicates the enabled and disabled states of an element.
+ HealthState HealthState `xml:"HealthState"` // Indicates the current health of the element.
+ IsFrozen bool `xml:"IsFrozen"` // Boolean indicating that the Log is currently frozen and modifications are not allowed.
+ LastChange LastChange `xml:"LastChange"` // An enumeration describing the last change to the MessageLog.
+ LogState LogState `xml:"LogState"` // LogState is an integer enumeration that indicates the current state of a log represented by CIM_Log subclasses.
+ MaxLogSize int `xml:"MaxLogSize"` // The maximum size, in bytes, to which the Log can grow. If there is no maximum, then MaxLogSize should be set to 0.
+ MaxNumberOfRecords int `xml:"MaxNumberOfRecords"` // Maximum number of records that can be captured in the Log. If undefined, a value of zero should be specified.
+ MaxRecordSize int `xml:"MaxRecordSize"` // Maximum size, in bytes, to which an individual Log entry (record) can grow - if the Capabilities array includes a value of 7 ("Variable Length Records Supported"). If the Capabilities array does not include a 7, then the Log only supports fixed length entries. The size of these entries is described by this property.
+ Name string `xml:"Name"` // The inherited Name serves as part of the key (a unique identifier) for the MessageLog instance.
+ OperationalStatus []OperationalStatus `xml:"OperationalStatus"` // Indicates the current statuses of the element.
+ OverwritePolicy OverwritePolicy `xml:"OverwritePolicy"` // An enumeration describing the behavior of the Log, when it becomes full or near full.
+ PercentageNearFull int `xml:"PercentageNearFull"` // If the OverwritePolicy is based on clearing records when the Log is near full (value=3), this property defines the record capacity (in percentage) that is considered to be 'near full'.
+ RequestedState RequestedState `xml:"RequestedState"` // RequestedState is an integer enumeration that indicates the last requested or desired state for the element, irrespective of the mechanism through which it was requested.
+ SizeOfHeader int `xml:"SizeOfHeader"` // The size of the Log header, in bytes, if one is present. If there is no Log header, then this property should be set to 0. Headers may include general information about the Log such as the current number of records, time of last update, or a pointer to the location of the first Log entry. Note that this property is NOT the size of the header for an individual Log entry. The latter is described by the property, SizeOfRecordHeader.
+ SizeOfRecordHeader int `xml:"SizeOfRecordHeader"` // The size of the header for the Log's individual entries, in bytes, if record headers are defined. If there are no record headers, then this property should be set to 0. Record headers may include information such as the type of the Log entry, the date/time that the entry was last updated, or a pointer to the start of optional data. Note that this property defines the header size for individual records in the Log, while the SizeOfHeader property describes the Log's overall header, typically located at the start of the MessageLog.
+ Status string `xml:"Status"` // A string indicating the current status of the object. This property is deprecated in lieu of OperationalStatus, which includes the same semantics in its enumeration.
+ }
+
+ // An array of integers indicating the Log capabilities. Information such as "Write Record Supported" (value= 2) or "Variable Length Records Supported" (8) is specified in this property.
+ //
+ // ValueMap={0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
+ //
+ // Values={Unknown, Other, Write Record Supported, Delete Record Supported, Can Move Backward in Log, Freeze Log Supported, Clear Log Supported, Supports Addressing by Ordinal Record Number, Variable Length Records Supported, Variable Formats for Records, Can Flag Records for Overwrite}
+ Capabilities int
+
+ // An enumeration describing the character set used to record data in the individual Log entries. For example, the Log records may contain ASCII data (value=2), or be raw octet strings (value=10).
+ //
+ // ValueMap={0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}
+ //
+ // Values={Unknown, Other, ASCII, Unicode, ISO2022, ISO8859, Extended UNIX Code, UTF-8, UCS-2, Bitmapped Data, OctetString, Defined by Individual Records}
+ CharacterSet int
+
+ // An enumeration describing the last change to the MessageLog.
+ //
+ // ValueMap={0, 1, 2, 3, 4}
+ //
+ // Values={Unknown, Add, Delete, Modify, Log Cleared}
+ LastChange int
+
+ // LogState is an integer enumeration that indicates the current state of a log represented by CIM_Log subclasses. LogState is to be used in conjunction with the EnabledState property to fully describe the current state of the log.
+ //
+ // The following text briefly summarizes the various log states:
+ //
+ // - Unknown (0) indicates the state of the log is unknown.
+ //
+ // - Normal (2) indicates that the log is or could be executing logging commands, will process any queued log entries, and will queue new logging requests.
+ //
+ // - Erasing (3) indicates that the log is being erased.
+ //
+ // - Not Applicable (4) indicates the log does not support representing a log state.
+ //
+ // ValueMap={0, 2, 3, 4, .., 32768..65535}
+ //
+ // Values={Unknown, Normal, Erasing, Not Applicable, DMTF Reserved, Vendor Reserved}
+ LogState int
+
+ // An enumeration describing the behavior of the Log, when it becomes full or near full. For example, the Log may wrap (value=2) or may simply stop recording entries (value =7).
+ //
+ // Some of the property's possible values need further explanation:
+ //
+ // - 3="Clear When Near Full" indicates that all of the Log's entries will be deleted when a specified record capacity is reached. The capacity is specified in percentage, using the property, PercentageNearFull. 'Near Full' may be less than 100% if the Log takes time to clear, and a position should always be available for new records.
+ //
+ // - 4="Overwrite Outdated When Needed" describes that Log entries (timestamped later than the date/time specified in the property, TimeWhenOutdated) can be overwritten.
+ //
+ // - 5="Remove Outdated Records" specifies that records (timestamped later than the date/time specified in the property, TimeWhenOutdated) are logically and/or physically removed from the Log.
+ //
+ // - 6="Overwrite Specific Records" indicates that specially flagged records may be overwritten. This property only makes sense when the Capabilities array includes a value of 10, "Can Flag Records for Overwrite".
+ //
+ // ValueMap={0, 1, 2, 3, 4, 5, 6, 7}
+ //
+ // Values={Unknown, Other, Wraps When Full, Clear When Near Full, Overwrite Outdated When Needed, Remove Outdated Records, Overwrite Specific Records, Never Overwrite}
+ OverwritePolicy int
+
+ // An enumerated value indicating an administrator's default or startup configuration for the Enabled State of an element. By default, the element is "Enabled" (value=2).
+ //
+ // ValueMap={2, 3, 5, 6, 7, 9, .., 32768..65535}
+ //
+ // Values={Enabled, Disabled, Not Applicable, Enabled but Offline, No Default, Quiesce, DMTF Reserved, Vendor Reserved}
+ EnabledDefault int
+
+ // EnabledState is an integer enumeration that indicates the enabled and disabled states of an element. It can also indicate the transitions between these requested states. For example, shutting down (value=4) and starting (value=10) are transient states between enabled and disabled.
+ //
+ // The following text briefly summarizes the various enabled and disabled states:
+ //
+ // - Enabled (2) indicates that the element is or could be executing commands, will process any queued commands, and queues new requests.
+ //
+ // - Disabled (3) indicates that the element will not execute commands and will drop any new requests.
+ //
+ // - Shutting Down (4) indicates that the element is in the process of going to a Disabled state.
+ //
+ // - Not Applicable (5) indicates the element does not support being enabled or disabled.
+ //
+ // - Enabled but Offline (6) indicates that the element might be completing commands, and will drop any new requests.
+ //
+ // - Test (7) indicates that the element is in a test state.
+ //
+ // - Deferred (8) indicates that the element might be completing commands, but will queue any new requests.
+ //
+ // - Quiesce (9) indicates that the element is enabled but in a restricted mode.
+ //
+ // - Starting (10) indicates that the element is in the process of going to an Enabled state. New requests are queued.
+ //
+ // ValueMap={0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11..32767, 32768..65535}
+ //
+ // Values={Unknown, Other, Enabled, Disabled, Shutting Down, Not Applicable, Enabled but Offline, In Test, Deferred, Quiesce, Starting, DMTF Reserved, Vendor Reserved}
+ EnabledState int
+
+ // Indicates the current health of the element. This attribute expresses the health of this element but not necessarily that of its subcomponents. The possible values are 0 to 30, where 5 means the element is entirely healthy and 30 means the element is completely non-functional.
+ //
+ // The following continuum is defined:
+ //
+ // - "Non-recoverable Error" (30) - The element has completely failed, and recovery is not possible. All functionality provided by this element has been lost.
+ //
+ // - "Critical Failure" (25) - The element is non-functional and recovery might not be possible.
+ //
+ // - "Major Failure" (20) - The element is failing. It is possible that some or all of the functionality of this component is degraded or not working.
+ //
+ // - "Minor Failure" (15) - All functionality is available but some might be degraded.
+ //
+ // - "Degraded/Warning" (10) - The element is in working order and all functionality is provided. However, the element is not working to the best of its abilities. For example, the element might not be operating at optimal performance or it might be reporting recoverable errors.
+ //
+ // - "OK" (5) - The element is fully functional and is operating within normal operational parameters and without error.
+ //
+ // - "Unknown" (0) - The implementation cannot report on HealthState at this time.
+ //
+ // DMTF has reserved the unused portion of the continuum for additional HealthStates in the future.
+ //
+ // ValueMap={0, 5, 10, 15, 20, 25, 30, .., 32768..65535}
+ //
+ // Values={Unknown, OK, Degraded/Warning, Minor failure, Major failure, Critical failure, Non-recoverable error, DMTF Reserved, Vendor Specific}
+ HealthState int
+
+ // Indicates the current statuses of the element. Various operational statuses are defined. Many of the enumeration's values are self-explanatory. However, a few are not and are described here in more detail:
+ //
+ // - "Stressed" indicates that the element is functioning, but needs attention. Examples of "Stressed" states are overload, overheated, and so on.
+ //
+ // - "Predictive Failure" indicates that an element is functioning nominally but predicting a failure in the near future.
+ //
+ // - "In Service" describes an element being configured, maintained, cleaned, or otherwise administered.
+ //
+ // - "No Contact" indicates that the monitoring system has knowledge of this element, but has never been able to establish communications with it.
+ //
+ // - "Lost Communication" indicates that the ManagedSystem Element is known to exist and has been contacted successfully in the past, but is currently unreachable.
+ //
+ // - "Stopped" and "Aborted" are similar, although the former implies a clean and orderly stop, while the latter implies an abrupt stop where the state and configuration of the element might need to be updated.
+ //
+ // - "Dormant" indicates that the element is inactive or quiesced.
+ //
+ // - "Supporting Entity in Error" indicates that this element might be "OK" but that another element, on which it is dependent, is in error. An example is a network service or endpoint that cannot function due to lower-layer networking problems.
+ //
+ // - "Completed" indicates that the element has completed its operation. This value should be combined with either OK, Error, or Degraded so that a client can tell if the complete operation Completed with OK (passed), Completed with Error (failed), or Completed with Degraded (the operation finished, but it did not complete OK or did not report an error).
+ //
+ // - "Power Mode" indicates that the element has additional power model information contained in the Associated PowerManagementService association.
+ //
+ // - "Relocating" indicates the element is being relocated.
+ //
+ // OperationalStatus replaces the Status property on ManagedSystemElement to provide a consistent approach to enumerations, to address implementation needs for an array property, and to provide a migration path from today's environment to the future. This change was not made earlier because it required the deprecated qualifier. Due to the widespread use of the existing Status property in management applications, it is strongly recommended that providers or instrumentation provide both the Status and OperationalStatus properties. Further, the first value of OperationalStatus should contain the primary status for the element. When instrumented, Status (because it is single-valued) should also provide the primary status of the element.
+ //
+ // ValueMap={0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, .., 0x8000..}
+ //
+ // Values={Unknown, Other, OK, Degraded, Stressed, Predictive Failure, Error, Non-Recoverable Error, Starting, Stopping, Stopped, In Service, No Contact, Lost Communication, Aborted, Dormant, Supporting Entity in Error, Completed, Power Mode, Relocating, DMTF Reserved, Vendor Reserved}
+ OperationalStatus int
+
+ // RequestedState is an integer enumeration that indicates the last requested or desired state for the element, irrespective of the mechanism through which it was requested. The actual state of the element is represented by EnabledState. This property is provided to compare the last requested and current enabled or disabled states.
+ //
+ // Note that when EnabledState is set to 5 ("Not Applicable"), then this property has no meaning. Refer to the EnabledState property description for explanations of the values in the RequestedState enumeration. "Unknown" (0) indicates the last requested state for the element is unknown.
+ //
+ // Note that the value "No Change" (5) has been deprecated in lieu of indicating the last requested state is "Unknown" (0). If the last requested or desired state is unknown, RequestedState should have the value "Unknown" (0), but may have the value "No Change" (5). Offline (6) indicates that the element has been requested to transition to the Enabled but Offline EnabledState. It should be noted that there are two new values in RequestedState that build on the statuses of EnabledState. These are "Reboot" (10) and "Reset" (11). Reboot refers to doing a "Shut Down" and then moving to an "Enabled" state. Reset indicates that the element is first "Disabled" and then "Enabled". The distinction between requesting "Shut Down" and "Disabled" should also be noted. Shut Down requests an orderly transition to the Disabled state, and might involve removing power, to completely erase any existing state. The Disabled state requests an immediate disabling of the element, such that it will not execute or accept any commands or processing requests. This property is set as the result of a method invocation (such as Start or StopService on CIM_Service), or can be overridden and defined as WRITEable in a subclass. The method approach is considered superior to a WRITEable property, because it allows an explicit invocation of the operation and the return of a result code. If knowledge of the last RequestedState is not supported for the EnabledLogicalElement, the property shall be NULL or have the value 12 "Not Applicable".
+ //
+ // ValueMap={0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, .., 32768..65535}
+ //
+ // Values={Unknown, Enabled, Disabled, Shut Down, No Change, Offline, Test, Deferred, Quiesce, Reboot, Reset, Not Applicable, DMTF Reserved, Vendor Reserved}
+ RequestedState int
+
+ GetRecordsResponse struct {
+ XMLName xml.Name `xml:"GetRecords_OUTPUT"`
+ IterationIdentifier int `xml:"IterationIdentifier"` // An identifier for the iterator.
+ NoMoreRecords bool `xml:"NoMoreRecords"` // Indicates that there are no more records to read
+ RecordArray []string `xml:"RecordArray"` // Array of records encoded as Base64
+ ReturnValue int `xml:"ReturnValue"` // ValueMap={0, 1, 2, 3} Values={Completed with No Error, Not Supported, Invalid record pointed, No record exists in log}
+ }
+
+ PositionToFirstRecordResponse struct {
+ XMLName xml.Name `xml:"PositionToFirstRecord_OUTPUT"`
+ IterationIdentifier int `xml:"IterationIdentifier"` // An identifier for the iterator.
+ ReturnValue int `xml:"ReturnValue"` // ValueMap={0, 1, 2} Values={Completed with No Error, Not Supported, No record exists}
+ }
+)
+
+// INPUTS
+type GetRecords_INPUT struct {
+ XMLName xml.Name `xml:"h:GetRecords_INPUT"`
+ H string `xml:"xmlns:h,attr"`
+ IterationIdentifier int `xml:"h:IterationIdentifier"` // An identifier for the iterator.
+ MaxReadRecords int `xml:"h:MaxReadRecords"` // Maximum number of records to read
+}
diff --git a/pkg/wsman/amt/messages.go b/pkg/wsman/amt/messages.go
new file mode 100644
index 00000000..c92c0750
--- /dev/null
+++ b/pkg/wsman/amt/messages.go
@@ -0,0 +1,104 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+// Package amt implements AMT classes to support communicating with Intel® AMT Devices
+package amt
+
+import (
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/alarmclock"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/auditlog"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/authorization"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/boot"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/environmentdetection"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/ethernetport"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/general"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/ieee8021x"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/kerberos"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/managementpresence"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/messagelog"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/mps"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/publickey"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/publicprivate"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/redirection"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/remoteaccess"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/setupandconfiguration"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/timesynchronization"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/tls"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/userinitiatedconnection"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/wifiportconfiguration"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+)
+
+// Messages contains the supported AMT classes
+type Messages struct {
+ wsmanMessageCreator *message.WSManMessageCreator
+ AlarmClockService alarmclock.Service
+ AuditLog auditlog.Service
+ AuthorizationService authorization.AuthorizationService
+ BootCapabilities boot.Capabilities
+ BootSettingData boot.SettingData
+ EnvironmentDetectionSettingData environmentdetection.SettingData
+ EthernetPortSettings ethernetport.Settings
+ GeneralSettings general.Settings
+ IEEE8021xCredentialContext ieee8021x.CredentialContext
+ IEEE8021xProfile ieee8021x.Profile
+ KerberosSettingData kerberos.SettingData
+ ManagementPresenceRemoteSAP managementpresence.RemoteSAP
+ MessageLog messagelog.MessageLog
+ MPSUsernamePassword mps.UsernamePassword
+ PublicKeyCertificate publickey.Certificate
+ PublicKeyManagementService publickey.ManagementService
+ PublicPrivateKeyPair publicprivate.KeyPair
+ RedirectionService redirection.Service
+ RemoteAccessPolicyAppliesToMPS remoteaccess.PolicyAppliesToMPS
+ RemoteAccessPolicyRule remoteaccess.PolicyRule
+ RemoteAccessService remoteaccess.Service
+ SetupAndConfigurationService setupandconfiguration.Service
+ TimeSynchronizationService timesynchronization.Service
+ TLSCredentialContext tls.CredentialContext
+ TLSProtocolEndpointCollection tls.ProtocolEndpointCollection
+ TLSSettingData tls.SettingData
+ UserInitiatedConnectionService userinitiatedconnection.Service
+ WiFiPortConfigurationService wifiportconfiguration.Service
+}
+
+// NewMessages instantiates a new instance of amt Messages
+func NewMessages(client client.WSMan) Messages {
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ m := Messages{
+ wsmanMessageCreator: wsmanMessageCreator,
+ }
+ m.AlarmClockService = alarmclock.NewServiceWithClient(wsmanMessageCreator, client)
+ m.AuditLog = auditlog.NewAuditLogWithClient(wsmanMessageCreator, client)
+ m.AuthorizationService = authorization.NewServiceWithClient(wsmanMessageCreator, client)
+ m.BootCapabilities = boot.NewBootCapabilitiesWithClient(wsmanMessageCreator, client)
+ m.BootSettingData = boot.NewBootSettingDataWithClient(wsmanMessageCreator, client)
+ m.EnvironmentDetectionSettingData = environmentdetection.NewEnvironmentDetectionSettingDataWithClient(wsmanMessageCreator, client)
+ m.EthernetPortSettings = ethernetport.NewEthernetPortSettingsWithClient(wsmanMessageCreator, client)
+ m.GeneralSettings = general.NewGeneralSettingsWithClient(wsmanMessageCreator, client)
+ m.IEEE8021xCredentialContext = ieee8021x.NewIEEE8021xCredentialContextWithClient(wsmanMessageCreator, client)
+ m.IEEE8021xProfile = ieee8021x.NewIEEE8021xProfileWithClient(wsmanMessageCreator, client)
+ m.KerberosSettingData = kerberos.NewKerberosSettingDataWithClient(wsmanMessageCreator, client)
+ m.ManagementPresenceRemoteSAP = managementpresence.NewManagementPresenceRemoteSAPWithClient(wsmanMessageCreator, client)
+ m.MessageLog = messagelog.NewMessageLogWithClient(wsmanMessageCreator, client)
+ m.MPSUsernamePassword = mps.NewMPSUsernamePasswordWithClient(wsmanMessageCreator, client)
+ m.PublicKeyCertificate = publickey.NewPublicKeyCertificateWithClient(wsmanMessageCreator, client)
+ m.PublicKeyManagementService = publickey.NewPublicKeyManagementServiceWithClient(wsmanMessageCreator, client)
+ m.PublicPrivateKeyPair = publicprivate.NewPublicPrivateKeyPairWithClient(wsmanMessageCreator, client)
+ m.RedirectionService = redirection.NewRedirectionServiceWithClient(wsmanMessageCreator, client)
+ m.RemoteAccessPolicyAppliesToMPS = remoteaccess.NewRemoteAccessPolicyAppliesToMPSWithClient(wsmanMessageCreator, client)
+ m.RemoteAccessPolicyRule = remoteaccess.NewPolicyRuleWithClient(wsmanMessageCreator, client)
+ m.RemoteAccessService = remoteaccess.NewRemoteAccessServiceWithClient(wsmanMessageCreator, client)
+ m.SetupAndConfigurationService = setupandconfiguration.NewSetupAndConfigurationServiceWithClient(wsmanMessageCreator, client)
+ m.TimeSynchronizationService = timesynchronization.NewTimeSynchronizationServiceWithClient(wsmanMessageCreator, client)
+ m.TLSCredentialContext = tls.NewTLSCredentialContextWithClient(wsmanMessageCreator, client)
+ m.TLSProtocolEndpointCollection = tls.NewTLSProtocolEndpointCollectionWithClient(wsmanMessageCreator, client)
+ m.TLSSettingData = tls.NewTLSSettingDataWithClient(wsmanMessageCreator, client)
+ m.UserInitiatedConnectionService = userinitiatedconnection.NewUserInitiatedConnectionServiceWithClient(wsmanMessageCreator, client)
+ m.WiFiPortConfigurationService = wifiportconfiguration.NewWiFiPortConfigurationServiceWithClient(wsmanMessageCreator, client)
+ return m
+}
diff --git a/pkg/amt/messages_test.go b/pkg/wsman/amt/messages_test.go
similarity index 62%
rename from pkg/amt/messages_test.go
rename to pkg/wsman/amt/messages_test.go
index 8e332baf..826d1e0d 100644
--- a/pkg/amt/messages_test.go
+++ b/pkg/wsman/amt/messages_test.go
@@ -9,31 +9,33 @@ import (
"reflect"
"testing"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/alarmclock"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/auditlog"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/authorization"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/boot"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/environmentdetection"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/ethernetport"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/general"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/ieee8021x"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/kerberos"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/managementpresence"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/messagelog"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/mps"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/publickey"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/publicprivate"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/redirection"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/remoteaccess"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/setupandconfiguration"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/timesynchronization"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/tls"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/userinitiatedconnection"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/amt/wifiportconfiguration"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/alarmclock"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/auditlog"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/authorization"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/boot"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/environmentdetection"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/ethernetport"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/general"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/ieee8021x"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/kerberos"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/managementpresence"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/messagelog"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/mps"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/publickey"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/publicprivate"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/redirection"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/remoteaccess"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/setupandconfiguration"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/timesynchronization"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/tls"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/userinitiatedconnection"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/wifiportconfiguration"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
)
func TestNewMessages(t *testing.T) {
- m := NewMessages()
+ mock := wsmantesting.MockClient{}
+ m := NewMessages(&mock)
if m.wsmanMessageCreator == nil {
t.Error("wsmanMessageCreator is not initialized")
@@ -41,13 +43,13 @@ func TestNewMessages(t *testing.T) {
if reflect.DeepEqual(m.AlarmClockService, alarmclock.Service{}) {
t.Error("AlarmClockService is not initialized")
}
- if reflect.DeepEqual(m.AuditLog, auditlog.AuditLog{}) {
+ if reflect.DeepEqual(m.AuditLog, auditlog.Service{}) {
t.Error("AuditLog is not initialized")
}
if reflect.DeepEqual(m.AuthorizationService, authorization.AuthorizationService{}) {
t.Error("AuthorizationService is not initialized")
}
- if reflect.DeepEqual(m.BootCapabilities, boot.BootCapabilities{}) {
+ if reflect.DeepEqual(m.BootCapabilities, boot.Capabilities{}) {
t.Error("BootCapabilities is not initialized")
}
if reflect.DeepEqual(m.BootSettingData, boot.SettingData{}) {
@@ -68,7 +70,7 @@ func TestNewMessages(t *testing.T) {
if reflect.DeepEqual(m.IEEE8021xProfile, ieee8021x.Profile{}) {
t.Error("IEEE8021xProfile is not initialized")
}
- if reflect.DeepEqual(m.KerberosSettingData, kerberos.KerberosSettingData{}) {
+ if reflect.DeepEqual(m.KerberosSettingData, kerberos.SettingData{}) {
t.Error("KerberosSettingData is not initialized")
}
if reflect.DeepEqual(m.ManagementPresenceRemoteSAP, managementpresence.RemoteSAP{}) {
@@ -110,6 +112,9 @@ func TestNewMessages(t *testing.T) {
if reflect.DeepEqual(m.TLSCredentialContext, tls.CredentialContext{}) {
t.Error("TLSCredentialContext is not initialized")
}
+ if reflect.DeepEqual(m.TLSProtocolEndpointCollection, tls.ProtocolEndpointCollection{}) {
+ t.Error("TLSProtocolEndpointCollection is not initialized")
+ }
if reflect.DeepEqual(m.TLSSettingData, tls.SettingData{}) {
t.Error("TLSSettingData is not initialized")
}
diff --git a/pkg/wsman/amt/methods/methods.go b/pkg/wsman/amt/methods/methods.go
new file mode 100644
index 00000000..4a9641df
--- /dev/null
+++ b/pkg/wsman/amt/methods/methods.go
@@ -0,0 +1,24 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+// Package methods provides utility functions used across the amt packages
+package methods
+
+import "fmt"
+
+// RequestStateChange creates an amt specific request state change action
+func RequestStateChange(className string) string {
+ return fmt.Sprintf("http://intel.com/wbem/wscim/1/amt-schema/1/%s/RequestStateChange", className)
+}
+
+// GenerateAction creates an amt specific action for custom methods
+func GenerateAction(className string, methodName string) string {
+ return fmt.Sprintf("http://intel.com/wbem/wscim/1/amt-schema/1/%s/%s", className, methodName)
+}
+
+// GenerateInputMethod creates the string used to populate the XML tag for INPUT calls
+func GenerateInputMethod(methodName string) string {
+ return fmt.Sprintf("%s_INPUT", methodName)
+}
diff --git a/pkg/wsman/amt/methods/methods_test.go b/pkg/wsman/amt/methods/methods_test.go
new file mode 100644
index 00000000..f2f4d009
--- /dev/null
+++ b/pkg/wsman/amt/methods/methods_test.go
@@ -0,0 +1,34 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package methods
+
+import (
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+)
+
+func TestMethods(t *testing.T) {
+ t.Run("GenerateAction Test", func(t *testing.T) {
+ expectedResult := "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_Test/TestMethod"
+ className := "AMT_Test"
+ methodName := "TestMethod"
+ result := GenerateAction(className, methodName)
+ assert.Equal(t, expectedResult, result)
+ })
+ t.Run("GenerateMethod Test", func(t *testing.T) {
+ expectedResult := "TestMethod_INPUT"
+ methodName := "TestMethod"
+ result := GenerateInputMethod(methodName)
+ assert.Equal(t, expectedResult, result)
+ })
+ t.Run("RequestStateChange Test", func(t *testing.T) {
+ expectedResult := "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_Test/RequestStateChange"
+ className := "AMT_Test"
+ result := RequestStateChange(className)
+ assert.Equal(t, expectedResult, result)
+ })
+}
diff --git a/pkg/wsman/amt/mps/constants.go b/pkg/wsman/amt/mps/constants.go
new file mode 100644
index 00000000..f06c750c
--- /dev/null
+++ b/pkg/wsman/amt/mps/constants.go
@@ -0,0 +1,10 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package mps
+
+const (
+ AMT_MPSUsernamePassword string = "AMT_MPSUsernamePassword"
+)
diff --git a/pkg/wsman/amt/mps/marshal.go b/pkg/wsman/amt/mps/marshal.go
new file mode 100644
index 00000000..7b2a2624
--- /dev/null
+++ b/pkg/wsman/amt/mps/marshal.go
@@ -0,0 +1,30 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package mps
+
+import (
+ "encoding/json"
+
+ "gopkg.in/yaml.v3"
+)
+
+// JSON marshals the type into JSON format
+func (r *Response) JSON() string {
+ jsonOutput, err := json.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(jsonOutput)
+}
+
+// YAML marshals the type into YAML format
+func (r *Response) YAML() string {
+ yamlOutput, err := yaml.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(yamlOutput)
+}
diff --git a/pkg/wsman/amt/mps/types.go b/pkg/wsman/amt/mps/types.go
new file mode 100644
index 00000000..70758081
--- /dev/null
+++ b/pkg/wsman/amt/mps/types.go
@@ -0,0 +1,64 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package mps
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+)
+
+type UsernamePassword struct {
+ base message.Base
+}
+
+// OUTPUTS
+// Response Types
+type (
+ Response struct {
+ *client.Message
+ XMLName xml.Name `xml:"Envelope"`
+ Header message.Header `xml:"Header"`
+ Body Body `xml:"Body"`
+ }
+
+ Body struct {
+ XMLName xml.Name `xml:"Body"`
+ GetResponse MPSUsernamePasswordResponse
+ EnumerateResponse common.EnumerateResponse
+ PullResponse PullResponse
+ }
+
+ MPSUsernamePasswordResponse struct {
+ XMLName xml.Name `xml:"AMT_MPSUsernamePassword"`
+ InstanceID string `xml:"InstanceID,omitempty"` // Within the scope of the instantiating Namespace, InstanceID opaquely and uniquely identifies an instance of this class. In order to ensure uniqueness within the NameSpace, the value of InstanceID SHOULD be constructed using the following 'preferred' algorithm: : Where and are separated by a colon ':', and where MUST include a copyrighted, trademarked or otherwise unique name that is owned by the business entity creating/defining the InstanceID, or is a registered ID that is assigned to the business entity by a recognized global authority. (This is similar to the _ structure of Schema class names.) In addition, to ensure uniqueness, MUST NOT contain a colon (':'). When using this algorithm, the first colon to appear in InstanceID MUST appear between and . is chosen by the organizational entity and SHOULD not be re-used to identify different underlying (real-world) elements. If the above 'preferred' algorithm is not used, the defining entity MUST assure that the resultant InstanceID is not re-used across any InstanceIDs produced by this or other providers for this instance's NameSpace. For DMTF defined instances, the 'preferred' algorithm MUST be used with the set to 'CIM'. RemoteID string `xml:"RemoteID,omitempty"` //
+ RemoteID string `xml:"RemoteID,omitempty"` // RemoteID is the name by which the principal is known at the remote secret key authentication service.
+ Secret string `xml:"Secret,omitempty"` // The secret known by the principal. This property is write-only.
+ Algorithm string `xml:"Algorithm,omitempty"` // No AMT SDK Documentation
+ Protocol string `xml:"Protocol,omitempty"` // No AMT SDK Documentation
+ }
+
+ PullResponse struct {
+ XMLName xml.Name `xml:"PullResponse"`
+ MPSUsernamePasswordItems []MPSUsernamePasswordResponse `xml:"Items>AMT_MPSUsernamePassword"`
+ }
+)
+
+// INPUTS
+// Request Types
+type (
+ MPSUsernamePasswordRequest struct {
+ XMLName xml.Name `xml:"h:AMT_MPSUsernamePassword"`
+ H string `xml:"xmlns:h,attr"`
+ InstanceID string `xml:"h:InstanceID,omitempty"` // Within the scope of the instantiating Namespace, InstanceID opaquely and uniquely identifies an instance of this class. In order to ensure uniqueness within the NameSpace, the value of InstanceID SHOULD be constructed using the following 'preferred' algorithm: : Where and are separated by a colon ':', and where MUST include a copyrighted, trademarked or otherwise unique name that is owned by the business entity creating/defining the InstanceID, or is a registered ID that is assigned to the business entity by a recognized global authority. (This is similar to the _ structure of Schema class names.) In addition, to ensure uniqueness, MUST NOT contain a colon (':'). When using this algorithm, the first colon to appear in InstanceID MUST appear between and . is chosen by the organizational entity and SHOULD not be re-used to identify different underlying (real-world) elements. If the above 'preferred' algorithm is not used, the defining entity MUST assure that the resultant InstanceID is not re-used across any InstanceIDs produced by this or other providers for this instance's NameSpace. For DMTF defined instances, the 'preferred' algorithm MUST be used with the set to 'CIM'. RemoteID string `xml:"RemoteID,omitempty"` //
+ RemoteID string `xml:"h:RemoteID,omitempty"` // RemoteID is the name by which the principal is known at the remote secret key authentication service.
+ Secret string `xml:"h:Secret,omitempty"` // The secret known by the principal. This property is write-only.
+ Algorithm string `xml:"h:Algorithm,omitempty"` // No AMT SDK Documentation
+ Protocol string `xml:"h:Protocol,omitempty"` // No AMT SDK Documentation
+ }
+)
diff --git a/pkg/wsman/amt/mps/usernamepassword.go b/pkg/wsman/amt/mps/usernamepassword.go
new file mode 100644
index 00000000..563665a1
--- /dev/null
+++ b/pkg/wsman/amt/mps/usernamepassword.go
@@ -0,0 +1,103 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+// Package mps facilitiates communication with Intel® AMT devices to configure the username and password used to access an MPS.
+package mps
+
+import (
+ "encoding/xml"
+ "fmt"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+)
+
+// NewMPSUsernamePasswordWithClient instantiates a new UsernamePassword
+func NewMPSUsernamePasswordWithClient(wsmanMessageCreator *message.WSManMessageCreator, client client.WSMan) UsernamePassword {
+ return UsernamePassword{
+ base: message.NewBaseWithClient(wsmanMessageCreator, AMT_MPSUsernamePassword, client),
+ }
+}
+
+// Get retrieves the representation of the instance
+func (usernamePassword UsernamePassword) Get() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: usernamePassword.base.Get(nil),
+ },
+ }
+ // send the message to AMT
+ err = usernamePassword.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Enumerate returns an enumeration context which is used in a subsequent Pull call
+func (usernamePassword UsernamePassword) Enumerate() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: usernamePassword.base.Enumerate(),
+ },
+ }
+ // send the message to AMT
+ err = usernamePassword.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Pull returns the instances of this class. An enumeration context provided by the Enumerate call is used as input.
+func (usernamePassword UsernamePassword) Pull(enumerationContext string) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: usernamePassword.base.Pull(enumerationContext),
+ },
+ }
+ // send the message to AMT
+ err = usernamePassword.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Put will change properties of the selected instance
+func (usernamePassword UsernamePassword) Put(mpsUsernamePassword MPSUsernamePasswordRequest) (response Response, err error) {
+ mpsUsernamePassword.H = fmt.Sprintf("%s%s", message.AMTSchema, AMT_MPSUsernamePassword)
+ response = Response{
+ Message: &client.Message{
+ XMLInput: usernamePassword.base.Put(mpsUsernamePassword, false, nil),
+ },
+ }
+ // send the message to AMT
+ err = usernamePassword.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
diff --git a/pkg/wsman/amt/mps/usernamepassword_test.go b/pkg/wsman/amt/mps/usernamepassword_test.go
new file mode 100644
index 00000000..0dfd99ac
--- /dev/null
+++ b/pkg/wsman/amt/mps/usernamepassword_test.go
@@ -0,0 +1,240 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package mps
+
+import (
+ "encoding/xml"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
+)
+
+func TestPositiveAMT_MPSUsernamePassword(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/mps",
+ }
+ elementUnderTest := NewMPSUsernamePasswordWithClient(wsmanMessageCreator, &client)
+
+ t.Run("amt_MPSUsernamePassword Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create a valid AMT_MPSUsernamePassword Get wsman message",
+ AMT_MPSUsernamePassword,
+ wsmantesting.GET,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Get"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GetResponse: MPSUsernamePasswordResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_MPSUsernamePassword", Local: "AMT_MPSUsernamePassword"},
+ InstanceID: "Intel(r) AMT:MPS Username Password 0",
+ RemoteID: "test",
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create a valid AMT_MPSUsernamePassword Enumerate wsman message",
+ AMT_MPSUsernamePassword,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Enumerate"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "19080000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid AMT_MPSUsernamePassword Pull wsman message",
+ AMT_MPSUsernamePassword,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Pull"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ MPSUsernamePasswordItems: []MPSUsernamePasswordResponse{
+ {
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_MPSUsernamePassword", Local: "AMT_MPSUsernamePassword"},
+ InstanceID: "Intel(r) AMT:MPS Username Password 0",
+ RemoteID: "test",
+ },
+ },
+ },
+ },
+ },
+ {
+ "should create a valid AMT_MPSUsernamePassword Put wsman message",
+ AMT_MPSUsernamePassword,
+ wsmantesting.PUT,
+ "Intel(r) AMT:MPS Username Password 0testP@ssw0rd",
+ func() (Response, error) {
+ client.CurrentMessage = "Put"
+ mpsUsernamePassword := MPSUsernamePasswordRequest{
+ H: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_MPSUsernamePassword",
+ InstanceID: "Intel(r) AMT:MPS Username Password 0",
+ Secret: "P@ssw0rd",
+ RemoteID: "test",
+ }
+ return elementUnderTest.Put(mpsUsernamePassword)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.NoError(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.Equal(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
+func TestNegativeAMT_MPSUsernamePassword(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/mps",
+ }
+ elementUnderTest := NewMPSUsernamePasswordWithClient(wsmanMessageCreator, &client)
+
+ t.Run("amt_MPSUsernamePassword Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create a valid AMT_MPSUsernamePassword Get wsman message",
+ AMT_MPSUsernamePassword,
+ wsmantesting.GET,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GetResponse: MPSUsernamePasswordResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_MPSUsernamePassword", Local: "AMT_MPSUsernamePassword"},
+ InstanceID: "Intel(r) AMT:MPS Username Password 0",
+ RemoteID: "test",
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create a valid AMT_MPSUsernamePassword Enumerate wsman message",
+ AMT_MPSUsernamePassword,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "19080000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid AMT_MPSUsernamePassword Pull wsman message",
+ AMT_MPSUsernamePassword,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ MPSUsernamePasswordItems: []MPSUsernamePasswordResponse{
+ {
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_MPSUsernamePassword", Local: "AMT_MPSUsernamePassword"},
+ InstanceID: "Intel(r) AMT:MPS Username Password 0",
+ RemoteID: "test",
+ },
+ },
+ },
+ },
+ },
+ {
+ "should create a valid AMT_MPSUsernamePassword Put wsman message",
+ AMT_MPSUsernamePassword,
+ wsmantesting.PUT,
+ "Intel(r) AMT:MPS Username Password 0testP@ssw0rd",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ mpsUsernamePassword := MPSUsernamePasswordRequest{
+ H: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_MPSUsernamePassword",
+ InstanceID: "Intel(r) AMT:MPS Username Password 0",
+ Secret: "P@ssw0rd",
+ RemoteID: "test",
+ }
+ return elementUnderTest.Put(mpsUsernamePassword)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.Error(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.NotEqual(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
diff --git a/pkg/wsman/amt/publickey/certificate.go b/pkg/wsman/amt/publickey/certificate.go
new file mode 100644
index 00000000..8e109d94
--- /dev/null
+++ b/pkg/wsman/amt/publickey/certificate.go
@@ -0,0 +1,140 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+// Package publickey facilitiates communication with Intel® AMT devices to access and configure Public Key Certificates and Public Key Management Service classes for AMT
+//
+// Certificate:
+// This class represents a X.509 Certificate in the Intel® AMT CertStore. Instances of this class can be created using the AMT_PublicKeyManagementService.AddCertificate and AMT_PublicKeyManagementService.AddTrustedRootCertificate methods. A certificate cannot be deleted while it is being used by any service (TLS/EAC).
+//
+// Management Service:
+// This service contains the information necessary to represent and manage the functionality provided by the Intel® AMT CertStore.
+package publickey
+
+import (
+ "encoding/xml"
+ "fmt"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+)
+
+// NewPublicKeyCertificateWithClient instantiates a new Certificate
+func NewPublicKeyCertificateWithClient(wsmanMessageCreator *message.WSManMessageCreator, client client.WSMan) Certificate {
+ return Certificate{
+ base: message.NewBaseWithClient(wsmanMessageCreator, AMT_PublicKeyCertificate, client),
+ }
+}
+
+// Get retrieves the representation of the instance
+func (certificate Certificate) Get(handle int) (response Response, err error) {
+ selector := message.Selector{
+ Name: "InstanceID",
+ Value: fmt.Sprintf("Intel(r) AMT Certificate: Handle: %d", handle),
+ }
+ response = Response{
+ Message: &client.Message{
+ XMLInput: certificate.base.Get(&selector),
+ },
+ }
+ // send the message to AMT
+ err = certificate.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Enumerate returns an enumeration context which is used in a subsequent Pull call
+func (certificate Certificate) Enumerate() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: certificate.base.Enumerate(),
+ },
+ }
+ // send the message to AMT
+ err = certificate.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Pull returns the instances of this class. An enumeration context provided by the Enumerate call is used as input.
+func (certificate Certificate) Pull(enumerationContext string) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: certificate.base.Pull(enumerationContext),
+ },
+ }
+ // send the message to AMT
+ err = certificate.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Put will change properties of the selected instance
+func (certificate Certificate) Put(handle int, cert string) (response Response, err error) {
+ selector := message.Selector{
+ Name: "InstanceID",
+ Value: fmt.Sprintf("Intel(r) AMT Certificate: Handle: %d", handle),
+ }
+ publicKeyCertificate := PublicKeyCertificateRequest{}
+ publicKeyCertificate.X509Certificate = cert
+ publicKeyCertificate.H = fmt.Sprintf("%s%s", message.AMTSchema, AMT_PublicKeyCertificate)
+ response = Response{
+ Message: &client.Message{
+ XMLInput: certificate.base.Put(publicKeyCertificate, true, &selector),
+ },
+ }
+ // send the message to AMT
+ err = certificate.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Delete removes a the specified instance
+func (certificate Certificate) Delete(instanceID string) (response Response, err error) {
+ selector := message.Selector{Name: "InstanceID", Value: instanceID}
+ response = Response{
+ Message: &client.Message{
+ XMLInput: certificate.base.Delete(selector),
+ },
+ }
+ // send the message to AMT
+ err = certificate.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
diff --git a/pkg/wsman/amt/publickey/certificate_test.go b/pkg/wsman/amt/publickey/certificate_test.go
new file mode 100644
index 00000000..10cb922f
--- /dev/null
+++ b/pkg/wsman/amt/publickey/certificate_test.go
@@ -0,0 +1,345 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package publickey
+
+import (
+ "encoding/xml"
+ "fmt"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
+)
+
+func TestPositiveAMT_PublicKeyCertificate(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/publickey/certificate",
+ }
+ elementUnderTest := NewPublicKeyCertificateWithClient(wsmanMessageCreator, &client)
+ t.Run("amt_PublicKeyCertificate Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ extraHeader string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create a valid AMT_PublicKeyCertificate Get wsman message",
+ AMT_PublicKeyCertificate,
+ wsmantesting.GET,
+ "",
+ "Intel(r) AMT Certificate: Handle: 0",
+ func() (Response, error) {
+ client.CurrentMessage = "Get"
+ return elementUnderTest.Get(0)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PublicKeyCertificateGetAndPutResponse: PublicKeyCertificateResponse{
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_PublicKeyCertificate), Local: "AMT_PublicKeyCertificate"},
+ ElementName: "Intel(r) AMT Certificate",
+ InstanceID: "Intel(r) AMT Certificate: Handle: 0",
+ Issuer: "C=unknown,O=unknown,CN=MPSRoot-0af1d5",
+ Subject: "C=unknown,O=unknown,CN=MPSRoot-0af1d5",
+ TrustedRootCertificate: true,
+ X509Certificate: "MIIEOzCCAqOgAwIBAgIDAZMjMA0GCSqGSIb3DQEBDAUAMD0xFzAVBgNVBAMTDk1QU1Jvb3QtMGFmMWQ1MRAwDgYDVQQKEwd1bmtub3duMRAwDgYDVQQGEwd1bmtub3duMCAXDTIyMDkyNDEwNDUwOFoYDzIwNTMwOTI0MTA0NTA4WjA9MRcwFQYDVQQDEw5NUFNSb290LTBhZjFkNTEQMA4GA1UEChMHdW5rbm93bjEQMA4GA1UEBhMHdW5rbm93bjCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBALz/oJNyWXlClSlteAieC8Uyd4A+tbn8b45k6LKiImhDmdz/xFo9xe0C9GNf7b42KVpg5WoH/sPhoClR9Tv5i1LnilT1SUir42fcm2NEV9dRcLsPd/RAQfz8u0D4zb3blnxE8isqzriNpG7kac35UidSr5ym8TZ3IwXx6JJuncGgfB0DFZADC/+dA74n3coykvWBYqLr6RI5pkAxvulkRlCsatJTJrvMUYJ51GI28jV56mIAc89sLrHqiSKCZBH9AcUrnZ/cB6ST/IikXpxy5wXBIvWT3VKVq75T/uIoCBEp5TLEn1EOYGqBBOCSQgmtmX7eVaB0s1+ppPW9w9a2zS45cHAtQ7tYvkkPv2dRhSzZdlk6HRXDP5wsF0aiflZCgbrjkq0SFC4e3Lo7XQX3FTNb0SOTZVTydupoMKkgJQTNlcosdu1ZzaIBl3eSkKkJZz2rUTssZC5tn9vcDd5vy3BzcGh5pvkgfAgN1sydqG7Ke1qCkNEzm11B/BsevatjjwIDAQABo0IwQDAMBgNVHRMEBTADAQH/MBEGCWCGSAGG+EIBAQQEAwIABzAdBgNVHQ4EFgQUCvHVQqerCid99eLApuLky9x6H5owDQYJKoZIhvcNAQEMBQADggGBAIzOyGV0hzsmH2biJlzwTZaHMxqS7boTFMkHw+KvzsI201tHqVmCoiQ8EHErBGLSoDOTDRgOUGOCA5XU5ie9OWupAGqKBSwIyAhmJMOzrzC4Gwpu8K1msoFJH30kx/V9purpbS3BRj0xfYXLa6IczbTg3E5IfTnZRJ9YuUtKQfI0P9c5U9CoKtddKn4+lRvOjFDoYfQGCJ7go3xjNCcGCVCjfkUhAVdbQ21DCRr6/YCZDWmjzZpL0p7UKF8roTiNuL/Z7gIXxch5HOmEWHY9uQ6K2MntuxAu0aK/mSD2kwmt/ECongdEGfUvhULLoPRQlQ2LnzcUQEgMECGQR5Yfy9jT0E8zdWDpc2tgVioNu6rEYKgp/GhG+sv7jv58pW82FRAV9xXtftW9+XDugC8tBJ6JHn0Q2v0QAflD2CEQVhWAY8bAqrbfTGUsaLfGL6kxV/qqssoMgLR8WhQ96T5le/4XGhQpbCHWIlctD6MwbrsunIAeQKp1Sc3DosY7DLq1MQ==",
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create a valid AMT_PublicKeyCertificate Enumerate wsman message",
+ AMT_PublicKeyCertificate,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Enumerate"
+ if elementUnderTest.base.WSManMessageCreator == nil {
+ print("Error")
+ }
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "CB000000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid AMT_PublicKeyCertificate Pull wsman message",
+ AMT_PublicKeyCertificate,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Pull"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: message.XMLPullResponseSpace, Local: "PullResponse"},
+ PublicKeyCertificateItems: []PublicKeyCertificateResponse{
+ {
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_PublicKeyCertificate), Local: "AMT_PublicKeyCertificate"},
+ ElementName: "Intel(r) AMT Certificate",
+ InstanceID: "Intel(r) AMT Certificate: Handle: 0",
+ Issuer: "C=unknown,O=unknown,CN=MPSRoot-0af1d5",
+ Subject: "C=unknown,O=unknown,CN=MPSRoot-0af1d5",
+ TrustedRootCertificate: true,
+ X509Certificate: "MIIEOzCCAqOgAwIBAgIDAZMjMA0GCSqGSIb3DQEBDAUAMD0xFzAVBgNVBAMTDk1QU1Jvb3QtMGFmMWQ1MRAwDgYDVQQKEwd1bmtub3duMRAwDgYDVQQGEwd1bmtub3duMCAXDTIyMDkyNDEwNDUwOFoYDzIwNTMwOTI0MTA0NTA4WjA9MRcwFQYDVQQDEw5NUFNSb290LTBhZjFkNTEQMA4GA1UEChMHdW5rbm93bjEQMA4GA1UEBhMHdW5rbm93bjCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBALz/oJNyWXlClSlteAieC8Uyd4A+tbn8b45k6LKiImhDmdz/xFo9xe0C9GNf7b42KVpg5WoH/sPhoClR9Tv5i1LnilT1SUir42fcm2NEV9dRcLsPd/RAQfz8u0D4zb3blnxE8isqzriNpG7kac35UidSr5ym8TZ3IwXx6JJuncGgfB0DFZADC/+dA74n3coykvWBYqLr6RI5pkAxvulkRlCsatJTJrvMUYJ51GI28jV56mIAc89sLrHqiSKCZBH9AcUrnZ/cB6ST/IikXpxy5wXBIvWT3VKVq75T/uIoCBEp5TLEn1EOYGqBBOCSQgmtmX7eVaB0s1+ppPW9w9a2zS45cHAtQ7tYvkkPv2dRhSzZdlk6HRXDP5wsF0aiflZCgbrjkq0SFC4e3Lo7XQX3FTNb0SOTZVTydupoMKkgJQTNlcosdu1ZzaIBl3eSkKkJZz2rUTssZC5tn9vcDd5vy3BzcGh5pvkgfAgN1sydqG7Ke1qCkNEzm11B/BsevatjjwIDAQABo0IwQDAMBgNVHRMEBTADAQH/MBEGCWCGSAGG+EIBAQQEAwIABzAdBgNVHQ4EFgQUCvHVQqerCid99eLApuLky9x6H5owDQYJKoZIhvcNAQEMBQADggGBAIzOyGV0hzsmH2biJlzwTZaHMxqS7boTFMkHw+KvzsI201tHqVmCoiQ8EHErBGLSoDOTDRgOUGOCA5XU5ie9OWupAGqKBSwIyAhmJMOzrzC4Gwpu8K1msoFJH30kx/V9purpbS3BRj0xfYXLa6IczbTg3E5IfTnZRJ9YuUtKQfI0P9c5U9CoKtddKn4+lRvOjFDoYfQGCJ7go3xjNCcGCVCjfkUhAVdbQ21DCRr6/YCZDWmjzZpL0p7UKF8roTiNuL/Z7gIXxch5HOmEWHY9uQ6K2MntuxAu0aK/mSD2kwmt/ECongdEGfUvhULLoPRQlQ2LnzcUQEgMECGQR5Yfy9jT0E8zdWDpc2tgVioNu6rEYKgp/GhG+sv7jv58pW82FRAV9xXtftW9+XDugC8tBJ6JHn0Q2v0QAflD2CEQVhWAY8bAqrbfTGUsaLfGL6kxV/qqssoMgLR8WhQ96T5le/4XGhQpbCHWIlctD6MwbrsunIAeQKp1Sc3DosY7DLq1MQ==",
+ },
+ {
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_PublicKeyCertificate), Local: "AMT_PublicKeyCertificate"},
+ ElementName: "Intel(r) AMT Certificate",
+ InstanceID: "Intel(r) AMT Certificate: Handle: 1",
+ Issuer: "C=unknown,O=unknown,CN=MPSRoot-0af1d5",
+ Subject: "C=unknown,O=unknown,CN=MPSRoot-0af1d5",
+ TrustedRootCertificate: false,
+ X509Certificate: "MIIEOzCCAqOgAwIBAgIDAZMjMA0GCSqGSIb3DQEBDAUAMD0xFzAVBgNVBAMTDk1QU1Jvb3QtMGFmMWQ1MRAwDgYDVQQKEwd1bmtub3duMRAwDgYDVQQGEwd1bmtub3duMCAXDTIyMDkyNDEwNDUwOFoYDzIwNTMwOTI0MTA0NTA4WjA9MRcwFQYDVQQDEw5NUFNSb290LTBhZjFkNTEQMA4GA1UEChMHdW5rbm93bjEQMA4GA1UEBhMHdW5rbm93bjCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBALz/oJNyWXlClSlteAieC8Uyd4A+tbn8b45k6LKiImhDmdz/xFo9xe0C9GNf7b42KVpg5WoH/sPhoClR9Tv5i1LnilT1SUir42fcm2NEV9dRcLsPd/RAQfz8u0D4zb3blnxE8isqzriNpG7kac35UidSr5ym8TZ3IwXx6JJuncGgfB0DFZADC/+dA74n3coykvWBYqLr6RI5pkAxvulkRlCsatJTJrvMUYJ51GI28jV56mIAc89sLrHqiSKCZBH9AcUrnZ/cB6ST/IikXpxy5wXBIvWT3VKVq75T/uIoCBEp5TLEn1EOYGqBBOCSQgmtmX7eVaB0s1+ppPW9w9a2zS45cHAtQ7tYvkkPv2dRhSzZdlk6HRXDP5wsF0aiflZCgbrjkq0SFC4e3Lo7XQX3FTNb0SOTZVTydupoMKkgJQTNlcosdu1ZzaIBl3eSkKkJZz2rUTssZC5tn9vcDd5vy3BzcGh5pvkgfAgN1sydqG7Ke1qCkNEzm11B/BsevatjjwIDAQABo0IwQDAMBgNVHRMEBTADAQH/MBEGCWCGSAGG+EIBAQQEAwIABzAdBgNVHQ4EFgQUCvHVQqerCid99eLApuLky9x6H5owDQYJKoZIhvcNAQEMBQADggGBAIzOyGV0hzsmH2biJlzwTZaHMxqS7boTFMkHw+KvzsI201tHqVmCoiQ8EHErBGLSoDOTDRgOUGOCA5XU5ie9OWupAGqKBSwIyAhmJMOzrzC4Gwpu8K1msoFJH30kx/V9purpbS3BRj0xfYXLa6IczbTg3E5IfTnZRJ9YuUtKQfI0P9c5U9CoKtddKn4+lRvOjFDoYfQGCJ7go3xjNCcGCVCjfkUhAVdbQ21DCRr6/YCZDWmjzZpL0p7UKF8roTiNuL/Z7gIXxch5HOmEWHY9uQ6K2MntuxAu0aK/mSD2kwmt/ECongdEGfUvhULLoPRQlQ2LnzcUQEgMECGQR5Yfy9jT0E8zdWDpc2tgVioNu6rEYKgp/GhG+sv7jv58pW82FRAV9xXtftW9+XDugC8tBJ6JHn0Q2v0QAflD2CEQVhWAY8bAqrbfTGUsaLfGL6kxV/qqssoMgLR8Whq96T5le/4XGhQpbCHWIlctD6MwbrsunIAeQKp1Sc3DosY7DLq1MQ==",
+ },
+ {
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_PublicKeyCertificate), Local: "AMT_PublicKeyCertificate"},
+ ElementName: "Intel(r) AMT Certificate",
+ InstanceID: "Intel(r) AMT Certificate: Handle: 2",
+ Issuer: "C=unknown,O=unknown,CN=MPSRoot-0af1d5",
+ Subject: "C=unknown,O=unknown,CN=MPSRoot-0af1d5",
+ TrustedRootCertificate: true,
+ X509Certificate: "MIIEOzCCAqOgAwIBAgIDAZMjMA0GCSqGSIb3DQEBDAUAMD0xFzAVBgNVBAMTDk1QU1Jvb3QtMGFmMWQ1MRAwDgYDVQQKEwd1bmtub3duMRAwDgYDVQQGEwd1bmtub3duMCAXDTIyMDkyNDEwNDUwOFoYDzIwNTMwOTI0MTA0NTA4WjA9MRcwFQYDVQQDEw5NUFNSb290LTBhZjFkNTEQMA4GA1UEChMHdW5rbm93bjEQMA4GA1UEBhMHdW5rbm93bjCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBALz/oJNyWXlClSlteAieC8Uyd4A+tbn8b45k6LKiImhDmdz/xFo9xe0C9GNf7b42KVpg5WoH/sPhoClR9Tv5i1LnilT1SUir42fcm2NEV9dRcLsPd/RAQfz8u0D4zb3blnxE8isqzriNpG7kac35UidSr5ym8TZ3IwXx6JJuncGgfB0DFBADC/+dA74n3coykvWBYqLr6RI5pkAxvulkRlCsatJTJrvMUYJ51GI28jV56mIAc89sLrHqiSKCZBH9AcUrnZ/cB6ST/IikXpxy5wXBIvWT3VKVq75T/uIoCBEp5TLEn1EOYGqBBOCSQgmtmX7eVaB0s1+ppPW9w9a2zS45cHAtQ7tYvkkPv2dRhSzZdlk6HRXDP5wsF0aiflZCgbrjkq0SFC4e3Lo7XQX3FTNb0SOTZVTydupoMKkgJQTNlcosdu1ZzaIBl3eSkKkJZz2rUTssZC5tn9vcDd5vy3BzcGh5pvkgfAgN1sydqG7Ke1qCkNEzm11B/BsevatjjwIDAQABo0IwQDAMBgNVHRMEBTADAQH/MBEGCWCGSAGG+EIBAQQEAwIABzAdBgNVHQ4EFgQUCvHVQqerCid99eLApuLky9x6H5owDQYJKoZIhvcNAQEMBQADggGBAIzOyGV0hzsmH2biJlzwTZaHMxqS7boTFMkHw+KvzsI201tHqVmCoiQ8EHErBGLSoDOTDRgOUGOCA5XU5ie9OWupAGqKBSwIyAhmJMOzrzC4Gwpu8K1msoFJH30kx/V9purpbS3BRj0xfYXLa6IczbTg3E5IfTnZRJ9YuUtKQfI0P9c5U9CoKtddKn4+lRvOjFDoYfQGCJ7go3xjNCcGCVCjfkUhAVdbQ21DCRr6/YCZDWmjzZpL0p7UKF8roTiNuL/Z7gIXxch5HOmEWHY9uQ6K2MntuxAu0aK/mSD2kwmt/ECongdEGfUvhULLoPRQlQ2LnzcUQEgMECGQR5Yfy9jT0E8zdWDpc2tgVioNu6rEYKgp/GhG+sv7jv58pW82FRAV9xXtftW9+XDugC8tBJ6JHn0Q2v0QAflD2CEQVhWAY8bAqrbfTGUsaLfGL6kxV/qqssoMgLR8Whq96T5le/4XGhQpbCHWIlctD6MwbrsunIAeQKp1Sc3DosY7DLq1MQ==",
+ },
+ },
+ },
+ },
+ },
+
+ //PUTS
+ {
+ "should create a valid AMT_PublicKeyCertificate Put wsman message",
+ AMT_PublicKeyCertificate,
+ wsmantesting.PUT,
+ "MIIEOzCCAqOgAwIBAgIDAZMjMA0GCSqGSIb3DQEBDAUAMD0xFzAVBgNVBAMTDk1QU1Jvb3QtMGFmMWQ1MRAwDgYDVQQKEwd1bmtub3duMRAwDgYDVQQGEwd1bmtub3duMCAXDTIyMDkyNDEwNDUwOFoYDzIwNTMwOTI0MTA0NTA4WjA9MRcwFQYDVQQDEw5NUFNSb290LTBhZjFkNTEQMA4GA1UEChMHdW5rbm93bjEQMA4GA1UEBhMHdW5rbm93bjCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBALz/oJNyWXlClSlteAieC8Uyd4A+tbn8b45k6LKiImhDmdz/xFo9xe0C9GNf7b42KVpg5WoH/sPhoClR9Tv5i1LnilT1SUir42fcm2NEV9dRcLsPd/RAQfz8u0D4zb3blnxE8isqzriNpG7kac35UidSr5ym8TZ3IwXx6JJuncGgfB0DFZADC/+dA74n3coykvWBYqLr6RI5pkAxvulkRlCsatJTJrvMUYJ51GI28jV56mIAc89sLrHqiSKCZBH9AcUrnZ/cB6ST/IikXpxy5wXBIvWT3VKVq75T/uIoCBEp5TLEn1EOYGqBBOCSQgmtmX7eVaB0s1+ppPW9w9a2zS45cHAtQ7tYvkkPv2dRhSzZdlk6HRXDP5wsF0aiflZCgbrjkq0SFC4e3Lo7XQX3FTNb0SOTZVTydupoMKkgJQTNlcosdu1ZzaIBl3eSkKkJZz2rUTssZC5tn9vcDd5vy3BzcGh5pvkgfAgN1sydqG7Ke1qCkNEzm11B/BsevatjjwIDAQABo0IwQDAMBgNVHRMEBTADAQH/MBEGCWCGSAGG+EIBAQQEAwIABzAdBgNVHQ4EFgQUCvHVQqerCid99eLApuLky9x6H5owDQYJKoZIhvcNAQEMBQADggGBAIzOyGV0hzsmH2biJlzwTZaHMxqS7boTFMkHw+KvzsI201tHqVmCoiQ8EHErBGLSoDOTDRgOUGOCA5XU5ie9OWupAGqKBSwIyAhmJMOzrzC4Gwpu8K1msoFJH30kx/V9purpbS3BRj0xfYXLa6IczbTg3E5IfTnZRJ9YuUtKQfI0P9c5U9CoKtddKn4+lRvOjFDoYfQGCJ7go3xjNCcGCVCjfkUhAVdbQ21DCRr6/YCZDWmjzZpL0p7UKF8roTiNuL/Z7gIXxch5HOmEWHY9uQ6K2MntuxAu0aK/mSD2kwmt/ECongdEGfUvhULLoPRQlQ2LnzcUQEgMECGQR5Yfy9jT0E8zdWDpc2tgVioNu6rEYKgp/GhG+sv7jv58pW82FRAV9xXtftW9+XDugC8tBJ6JHn0Q2v0QAflD2CEQVhWAY8bAqrbfTGUsaLfGL6kxV/qqssoMgLR8WhQ96T5le/4XGhQpbCHWIlctD6MwbrsunIAeQKp1Sc3DosY7DLq1MQ==falsefalse",
+ "Intel(r) AMT Certificate: Handle: 0",
+ func() (Response, error) {
+ X509Certificate := "MIIEOzCCAqOgAwIBAgIDAZMjMA0GCSqGSIb3DQEBDAUAMD0xFzAVBgNVBAMTDk1QU1Jvb3QtMGFmMWQ1MRAwDgYDVQQKEwd1bmtub3duMRAwDgYDVQQGEwd1bmtub3duMCAXDTIyMDkyNDEwNDUwOFoYDzIwNTMwOTI0MTA0NTA4WjA9MRcwFQYDVQQDEw5NUFNSb290LTBhZjFkNTEQMA4GA1UEChMHdW5rbm93bjEQMA4GA1UEBhMHdW5rbm93bjCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBALz/oJNyWXlClSlteAieC8Uyd4A+tbn8b45k6LKiImhDmdz/xFo9xe0C9GNf7b42KVpg5WoH/sPhoClR9Tv5i1LnilT1SUir42fcm2NEV9dRcLsPd/RAQfz8u0D4zb3blnxE8isqzriNpG7kac35UidSr5ym8TZ3IwXx6JJuncGgfB0DFZADC/+dA74n3coykvWBYqLr6RI5pkAxvulkRlCsatJTJrvMUYJ51GI28jV56mIAc89sLrHqiSKCZBH9AcUrnZ/cB6ST/IikXpxy5wXBIvWT3VKVq75T/uIoCBEp5TLEn1EOYGqBBOCSQgmtmX7eVaB0s1+ppPW9w9a2zS45cHAtQ7tYvkkPv2dRhSzZdlk6HRXDP5wsF0aiflZCgbrjkq0SFC4e3Lo7XQX3FTNb0SOTZVTydupoMKkgJQTNlcosdu1ZzaIBl3eSkKkJZz2rUTssZC5tn9vcDd5vy3BzcGh5pvkgfAgN1sydqG7Ke1qCkNEzm11B/BsevatjjwIDAQABo0IwQDAMBgNVHRMEBTADAQH/MBEGCWCGSAGG+EIBAQQEAwIABzAdBgNVHQ4EFgQUCvHVQqerCid99eLApuLky9x6H5owDQYJKoZIhvcNAQEMBQADggGBAIzOyGV0hzsmH2biJlzwTZaHMxqS7boTFMkHw+KvzsI201tHqVmCoiQ8EHErBGLSoDOTDRgOUGOCA5XU5ie9OWupAGqKBSwIyAhmJMOzrzC4Gwpu8K1msoFJH30kx/V9purpbS3BRj0xfYXLa6IczbTg3E5IfTnZRJ9YuUtKQfI0P9c5U9CoKtddKn4+lRvOjFDoYfQGCJ7go3xjNCcGCVCjfkUhAVdbQ21DCRr6/YCZDWmjzZpL0p7UKF8roTiNuL/Z7gIXxch5HOmEWHY9uQ6K2MntuxAu0aK/mSD2kwmt/ECongdEGfUvhULLoPRQlQ2LnzcUQEgMECGQR5Yfy9jT0E8zdWDpc2tgVioNu6rEYKgp/GhG+sv7jv58pW82FRAV9xXtftW9+XDugC8tBJ6JHn0Q2v0QAflD2CEQVhWAY8bAqrbfTGUsaLfGL6kxV/qqssoMgLR8WhQ96T5le/4XGhQpbCHWIlctD6MwbrsunIAeQKp1Sc3DosY7DLq1MQ=="
+ client.CurrentMessage = "Put"
+ return elementUnderTest.Put(0, X509Certificate)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PublicKeyCertificateGetAndPutResponse: PublicKeyCertificateResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyCertificate", Local: "AMT_PublicKeyCertificate"},
+ ElementName: "Intel(r) AMT Certificate",
+ InstanceID: "Intel(r) AMT Certificate: Handle: 0",
+ Issuer: "C=unknown,O=unknown,CN=MPSRoot-0af1d5",
+ Subject: "C=unknown,O=unknown,CN=MPSRoot-0af1d5",
+ TrustedRootCertificate: true,
+ X509Certificate: "MIIEOzCCAqOgAwIBAgIDAZMjMA0GCSqGSIb3DQEBDAUAMD0xFzAVBgNVBAMTDk1QU1Jvb3QtMGFmMWQ1MRAwDgYDVQQKEwd1bmtub3duMRAwDgYDVQQGEwd1bmtub3duMCAXDTIyMDkyNDEwNDUwOFoYDzIwNTMwOTI0MTA0NTA4WjA9MRcwFQYDVQQDEw5NUFNSb290LTBhZjFkNTEQMA4GA1UEChMHdW5rbm93bjEQMA4GA1UEBhMHdW5rbm93bjCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBALz/oJNyWXlClSlteAieC8Uyd4A+tbn8b45k6LKiImhDmdz/xFo9xe0C9GNf7b42KVpg5WoH/sPhoClR9Tv5i1LnilT1SUir42fcm2NEV9dRcLsPd/RAQfz8u0D4zb3blnxE8isqzriNpG7kac35UidSr5ym8TZ3IwXx6JJuncGgfB0DFZADC/+dA74n3coykvWBYqLr6RI5pkAxvulkRlCsatJTJrvMUYJ51GI28jV56mIAc89sLrHqiSKCZBH9AcUrnZ/cB6ST/IikXpxy5wXBIvWT3VKVq75T/uIoCBEp5TLEn1EOYGqBBOCSQgmtmX7eVaB0s1+ppPW9w9a2zS45cHAtQ7tYvkkPv2dRhSzZdlk6HRXDP5wsF0aiflZCgbrjkq0SFC4e3Lo7XQX3FTNb0SOTZVTydupoMKkgJQTNlcosdu1ZzaIBl3eSkKkJZz2rUTssZC5tn9vcDd5vy3BzcGh5pvkgfAgN1sydqG7Ke1qCkNEzm11B/BsevatjjwIDAQABo0IwQDAMBgNVHRMEBTADAQH/MBEGCWCGSAGG+EIBAQQEAwIABzAdBgNVHQ4EFgQUCvHVQqerCid99eLApuLky9x6H5owDQYJKoZIhvcNAQEMBQADggGBAIzOyGV0hzsmH2biJlzwTZaHMxqS7boTFMkHw+KvzsI201tHqVmCoiQ8EHErBGLSoDOTDRgOUGOCA5XU5ie9OWupAGqKBSwIyAhmJMOzrzC4Gwpu8K1msoFJH30kx/V9purpbS3BRj0xfYXLa6IczbTg3E5IfTnZRJ9YuUtKQfI0P9c5U9CoKtddKn4+lRvOjFDoYfQGCJ7go3xjNCcGCVCjfkUhAVdbQ21DCRr6/YCZDWmjzZpL0p7UKF8roTiNuL/Z7gIXxch5HOmEWHY9uQ6K2MntuxAu0aK/mSD2kwmt/ECongdEGfUvhULLoPRQlQ2LnzcUQEgMECGQR5Yfy9jT0E8zdWDpc2tgVioNu6rEYKgp/GhG+sv7jv58pW82FRAV9xXtftW9+XDugC8tBJ6JHn0Q2v0QAflD2CEQVhWAY8bAqrbfTGUsaLfGL6kxV/qqssoMgLR8WhQ96T5le/4XGhQpbCHWIlctD6MwbrsunIAeQKp1Sc3DosY7DLq1MQ==",
+ },
+ },
+ },
+ //DELETE
+ {
+ "should create a valid AMT_PublicKeyCertificate Delete wsman message",
+ AMT_PublicKeyCertificate,
+ wsmantesting.DELETE,
+ "",
+ "instanceID123",
+ func() (Response, error) {
+ client.CurrentMessage = "Delete"
+ return elementUnderTest.Delete("instanceID123")
+ },
+ Body{XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"}},
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, test.extraHeader, test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.NoError(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.Equal(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
+func TestNegativeAMT_PublicKeyCertificate(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/publickey/certificate",
+ }
+ elementUnderTest := NewPublicKeyCertificateWithClient(wsmanMessageCreator, &client)
+ t.Run("amt_PublicKeyCertificate Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ extraHeader string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create a valid AMT_PublicKeyCertificate Get wsman message",
+ AMT_PublicKeyCertificate,
+ wsmantesting.GET,
+ "",
+ "Intel(r) AMT Certificate: Handle: 0",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Get(0)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PublicKeyCertificateGetAndPutResponse: PublicKeyCertificateResponse{
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_PublicKeyCertificate), Local: "AMT_PublicKeyCertificate"},
+ ElementName: "Intel(r) AMT Certificate",
+ InstanceID: "Intel(r) AMT Certificate: Handle: 0",
+ Issuer: "C=unknown,O=unknown,CN=MPSRoot-0af1d5",
+ Subject: "C=unknown,O=unknown,CN=MPSRoot-0af1d5",
+ TrustedRootCertificate: true,
+ X509Certificate: "MIIEOzCCAqOgAwIBAgIDAZMjMA0GCSqGSIb3DQEBDAUAMD0xFzAVBgNVBAMTDk1QU1Jvb3QtMGFmMWQ1MRAwDgYDVQQKEwd1bmtub3duMRAwDgYDVQQGEwd1bmtub3duMCAXDTIyMDkyNDEwNDUwOFoYDzIwNTMwOTI0MTA0NTA4WjA9MRcwFQYDVQQDEw5NUFNSb290LTBhZjFkNTEQMA4GA1UEChMHdW5rbm93bjEQMA4GA1UEBhMHdW5rbm93bjCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBALz/oJNyWXlClSlteAieC8Uyd4A+tbn8b45k6LKiImhDmdz/xFo9xe0C9GNf7b42KVpg5WoH/sPhoClR9Tv5i1LnilT1SUir42fcm2NEV9dRcLsPd/RAQfz8u0D4zb3blnxE8isqzriNpG7kac35UidSr5ym8TZ3IwXx6JJuncGgfB0DFZADC/+dA74n3coykvWBYqLr6RI5pkAxvulkRlCsatJTJrvMUYJ51GI28jV56mIAc89sLrHqiSKCZBH9AcUrnZ/cB6ST/IikXpxy5wXBIvWT3VKVq75T/uIoCBEp5TLEn1EOYGqBBOCSQgmtmX7eVaB0s1+ppPW9w9a2zS45cHAtQ7tYvkkPv2dRhSzZdlk6HRXDP5wsF0aiflZCgbrjkq0SFC4e3Lo7XQX3FTNb0SOTZVTydupoMKkgJQTNlcosdu1ZzaIBl3eSkKkJZz2rUTssZC5tn9vcDd5vy3BzcGh5pvkgfAgN1sydqG7Ke1qCkNEzm11B/BsevatjjwIDAQABo0IwQDAMBgNVHRMEBTADAQH/MBEGCWCGSAGG+EIBAQQEAwIABzAdBgNVHQ4EFgQUCvHVQqerCid99eLApuLky9x6H5owDQYJKoZIhvcNAQEMBQADggGBAIzOyGV0hzsmH2biJlzwTZaHMxqS7boTFMkHw+KvzsI201tHqVmCoiQ8EHErBGLSoDOTDRgOUGOCA5XU5ie9OWupAGqKBSwIyAhmJMOzrzC4Gwpu8K1msoFJH30kx/V9purpbS3BRj0xfYXLa6IczbTg3E5IfTnZRJ9YuUtKQfI0P9c5U9CoKtddKn4+lRvOjFDoYfQGCJ7go3xjNCcGCVCjfkUhAVdbQ21DCRr6/YCZDWmjzZpL0p7UKF8roTiNuL/Z7gIXxch5HOmEWHY9uQ6K2MntuxAu0aK/mSD2kwmt/ECongdEGfUvhULLoPRQlQ2LnzcUQEgMECGQR5Yfy9jT0E8zdWDpc2tgVioNu6rEYKgp/GhG+sv7jv58pW82FRAV9xXtftW9+XDugC8tBJ6JHn0Q2v0QAflD2CEQVhWAY8bAqrbfTGUsaLfGL6kxV/qqssoMgLR8Whq96T5le/4XGhQpbCHWIlctD6MwbrsunIAeQKp1Sc3DosY7DLq1MQ==",
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create a valid AMT_PublicKeyCertificate Enumerate wsman message",
+ AMT_PublicKeyCertificate,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ if elementUnderTest.base.WSManMessageCreator == nil {
+ print("Error")
+ }
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "CB000000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid AMT_PublicKeyCertificate Pull wsman message",
+ AMT_PublicKeyCertificate,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: message.XMLPullResponseSpace, Local: "PullResponse"},
+ PublicKeyCertificateItems: []PublicKeyCertificateResponse{
+ {
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_PublicKeyCertificate), Local: "AMT_PublicKeyCertificate"},
+ ElementName: "Intel(r) AMT Certificate",
+ InstanceID: "Intel(r) AMT Certificate: Handle: 0",
+ Issuer: "C=unknown,O=unknown,CN=MPSRoot-0af1d5",
+ Subject: "C=unknown,O=unknown,CN=MPSRoot-0af1d5",
+ TrustedRootCertificate: true,
+ X509Certificate: "MIIEOzCCAqOgAwIBAgIDAZMjMA0GCSqGSIb3DQEBDAUAMD0xFzAVBgNVBAMTDk1QU1Jvb3QtMGFmMWQ1MRAwDgYDVQQKEwd1bmtub3duMRAwDgYDVQQGEwd1bmtub3duMCAXDTIyMDkyNDEwNDUwOFoYDzIwNTMwOTI0MTA0NTA4WjA9MRcwFQYDVQQDEw5NUFNSb290LTBhZjFkNTEQMA4GA1UEChMHdW5rbm93bjEQMA4GA1UEBhMHdW5rbm93bjCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBALz/oJNyWXlClSlteAieC8Uyd4A+tbn8b45k6LKiImhDmdz/xFo9xe0C9GNf7b42KVpg5WoH/sPhoClR9Tv5i1LnilT1SUir42fcm2NEV9dRcLsPd/RAQfz8u0D4zb3blnxE8isqzriNpG7kac35UidSr5ym8TZ3IwXx6JJuncGgfB0DFZADC/+dA74n3coykvWBYqLr6RI5pkAxvulkRlCsatJTJrvMUYJ51GI28jV56mIAc89sLrHqiSKCZBH9AcUrnZ/cB6ST/IikXpxy5wXBIvWT3VKVq75T/uIoCBEp5TLEn1EOYGqBBOCSQgmtmX7eVaB0s1+ppPW9w9a2zS45cHAtQ7tYvkkPv2dRhSzZdlk6HRXDP5wsF0aiflZCgbrjkq0SFC4e3Lo7XQX3FTNb0SOTZVTydupoMKkgJQTNlcosdu1ZzaIBl3eSkKkJZz2rUTssZC5tn9vcDd5vy3BzcGh5pvkgfAgN1sydqG7Ke1qCkNEzm11B/BsevatjjwIDAQABo0IwQDAMBgNVHRMEBTADAQH/MBEGCWCGSAGG+EIBAQQEAwIABzAdBgNVHQ4EFgQUCvHVQqerCid99eLApuLky9x6H5owDQYJKoZIhvcNAQEMBQADggGBAIzOyGV0hzsmH2biJlzwTZaHMxqS7boTFMkHw+KvzsI201tHqVmCoiQ8EHErBGLSoDOTDRgOUGOCA5XU5ie9OWupAGqKBSwIyAhmJMOzrzC4Gwpu8K1msoFJH30kx/V9purpbS3BRj0xfYXLa6IczbTg3E5IfTnZRJ9YuUtKQfI0P9c5U9CoKtddKn4+lRvOjFDoYfQGCJ7go3xjNCcGCVCjfkUhAVdbQ21DCRr6/YCZDWmjzZpL0p7UKF8roTiNuL/Z7gIXxch5HOmEWHY9uQ6K2MntuxAu0aK/mSD2kwmt/ECongdEGfUvhULLoPRQlQ2LnzcUQEgMECGQR5Yfy9jT0E8zdWDpc2tgVioNu6rEYKgp/GhG+sv7jv58pW82FRAV9xXtftW9+XDugC8tBJ6JHn0Q2v0QAflD2CEQVhWAY8bAqrbfTGUsaLfGL6kxV/qqssoMgLR8WhQ96T5le/4XGhQpbCHWIlctD6MwbrsunIAeQKp1Sc3DosY7DLq1MQ==",
+ },
+ {
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_PublicKeyCertificate), Local: "AMT_PublicKeyCertificate"},
+ ElementName: "Intel(r) AMT Certificate",
+ InstanceID: "Intel(r) AMT Certificate: Handle: 1",
+ Issuer: "C=unknown,O=unknown,CN=MPSRoot-0af1d5",
+ Subject: "C=unknown,O=unknown,CN=MPSRoot-0af1d5",
+ TrustedRootCertificate: false,
+ X509Certificate: "MIIEOzCCAqOgAwIBAgIDAZMjMA0GCSqGSIb3DQEBDAUAMD0xFzAVBgNVBAMTDk1QU1Jvb3QtMGFmMWQ1MRAwDgYDVQQKEwd1bmtub3duMRAwDgYDVQQGEwd1bmtub3duMCAXDTIyMDkyNDEwNDUwOFoYDzIwNTMwOTI0MTA0NTA4WjA9MRcwFQYDVQQDEw5NUFNSb290LTBhZjFkNTEQMA4GA1UEChMHdW5rbm93bjEQMA4GA1UEBhMHdW5rbm93bjCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBALz/oJNyWXlClSlteAieC8Uyd4A+tbn8b45k6LKiImhDmdz/xFo9xe0C9GNf7b42KVpg5WoH/sPhoClR9Tv5i1LnilT1SUir42fcm2NEV9dRcLsPd/RAQfz8u0D4zb3blnxE8isqzriNpG7kac35UidSr5ym8TZ3IwXx6JJuncGgfB0DFZADC/+dA74n3coykvWBYqLr6RI5pkAxvulkRlCsatJTJrvMUYJ51GI28jV56mIAc89sLrHqiSKCZBH9AcUrnZ/cB6ST/IikXpxy5wXBIvWT3VKVq75T/uIoCBEp5TLEn1EOYGqBBOCSQgmtmX7eVaB0s1+ppPW9w9a2zS45cHAtQ7tYvkkPv2dRhSzZdlk6HRXDP5wsF0aiflZCgbrjkq0SFC4e3Lo7XQX3FTNb0SOTZVTydupoMKkgJQTNlcosdu1ZzaIBl3eSkKkJZz2rUTssZC5tn9vcDd5vy3BzcGh5pvkgfAgN1sydqG7Ke1qCkNEzm11B/BsevatjjwIDAQABo0IwQDAMBgNVHRMEBTADAQH/MBEGCWCGSAGG+EIBAQQEAwIABzAdBgNVHQ4EFgQUCvHVQqerCid99eLApuLky9x6H5owDQYJKoZIhvcNAQEMBQADggGBAIzOyGV0hzsmH2biJlzwTZaHMxqS7boTFMkHw+KvzsI201tHqVmCoiQ8EHErBGLSoDOTDRgOUGOCA5XU5ie9OWupAGqKBSwIyAhmJMOzrzC4Gwpu8K1msoFJH30kx/V9purpbS3BRj0xfYXLa6IczbTg3E5IfTnZRJ9YuUtKQfI0P9c5U9CoKtddKn4+lRvOjFDoYfQGCJ7go3xjNCcGCVCjfkUhAVdbQ21DCRr6/YCZDWmjzZpL0p7UKF8roTiNuL/Z7gIXxch5HOmEWHY9uQ6K2MntuxAu0aK/mSD2kwmt/ECongdEGfUvhULLoPRQlQ2LnzcUQEgMECGQR5Yfy9jT0E8zdWDpc2tgVioNu6rEYKgp/GhG+sv7jv58pW82FRAV9xXtftW9+XDugC8tBJ6JHn0Q2v0QAflD2CEQVhWAY8bAqrbfTGUsaLfGL6kxV/qqssoMgLR8Whq96T5le/4XGhQpbCHWIlctD6MwbrsunIAeQKp1Sc3DosY7DLq1MQ==",
+ },
+ {
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_PublicKeyCertificate), Local: "AMT_PublicKeyCertificate"},
+ ElementName: "Intel(r) AMT Certificate",
+ InstanceID: "Intel(r) AMT Certificate: Handle: 2",
+ Issuer: "C=unknown,O=unknown,CN=MPSRoot-0af1d5",
+ Subject: "C=unknown,O=unknown,CN=MPSRoot-0af1d5",
+ TrustedRootCertificate: true,
+ X509Certificate: "MIIEOzCCAqOgAwIBAgIDAZMjMA0GCSqGSIb3DQEBDAUAMD0xFzAVBgNVBAMTDk1QU1Jvb3QtMGFmMWQ1MRAwDgYDVQQKEwd1bmtub3duMRAwDgYDVQQGEwd1bmtub3duMCAXDTIyMDkyNDEwNDUwOFoYDzIwNTMwOTI0MTA0NTA4WjA9MRcwFQYDVQQDEw5NUFNSb290LTBhZjFkNTEQMA4GA1UEChMHdW5rbm93bjEQMA4GA1UEBhMHdW5rbm93bjCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBALz/oJNyWXlClSlteAieC8Uyd4A+tbn8b45k6LKiImhDmdz/xFo9xe0C9GNf7b42KVpg5WoH/sPhoClR9Tv5i1LnilT1SUir42fcm2NEV9dRcLsPd/RAQfz8u0D4zb3blnxE8isqzriNpG7kac35UidSr5ym8TZ3IwXx6JJuncGgfB0DFBADC/+dA74n3coykvWBYqLr6RI5pkAxvulkRlCsatJTJrvMUYJ51GI28jV56mIAc89sLrHqiSKCZBH9AcUrnZ/cB6ST/IikXpxy5wXBIvWT3VKVq75T/uIoCBEp5TLEn1EOYGqBBOCSQgmtmX7eVaB0s1+ppPW9w9a2zS45cHAtQ7tYvkkPv2dRhSzZdlk6HRXDP5wsF0aiflZCgbrjkq0SFC4e3Lo7XQX3FTNb0SOTZVTydupoMKkgJQTNlcosdu1ZzaIBl3eSkKkJZz2rUTssZC5tn9vcDd5vy3BzcGh5pvkgfAgN1sydqG7Ke1qCkNEzm11B/BsevatjjwIDAQABo0IwQDAMBgNVHRMEBTADAQH/MBEGCWCGSAGG+EIBAQQEAwIABzAdBgNVHQ4EFgQUCvHVQqerCid99eLApuLky9x6H5owDQYJKoZIhvcNAQEMBQADggGBAIzOyGV0hzsmH2biJlzwTZaHMxqS7boTFMkHw+KvzsI201tHqVmCoiQ8EHErBGLSoDOTDRgOUGOCA5XU5ie9OWupAGqKBSwIyAhmJMOzrzC4Gwpu8K1msoFJH30kx/V9purpbS3BRj0xfYXLa6IczbTg3E5IfTnZRJ9YuUtKQfI0P9c5U9CoKtddKn4+lRvOjFDoYfQGCJ7go3xjNCcGCVCjfkUhAVdbQ21DCRr6/YCZDWmjzZpL0p7UKF8roTiNuL/Z7gIXxch5HOmEWHY9uQ6K2MntuxAu0aK/mSD2kwmt/ECongdEGfUvhULLoPRQlQ2LnzcUQEgMECGQR5Yfy9jT0E8zdWDpc2tgVioNu6rEYKgp/GhG+sv7jv58pW82FRAV9xXtftW9+XDugC8tBJ6JHn0Q2v0QAflD2CEQVhWAY8bAqrbfTGUsaLfGL6kxV/qqssoMgLR8Whq96T5le/4XGhQpbCHWIlctD6MwbrsunIAeQKp1Sc3DosY7DLq1MQ==",
+ },
+ },
+ },
+ },
+ },
+
+ //PUTS
+ {
+ "should create a valid AMT_PublicKeyCertificate Put wsman message",
+ AMT_PublicKeyCertificate,
+ wsmantesting.PUT,
+ "MIIEOzCCAqOgAwIBAgIDAZMjMA0GCSqGSIb3DQEBDAUAMD0xFzAVBgNVBAMTDk1QU1Jvb3QtMGFmMWQ1MRAwDgYDVQQKEwd1bmtub3duMRAwDgYDVQQGEwd1bmtub3duMCAXDTIyMDkyNDEwNDUwOFoYDzIwNTMwOTI0MTA0NTA4WjA9MRcwFQYDVQQDEw5NUFNSb290LTBhZjFkNTEQMA4GA1UEChMHdW5rbm93bjEQMA4GA1UEBhMHdW5rbm93bjCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBALz/oJNyWXlClSlteAieC8Uyd4A+tbn8b45k6LKiImhDmdz/xFo9xe0C9GNf7b42KVpg5WoH/sPhoClR9Tv5i1LnilT1SUir42fcm2NEV9dRcLsPd/RAQfz8u0D4zb3blnxE8isqzriNpG7kac35UidSr5ym8TZ3IwXx6JJuncGgfB0DFZADC/+dA74n3coykvWBYqLr6RI5pkAxvulkRlCsatJTJrvMUYJ51GI28jV56mIAc89sLrHqiSKCZBH9AcUrnZ/cB6ST/IikXpxy5wXBIvWT3VKVq75T/uIoCBEp5TLEn1EOYGqBBOCSQgmtmX7eVaB0s1+ppPW9w9a2zS45cHAtQ7tYvkkPv2dRhSzZdlk6HRXDP5wsF0aiflZCgbrjkq0SFC4e3Lo7XQX3FTNb0SOTZVTydupoMKkgJQTNlcosdu1ZzaIBl3eSkKkJZz2rUTssZC5tn9vcDd5vy3BzcGh5pvkgfAgN1sydqG7Ke1qCkNEzm11B/BsevatjjwIDAQABo0IwQDAMBgNVHRMEBTADAQH/MBEGCWCGSAGG+EIBAQQEAwIABzAdBgNVHQ4EFgQUCvHVQqerCid99eLApuLky9x6H5owDQYJKoZIhvcNAQEMBQADggGBAIzOyGV0hzsmH2biJlzwTZaHMxqS7boTFMkHw+KvzsI201tHqVmCoiQ8EHErBGLSoDOTDRgOUGOCA5XU5ie9OWupAGqKBSwIyAhmJMOzrzC4Gwpu8K1msoFJH30kx/V9purpbS3BRj0xfYXLa6IczbTg3E5IfTnZRJ9YuUtKQfI0P9c5U9CoKtddKn4+lRvOjFDoYfQGCJ7go3xjNCcGCVCjfkUhAVdbQ21DCRr6/YCZDWmjzZpL0p7UKF8roTiNuL/Z7gIXxch5HOmEWHY9uQ6K2MntuxAu0aK/mSD2kwmt/ECongdEGfUvhULLoPRQlQ2LnzcUQEgMECGQR5Yfy9jT0E8zdWDpc2tgVioNu6rEYKgp/GhG+sv7jv58pW82FRAV9xXtftW9+XDugC8tBJ6JHn0Q2v0QAflD2CEQVhWAY8bAqrbfTGUsaLfGL6kxV/qqssoMgLR8WhQ96T5le/4XGhQpbCHWIlctD6MwbrsunIAeQKp1Sc3DosY7DLq1MQ==falsefalse",
+ "Intel(r) AMT Certificate: Handle: 0",
+ func() (Response, error) {
+ X509Certificate := "MIIEOzCCAqOgAwIBAgIDAZMjMA0GCSqGSIb3DQEBDAUAMD0xFzAVBgNVBAMTDk1QU1Jvb3QtMGFmMWQ1MRAwDgYDVQQKEwd1bmtub3duMRAwDgYDVQQGEwd1bmtub3duMCAXDTIyMDkyNDEwNDUwOFoYDzIwNTMwOTI0MTA0NTA4WjA9MRcwFQYDVQQDEw5NUFNSb290LTBhZjFkNTEQMA4GA1UEChMHdW5rbm93bjEQMA4GA1UEBhMHdW5rbm93bjCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBALz/oJNyWXlClSlteAieC8Uyd4A+tbn8b45k6LKiImhDmdz/xFo9xe0C9GNf7b42KVpg5WoH/sPhoClR9Tv5i1LnilT1SUir42fcm2NEV9dRcLsPd/RAQfz8u0D4zb3blnxE8isqzriNpG7kac35UidSr5ym8TZ3IwXx6JJuncGgfB0DFZADC/+dA74n3coykvWBYqLr6RI5pkAxvulkRlCsatJTJrvMUYJ51GI28jV56mIAc89sLrHqiSKCZBH9AcUrnZ/cB6ST/IikXpxy5wXBIvWT3VKVq75T/uIoCBEp5TLEn1EOYGqBBOCSQgmtmX7eVaB0s1+ppPW9w9a2zS45cHAtQ7tYvkkPv2dRhSzZdlk6HRXDP5wsF0aiflZCgbrjkq0SFC4e3Lo7XQX3FTNb0SOTZVTydupoMKkgJQTNlcosdu1ZzaIBl3eSkKkJZz2rUTssZC5tn9vcDd5vy3BzcGh5pvkgfAgN1sydqG7Ke1qCkNEzm11B/BsevatjjwIDAQABo0IwQDAMBgNVHRMEBTADAQH/MBEGCWCGSAGG+EIBAQQEAwIABzAdBgNVHQ4EFgQUCvHVQqerCid99eLApuLky9x6H5owDQYJKoZIhvcNAQEMBQADggGBAIzOyGV0hzsmH2biJlzwTZaHMxqS7boTFMkHw+KvzsI201tHqVmCoiQ8EHErBGLSoDOTDRgOUGOCA5XU5ie9OWupAGqKBSwIyAhmJMOzrzC4Gwpu8K1msoFJH30kx/V9purpbS3BRj0xfYXLa6IczbTg3E5IfTnZRJ9YuUtKQfI0P9c5U9CoKtddKn4+lRvOjFDoYfQGCJ7go3xjNCcGCVCjfkUhAVdbQ21DCRr6/YCZDWmjzZpL0p7UKF8roTiNuL/Z7gIXxch5HOmEWHY9uQ6K2MntuxAu0aK/mSD2kwmt/ECongdEGfUvhULLoPRQlQ2LnzcUQEgMECGQR5Yfy9jT0E8zdWDpc2tgVioNu6rEYKgp/GhG+sv7jv58pW82FRAV9xXtftW9+XDugC8tBJ6JHn0Q2v0QAflD2CEQVhWAY8bAqrbfTGUsaLfGL6kxV/qqssoMgLR8WhQ96T5le/4XGhQpbCHWIlctD6MwbrsunIAeQKp1Sc3DosY7DLq1MQ=="
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Put(0, X509Certificate)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PublicKeyCertificateGetAndPutResponse: PublicKeyCertificateResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyCertificate", Local: "AMT_PublicKeyCertificate"},
+ ElementName: "Intel(r) AMT Certificate",
+ InstanceID: "Intel(r) AMT Certificate: Handle: 0",
+ Issuer: "C=unknown,O=unknown,CN=MPSRoot-0af1d5",
+ Subject: "C=unknown,O=unknown,CN=MPSRoot-0af1d5",
+ TrustedRootCertificate: true,
+ X509Certificate: "MIIEOzCCAqOgAwIBAgIDAZMjMA0GCSqGSIb3DQEBDAUAMD0xFzAVBgNVBAMTDk1QU1Jvb3QtMGFmMWQ1MRAwDgYDVQQKEwd1bmtub3duMRAwDgYDVQQGEwd1bmtub3duMCAXDTIyMDkyNDEwNDUwOFoYDzIwNTMwOTI0MTA0NTA4WjA9MRcwFQYDVQQDEw5NUFNSb290LTBhZjFkNTEQMA4GA1UEChMHdW5rbm93bjEQMA4GA1UEBhMHdW5rbm93bjCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBALz/oJNyWXlClSlteAieC8Uyd4A+tbn8b45k6LKiImhDmdz/xFo9xe0C9GNf7b42KVpg5WoH/sPhoClR9Tv5i1LnilT1SUir42fcm2NEV9dRcLsPd/RAQfz8u0D4zb3blnxE8isqzriNpG7kac35UidSr5ym8TZ3IwXx6JJuncGgfB0DFZADC/+dA74n3coykvWBYqLr6RI5pkAxvulkRlCsatJTJrvMUYJ51GI28jV56mIAc89sLrHqiSKCZBH9AcUrnZ/cB6ST/IikXpxy5wXBIvWT3VKVq75T/uIoCBEp5TLEn1EOYGqBBOCSQgmtmX7eVaB0s1+ppPW9w9a2zS45cHAtQ7tYvkkPv2dRhSzZdlk6HRXDP5wsF0aiflZCgbrjkq0SFC4e3Lo7XQX3FTNb0SOTZVTydupoMKkgJQTNlcosdu1ZzaIBl3eSkKkJZz2rUTssZC5tn9vcDd5vy3BzcGh5pvkgfAgN1sydqG7Ke1qCkNEzm11B/BsevatjjwIDAQABo0IwQDAMBgNVHRMEBTADAQH/MBEGCWCGSAGG+EIBAQQEAwIABzAdBgNVHQ4EFgQUCvHVQqerCid99eLApuLky9x6H5owDQYJKoZIhvcNAQEMBQADggGBAIzOyGV0hzsmH2biJlzwTZaHMxqS7boTFMkHw+KvzsI201tHqVmCoiQ8EHErBGLSoDOTDRgOUGOCA5XU5ie9OWupAGqKBSwIyAhmJMOzrzC4Gwpu8K1msoFJH30kx/V9purpbS3BRj0xfYXLa6IczbTg3E5IfTnZRJ9YuUtKQfI0P9c5U9CoKtddKn4+lRvOjFDoYfQGCJ7go3xjNCcGCVCjfkUhAVdbQ21DCRr6/YCZDWmjzZpL0p7UKF8roTiNuL/Z7gIXxch5HOmEWHY9uQ6K2MntuxAu0aK/mSD2kwmt/ECongdEGfUvhULLoPRQlQ2LnzcUQEgMECGQR5Yfy9jT0E8zdWDpc2tgVioNu6rEYKgp/GhG+sv7jv58pW82FRAV9xXtftW9+XDugC8tBJ6JHn0Q2v0QAflD2CEQVhWAY8bAqrbfTGUsaLfGL6kxV/qqssoMgLR8WhQ96T5le/4XGhQpbCHWIlctD6MwbrsunIAeQKp1Sc3DosY7DLq1MQ==",
+ },
+ },
+ },
+ //DELETE
+ {
+ "should create a valid AMT_PublicKeyCertificate Delete wsman message",
+ AMT_PublicKeyCertificate,
+ wsmantesting.DELETE,
+ "",
+ "instanceID123",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Delete("instanceID123")
+ },
+ Body{XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"}},
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, test.extraHeader, test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.Error(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.NotEqual(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
diff --git a/pkg/wsman/amt/publickey/constants.go b/pkg/wsman/amt/publickey/constants.go
new file mode 100644
index 00000000..21078349
--- /dev/null
+++ b/pkg/wsman/amt/publickey/constants.go
@@ -0,0 +1,67 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package publickey
+
+const (
+ AMT_PublicKeyCertificate string = "AMT_PublicKeyCertificate"
+ AMT_PublicKeyManagementService string = "AMT_PublicKeyManagementService"
+ GeneratePKCS10RequestEx string = "GeneratePKCS10RequestEx"
+ AddTrustedRootCertificate string = "AddTrustedRootCertificate"
+ AddCertificate string = "AddCertificate"
+ GenerateKeyPair string = "GenerateKeyPair"
+ AddKey string = "AddKey"
+)
+
+const (
+ RSA KeyAlgorithm = 0
+)
+
+const (
+ KeyLength2048 KeyLength = 2048
+)
+
+const (
+ SHA1RSA SigningAlgorithm = iota
+ SHA256RSA
+)
+
+const (
+ EnabledDefaultEnabled EnabledDefault = 2
+ EnabledDefaultDisabled EnabledDefault = 3
+ EnabledDefaultNotApplicable EnabledDefault = 5
+ EnabledDefaultEnabledbutOffline EnabledDefault = 6
+ EnabledDefaultNoDefault EnabledDefault = 7
+ EnabledDefaultQuiesce EnabledDefault = 9
+)
+
+const (
+ RequestedStateUnknown RequestedState = 0
+ RequestedStateEnabled RequestedState = 2
+ RequestedStateDisabled RequestedState = 3
+ RequestedStateShutDown RequestedState = 4
+ RequestedStateNoChange RequestedState = 5
+ RequestedStateOffline RequestedState = 6
+ RequestedStateTest RequestedState = 7
+ RequestedStateDeferred RequestedState = 8
+ RequestedStateQuiesce RequestedState = 9
+ RequestedStateReboot RequestedState = 10
+ RequestedStateReset RequestedState = 11
+ RequestedStateNotApplicable RequestedState = 12
+)
+
+const (
+ EnabledStateUnknown EnabledState = iota
+ EnabledStateOther
+ EnabledStateEnabled
+ EnabledStateDisabled
+ EnabledStateShuttingDown
+ EnabledStateNotApplicable
+ EnabledStateEnabledbutOffline
+ EnabledStateInTest
+ EnabledStateDeferred
+ EnabledStateQuiesce
+ EnabledStateStarting
+)
diff --git a/pkg/wsman/amt/publickey/managementservice.go b/pkg/wsman/amt/publickey/managementservice.go
new file mode 100644
index 00000000..a7d59a3c
--- /dev/null
+++ b/pkg/wsman/amt/publickey/managementservice.go
@@ -0,0 +1,282 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package publickey
+
+import (
+ "encoding/xml"
+ "errors"
+ "fmt"
+ "strconv"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/methods"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+)
+
+// NewPublicKeyManagementServiceWithClient instantiates a new ManagementService
+func NewPublicKeyManagementServiceWithClient(wsmanMessageCreator *message.WSManMessageCreator, client client.WSMan) ManagementService {
+ return ManagementService{
+ base: message.NewBaseWithClient(wsmanMessageCreator, AMT_PublicKeyManagementService, client),
+ }
+}
+
+// Get retrieves the representation of the instance
+func (managementService ManagementService) Get() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: managementService.base.Get(nil),
+ },
+ }
+ // send the message to AMT
+ err = managementService.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Enumerate returns an enumeration context which is used in a subsequent Pull call
+func (managementService ManagementService) Enumerate() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: managementService.base.Enumerate(),
+ },
+ }
+ // send the message to AMT
+ err = managementService.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Pull returns the instances of this class. An enumeration context provided by the Enumerate call is used as input.
+func (managementService ManagementService) Pull(enumerationContext string) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: managementService.base.Pull(enumerationContext),
+ },
+ }
+ // send the message to AMT
+ err = managementService.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Delete removes a the specified instance
+func (managementService ManagementService) Delete(instanceID string) (response Response, err error) {
+ selector := message.Selector{Name: "InstanceID", Value: instanceID}
+ response = Response{
+ Message: &client.Message{
+ XMLInput: managementService.base.Delete(selector),
+ },
+ }
+ // send the message to AMT
+ err = managementService.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+//unittest
+// func TestCheckReturnValue(t *testing.T) {
+// tests := []struct {
+// name string
+// in error
+// item string
+// want error
+// }{
+// {"TestNoError", 0, "item", nil},
+// {"TestAlreadyExists", common.PT_STATUS_DUPLICATE, "item", utils.AmtPtStatusCodeBase + common.PT_STATUS_DUPLICATE},
+// {"TestInvalidItem", common.PT_STATUS_INVALID_CERT, "item", utils.AmtPtStatusCodeBase + common.PT_STATUS_INVALID_CERT},
+// {"TestNonZeroReturnCode", 2082, "item", utils.AmtPtStatusCodeBase + 2082},
+// }
+
+// for _, tt := range tests {
+// t.Run(tt.name, func(t *testing.T) {
+// got := checkReturnValue(tt.in, tt.item)
+// assert.Equal(t, tt.want, got)
+// })
+// }
+// }
+func checkReturnValue(rc int, item string) (err error) {
+ if rc != common.PT_STATUS_SUCCESS {
+ if rc == common.PT_STATUS_DUPLICATE {
+ return errors.New(item + " already exists and must be removed before continuing")
+ } else if rc == common.PT_STATUS_INVALID_CERT {
+ return errors.New(item + " is invalid")
+ } else {
+ return errors.New(item + " non-zero return code: " + strconv.Itoa(rc))
+ }
+ }
+ return nil
+}
+
+// This function adds new certificate to the Intel® AMT CertStore. A certificate cannot be removed if it is referenced (for example, used by TLS, 802.1X or EAC).
+func (managementService ManagementService) AddCertificate(certificateBlob string) (response Response, err error) {
+ header := managementService.base.WSManMessageCreator.CreateHeader(methods.GenerateAction(AMT_PublicKeyManagementService, AddCertificate), AMT_PublicKeyManagementService, nil, "", "")
+ certificate := AddCertificate_INPUT{
+ H: fmt.Sprintf("%s%s", message.AMTSchema, AMT_PublicKeyManagementService),
+ CertificateBlob: certificateBlob,
+ }
+ body := managementService.base.WSManMessageCreator.CreateBody(methods.GenerateInputMethod(AddCertificate), AMT_PublicKeyManagementService, &certificate)
+ response = Response{
+ Message: &client.Message{
+ XMLInput: managementService.base.WSManMessageCreator.CreateXML(header, body),
+ },
+ }
+ // send the message to AMT
+ err = managementService.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ err = checkReturnValue(response.Body.AddCertificate_OUTPUT.ReturnValue, "Client Certificate")
+ return
+}
+
+// This function adds new root certificate to the Intel® AMT CertStore. A certificate cannot be removed if it is referenced (for example, used by TLS, 802.1X or EAC).
+func (managementService ManagementService) AddTrustedRootCertificate(certificateBlob string) (response Response, err error) {
+ header := managementService.base.WSManMessageCreator.CreateHeader(methods.GenerateAction(AMT_PublicKeyManagementService, AddTrustedRootCertificate), AMT_PublicKeyManagementService, nil, "", "")
+ trustedRootCert := AddTrustedRootCertificate_INPUT{
+ H: fmt.Sprintf("%s%s", message.AMTSchema, AMT_PublicKeyManagementService),
+ CertificateBlob: certificateBlob,
+ }
+ body := managementService.base.WSManMessageCreator.CreateBody(methods.GenerateInputMethod(AddTrustedRootCertificate), AMT_PublicKeyManagementService, &trustedRootCert)
+
+ response = Response{
+ Message: &client.Message{
+ XMLInput: managementService.base.WSManMessageCreator.CreateXML(header, body),
+ },
+ }
+ // send the message to AMT
+ err = managementService.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ err = checkReturnValue(response.Body.AddTrustedRootCertificate_OUTPUT.ReturnValue, "Root Certificate")
+
+ return
+}
+
+// This API is used to generate a key in the FW
+func (managementService ManagementService) GenerateKeyPair(keyAlgorithm KeyAlgorithm, keyLength KeyLength) (response Response, err error) {
+ header := managementService.base.WSManMessageCreator.CreateHeader(methods.GenerateAction(AMT_PublicKeyManagementService, GenerateKeyPair), AMT_PublicKeyManagementService, nil, "", "")
+ generateKeyPair := GenerateKeyPair_INPUT{
+ H: fmt.Sprintf("%s%s", message.AMTSchema, AMT_PublicKeyManagementService),
+ KeyAlgorithm: keyAlgorithm,
+ KeyLength: keyLength,
+ }
+ body := managementService.base.WSManMessageCreator.CreateBody(methods.GenerateInputMethod(GenerateKeyPair), AMT_PublicKeyManagementService, &generateKeyPair)
+ response = Response{
+ Message: &client.Message{
+ XMLInput: managementService.base.WSManMessageCreator.CreateXML(header, body),
+ },
+ }
+ // send the message to AMT
+ err = managementService.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ err = checkReturnValue(response.Body.AddKey_OUTPUT.ReturnValue, "Private Key")
+
+ return
+}
+
+// This API is used to create a PKCS#10 certificate signing request based on a key from the key store.
+func (managementService ManagementService) GeneratePKCS10RequestEx(keyPair, nullSignedCertificateRequest string, signingAlgorithm SigningAlgorithm) (response Response, err error) {
+ header := managementService.base.WSManMessageCreator.CreateHeader(methods.GenerateAction(AMT_PublicKeyManagementService, GeneratePKCS10RequestEx), AMT_PublicKeyManagementService, nil, "", "")
+ pkcs10Request := PKCS10Request{
+ H: fmt.Sprintf("%s%s", message.AMTSchema, AMT_PublicKeyManagementService),
+ KeyPair: keyPair,
+ NullSignedCertificateRequest: nullSignedCertificateRequest,
+ SigningAlgorithm: signingAlgorithm,
+ }
+ body := managementService.base.WSManMessageCreator.CreateBody(methods.GenerateInputMethod(GeneratePKCS10RequestEx), AMT_PublicKeyManagementService, &pkcs10Request)
+ response = Response{
+ Message: &client.Message{
+ XMLInput: managementService.base.WSManMessageCreator.CreateXML(header, body),
+ },
+ }
+ // send the message to AMT
+ err = managementService.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// This function adds new certificate key to the Intel® AMT CertStore. A key cannot be removed if its corresponding certificate is referenced (for example, used by TLS, 802.1X or EAC).
+// After the method succeeds, a new instance of AMT_PublicPrivateKeyPair will be created.
+// Possible return values are: PT_STATUS_SUCCESS(0), PT_STATUS_INTERNAL_ERROR(1), PT_STATUS_MAX_LIMIT_REACHED(23),
+// PT_STATUS_FLASH_WRITE_LIMIT_EXCEEDED(38), PT_STATUS_DUPLICATE(2068), PT_STATUS_INVALID_KEY(2062).
+func (managementService ManagementService) AddKey(keyBlob string) (response Response, err error) {
+ header := managementService.base.WSManMessageCreator.CreateHeader(methods.GenerateAction(AMT_PublicKeyManagementService, AddKey), AMT_PublicKeyManagementService, nil, "", "")
+ params := &AddKey_INPUT{
+ H: fmt.Sprintf("%s%s", message.AMTSchema, AMT_PublicKeyManagementService),
+ KeyBlob: keyBlob,
+ }
+ body := managementService.base.WSManMessageCreator.CreateBody(methods.GenerateInputMethod(AddKey), AMT_PublicKeyManagementService, params)
+ response = Response{
+ Message: &client.Message{
+ XMLInput: managementService.base.WSManMessageCreator.CreateXML(header, body),
+ },
+ }
+ // send the message to AMT
+ err = managementService.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
diff --git a/pkg/wsman/amt/publickey/managementservice_test.go b/pkg/wsman/amt/publickey/managementservice_test.go
new file mode 100644
index 00000000..3507e365
--- /dev/null
+++ b/pkg/wsman/amt/publickey/managementservice_test.go
@@ -0,0 +1,586 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package publickey
+
+import (
+ "encoding/xml"
+ "fmt"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
+)
+
+const (
+ EnvelopeResponseService = `http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous0`
+ GetBodyService = `AMT_PublicKeyManagementServiceIntel(r) AMT Public Key Management ServiceIntel(r) AMT Public Key Management ServiceCIM_ComputerSystemManagedSystem`
+)
+
+func TestPositiveAMT_PublicKeyManagementService(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/publickey/management",
+ }
+ elementUnderTest := NewPublicKeyManagementServiceWithClient(wsmanMessageCreator, &client)
+ t.Run("amt_PublicKeyManagementService Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ extraHeader string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create a valid AMT_PublicKeyManagementService Get wsman message",
+ AMT_PublicKeyManagementService,
+ wsmantesting.GET,
+ "",
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Get"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ KeyManagementGetResponse: KeyManagementResponse{
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_PublicKeyManagementService), Local: AMT_PublicKeyManagementService},
+ CreationClassName: "AMT_PublicKeyManagementService",
+ ElementName: "Intel(r) AMT Certificate Store Service",
+ EnabledDefault: 5,
+ EnabledState: 5,
+ Name: "Intel(r) AMT Public Key Management Service",
+ RequestedState: 12,
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "Intel(r) AMT",
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create a valid AMT_PublicKeyManagementService Enumerate wsman message",
+ AMT_PublicKeyManagementService,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Enumerate"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "7E000000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid AMT_PublicKeyManagementService Pull wsman message",
+ AMT_PublicKeyManagementService,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Pull"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: message.XMLPullResponseSpace, Local: "PullResponse"},
+ KeyManagementItems: []KeyManagementResponse{
+ {
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_PublicKeyManagementService), Local: AMT_PublicKeyManagementService},
+ CreationClassName: "AMT_PublicKeyManagementService",
+ ElementName: "Intel(r) AMT Certificate Store Service",
+ EnabledDefault: 5,
+ EnabledState: 5,
+ Name: "Intel(r) AMT Public Key Management Service",
+ RequestedState: 12,
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "Intel(r) AMT",
+ },
+ },
+ },
+ },
+ },
+
+ // AddTrustedRootCertificate
+ {
+ "should return a valid amt_PublicKeyManagementService AddTrustedRootCertificate wsman message",
+ AMT_PublicKeyManagementService,
+ `http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyManagementService/AddTrustedRootCertificate`,
+ fmt.Sprintf(`%s`, wsmantesting.TrustedRootCert),
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "AddTrustedRootCertificate"
+ return elementUnderTest.AddTrustedRootCertificate(wsmantesting.TrustedRootCert)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ AddTrustedRootCertificate_OUTPUT: AddTrustedRootCertificate_OUTPUT{
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_PublicKeyManagementService), Local: "AddTrustedRootCertificate_OUTPUT"},
+ CreatedCertificate: CreatedCertificateResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyManagementService", Local: "CreatedCertificate"},
+ Address: "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
+ ReferenceParameters: ReferenceParametersResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/08/addressing", Local: "ReferenceParameters"},
+ ResourceURI: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyCertificate",
+ SelectorSet: SelectorSetResponse{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "SelectorSet"},
+ Selectors: []SelectorResponse{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "InstanceID",
+ Text: "Intel(r) AMT Certificate: Handle: 2",
+ },
+ },
+ },
+ },
+ },
+ ReturnValue: 0,
+ },
+ },
+ },
+
+ // GenerateKeyPair
+ {
+ "should return a valid amt_PublicKeyManagementService GenerateKeyPair wsman message",
+ AMT_PublicKeyManagementService,
+ `http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyManagementService/GenerateKeyPair`,
+ `02048`,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "GenerateKeyPair"
+ return elementUnderTest.GenerateKeyPair(RSA, KeyLength2048)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GenerateKeyPair_OUTPUT: GenerateKeyPair_OUTPUT{
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_PublicKeyManagementService), Local: "GenerateKeyPair_OUTPUT"},
+ KeyPair: KeyPairResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyManagementService", Local: "KeyPair"},
+ Address: "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
+ ReferenceParameters: ReferenceParametersResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/08/addressing", Local: "ReferenceParameters"},
+ ResourceURI: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicPrivateKeyPair",
+ SelectorSet: SelectorSetResponse{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "SelectorSet"},
+ Selectors: []SelectorResponse{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "InstanceID",
+ Text: "Intel(r) AMT Key: Handle: 0",
+ },
+ },
+ },
+ },
+ },
+ ReturnValue: 0,
+ },
+ },
+ },
+ // AddCertificate
+ {
+ "should return a valid amt_PublicKeyManagementService AddCertificate wsman message",
+ AMT_PublicKeyManagementService,
+ `http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyManagementService/AddCertificate`,
+ fmt.Sprintf(`%s`, wsmantesting.TrustedRootCert),
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "AddCertificate"
+ return elementUnderTest.AddCertificate(wsmantesting.TrustedRootCert)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ AddCertificate_OUTPUT: AddCertificate_OUTPUT{
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_PublicKeyManagementService), Local: "AddCertificate_OUTPUT"},
+ CreatedCertificate: CreatedCertificateResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyManagementService", Local: "CreatedCertificate"},
+ Address: "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
+ ReferenceParameters: ReferenceParametersResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/08/addressing", Local: "ReferenceParameters"},
+ ResourceURI: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyCertificate",
+ SelectorSet: SelectorSetResponse{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "SelectorSet"},
+ Selectors: []SelectorResponse{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "InstanceID",
+ Text: "Intel(r) AMT Certificate: Handle: 1",
+ },
+ },
+ },
+ },
+ },
+ ReturnValue: 0,
+ },
+ },
+ },
+
+ // {"should return a valid amt_PublicKeyManagementService GeneratePKCS10RequestEx wsman message", AMT_PublicKeyManagementService, "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyManagementService/GeneratePKCS10RequestEx", `testreallylongcertificateteststring1`, "", func() string {
+ // pkcs10Request := PKCS10Request{
+ // KeyPair: "test",
+ // NullSignedCertificateRequest: "reallylongcertificateteststring",
+ // SigningAlgorithm: 1,
+ // }
+ // return elementUnderTest.GeneratePKCS10RequestEx(pkcs10Request)
+ // }},
+
+ // AddKey
+ {
+ "should return a valid amt_PublicKeyManagementService AddKey wsman message",
+ AMT_PublicKeyManagementService,
+ "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyManagementService/AddKey",
+ `privatekey`,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "AddKey"
+ cert := "privatekey"
+ return elementUnderTest.AddKey(cert)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ AddKey_OUTPUT: AddKey_OUTPUT{
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_PublicKeyManagementService), Local: "AddKey_OUTPUT"},
+ CreatedKey: CreatedKeyResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyManagementService", Local: "CreatedKey"},
+ Address: "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
+ ReferenceParameters: ReferenceParametersResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/08/addressing", Local: "ReferenceParameters"},
+ ResourceURI: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyCertificate",
+ SelectorSet: SelectorSetResponse{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "SelectorSet"},
+ Selectors: []SelectorResponse{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "InstanceID",
+ Text: "Intel(r) AMT Key: Handle: 1",
+ },
+ },
+ },
+ },
+ },
+ ReturnValue: 0,
+ },
+ },
+ },
+ // DELETE
+ {
+ "should create a valid amt_PublicKeyManagementService Delete wsman message",
+ AMT_PublicKeyManagementService,
+ wsmantesting.DELETE,
+ "",
+ "instanceID123",
+ func() (Response, error) {
+ client.CurrentMessage = "Delete"
+ return elementUnderTest.Delete("instanceID123")
+ },
+ Body{XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"}},
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, test.extraHeader, test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.NoError(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.Equal(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
+func TestNegativeAMT_PublicKeyManagementService(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/publickey/management",
+ }
+ elementUnderTest := NewPublicKeyManagementServiceWithClient(wsmanMessageCreator, &client)
+ t.Run("amt_PublicKeyManagementService Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ extraHeader string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create a valid AMT_PublicKeyManagementService Get wsman message",
+ AMT_PublicKeyManagementService,
+ wsmantesting.GET,
+ "",
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ KeyManagementGetResponse: KeyManagementResponse{
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_PublicKeyManagementService), Local: AMT_PublicKeyManagementService},
+ CreationClassName: "AMT_PublicKeyManagementService",
+ ElementName: "Intel(r) AMT Certificate Store Service",
+ EnabledDefault: 5,
+ EnabledState: 5,
+ Name: "Intel(r) AMT Public Key Management Service",
+ RequestedState: 12,
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "Intel(r) AMT",
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create a valid AMT_PublicKeyManagementService Enumerate wsman message",
+ AMT_PublicKeyManagementService,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "7E000000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid AMT_PublicKeyManagementService Pull wsman message",
+ AMT_PublicKeyManagementService,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: message.XMLPullResponseSpace, Local: "PullResponse"},
+ KeyManagementItems: []KeyManagementResponse{
+ {
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_PublicKeyManagementService), Local: AMT_PublicKeyManagementService},
+ CreationClassName: "AMT_PublicKeyManagementService",
+ ElementName: "Intel(r) AMT Certificate Store Service",
+ EnabledDefault: 5,
+ EnabledState: 5,
+ Name: "Intel(r) AMT Public Key Management Service",
+ RequestedState: 12,
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "Intel(r) AMT",
+ },
+ },
+ },
+ },
+ },
+
+ // AddTrustedRootCertificate
+ {
+ "should return a valid amt_PublicKeyManagementService AddTrustedRootCertificate wsman message",
+ AMT_PublicKeyManagementService,
+ `http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyManagementService/AddTrustedRootCertificate`,
+ fmt.Sprintf(`%s`, wsmantesting.TrustedRootCert),
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.AddTrustedRootCertificate(wsmantesting.TrustedRootCert)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ AddTrustedRootCertificate_OUTPUT: AddTrustedRootCertificate_OUTPUT{
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_PublicKeyManagementService), Local: "AddTrustedRootCertificate_OUTPUT"},
+ CreatedCertificate: CreatedCertificateResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyManagementService", Local: "CreatedCertificate"},
+ Address: "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
+ ReferenceParameters: ReferenceParametersResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/08/addressing", Local: "ReferenceParameters"},
+ ResourceURI: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyCertificate",
+ SelectorSet: SelectorSetResponse{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "SelectorSet"},
+ Selectors: []SelectorResponse{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "InstanceID",
+ Text: "Intel(r) AMT Certificate: Handle: 2",
+ },
+ },
+ },
+ },
+ },
+ ReturnValue: 0,
+ },
+ },
+ },
+
+ // GenerateKeyPair
+ {
+ "should return a valid amt_PublicKeyManagementService GenerateKeyPair wsman message",
+ AMT_PublicKeyManagementService,
+ `http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyManagementService/GenerateKeyPair`,
+ `02048`,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.GenerateKeyPair(RSA, KeyLength2048)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GenerateKeyPair_OUTPUT: GenerateKeyPair_OUTPUT{
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_PublicKeyManagementService), Local: "GenerateKeyPair_OUTPUT"},
+ KeyPair: KeyPairResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyManagementService", Local: "KeyPair"},
+ Address: "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
+ ReferenceParameters: ReferenceParametersResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/08/addressing", Local: "ReferenceParameters"},
+ ResourceURI: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicPrivateKeyPair",
+ SelectorSet: SelectorSetResponse{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "SelectorSet"},
+ Selectors: []SelectorResponse{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "InstanceID",
+ Text: "Intel(r) AMT Key: Handle: 0",
+ },
+ },
+ },
+ },
+ },
+ ReturnValue: 0,
+ },
+ },
+ },
+ // AddCertificate
+ {
+ "should return a valid amt_PublicKeyManagementService AddCertificate wsman message",
+ AMT_PublicKeyManagementService,
+ `http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyManagementService/AddCertificate`,
+ fmt.Sprintf(`%s`, wsmantesting.TrustedRootCert),
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.AddCertificate(wsmantesting.TrustedRootCert)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ AddCertificate_OUTPUT: AddCertificate_OUTPUT{
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_PublicKeyManagementService), Local: "AddCertificate_OUTPUT"},
+ CreatedCertificate: CreatedCertificateResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyManagementService", Local: "CreatedCertificate"},
+ Address: "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
+ ReferenceParameters: ReferenceParametersResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/08/addressing", Local: "ReferenceParameters"},
+ ResourceURI: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyCertificate",
+ SelectorSet: SelectorSetResponse{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "SelectorSet"},
+ Selectors: []SelectorResponse{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "InstanceID",
+ Text: "Intel(r) AMT Certificate: Handle: 1",
+ },
+ },
+ },
+ },
+ },
+ ReturnValue: 0,
+ },
+ },
+ },
+
+ // {"should return a valid amt_PublicKeyManagementService GeneratePKCS10RequestEx wsman message", AMT_PublicKeyManagementService, "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyManagementService/GeneratePKCS10RequestEx", `testreallylongcertificateteststring1`, "", func() string {
+ // pkcs10Request := PKCS10Request{
+ // KeyPair: "test",
+ // NullSignedCertificateRequest: "reallylongcertificateteststring",
+ // SigningAlgorithm: 1,
+ // }
+ // return elementUnderTest.GeneratePKCS10RequestEx(pkcs10Request)
+ // }},
+
+ // AddKey
+ {
+ "should return a valid amt_PublicKeyManagementService AddKey wsman message",
+ AMT_PublicKeyManagementService,
+ "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyManagementService/AddKey",
+ `privatekey`,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ cert := "privatekey"
+ return elementUnderTest.AddKey(cert)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ AddKey_OUTPUT: AddKey_OUTPUT{
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_PublicKeyManagementService), Local: "AddKey_OUTPUT"},
+ CreatedKey: CreatedKeyResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyManagementService", Local: "CreatedKey"},
+ Address: "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
+ ReferenceParameters: ReferenceParametersResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/08/addressing", Local: "ReferenceParameters"},
+ ResourceURI: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyCertificate",
+ SelectorSet: SelectorSetResponse{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "SelectorSet"},
+ Selectors: []SelectorResponse{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "InstanceID",
+ Text: "Intel(r) AMT Key: Handle: 1",
+ },
+ },
+ },
+ },
+ },
+ ReturnValue: 0,
+ },
+ },
+ },
+ // DELETE
+ {
+ "should create a valid amt_PublicKeyManagementService Delete wsman message",
+ AMT_PublicKeyManagementService,
+ wsmantesting.DELETE,
+ "",
+ "instanceID123",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Delete("instanceID123")
+ },
+ Body{XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"}},
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, test.extraHeader, test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.Error(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.NotEqual(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
diff --git a/pkg/wsman/amt/publickey/marshal.go b/pkg/wsman/amt/publickey/marshal.go
new file mode 100644
index 00000000..4ae41de0
--- /dev/null
+++ b/pkg/wsman/amt/publickey/marshal.go
@@ -0,0 +1,30 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package publickey
+
+import (
+ "encoding/json"
+
+ "gopkg.in/yaml.v3"
+)
+
+// JSON marshals the type into JSON format
+func (r *Response) JSON() string {
+ jsonOutput, err := json.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(jsonOutput)
+}
+
+// YAML marshals the type into YAML format
+func (r *Response) YAML() string {
+ yamlOutput, err := yaml.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(yamlOutput)
+}
diff --git a/pkg/wsman/amt/publickey/types.go b/pkg/wsman/amt/publickey/types.go
new file mode 100644
index 00000000..74cdb485
--- /dev/null
+++ b/pkg/wsman/amt/publickey/types.go
@@ -0,0 +1,264 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package publickey
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+)
+
+type ManagementService struct {
+ base message.Base
+}
+
+type Certificate struct {
+ base message.Base
+}
+
+// OUTPUTS
+// Response Types
+type (
+ Response struct {
+ *client.Message
+ XMLName xml.Name `xml:"Envelope"`
+ Header message.Header `xml:"Header"`
+ Body Body `xml:"Body"`
+ }
+ Body struct {
+ XMLName xml.Name `xml:"Body"`
+ AddTrustedRootCertificate_OUTPUT AddTrustedRootCertificate_OUTPUT `xml:"AddTrustedRootCertificate_OUTPUT,omitempty"`
+ AddCertificate_OUTPUT AddCertificate_OUTPUT `xml:"AddCertificate_OUTPUT,omitempty"`
+ AddKey_OUTPUT AddKey_OUTPUT `xml:"AddKey_OUTPUT,omitempty"`
+ GenerateKeyPair_OUTPUT GenerateKeyPair_OUTPUT `xml:"GenerateKeyPair_OUTPUT,omitempty"`
+ KeyManagementGetResponse KeyManagementResponse `xml:"AMT_PublicKeyManagementService,omitempty"`
+ PublicKeyCertificateGetAndPutResponse PublicKeyCertificateResponse `xml:"AMT_PublicKeyCertificate,omitempty"`
+ EnumerateResponse common.EnumerateResponse
+ PullResponse PullResponse
+ }
+ PullResponse struct {
+ XMLName xml.Name `xml:"PullResponse,omitempty"`
+ KeyManagementItems []KeyManagementResponse `xml:"Items>AMT_PublicKeyManagementService,omitempty"`
+ PublicKeyCertificateItems []PublicKeyCertificateResponse `xml:"Items>AMT_PublicKeyCertificate,omitempty"`
+ }
+ KeyManagementResponse struct {
+ XMLName xml.Name `xml:"AMT_PublicKeyManagementService,omitempty"`
+ CreationClassName string `xml:"CreationClassName,omitempty"` // CreationClassName indicates the name of the class or the subclass that is used in the creation of an instance. When used with the other key properties of this class, this property allows all instances of this class and its subclasses to be uniquely identified.
+ ElementName string `xml:"ElementName,omitempty"` // A user-friendly name for the object. This property allows each instance to define a user-friendly name in addition to its key properties, identity data, and description information. Note that the Name property of ManagedSystemElement is also defined as a user-friendly name. But, it is often subclassed to be a Key. It is not reasonable that the same property can convey both identity and a user-friendly name, without inconsistencies. Where Name exists and is not a Key (such as for instances of LogicalDevice), the same information can be present in both the Name and ElementName properties. Note that if there is an associated instance of CIM_EnabledLogicalElementCapabilities, restrictions on this properties may exist as defined in ElementNameMask and MaxElementNameLen properties defined in that class.
+ EnabledDefault EnabledDefault `xml:"EnabledDefault"` // An enumerated value indicating an administrator's default or startup configuration for the Enabled State of an element. By default, the element is "Enabled" (value=2).
+ EnabledState EnabledState `xml:"EnabledState"` // EnabledState is an integer enumeration that indicates the enabled and disabled states of an element.
+ Name string `xml:"Name,omitempty"` // The Name property uniquely identifies the Service and provides an indication of the functionality that is managed. This functionality is described in more detail in the Description property of the object.
+ OperationalStatus []OperationalStatus `xml:"OperationalStatus,omitempty"` // Indicates the current statuses of the element.
+ RequestedState RequestedState `xml:"RequestedState"` // RequestedState is an integer enumeration that indicates the last requested or desired state for the element, irrespective of the mechanism through which it was requested.
+ SystemCreationClassName string `xml:"SystemCreationClassName,omitempty"` // The CreationClassName of the scoping System.
+ SystemName string `xml:"SystemName,omitempty"` // The Name of the scoping System.
+ }
+ PublicKeyCertificateResponse struct {
+ XMLName xml.Name `xml:"AMT_PublicKeyCertificate,omitempty"`
+ ElementName string `xml:"ElementName,omitempty"` // A user-friendly name for the object . . .
+ InstanceID string `xml:"InstanceID,omitempty"` // Within the scope of the instantiating Namespace, InstanceID opaquely and uniquely identifies an instance of this class.
+ X509Certificate string `xml:"X509Certificate,omitempty"` // uint8[4100] // The X.509 Certificate blob.
+ TrustedRootCertificate bool `xml:"TrustedRootCertficate"` // For root certificate [that were added by AMT_PublicKeyManagementService.AddTrustedRootCertificate()]this property will be true. FYI Certificate is spelled wrong comimg from AMT.
+ Issuer string `xml:"Issuer,omitempty"` // The Issuer field of this certificate.
+ Subject string `xml:"Subject,omitempty"` // The Subject field of this certificate.
+ ReadOnlyCertificate bool `xml:"ReadOnlyCertificate"` // Indicates whether the certificate is an Intel AMT self-signed certificate. If True, the certificate cannot be deleted.
+ }
+ AddTrustedRootCertificate_OUTPUT struct {
+ XMLName xml.Name `xml:"AddTrustedRootCertificate_OUTPUT"`
+ CreatedCertificate CreatedCertificateResponse `xml:"CreatedCertificate,omitempty"`
+ ReturnValue int `xml:"ReturnValue,omitempty"`
+ }
+ AddCertificate_OUTPUT struct {
+ XMLName xml.Name `xml:"AddCertificate_OUTPUT"`
+ CreatedCertificate CreatedCertificateResponse `xml:"CreatedCertificate,omitempty"`
+ ReturnValue int `xml:"ReturnValue,omitempty"`
+ }
+ AddKey_OUTPUT struct {
+ XMLName xml.Name `xml:"AddKey_OUTPUT,omitempty"`
+ CreatedKey CreatedKeyResponse `xml:"CreatedKey,omitempty"`
+ ReturnValue int `xml:"ReturnValue,omitempty"`
+ }
+ GenerateKeyPair_OUTPUT struct {
+ XMLName xml.Name `xml:"GenerateKeyPair_OUTPUT,omitempty"`
+ KeyPair KeyPairResponse `xml:"KeyPair,omitempty"`
+ ReturnValue int `xml:"ReturnValue,omitempty"`
+ }
+ KeyPairResponse struct {
+ XMLName xml.Name `xml:"KeyPair,omitempty"`
+ Address string `xml:"Address,omitempty"`
+ ReferenceParameters ReferenceParametersResponse `xml:"ReferenceParameters,omitempty"`
+ }
+ CreatedKeyResponse struct {
+ XMLName xml.Name `xml:"CreatedKey,omitempty"`
+ Address string `xml:"Address,omitempty"`
+ ReferenceParameters ReferenceParametersResponse `xml:"ReferenceParameters,omitempty"`
+ }
+ CreatedCertificateResponse struct {
+ XMLName xml.Name `xml:"CreatedCertificate,omitempty"`
+ Address string `xml:"Address,omitempty"`
+ ReferenceParameters ReferenceParametersResponse `xml:"ReferenceParameters,omitempty"`
+ }
+ ReferenceParametersResponse struct {
+ XMLName xml.Name `xml:"ReferenceParameters,omitempty"`
+ ResourceURI string
+ SelectorSet SelectorSetResponse `xml:"SelectorSet,omitempty"`
+ }
+ SelectorSetResponse struct {
+ XMLName xml.Name `xml:"SelectorSet,omitempty"`
+ Selectors []SelectorResponse `xml:"Selector"`
+ }
+ SelectorResponse struct {
+ XMLName xml.Name `xml:"Selector,omitempty"`
+ Name string `xml:"Name,attr"`
+ Text string `xml:",chardata"`
+ }
+
+ // Indicates the current statuses of the element. Various operational statuses are defined. Many of the enumeration's values are self-explanatory. However, a few are not and are described here in more detail.
+ //
+ // "Stressed" indicates that the element is functioning, but needs attention. Examples of "Stressed" states are overload, overheated, and so on.
+ //
+ // "Predictive Failure" indicates that an element is functioning nominally but predicting a failure in the near future.
+ //
+ // "In Service" describes an element being configured, maintained, cleaned, or otherwise administered.
+ //
+ // "No Contact" indicates that the monitoring system has knowledge of this element, but has never been able to establish communications with it.
+ //
+ // "Lost Communication" indicates that the ManagedSystem Element is known to exist and has been contacted successfully in the past, but is currently unreachable.
+ //
+ // "Stopped" and "Aborted" are similar, although the former implies a clean and orderly stop, while the latter implies an abrupt stop where the state and configuration of the element might need to be updated.
+ //
+ // "Dormant" indicates that the element is inactive or quiesced.
+ //
+ // "Supporting Entity in Error" indicates that this element might be "OK" but that another element, on which it is dependent, is in error. An example is a network service or endpoint that cannot function due to lower-layer networking problems.
+ //
+ // "Completed" indicates that the element has completed its operation. This value should be combined with either OK, Error, or Degraded so that a client can tell if the complete operation Completed with OK (passed), Completed with Error (failed), or Completed with Degraded (the operation finished, but it did not complete OK or did not report an error).
+ //
+ // "Power Mode" indicates that the element has additional power model information contained in the Associated PowerManagementService association.
+ //
+ // "Relocating" indicates the element is being relocated.
+ //
+ // OperationalStatus replaces the Status property on ManagedSystemElement to provide a consistent approach to enumerations, to address implementation needs for an array property, and to provide a migration path from today's environment to the future. This change was not made earlier because it required the deprecated qualifier. Due to the widespread use of the existing Status property in management applications, it is strongly recommended that providers or instrumentation provide both the Status and OperationalStatus properties. Further, the first value of OperationalStatus should contain the primary status for the element. When instrumented, Status (because it is single-valued) should also provide the primary status of the element.
+ //
+ // ValueMap={0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, .., 0x8000..}
+ //
+ // Values={Unknown, Other, OK, Degraded, Stressed, Predictive Failure, Error, Non-Recoverable Error, Starting, Stopping, Stopped, In Service, No Contact, Lost Communication, Aborted, Dormant, Supporting Entity in Error, Completed, Power Mode, Relocating, DMTF Reserved, Vendor Reserved}
+ OperationalStatus int
+ // An enumerated value indicating an administrator's default or startup configuration for the Enabled State of an element. By default, the element is "Enabled" (value=2).
+ //
+ // ValueMap={2, 3, 5, 6, 7, 9, .., 32768..65535}
+ //
+ // Values={Enabled, Disabled, Not Applicable, Enabled but Offline, No Default, Quiesce, DMTF Reserved, Vendor Reserved}
+ EnabledDefault int
+ // EnabledState is an integer enumeration that indicates the enabled and disabled states of an element. It can also indicate the transitions between these requested states. For example, shutting down (value=4) and starting (value=10) are transient states between enabled and disabled.
+ //
+ // The following text briefly summarizes the various enabled and disabled states:
+ //
+ // Enabled (2) indicates that the element is or could be executing commands, will process any queued commands, and queues new requests.
+ //
+ // Disabled (3) indicates that the element will not execute commands and will drop any new requests.
+ //
+ // Shutting Down (4) indicates that the element is in the process of going to a Disabled state.
+ //
+ // Not Applicable (5) indicates the element does not support being enabled or disabled.
+ //
+ // Enabled but Offline (6) indicates that the element might be completing commands, and will drop any new requests.
+ //
+ // Test (7) indicates that the element is in a test state.
+ //
+ // Deferred (8) indicates that the element might be completing commands, but will queue any new requests.
+ //
+ // Quiesce (9) indicates that the element is enabled but in a restricted mode.
+ //
+ // Starting (10) indicates that the element is in the process of going to an Enabled state. New requests are queued.
+ //
+ // Value 6 ("Enabled but Offline") can be recieved also if the Audit Log is in locked state.
+ //
+ // ValueMap={0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11..32767, 32768..65535}
+ //
+ // Values={Unknown, Other, Enabled, Disabled, Shutting Down, Not Applicable, Enabled but Offline, In Test, Deferred, Quiesce, Starting, DMTF Reserved, Vendor Reserved}
+ EnabledState int
+ // RequestedState is an integer enumeration that indicates the last requested or desired state for the element, irrespective of the mechanism through which it was requested. The actual state of the element is represented by EnabledState. This property is provided to compare the last requested and current enabled or disabled states. Note that when EnabledState is set to 5 ("Not Applicable"), then this property has no meaning. Refer to the EnabledState property description for explanations of the values in the RequestedState enumeration.
+ //
+ // "Unknown" (0) indicates the last requested state for the element is unknown.
+ //
+ // Note that the value "No Change" (5) has been deprecated in lieu of indicating the last requested state is "Unknown" (0). If the last requested or desired state is unknown, RequestedState should have the value "Unknown" (0), but may have the value "No Change" (5).Offline (6) indicates that the element has been requested to transition to the Enabled but Offline EnabledState. It should be noted that there are two new values in RequestedState that build on the statuses of EnabledState. These are "Reboot" (10) and "Reset" (11). Reboot refers to doing a "Shut Down" and then moving to an "Enabled" state. Reset indicates that the element is first "Disabled" and then "Enabled". The distinction between requesting "Shut Down" and "Disabled" should also be noted. Shut Down requests an orderly transition to the Disabled state, and might involve removing power, to completely erase any existing state. The Disabled state requests an immediate disabling of the element, such that it will not execute or accept any commands or processing requests.
+ //
+ // This property is set as the result of a method invocation (such as Start or StopService on CIM_Service), or can be overridden and defined as WRITEable in a subclass. The method approach is considered superior to a WRITEable property, because it allows an explicit invocation of the operation and the return of a result code.
+ //
+ // If knowledge of the last RequestedState is not supported for the EnabledLogicalElement, the property shall be NULL or have the value 12 "Not Applicable".
+ //
+ // ValueMap={0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, .., 32768..65535}
+ //
+ // Values={Unknown, Enabled, Disabled, Shut Down, No Change, Offline, Test, Deferred, Quiesce, Reboot, Reset, Not Applicable, DMTF Reserved, Vendor Reserved}
+ RequestedState int
+)
+
+// INPUTS
+// Request Types
+type (
+ PublicKeyCertificateRequest struct {
+ XMLName xml.Name `xml:"h:AMT_PublicKeyCertificate"`
+ H string `xml:"xmlns:h,attr"`
+ ElementName string `xml:"h:ElementName"` // A user-friendly name for the object. This property allows each instance to define a user-friendly name in addition to its key properties, identity data, and description information. Note that the Name property of ManagedSystemElement is also defined as a user-friendly name. But, it is often subclassed to be a Key. It is not reasonable that the same property can convey both identity and a user-friendly name, without inconsistencies. Where Name exists and is not a Key (such as for instances of LogicalDevice), the same information can be present in both the Name and ElementName properties. Note that if there is an associated instance of CIM_EnabledLogicalElementCapabilities, restrictions on this properties may exist as defined in ElementNameMask and MaxElementNameLen properties defined in that class.
+ InstanceID string `xml:"h:InstanceID"` // Within the scope of the instantiating Namespace, InstanceID opaquely and uniquely identifies an instance of this class.
+ X509Certificate string `xml:"h:X509Certificate"` // uint8[4100] // The X.509 Certificate blob.
+ TrustedRootCertificate bool `xml:"h:TrustedRootCertificate"` // For root certificate [that were added by AMT_PublicKeyManagementService.AddTrustedRootCertificate()]this property will be true.
+ Issuer string `xml:"h:Issuer"` // The Issuer field of this certificate.
+ Subject string `xml:"h:Subject"` // The Subject field of this certificate.
+ ReadOnlyCertificate bool `xml:"h:ReadOnlyCertificate"` // Indicates whether the certificate is an Intel AMT self-signed certificate. If True, the certificate cannot be deleted.
+ }
+ AddCertificate_INPUT struct {
+ XMLName xml.Name `xml:"h:AddCertificate_INPUT"`
+ H string `xml:"xmlns:h,attr"`
+ CertificateBlob string `xml:"h:CertificateBlob"` // The use of ECC 192/224 is blocked starting from Intel® CSME 18.0.
+ }
+ AddTrustedRootCertificate_INPUT struct {
+ XMLName xml.Name `xml:"h:AddTrustedRootCertificate_INPUT"`
+ H string `xml:"xmlns:h,attr"`
+ CertificateBlob string `xml:"h:CertificateBlob"` // The use of ECC 192/224 is blocked starting from Intel® CSME 18.0.
+ }
+ AddKey_INPUT struct {
+ XMLName xml.Name `xml:"h:AddKey_INPUT"`
+ H string `xml:"xmlns:h,attr"`
+ KeyBlob string `xml:"h:KeyBlob"` // The use of ECC 192/224 is blocked starting from Intel® CSME 18.0.
+ }
+ GenerateKeyPair_INPUT struct {
+ XMLName xml.Name `xml:"h:GenerateKeyPair_INPUT"`
+ H string `xml:"xmlns:h,attr"`
+ KeyAlgorithm KeyAlgorithm `xml:"h:KeyAlgorithm"` // The algorithm of the generated key.
+ KeyLength KeyLength `xml:"h:KeyLength"` // The length of the generatd key in bits.
+ }
+ PKCS10Request struct {
+ XMLName xml.Name `xml:"h:GeneratePKCS10RequestEx_INPUT"`
+ H string `xml:"xmlns:h,attr"`
+ KeyPair string `xml:"h:KeyPair"`
+ NullSignedCertificateRequest string `xml:"h:NullSignedCertificateRequest"` // A binary representation of the null-signed PKCS#10 request.the request must include a valid PKCS10RequestInfo, that will be signed by AMT FW. The Public Key specified in the request must match the public key of the referenced KeyPair parameter.
+ SigningAlgorithm SigningAlgorithm `xml:"h:SigningAlgorithm"` // The signing algorithm that the FW should use for signing the certificate request
+ }
+
+ // The signing algorithm that the FW should use for signing the certificate request
+ //
+ // Required
+ //
+ // ValueMap={0, 1, ..}
+ //
+ // Values={SHA1-RSA, SHA256-RSA, Reserved} Note: SHA1 is no longer available starting from Intel CSME 18.0.
+ SigningAlgorithm int
+
+ // The algorithm of the generated key.
+ //
+ // Required
+ //
+ // ValueMap={0, ..}
+ //
+ // Values={RSA, Reserved}
+ KeyAlgorithm int
+
+ // The length of the generatd key in bits
+ KeyLength int
+)
diff --git a/pkg/wsman/amt/publicprivate/constants.go b/pkg/wsman/amt/publicprivate/constants.go
new file mode 100644
index 00000000..065e5252
--- /dev/null
+++ b/pkg/wsman/amt/publicprivate/constants.go
@@ -0,0 +1,10 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package publicprivate
+
+const (
+ AMT_PublicPrivateKeyPair string = "AMT_PublicPrivateKeyPair"
+)
diff --git a/pkg/wsman/amt/publicprivate/keypair.go b/pkg/wsman/amt/publicprivate/keypair.go
new file mode 100644
index 00000000..d12b53d5
--- /dev/null
+++ b/pkg/wsman/amt/publicprivate/keypair.go
@@ -0,0 +1,112 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+// Package publicprivate facilitiates communication with Intel® AMT devices to manage a public-private key in the Intel® AMT CertStore.
+//
+// Instances of this class can be created using the AMT_PublicKeyManagementService.AddKey method. You can't delete a key instance if it is used by some service (TLS/EAC).
+package publicprivate
+
+import (
+ "encoding/xml"
+ "fmt"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+)
+
+// NewPublicPrivateKeyPairWithClient instantiates a new KeyPair
+func NewPublicPrivateKeyPairWithClient(wsmanMessageCreator *message.WSManMessageCreator, client client.WSMan) KeyPair {
+ return KeyPair{
+ base: message.NewBaseWithClient(wsmanMessageCreator, AMT_PublicPrivateKeyPair, client),
+ }
+}
+
+// Get retrieves the representation of the instance
+func (keyPair KeyPair) Get(handle int) (response Response, err error) {
+ selector := message.Selector{
+ Name: "InstanceID",
+ Value: fmt.Sprintf("Intel(r) AMT Key: Handle: %d", handle),
+ }
+ response = Response{
+ Message: &client.Message{
+ XMLInput: keyPair.base.Get((*message.Selector)(&selector)),
+ },
+ }
+ // send the message to AMT
+ err = keyPair.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Enumerate returns an enumeration context which is used in a subsequent Pull call
+func (keyPair KeyPair) Enumerate() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: keyPair.base.Enumerate(),
+ },
+ }
+ // send the message to AMT
+ err = keyPair.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Pull returns the instances of this class. An enumeration context provided by the Enumerate call is used as input.
+func (keyPair KeyPair) Pull(enumerationContext string) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: keyPair.base.Pull(enumerationContext),
+ },
+ }
+ // send the message to AMT
+ err = keyPair.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Deletes an instance of a key pair
+func (keyPair KeyPair) Delete(handle string) (response Response, err error) {
+ selector := message.Selector{
+ Name: "InstanceID",
+ Value: handle,
+ }
+ response = Response{
+ Message: &client.Message{
+ XMLInput: keyPair.base.Delete(selector),
+ },
+ }
+ // send the message to AMT
+ err = keyPair.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
diff --git a/pkg/wsman/amt/publicprivate/keypair_test.go b/pkg/wsman/amt/publicprivate/keypair_test.go
new file mode 100644
index 00000000..748784b6
--- /dev/null
+++ b/pkg/wsman/amt/publicprivate/keypair_test.go
@@ -0,0 +1,251 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package publicprivate
+
+import (
+ "encoding/xml"
+ "fmt"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
+)
+
+func TestPositiveAMT_PublicPrivateKeyPair(t *testing.T) {
+ messageID := 0
+ resourceUriBase := message.AMTSchema
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/publicprivate",
+ }
+ elementUnderTest := NewPublicPrivateKeyPairWithClient(wsmanMessageCreator, &client)
+
+ t.Run("amt_PublicPrivateKeyPair Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ extraHeader string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create a valid AMT_PublicPrivateKeyPair Get wsman message",
+ AMT_PublicPrivateKeyPair, wsmantesting.GET,
+ "",
+ "Intel(r) AMT Key: Handle: 0",
+ func() (Response, error) {
+ client.CurrentMessage = "Get"
+ return elementUnderTest.Get(0)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GetResponse: PublicPrivateKeyPair{
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_PublicPrivateKeyPair), Local: AMT_PublicPrivateKeyPair},
+ ElementName: "Intel(r) AMT Key",
+ InstanceID: "Intel(r) AMT Key: Handle: 0",
+ DERKey: "MIIBCgKCAQEA4y00wezZ1XwsSITMvqeYf61tgfVhlGbBVwq9Au0BaEgofPFCLuWMnKaTnMhUlJEGaeB2y6F8qjId0xMwLtNY6XWhmMoCP0R+ymgClT0treqtYp2zL1QPK1R04KTgF0KZh247oQpPGnB2nIe7PKCjPaY8BfOyBC6eNLeWUVIOA5TLL0gSTuk8y3iaadKo+LoWBaH/WDrIJ21Dzn6yU3zGueA8tphPH7yXaOJuNiijOUYZjVT7J0Ia8qMxUv1CrbfL2+N0lrcCG/E4f0QF1XgoCJnwIHdYaNhWzKVhfh2TTZIxJo8bXngckNOLzdYM35hUq98CxPiMSO8+G7J8RZaobQIDAQAB",
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create a valid AMT_PublicPrivateKeyPair Enumerate wsman message",
+ AMT_PublicPrivateKeyPair,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Enumerate"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "56080000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid AMT_PublicPrivateKeyPair Pull wsman message",
+ AMT_PublicPrivateKeyPair,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Pull"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: message.XMLPullResponseSpace, Local: "PullResponse"},
+ PublicPrivateKeyPairItems: []PublicPrivateKeyPair{
+ {
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_PublicPrivateKeyPair), Local: AMT_PublicPrivateKeyPair},
+ ElementName: "Intel(r) AMT Key",
+ InstanceID: "Intel(r) AMT Key: Handle: 0",
+ DERKey: "MIIBCgKCAQEA4y00wezZ1XwsSITMvqeYf61tgfVhlGbBVwq9Au0BaEgofPFCLuWMnKaTnMhUlJEGaeB2y6F8qjId0xMwLtNY6XWhmMoCP0R+ymgClT0treqtYp2zL1QPK1R04KTgF0KZh247oQpPGnB2nIe7PKCjPaY8BfOyBC6eNLeWUVIOA5TLL0gSTuk8y3iaadKo+LoWBaH/WDrIJ21Dzn6yU3zGueA8tphPH7yXaOJuNiijOUYZjVT7J0Ia8qMxUv1CrbfL2+N0lrcCG/E4f0QF1XgoCJnwIHdYaNhWzKVhfh2TTZIxJo8bXngckNOLzdYM35hUq98CxPiMSO8+G7J8RZaobQIDAQAB",
+ },
+ {
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_PublicPrivateKeyPair), Local: AMT_PublicPrivateKeyPair},
+ ElementName: "Intel(r) AMT Key",
+ InstanceID: "Intel(r) AMT Key: Handle: 1",
+ DERKey: "MIIBCgKCAQEAvMgYL2FyGuHOVvwYgjABqRlJ8j8LhMo2OCU1HU2WvDN3NoLmjAh2XmBS6ic5IjIc4VtjL7S8ImKP8+PSye9nxf+lv33AqcGsvQFcUuJ5gLTnYzrmqVk6XTcHf1qtvHEmVoykTV6bN7BQx0eTejTjhw3Ro6HZBMyStaTGIKjC9HLQySV6SnFGbrjdNZZoCYsaT8dVetn23npeses9f6dZT5K3IgpA13NcdJioS71uppjIcg8dXpcxA4QKgHLmmELPN9JLbywMvcCuU+xMDceWQlFld9ohmr8NiwgebLyVCh/Q+O+jkQT43snNolyTGLRWQFR4M6DT5fdgXivoFhzMcwIDAQAB",
+ },
+ },
+ },
+ },
+ },
+ //DELETE
+ {
+ "should create a valid AMT_PublicPrivateKeyPair Delete wsman message",
+ AMT_PublicPrivateKeyPair,
+ wsmantesting.DELETE,
+ "",
+ "Intel(r) AMT Key: Handle: 0",
+ func() (Response, error) {
+ client.CurrentMessage = "Delete"
+ return elementUnderTest.Delete("Intel(r) AMT Key: Handle: 0")
+ },
+ Body{XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"}},
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, test.extraHeader, test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.NoError(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.Equal(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
+func TestNegativeAMT_PublicPrivateKeyPair(t *testing.T) {
+ messageID := 0
+ resourceUriBase := message.AMTSchema
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/publicprivate",
+ }
+ elementUnderTest := NewPublicPrivateKeyPairWithClient(wsmanMessageCreator, &client)
+
+ t.Run("amt_PublicPrivateKeyPair Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ extraHeader string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create a valid AMT_PublicPrivateKeyPair Get wsman message",
+ AMT_PublicPrivateKeyPair, wsmantesting.GET,
+ "",
+ "Intel(r) AMT Key: Handle: 0",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Get(0)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GetResponse: PublicPrivateKeyPair{
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_PublicPrivateKeyPair), Local: AMT_PublicPrivateKeyPair},
+ ElementName: "Intel(r) AMT Key",
+ InstanceID: "Intel(r) AMT Key: Handle: 0",
+ DERKey: "MIIBCgKCAQEA4y00wezZ1XwsSITMvqeYf61tgfVhlGbBVwq9Au0BaEgofPFCLuWMnKaTnMhUlJEGaeB2y6F8qjId0xMwLtNY6XWhmMoCP0R+ymgClT0treqtYp2zL1QPK1R04KTgF0KZh247oQpPGnB2nIe7PKCjPaY8BfOyBC6eNLeWUVIOA5TLL0gSTuk8y3iaadKo+LoWBaH/WDrIJ21Dzn6yU3zGueA8tphPH7yXaOJuNiijOUYZjVT7J0Ia8qMxUv1CrbfL2+N0lrcCG/E4f0QF1XgoCJnwIHdYaNhWzKVhfh2TTZIxJo8bXngckNOLzdYM35hUq98CxPiMSO8+G7J8RZaobQIDAQAB",
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create a valid AMT_PublicPrivateKeyPair Enumerate wsman message",
+ AMT_PublicPrivateKeyPair,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "56080000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid AMT_PublicPrivateKeyPair Pull wsman message",
+ AMT_PublicPrivateKeyPair,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: message.XMLPullResponseSpace, Local: "PullResponse"},
+ PublicPrivateKeyPairItems: []PublicPrivateKeyPair{
+ {
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_PublicPrivateKeyPair), Local: AMT_PublicPrivateKeyPair},
+ ElementName: "Intel(r) AMT Key",
+ InstanceID: "Intel(r) AMT Key: Handle: 0",
+ DERKey: "MIIBCgKCAQEA4y00wezZ1XwsSITMvqeYf61tgfVhlGbBVwq9Au0BaEgofPFCLuWMnKaTnMhUlJEGaeB2y6F8qjId0xMwLtNY6XWhmMoCP0R+ymgClT0treqtYp2zL1QPK1R04KTgF0KZh247oQpPGnB2nIe7PKCjPaY8BfOyBC6eNLeWUVIOA5TLL0gSTuk8y3iaadKo+LoWBaH/WDrIJ21Dzn6yU3zGueA8tphPH7yXaOJuNiijOUYZjVT7J0Ia8qMxUv1CrbfL2+N0lrcCG/E4f0QF1XgoCJnwIHdYaNhWzKVhfh2TTZIxJo8bXngckNOLzdYM35hUq98CxPiMSO8+G7J8RZaobQIDAQAB",
+ },
+ {
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_PublicPrivateKeyPair), Local: AMT_PublicPrivateKeyPair},
+ ElementName: "Intel(r) AMT Key",
+ InstanceID: "Intel(r) AMT Key: Handle: 1",
+ DERKey: "MIIBCgKCAQEAvMgYL2FyGuHOVvwYgjABqRlJ8j8LhMo2OCU1HU2WvDN3NoLmjAh2XmBS6ic5IjIc4VtjL7S8ImKP8+PSye9nxf+lv33AqcGsvQFcUuJ5gLTnYzrmqVk6XTcHf1qtvHEmVoykTV6bN7BQx0eTejTjhw3Ro6HZBMyStaTGIKjC9HLQySV6SnFGbrjdNZZoCYsaT8dVetn23npeses9f6dZT5K3IgpA13NcdJioS71uppjIcg8dXpcxA4QKgHLmmELPN9JLbywMvcCuU+xMDceWQlFld9ohmr8NiwgebLyVCh/Q+O+jkQT43snNolyTGLRWQFR4M6DT5fdgXivoFhzMcwIDAQAB",
+ },
+ },
+ },
+ },
+ },
+ //DELETE
+ {
+ "should create a valid AMT_PublicPrivateKeyPair Delete wsman message",
+ AMT_PublicPrivateKeyPair,
+ wsmantesting.DELETE,
+ "",
+ "Intel(r) AMT Key: Handle: 0",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Delete("Intel(r) AMT Key: Handle: 0")
+ },
+ Body{XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"}},
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, test.extraHeader, test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.Error(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.NotEqual(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
diff --git a/pkg/wsman/amt/publicprivate/marshal.go b/pkg/wsman/amt/publicprivate/marshal.go
new file mode 100644
index 00000000..933703b1
--- /dev/null
+++ b/pkg/wsman/amt/publicprivate/marshal.go
@@ -0,0 +1,30 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package publicprivate
+
+import (
+ "encoding/json"
+
+ "gopkg.in/yaml.v3"
+)
+
+// JSON marshals the type into JSON format
+func (r *Response) JSON() string {
+ jsonOutput, err := json.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(jsonOutput)
+}
+
+// YAML marshals the type into YAML format
+func (r *Response) YAML() string {
+ yamlOutput, err := yaml.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(yamlOutput)
+}
diff --git a/pkg/wsman/amt/publicprivate/types.go b/pkg/wsman/amt/publicprivate/types.go
new file mode 100644
index 00000000..fe56e5c9
--- /dev/null
+++ b/pkg/wsman/amt/publicprivate/types.go
@@ -0,0 +1,50 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package publicprivate
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+)
+
+type KeyPair struct {
+ base message.Base
+}
+
+// OUTPUTS
+// Response Types
+type (
+ Response struct {
+ *client.Message
+ XMLName xml.Name `xml:"Envelope"`
+ Header message.Header `xml:"Header"`
+ Body Body `xml:"Body"`
+ }
+
+ Body struct {
+ XMLName xml.Name `xml:"Body"`
+ GetResponse PublicPrivateKeyPair
+ EnumerateResponse common.EnumerateResponse
+ PullResponse PullResponse
+ }
+
+ PullResponse struct {
+ XMLName xml.Name `xml:"PullResponse"`
+ PublicPrivateKeyPairItems []PublicPrivateKeyPair `xml:"Items>AMT_PublicPrivateKeyPair"`
+ }
+
+ PublicPrivateKeyPair struct {
+ XMLName xml.Name `xml:"AMT_PublicPrivateKeyPair"`
+ ElementName string // A user-friendly name for the object. This property allows each instance to define a user-friendly name in addition to its key properties, identity data, and description information. Note that the Name property of ManagedSystemElement is also defined as a user-friendly name. But, it is often subclassed to be a Key. It is not reasonable that the same property can convey both identity and a user-friendly name, without inconsistencies. Where Name exists and is not a Key (such as for instances of LogicalDevice), the same information can be present in both the Name and ElementName properties. Note that if there is an associated instance of CIM_EnabledLogicalElementCapabilities, restrictions on this properties may exist as defined in ElementNameMask and MaxElementNameLen properties defined in that class.
+ InstanceID string // Within the scope of the instantiating Namespace, InstanceID opaquely and uniquely identifies an instance of this class.
+ DERKey string // RSA Key encoded as DES PKCS#1. The Exponent (E) is 65537 (0x010001).When this structure is used as an output parameter (GET or PULL method),only the public section of the key is exported. uint8[1210]
+ }
+
+ PublicPrivateSelector message.Selector
+)
diff --git a/pkg/wsman/amt/redirection/constants.go b/pkg/wsman/amt/redirection/constants.go
new file mode 100644
index 00000000..86333919
--- /dev/null
+++ b/pkg/wsman/amt/redirection/constants.go
@@ -0,0 +1,37 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package redirection
+
+const (
+ AMT_RedirectionService string = "AMT_RedirectionService"
+ RequestStateChange string = "RequestStateChange"
+)
+
+const (
+ Unknown EnabledState = iota
+ Other
+ Enabled
+ Disabled
+ ShuttingDown
+ NotApplicable
+ EnabledButOffline
+ InTest
+ Deferred
+ Quiesce
+ Starting
+ DMTFReserved
+ IDERAndSOLAreDisabled = 32768
+ IDERIsEnabledAndSOLIsDisabled = 32769
+ SOLIsEnabledAndIDERIsDisabled = 32770
+ IDERAndSOLAreEnabled = 32771
+)
+
+const (
+ DisableIDERAndSOL RequestedState = 32768
+ EnableIDERAndDisableSOL RequestedState = 32769
+ EnableSOLAndDisableIDER RequestedState = 32770
+ EnableIDERAndSOL RequestedState = 32771
+)
diff --git a/pkg/wsman/amt/redirection/marshal.go b/pkg/wsman/amt/redirection/marshal.go
new file mode 100644
index 00000000..494f48a5
--- /dev/null
+++ b/pkg/wsman/amt/redirection/marshal.go
@@ -0,0 +1,30 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package redirection
+
+import (
+ "encoding/json"
+
+ "gopkg.in/yaml.v3"
+)
+
+// JSON marshals the type into JSON format
+func (r *Response) JSON() string {
+ jsonOutput, err := json.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(jsonOutput)
+}
+
+// YAML marshals the type into YAML format
+func (r *Response) YAML() string {
+ yamlOutput, err := yaml.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(yamlOutput)
+}
diff --git a/pkg/wsman/amt/redirection/service.go b/pkg/wsman/amt/redirection/service.go
new file mode 100644
index 00000000..b911bb21
--- /dev/null
+++ b/pkg/wsman/amt/redirection/service.go
@@ -0,0 +1,141 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+// Package redirection facilitiates communication with Intel® AMT devices to configure the IDER and SOL redirection functionalities
+package redirection
+
+import (
+ "encoding/xml"
+ "fmt"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/methods"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+)
+
+// NewRedirectionServiceWithClient instantiates a new Service
+func NewRedirectionServiceWithClient(wsmanMessageCreator *message.WSManMessageCreator, client client.WSMan) Service {
+ return Service{
+ base: message.NewBaseWithClient(wsmanMessageCreator, AMT_RedirectionService, client),
+ }
+}
+
+// Get retrieves the representation of the instance
+func (service Service) Get() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: service.base.Get(nil),
+ },
+ }
+
+ // send the message to AMT
+ err = service.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Enumerate returns an enumeration context which is used in a subsequent Pull call
+func (service Service) Enumerate() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: service.base.Enumerate(),
+ },
+ }
+ // send the message to AMT
+ err = service.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Pull returns the instances of this class. An enumeration context provided by the Enumerate call is used as input.
+func (service Service) Pull(enumerationContext string) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: service.base.Pull(enumerationContext),
+ },
+ }
+ // send the message to AMT
+ err = service.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Put changes properties of the selected instance.
+// The following properties must be included in any representation of AMT_RedirectionService:
+//
+// - Name(cannot be modified)
+//
+// - CreationClassName(cannot be modified)
+//
+// - SystemName (cannot be modified)
+//
+// - SystemCreationClassName (cannot be modified)
+//
+// - ListenerEnabled
+func (service Service) Put(redirectionService RedirectionRequest) (response Response, err error) {
+ redirectionService.H = fmt.Sprintf("%s%s", message.AMTSchema, AMT_RedirectionService)
+ response = Response{
+ Message: &client.Message{
+ XMLInput: service.base.Put(redirectionService, false, nil),
+ },
+ }
+ // send the message to AMT
+ err = service.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// RequestStateChange requests that AMT change the state of the element to the value specified in the RequestedState parameter.
+// When the requested state change takes place, the EnabledState and RequestedState of the element will be the same.
+// Invoking the RequestStateChange method multiple times could result in earlier requests being overwritten or lost.
+// If 0 is returned, then the task completed successfully and the use of ConcreteJob was not required.
+// If 4096 (0x1000) is returned, then the task will take some time to complete, ConcreteJob will be created, and its reference returned in the output parameter Job.
+// Any other return code indicates an error condition.
+func (service Service) RequestStateChange(requestedState RequestedState) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: service.base.RequestStateChange(methods.GenerateAction(AMT_RedirectionService, RequestStateChange), int(requestedState)),
+ },
+ }
+ // send the message to AMT
+ err = service.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
diff --git a/pkg/wsman/amt/redirection/service_test.go b/pkg/wsman/amt/redirection/service_test.go
new file mode 100644
index 00000000..e770ef10
--- /dev/null
+++ b/pkg/wsman/amt/redirection/service_test.go
@@ -0,0 +1,332 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package redirection
+
+import (
+ "encoding/xml"
+ "fmt"
+ "testing"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
+ "github.com/stretchr/testify/assert"
+)
+
+func TestPositiveAMT_RedirectionService(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/redirectionservice",
+ }
+ elementUnderTest := NewRedirectionServiceWithClient(wsmanMessageCreator, &client)
+
+ t.Run("amt_RedirectionService Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create a valid AMT_RedirectionService Get wsman message",
+ AMT_RedirectionService,
+ wsmantesting.GET,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Get"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GetAndPutResponse: RedirectionResponse{
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_RedirectionService), Local: AMT_RedirectionService},
+ CreationClassName: AMT_RedirectionService,
+ ElementName: "Intel(r) AMT Redirection Service",
+ EnabledState: 32771,
+ ListenerEnabled: true,
+ Name: "Intel(r) AMT Redirection Service",
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "Intel(r) AMT",
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create a valid AMT_RedirectionService Enumerate wsman message",
+ AMT_RedirectionService,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Enumerate"
+ if elementUnderTest.base.WSManMessageCreator == nil {
+ print("Error")
+ }
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "D3000000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid AMT_RedirectionService Pull wsman message",
+ AMT_RedirectionService,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Pull"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: message.XMLPullResponseSpace, Local: "PullResponse"},
+ RedirectionItems: []RedirectionResponse{
+ {
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_RedirectionService), Local: AMT_RedirectionService},
+ CreationClassName: AMT_RedirectionService,
+ ElementName: "Intel(r) AMT Redirection Service",
+ EnabledState: 32771,
+ ListenerEnabled: true,
+ Name: "Intel(r) AMT Redirection Service",
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "Intel(r) AMT",
+ },
+ },
+ },
+ },
+ },
+ //PUTS
+ {
+ "should create a valid AMT_RedirectionService Put wsman message",
+ AMT_RedirectionService,
+ wsmantesting.PUT,
+ "AMT_RedirectionServiceIntel(r) AMT Redirection Service32771trueIntel(r) AMT Redirection ServiceCIM_ComputerSystemIntel(r) AMT",
+ func() (Response, error) {
+ client.CurrentMessage = "Put"
+ redirectionRequest := RedirectionRequest{
+ CreationClassName: AMT_RedirectionService,
+ ElementName: "Intel(r) AMT Redirection Service",
+ EnabledState: 32771,
+ ListenerEnabled: true,
+ Name: "Intel(r) AMT Redirection Service",
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "Intel(r) AMT",
+ }
+ return elementUnderTest.Put(redirectionRequest)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GetAndPutResponse: RedirectionResponse{
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_RedirectionService), Local: AMT_RedirectionService},
+ CreationClassName: AMT_RedirectionService,
+ ElementName: "Intel(r) AMT Redirection Service",
+ EnabledState: 32771,
+ ListenerEnabled: true,
+ Name: "Intel(r) AMT Redirection Service",
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "Intel(r) AMT",
+ },
+ },
+ },
+ //REQUEST STATE CHANGE
+ {
+ "should create a valid AMT_RedirectionService Request State Change wsman message",
+ AMT_RedirectionService,
+ fmt.Sprintf("%s%s/%s", message.AMTSchema, AMT_RedirectionService, "RequestStateChange"),
+ "32771",
+ func() (Response, error) {
+ client.CurrentMessage = "RequestStateChange"
+ return elementUnderTest.RequestStateChange(EnableIDERAndSOL)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ RequestStateChange_OUTPUT: RequestStateChange_OUTPUT{
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_RedirectionService), Local: "RequestStateChange_OUTPUT"},
+ ReturnValue: 0,
+ },
+ },
+ },
+ }
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.NoError(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.Equal(t, test.expectedResponse, response.Body)
+
+ })
+ }
+
+ })
+}
+func TestNegativeAMT_RedirectionService(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/redirectionservice",
+ }
+ elementUnderTest := NewRedirectionServiceWithClient(wsmanMessageCreator, &client)
+
+ t.Run("amt_RedirectionService Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create a valid AMT_RedirectionService Get wsman message",
+ AMT_RedirectionService,
+ wsmantesting.GET,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GetAndPutResponse: RedirectionResponse{
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_RedirectionService), Local: AMT_RedirectionService},
+ CreationClassName: AMT_RedirectionService,
+ ElementName: "Intel(r) AMT Redirection Service",
+ EnabledState: 32771,
+ ListenerEnabled: true,
+ Name: "Intel(r) AMT Redirection Service",
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "Intel(r) AMT",
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create a valid AMT_RedirectionService Enumerate wsman message",
+ AMT_RedirectionService,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ if elementUnderTest.base.WSManMessageCreator == nil {
+ print("Error")
+ }
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "D3000000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid AMT_RedirectionService Pull wsman message",
+ AMT_RedirectionService,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: message.XMLPullResponseSpace, Local: "PullResponse"},
+ RedirectionItems: []RedirectionResponse{
+ {
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_RedirectionService), Local: AMT_RedirectionService},
+ CreationClassName: AMT_RedirectionService,
+ ElementName: "Intel(r) AMT Redirection Service",
+ EnabledState: 32771,
+ ListenerEnabled: true,
+ Name: "Intel(r) AMT Redirection Service",
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "Intel(r) AMT",
+ },
+ },
+ },
+ },
+ },
+ //PUTS
+ {
+ "should create a valid AMT_RedirectionService Put wsman message",
+ AMT_RedirectionService,
+ wsmantesting.PUT,
+ "AMT_RedirectionServiceIntel(r) AMT Redirection Service32771trueIntel(r) AMT Redirection ServiceCIM_ComputerSystemIntel(r) AMT",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ redirectionRequest := RedirectionRequest{
+ CreationClassName: AMT_RedirectionService,
+ ElementName: "Intel(r) AMT Redirection Service",
+ EnabledState: 32771,
+ ListenerEnabled: true,
+ Name: "Intel(r) AMT Redirection Service",
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "Intel(r) AMT",
+ }
+ return elementUnderTest.Put(redirectionRequest)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GetAndPutResponse: RedirectionResponse{
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_RedirectionService), Local: AMT_RedirectionService},
+ CreationClassName: AMT_RedirectionService,
+ ElementName: "Intel(r) AMT Redirection Service",
+ EnabledState: 32771,
+ ListenerEnabled: true,
+ Name: "Intel(r) AMT Redirection Service",
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "Intel(r) AMT",
+ },
+ },
+ },
+ //REQUEST STATE CHANGE
+ {
+ "should create a valid AMT_RedirectionService Request State Change wsman message",
+ AMT_RedirectionService,
+ fmt.Sprintf("%s%s/%s", message.AMTSchema, AMT_RedirectionService, "RequestStateChange"),
+ "32771",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.RequestStateChange(EnableIDERAndSOL)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ RequestStateChange_OUTPUT: RequestStateChange_OUTPUT{
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_RedirectionService), Local: "RequestStateChange_OUTPUT"},
+ ReturnValue: 0,
+ },
+ },
+ },
+ }
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.Error(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.NotEqual(t, test.expectedResponse, response.Body)
+
+ })
+ }
+
+ })
+}
diff --git a/pkg/wsman/amt/redirection/types.go b/pkg/wsman/amt/redirection/types.go
new file mode 100644
index 00000000..a66b6946
--- /dev/null
+++ b/pkg/wsman/amt/redirection/types.go
@@ -0,0 +1,107 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package redirection
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+)
+
+type Service struct {
+ base message.Base
+}
+
+// OUTPUT
+// Response Types
+type (
+ Response struct {
+ *client.Message
+ XMLName xml.Name `xml:"Envelope"`
+ Header message.Header `xml:"Header"`
+ Body Body `xml:"Body"`
+ }
+ Body struct {
+ XMLName xml.Name `xml:"Body"`
+ GetAndPutResponse RedirectionResponse `xml:"AMT_RedirectionService"`
+ RequestStateChange_OUTPUT RequestStateChange_OUTPUT `xml:"RequestStateChange_OUTPUT"`
+ EnumerateResponse common.EnumerateResponse
+ PullResponse PullResponse
+ }
+ RedirectionResponse struct {
+ XMLName xml.Name `xml:"AMT_RedirectionService"`
+ CreationClassName string `xml:"CreationClassName,omitempty"` // CreationClassName indicates the name of the class or the subclass that is used in the creation of an instance. When used with the other key properties of this class, this property allows all instances of this class and its subclasses to be uniquely identified.
+ ElementName string `xml:"ElementName,omitempty"` // A user-friendly name for the object. This property allows each instance to define a user-friendly name in addition to its key properties, identity data, and description information. Note that the Name property of ManagedSystemElement is also defined as a user-friendly name. But, it is often subclassed to be a Key. It is not reasonable that the same property can convey both identity and a user-friendly name, without inconsistencies. Where Name exists and is not a Key (such as for instances of LogicalDevice), the same information can be present in both the Name and ElementName properties. Note that if there is an associated instance of CIM_EnabledLogicalElementCapabilities, restrictions on this properties may exist as defined in ElementNameMask and MaxElementNameLen properties defined in that class.
+ EnabledState EnabledState `xml:"EnabledState"` // EnabledState is an integer enumeration that indicates the enabled and disabled states of an element.
+ ListenerEnabled bool `xml:"ListenerEnabled"` // Describes the listener state of this service. The service is operational only if its EnabledState is set to Enabled (by the Intel® AMT Administrator) and the ListenerEnabled is set to TRUE (by a RedirectionRealm user)
+ Name string `xml:"Name,omitempty"` // The Name property uniquely identifies the Service and provides an indication of the functionality that is managed. This functionality is described in more detail in the Description property of the object.
+ SystemCreationClassName string `xml:"SystemCreationClassName,omitempty"` // The CreationClassName of the scoping System.
+ SystemName string `xml:"SystemName,omitempty"` // The Name of the scoping System.
+ AccessLog []string `xml:"AccessLog,omitempty"` // A list of string elements, describing recent IDE redirection operations. The format of each element is: 'Date (MM/DD/YYYY), Time (hh:mm:ss), IP:Port'
+ }
+ PullResponse struct {
+ XMLName xml.Name `xml:"PullResponse"`
+ RedirectionItems []RedirectionResponse `xml:"Items>AMT_RedirectionService"`
+ }
+ RequestStateChange_OUTPUT struct {
+ XMLName xml.Name `xml:"RequestStateChange_OUTPUT"`
+ // ValueMap={0, 1, 2, 3, 4, 5, 6, .., 4096, 4097, 4098, 4099, 4100..32767, 32768..65535}
+ //
+ // Values={Completed with No Error, Not Supported, Unknown or Unspecified Error, Cannot complete within Timeout Period, Failed, Invalid Parameter, In Use, DMTF Reserved, Method Parameters Checked - Job Started, Invalid State Transition, Use of Timeout Parameter Not Supported, Busy, Method Reserved, Vendor Specific}
+ ReturnValue int `xml:"ReturnValue"`
+ }
+)
+
+// INPUT
+// Request Types
+type (
+ RedirectionRequest struct {
+ XMLName xml.Name `xml:"h:AMT_RedirectionService"`
+ H string `xml:"xmlns:h,attr"`
+ CreationClassName string `xml:"h:CreationClassName,omitempty"` // CreationClassName indicates the name of the class or the subclass that is used in the creation of an instance. When used with the other key properties of this class, this property allows all instances of this class and its subclasses to be uniquely identified.
+ ElementName string `xml:"h:ElementName,omitempty"` // A user-friendly name for the object. This property allows each instance to define a user-friendly name in addition to its key properties, identity data, and description information. Note that the Name property of ManagedSystemElement is also defined as a user-friendly name. But, it is often subclassed to be a Key. It is not reasonable that the same property can convey both identity and a user-friendly name, without inconsistencies. Where Name exists and is not a Key (such as for instances of LogicalDevice), the same information can be present in both the Name and ElementName properties. Note that if there is an associated instance of CIM_EnabledLogicalElementCapabilities, restrictions on this properties may exist as defined in ElementNameMask and MaxElementNameLen properties defined in that class.
+ EnabledState EnabledState `xml:"h:EnabledState"` // EnabledState is an integer enumeration that indicates the enabled and disabled states of an element.
+ ListenerEnabled bool `xml:"h:ListenerEnabled"` // Describes the listener state of this service. The service is operational only if its EnabledState is set to Enabled (by the Intel® AMT Administrator) and the ListenerEnabled is set to TRUE (by a RedirectionRealm user)
+ Name string `xml:"h:Name,omitempty"` // The Name property uniquely identifies the Service and provides an indication of the functionality that is managed. This functionality is described in more detail in the Description property of the object.
+ SystemCreationClassName string `xml:"h:SystemCreationClassName,omitempty"` // The CreationClassName of the scoping System.
+ SystemName string `xml:"h:SystemName,omitempty"` // The Name of the scoping System.
+ AccessLog []string `xml:"AccessLog,omitempty"` // Read only. A list of string elements, describing recent IDE redirection operations. The format of each element is: 'Date (MM/DD/YYYY), Time (hh:mm:ss), IP:Port'
+ }
+)
+
+// EnabledState is an integer enumeration that indicates the enabled and disabled states of an element. It can also indicate the transitions between these requested states. For example, shutting down (value=4) and starting (value=10) are transient states between enabled and disabled. The following text briefly summarizes the various enabled and disabled states:
+//
+// Enabled (2) indicates that the element is or could be executing commands, will process any queued commands, and queues new requests.
+//
+// Disabled (3) indicates that the element will not execute commands and will drop any new requests.
+//
+// Shutting Down (4) indicates that the element is in the process of going to a Disabled state.
+//
+// Not Applicable (5) indicates the element does not support being enabled or disabled.
+//
+// Enabled but Offline (6) indicates that the element might be completing commands, and will drop any new requests.
+//
+// Test (7) indicates that the element is in a test state.
+//
+// Deferred (8) indicates that the element might be completing commands, but will queue any new requests.
+//
+// Quiesce (9) indicates that the element is enabled but in a restricted mode. The behavior of the element is similar to the Enabled state, but it processes only a restricted set of commands. All other requests are queued.
+//
+// Starting (10) indicates that the element is in the process of going to an Enabled state. New requests are queued.
+//
+// ValueMap={0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11..32767, 32768, 32769, 32770, 32771, 32772..65535}
+//
+// Values={Unknown, Other, Enabled, Disabled, Shutting Down, Not Applicable, Enabled but Offline, In Test, Deferred, Quiesce, Starting, DMTF Reserved, IDER and SOL are disabled, IDER is enabled and SOL is disabled, SOL is enabled and IDER is disabled, IDER and SOL are enabled, Vendor Reserved}
+type EnabledState int
+
+// The state requested for the element. This information will be placed into the RequestedState property of the instance if the return code of the RequestStateChange method is 0 ('Completed with No Error'), 3 ('Timeout'), or 4096 (0x1000) ('Job Started'). Refer to the description of the EnabledState and RequestedState properties for the detailed explanations of the RequestedState values.
+//
+// ValueMap={2, 3, 4, 6, 7, 8, 9, 10, 11, .., 32768, 32769, 32770, 32771, 32772..65535}
+//
+// Values={Enabled, Disabled, Shut Down, Offline, Test, Defer, Quiesce, Reboot, Reset, DMTF Reserved, disable IDER and SOL, enable IDER and disable SOL, enable SOL and disable IDER, enable IDER and SOL, Vendor Reserved}
+type RequestedState int
diff --git a/pkg/wsman/amt/remoteaccess/constants.go b/pkg/wsman/amt/remoteaccess/constants.go
new file mode 100644
index 00000000..9e472606
--- /dev/null
+++ b/pkg/wsman/amt/remoteaccess/constants.go
@@ -0,0 +1,43 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package remoteaccess
+
+const (
+ AMT_RemoteAccessPolicyAppliesToMPS string = "AMT_RemoteAccessPolicyAppliesToMPS"
+ AMT_RemoteAccessPolicyRule string = "AMT_RemoteAccessPolicyRule"
+ AMT_RemoteAccessService string = "AMT_RemoteAccessService"
+ AddMps string = "AddMpServer"
+ AddRemoteAccessPolicyRule string = "AddRemoteAccessPolicyRule"
+)
+
+const (
+ IPv4Address MPServerInfoFormat = 3
+ IPv6Address MPServerInfoFormat = 4
+ FQDN MPServerInfoFormat = 201
+)
+
+const (
+ MutualAuthentication MPServerAuthMethod = 1
+ UsernamePasswordAuthentication MPServerAuthMethod = 2
+)
+
+const (
+ UserInitiated Trigger = iota
+ Alert
+ Periodic
+ HomeProvisioning
+)
+
+const (
+ PolicyDecisionStrategyFirstMatching PolicyDecisionStrategy = 1
+ PolicyDecisionStrategyAll PolicyDecisionStrategy = 2
+)
+
+const (
+ ExternalMPS MPSType = iota
+ InternalMPS
+ BothMPS
+)
diff --git a/pkg/wsman/amt/remoteaccess/marshal.go b/pkg/wsman/amt/remoteaccess/marshal.go
new file mode 100644
index 00000000..6f7b4505
--- /dev/null
+++ b/pkg/wsman/amt/remoteaccess/marshal.go
@@ -0,0 +1,30 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package remoteaccess
+
+import (
+ "encoding/json"
+
+ "gopkg.in/yaml.v3"
+)
+
+// JSON marshals the type into JSON format
+func (r *Response) JSON() string {
+ jsonOutput, err := json.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(jsonOutput)
+}
+
+// YAML marshals the type into YAML format
+func (r *Response) YAML() string {
+ yamlOutput, err := yaml.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(yamlOutput)
+}
diff --git a/pkg/wsman/amt/remoteaccess/policyappliestomps.go b/pkg/wsman/amt/remoteaccess/policyappliestomps.go
new file mode 100644
index 00000000..5e2f79c1
--- /dev/null
+++ b/pkg/wsman/amt/remoteaccess/policyappliestomps.go
@@ -0,0 +1,144 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+// Package remoteaccess facilitiates communication with Intel® AMT devices to access and configure Remote Access Policy Applies to MPS, Remote Access Policy Rules, and Remote Access Service.
+//
+// Remote Access Policy Applies To MPS:
+// This class associates a Management Presence Server with a Remote Access Policy rule.
+// When a Policy Rule is triggered, the Intel® AMT subsystem will attempt to connect to the MpServers associated with the triggered policy in the order by which the associations were created.
+// This order is indicated in the OrderOfAccess field where lower numbers indicate a higher priority.
+//
+// Remote Access Policy Rule:
+// Represents a Remote Access policy.
+// The policy defines a condition that will trigger the establishment of a tunnel between the Intel® AMT subsystem and a remote MpServer.
+// The policy also defines parameters for the connection such as TunnelLifeTime in seconds.
+//
+// Remote Access Service:
+// Represents the Remote Access Service in the Intel® AMT subsystem.
+package remoteaccess
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+)
+
+// NewRemoteAccessPolicyAppliesToMPSWithClient instantiates a new PolicyAppliesToMPS
+func NewRemoteAccessPolicyAppliesToMPSWithClient(wsmanMessageCreator *message.WSManMessageCreator, client client.WSMan) PolicyAppliesToMPS {
+ return PolicyAppliesToMPS{
+ base: message.NewBaseWithClient(wsmanMessageCreator, AMT_RemoteAccessPolicyAppliesToMPS, client),
+ }
+}
+
+// Get retrieves the representation of the instance
+func (policyAppliesToMPS PolicyAppliesToMPS) Get() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: policyAppliesToMPS.base.Get(nil),
+ },
+ }
+ // send the message to AMT
+ err = policyAppliesToMPS.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Enumerate returns an enumeration context which is used in a subsequent Pull call
+func (policyAppliesToMPS PolicyAppliesToMPS) Enumerate() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: policyAppliesToMPS.base.Enumerate(),
+ },
+ }
+ // send the message to AMT
+ err = policyAppliesToMPS.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+
+ return
+}
+
+// Pull returns the instances of this class. An enumeration context provided by the Enumerate call is used as input.
+func (policyAppliesToMPS PolicyAppliesToMPS) Pull(enumerationContext string) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: policyAppliesToMPS.base.Pull(enumerationContext),
+ },
+ }
+ // send the message to AMT
+ err = policyAppliesToMPS.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+
+ return
+}
+
+// Put will change properties of the selected instance
+func (policyAppliesToMPS PolicyAppliesToMPS) Put(remoteAccessPolicyAppliesToMPS *RemoteAccessPolicyAppliesToMPSRequest) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: policyAppliesToMPS.base.Put(remoteAccessPolicyAppliesToMPS, false, nil),
+ },
+ }
+ // send the message to AMT
+ err = policyAppliesToMPS.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+
+ return
+}
+
+// Delete removes a the specified instance
+func (policyAppliesToMPS PolicyAppliesToMPS) Delete(handle string) (response Response, err error) {
+ selector := message.Selector{Name: "Name", Value: handle}
+ response = Response{
+ Message: &client.Message{
+ XMLInput: policyAppliesToMPS.base.Delete(selector),
+ },
+ }
+ // send the message to AMT
+ err = policyAppliesToMPS.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+
+ return
+}
diff --git a/pkg/wsman/amt/remoteaccess/policyappliestomps_test.go b/pkg/wsman/amt/remoteaccess/policyappliestomps_test.go
new file mode 100644
index 00000000..64d3b823
--- /dev/null
+++ b/pkg/wsman/amt/remoteaccess/policyappliestomps_test.go
@@ -0,0 +1,654 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package remoteaccess
+
+import (
+ "encoding/xml"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
+)
+
+const (
+ EnvelopeResponseApply = `http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous0`
+ GetBodyApply = `AMT_AuthorizationServiceIntel(r) AMT Authorization ServiceIntel(r) AMT Alarm Clock ServiceCIM_ComputerSystemManagedSystem`
+)
+
+func TestPositiveAMT_RemoteAccessPolicyAppliesToMPS(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/remoteaccess/policyappliestomps",
+ }
+ elementUnderTest := NewRemoteAccessPolicyAppliesToMPSWithClient(wsmanMessageCreator, &client)
+ t.Run("amt_RemoteAccessPolicyAppliesToMPS Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ extraHeader string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create a valid AMT_RemoteAccessPolicyAppliesToMPS Get wsman message",
+ AMT_RemoteAccessPolicyAppliesToMPS,
+ wsmantesting.GET,
+ "",
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Get"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ RemoteAccessPolicyAppliesToMPSGetResponse: RemoteAccessPolicyAppliesToMPSResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_RemoteAccessPolicyAppliesToMPS", Local: "AMT_RemoteAccessPolicyAppliesToMPS"},
+ ManagedElement: ManagedElementResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_RemoteAccessPolicyAppliesToMPS", Local: "ManagedElement"},
+ Address: "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
+ ReferenceParameters: ReferenceParametersResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/08/addressing", Local: "ReferenceParameters"},
+ ResourceURI: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_ManagementPresenceRemoteSAP",
+ SelectorSet: SelectorSetResponse{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "SelectorSet"},
+ Selectors: []SelectorResponse{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "CreationClassName",
+ Text: "AMT_ManagementPresenceRemoteSAP",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "Name",
+ Text: "Intel(r) AMT:Management Presence Server 0",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "SystemCreationClassName",
+ Text: "CIM_ComputerSystem",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "SystemName",
+ Text: "Intel(r) AMT",
+ },
+ },
+ },
+ },
+ },
+ MpsType: 2,
+ OrderOfAccess: 0,
+ PolicySet: PolicySetResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_RemoteAccessPolicyAppliesToMPS", Local: "PolicySet"},
+ Address: "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
+ ReferenceParameters: ReferenceParametersResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/08/addressing", Local: "ReferenceParameters"},
+ ResourceURI: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_RemoteAccessPolicyRule",
+ SelectorSet: SelectorSetResponse{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "SelectorSet"},
+ Selectors: []SelectorResponse{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "CreationClassName",
+ Text: "AMT_RemoteAccessPolicyRule",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "PolicyRuleName",
+ Text: "Periodic",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "SystemCreationClassName",
+ Text: "CIM_ComputerSystem",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "SystemName",
+ Text: "Intel(r) AMT",
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create a valid AMT_RemoteAccessPolicyAppliesToMPS Enumerate wsman message",
+ AMT_RemoteAccessPolicyAppliesToMPS,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Enumerate"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "CE000000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid AMT_RemoteAccessPolicyAppliesToMPS Pull wsman message",
+ AMT_RemoteAccessPolicyAppliesToMPS,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Pull"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ PolicyAppliesItems: []RemoteAccessPolicyAppliesToMPSResponse{
+ {
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_RemoteAccessPolicyAppliesToMPS", Local: "AMT_RemoteAccessPolicyAppliesToMPS"},
+ ManagedElement: ManagedElementResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_RemoteAccessPolicyAppliesToMPS", Local: "ManagedElement"},
+ Address: "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
+ ReferenceParameters: ReferenceParametersResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/08/addressing", Local: "ReferenceParameters"},
+ ResourceURI: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_ManagementPresenceRemoteSAP",
+ SelectorSet: SelectorSetResponse{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "SelectorSet"},
+ Selectors: []SelectorResponse{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "CreationClassName",
+ Text: "AMT_ManagementPresenceRemoteSAP",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "Name",
+ Text: "Intel(r) AMT:Management Presence Server 0",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "SystemCreationClassName",
+ Text: "CIM_ComputerSystem",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "SystemName",
+ Text: "Intel(r) AMT",
+ },
+ },
+ },
+ },
+ },
+ MpsType: 0,
+ OrderOfAccess: 0,
+ PolicySet: PolicySetResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_RemoteAccessPolicyAppliesToMPS", Local: "PolicySet"},
+ Address: "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
+ ReferenceParameters: ReferenceParametersResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/08/addressing", Local: "ReferenceParameters"},
+ ResourceURI: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_RemoteAccessPolicyRule",
+ SelectorSet: SelectorSetResponse{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "SelectorSet"},
+ Selectors: []SelectorResponse{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "CreationClassName",
+ Text: "AMT_RemoteAccessPolicyRule",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "PolicyRuleName",
+ Text: "Periodic",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "SystemCreationClassName",
+ Text: "CIM_ComputerSystem",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "SystemName",
+ Text: "Intel(r) AMT",
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ {
+ "should create a valid AMT_RemoteAccessPolicyAppliesToMPS Put wsman message",
+ AMT_RemoteAccessPolicyAppliesToMPS,
+ wsmantesting.PUT,
+ `http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymoushttp://intel.com/wbem/wscim/1/amt-schema/1/AMT_ManagementPresenceRemoteSAPAMT_ManagementPresenceRemoteSAPIntel(r) AMT:Management Presence Server 0CIM_ComputerSystemIntel(r) AMT02http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymoushttp://intel.com/wbem/wscim/1/amt-schema/1/AMT_RemoteAccessPolicyRuleAMT_RemoteAccessPolicyRulePeriodicCIM_ComputerSystemIntel(r) AMT`,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Put"
+ rapatmps := RemoteAccessPolicyAppliesToMPSRequest{
+ H: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_RemoteAccessPolicyAppliesToMPS",
+ ManagedElement: ManagedElement{
+ B: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_RemoteAccessPolicyAppliesToMPS",
+ Address: "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
+ ReferenceParameters: ReferenceParameters{
+ C: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd",
+ ResourceURI: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_ManagementPresenceRemoteSAP",
+ SelectorSet: SelectorSet{
+ Selectors: []Selector{
+ {
+ Name: "CreationClassName",
+ Text: "AMT_ManagementPresenceRemoteSAP",
+ },
+ {
+ Name: "Name",
+ Text: "Intel(r) AMT:Management Presence Server 0",
+ },
+ {
+ Name: "SystemCreationClassName",
+ Text: "CIM_ComputerSystem",
+ },
+ {
+ Name: "SystemName",
+ Text: "Intel(r) AMT",
+ },
+ },
+ },
+ },
+ },
+ OrderOfAccess: 0,
+ MPSType: BothMPS,
+ PolicySet: PolicySet{
+ B: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_RemoteAccessPolicyAppliesToMPS",
+ Address: "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
+ ReferenceParameters: ReferenceParameters{
+ C: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd",
+ ResourceURI: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_RemoteAccessPolicyRule",
+ SelectorSet: SelectorSet{
+ Selectors: []Selector{
+ {
+ Name: "CreationClassName",
+ Text: "AMT_RemoteAccessPolicyRule",
+ },
+ {
+ Name: "PolicyRuleName",
+ Text: "Periodic",
+ },
+ {
+ Name: "SystemCreationClassName",
+ Text: "CIM_ComputerSystem",
+ },
+ {
+ Name: "SystemName",
+ Text: "Intel(r) AMT",
+ },
+ },
+ },
+ },
+ },
+ }
+ return elementUnderTest.Put(&rapatmps)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ },
+ },
+ //{"should create a valid AMT_RemoteAccessPolicyAppliesToMPS Create wsman message", AMT_RemoteAccessPolicyAppliesToMPS, wsmantesting.PULL, wsmantesting.PULL_BODY, "", func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
+ {
+ "should create a valid AMT_RemoteAccessPolicyAppliesToMPS Delete wsman message",
+ AMT_RemoteAccessPolicyAppliesToMPS, wsmantesting.DELETE,
+ "",
+ "Instance",
+ func() (Response, error) {
+ return elementUnderTest.Delete("Instance")
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, test.extraHeader, test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.NoError(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.Equal(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
+func TestNegativeAMT_RemoteAccessPolicyAppliesToMPS(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/remoteaccess/policyappliestomps",
+ }
+ elementUnderTest := NewRemoteAccessPolicyAppliesToMPSWithClient(wsmanMessageCreator, &client)
+ t.Run("amt_RemoteAccessPolicyAppliesToMPS Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ extraHeader string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create a valid AMT_RemoteAccessPolicyAppliesToMPS Get wsman message",
+ AMT_RemoteAccessPolicyAppliesToMPS,
+ wsmantesting.GET,
+ "",
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ RemoteAccessPolicyAppliesToMPSGetResponse: RemoteAccessPolicyAppliesToMPSResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_RemoteAccessPolicyAppliesToMPS", Local: "AMT_RemoteAccessPolicyAppliesToMPS"},
+ ManagedElement: ManagedElementResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_RemoteAccessPolicyAppliesToMPS", Local: "ManagedElement"},
+ Address: "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
+ ReferenceParameters: ReferenceParametersResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/08/addressing", Local: "ReferenceParameters"},
+ ResourceURI: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_ManagementPresenceRemoteSAP",
+ SelectorSet: SelectorSetResponse{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "SelectorSet"},
+ Selectors: []SelectorResponse{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "CreationClassName",
+ Text: "AMT_ManagementPresenceRemoteSAP",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "Name",
+ Text: "Intel(r) AMT:Management Presence Server 0",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "SystemCreationClassName",
+ Text: "CIM_ComputerSystem",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "SystemName",
+ Text: "Intel(r) AMT",
+ },
+ },
+ },
+ },
+ },
+ MpsType: 2,
+ OrderOfAccess: 0,
+ PolicySet: PolicySetResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_RemoteAccessPolicyAppliesToMPS", Local: "PolicySet"},
+ Address: "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
+ ReferenceParameters: ReferenceParametersResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/08/addressing", Local: "ReferenceParameters"},
+ ResourceURI: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_RemoteAccessPolicyRule",
+ SelectorSet: SelectorSetResponse{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "SelectorSet"},
+ Selectors: []SelectorResponse{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "CreationClassName",
+ Text: "AMT_RemoteAccessPolicyRule",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "PolicyRuleName",
+ Text: "Periodic",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "SystemCreationClassName",
+ Text: "CIM_ComputerSystem",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "SystemName",
+ Text: "Intel(r) AMT",
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create a valid AMT_RemoteAccessPolicyAppliesToMPS Enumerate wsman message",
+ AMT_RemoteAccessPolicyAppliesToMPS,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "CE000000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid AMT_RemoteAccessPolicyAppliesToMPS Pull wsman message",
+ AMT_RemoteAccessPolicyAppliesToMPS,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ PolicyAppliesItems: []RemoteAccessPolicyAppliesToMPSResponse{
+ {
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_RemoteAccessPolicyAppliesToMPS", Local: "AMT_RemoteAccessPolicyAppliesToMPS"},
+ ManagedElement: ManagedElementResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_RemoteAccessPolicyAppliesToMPS", Local: "ManagedElement"},
+ Address: "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
+ ReferenceParameters: ReferenceParametersResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/08/addressing", Local: "ReferenceParameters"},
+ ResourceURI: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_ManagementPresenceRemoteSAP",
+ SelectorSet: SelectorSetResponse{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "SelectorSet"},
+ Selectors: []SelectorResponse{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "CreationClassName",
+ Text: "AMT_ManagementPresenceRemoteSAP",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "Name",
+ Text: "Intel(r) AMT:Management Presence Server 0",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "SystemCreationClassName",
+ Text: "CIM_ComputerSystem",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "SystemName",
+ Text: "Intel(r) AMT",
+ },
+ },
+ },
+ },
+ },
+ MpsType: 0,
+ OrderOfAccess: 0,
+ PolicySet: PolicySetResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_RemoteAccessPolicyAppliesToMPS", Local: "PolicySet"},
+ Address: "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
+ ReferenceParameters: ReferenceParametersResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/08/addressing", Local: "ReferenceParameters"},
+ ResourceURI: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_RemoteAccessPolicyRule",
+ SelectorSet: SelectorSetResponse{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "SelectorSet"},
+ Selectors: []SelectorResponse{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "CreationClassName",
+ Text: "AMT_RemoteAccessPolicyRule",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "PolicyRuleName",
+ Text: "Periodic",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "SystemCreationClassName",
+ Text: "CIM_ComputerSystem",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "SystemName",
+ Text: "Intel(r) AMT",
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ {
+ "should create a valid AMT_RemoteAccessPolicyAppliesToMPS Put wsman message",
+ AMT_RemoteAccessPolicyAppliesToMPS,
+ wsmantesting.PUT,
+ `http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymoushttp://intel.com/wbem/wscim/1/amt-schema/1/AMT_ManagementPresenceRemoteSAPAMT_ManagementPresenceRemoteSAPIntel(r) AMT:Management Presence Server 0CIM_ComputerSystemIntel(r) AMT02http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymoushttp://intel.com/wbem/wscim/1/amt-schema/1/AMT_RemoteAccessPolicyRuleAMT_RemoteAccessPolicyRulePeriodicCIM_ComputerSystemIntel(r) AMT`,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ rapatmps := RemoteAccessPolicyAppliesToMPSRequest{
+ H: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_RemoteAccessPolicyAppliesToMPS",
+ ManagedElement: ManagedElement{
+ B: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_RemoteAccessPolicyAppliesToMPS",
+ Address: "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
+ ReferenceParameters: ReferenceParameters{
+ C: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd",
+ ResourceURI: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_ManagementPresenceRemoteSAP",
+ SelectorSet: SelectorSet{
+ Selectors: []Selector{
+ {
+ Name: "CreationClassName",
+ Text: "AMT_ManagementPresenceRemoteSAP",
+ },
+ {
+ Name: "Name",
+ Text: "Intel(r) AMT:Management Presence Server 0",
+ },
+ {
+ Name: "SystemCreationClassName",
+ Text: "CIM_ComputerSystem",
+ },
+ {
+ Name: "SystemName",
+ Text: "Intel(r) AMT",
+ },
+ },
+ },
+ },
+ },
+ OrderOfAccess: 0,
+ MPSType: BothMPS,
+ PolicySet: PolicySet{
+ B: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_RemoteAccessPolicyAppliesToMPS",
+ Address: "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
+ ReferenceParameters: ReferenceParameters{
+ C: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd",
+ ResourceURI: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_RemoteAccessPolicyRule",
+ SelectorSet: SelectorSet{
+ Selectors: []Selector{
+ {
+ Name: "CreationClassName",
+ Text: "AMT_RemoteAccessPolicyRule",
+ },
+ {
+ Name: "PolicyRuleName",
+ Text: "Periodic",
+ },
+ {
+ Name: "SystemCreationClassName",
+ Text: "CIM_ComputerSystem",
+ },
+ {
+ Name: "SystemName",
+ Text: "Intel(r) AMT",
+ },
+ },
+ },
+ },
+ },
+ }
+ return elementUnderTest.Put(&rapatmps)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ },
+ },
+ //{"should create a valid AMT_RemoteAccessPolicyAppliesToMPS Create wsman message", AMT_RemoteAccessPolicyAppliesToMPS, wsmantesting.PULL, wsmantesting.PULL_BODY, "", func() string { return elementUnderTest.Pull(wsmantesting.EnumerationContext) }},
+ {
+ "should create a valid AMT_RemoteAccessPolicyAppliesToMPS Delete wsman message",
+ AMT_RemoteAccessPolicyAppliesToMPS, wsmantesting.DELETE,
+ "",
+ "Instance",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Delete("Instance")
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, test.extraHeader, test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.Error(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.NotEqual(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
diff --git a/pkg/wsman/amt/remoteaccess/policyrule.go b/pkg/wsman/amt/remoteaccess/policyrule.go
new file mode 100644
index 00000000..1f477541
--- /dev/null
+++ b/pkg/wsman/amt/remoteaccess/policyrule.go
@@ -0,0 +1,128 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package remoteaccess
+
+import (
+ "encoding/xml"
+ "fmt"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+)
+
+// NewPolicyRuleWithClient instantiates a new PolicyRule
+func NewPolicyRuleWithClient(wsmanMessageCreator *message.WSManMessageCreator, clientPolicy client.WSMan) PolicyRule {
+ return PolicyRule{
+ base: message.NewBaseWithClient(wsmanMessageCreator, AMT_RemoteAccessPolicyRule, clientPolicy),
+ }
+}
+
+// Get retrieves the representation of the instance
+func (policyRule PolicyRule) Get() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: policyRule.base.Get(nil),
+ },
+ }
+ // send the message to AMT
+ err = policyRule.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Enumerate returns an enumeration context which is used in a subsequent Pull call
+func (policyRule PolicyRule) Enumerate() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: policyRule.base.Enumerate(),
+ },
+ }
+ // send the message to AMT
+ err = policyRule.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+
+ return
+}
+
+// Pull returns the instances of this class. An enumeration context provided by the Enumerate call is used as input.
+func (policyRule PolicyRule) Pull(enumerationContext string) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: policyRule.base.Pull(enumerationContext),
+ },
+ }
+ // send the message to AMT
+ err = policyRule.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+
+ return
+}
+
+// Put will change properties of the selected instance
+func (policyRule PolicyRule) Put(remoteAccessPolicyRule RemoteAccessPolicyRuleRequest) (response Response, err error) {
+ remoteAccessPolicyRule.H = fmt.Sprintf("%s%s", message.AMTSchema, AMT_RemoteAccessPolicyRule)
+ response = Response{
+ Message: &client.Message{
+ XMLInput: policyRule.base.Put(remoteAccessPolicyRule, false, nil),
+ },
+ }
+ // send the message to AMT
+ err = policyRule.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Delete removes a the specified instance
+func (policyRule PolicyRule) Delete(handle string) (response Response, err error) {
+ selector := message.Selector{Name: "PolicyRuleName", Value: handle}
+ response = Response{
+ Message: &client.Message{
+ XMLInput: policyRule.base.Delete(selector),
+ },
+ }
+ // send the message to AMT
+ err = policyRule.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
diff --git a/pkg/wsman/amt/remoteaccess/policyrule_test.go b/pkg/wsman/amt/remoteaccess/policyrule_test.go
new file mode 100644
index 00000000..00f35958
--- /dev/null
+++ b/pkg/wsman/amt/remoteaccess/policyrule_test.go
@@ -0,0 +1,269 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package remoteaccess
+
+import (
+ "encoding/xml"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
+)
+
+const (
+ EnvelopeResponsePolicy = `http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous0`
+ GetBodyPolicy = `AMT_RemoteAccessPolicyRuleIntel(r) AMT Remote Access Policy RuleIntel(r) AMT Remote Access Policy RuleCIM_ComputerSystemManagedSystem`
+)
+
+func TestPositiveAMT_RemoteAccessPolicyRule(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/remoteaccess/policyrule",
+ }
+ elementUnderTest := NewPolicyRuleWithClient(wsmanMessageCreator, &client)
+ t.Run("amt_* Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ extraHeader string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create a valid AMT_RemoteAccessPolicyRule Get wsman message",
+ AMT_RemoteAccessPolicyRule,
+ wsmantesting.GET,
+ "",
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Get"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ RemoteAccessPolicyRuleGetResponse: RemoteAccessPolicyRuleResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_RemoteAccessPolicyRule", Local: "AMT_RemoteAccessPolicyRule"},
+ CreationClassName: AMT_RemoteAccessPolicyRule,
+ ElementName: "Inte(r) AMT:Remote Access Policy",
+ ExtendedData: "AAAAAAAAABk=",
+ PolicyRuleName: "Periodic",
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "Intel(r) AMT",
+ Trigger: 2,
+ TunnelLifeTime: 0,
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create a valid AMT_RemoteAccessPolicyRule Enumerate wsman message",
+ AMT_RemoteAccessPolicyRule,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Enumerate"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "D3000000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid AMT_RemoteAccessPolicyRule Pull wsman message",
+ AMT_RemoteAccessPolicyRule,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Pull"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ RemotePolicyRuleItems: []RemoteAccessPolicyRuleResponse{
+ {
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_RemoteAccessPolicyRule", Local: "AMT_RemoteAccessPolicyRule"},
+ CreationClassName: "AMT_RemoteAccessPolicyRule",
+ ElementName: "Inte(r) AMT:Remote Access Policy",
+ ExtendedData: "AAAAAAAAABk=",
+ PolicyRuleName: "Periodic",
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "Intel(r) AMT",
+ Trigger: 2,
+ TunnelLifeTime: 0,
+ },
+ },
+ },
+ },
+ },
+
+ //DELETE
+ {
+ "should create a valid AMT_RemoteAccessPolicyRule Delete wsman message",
+ AMT_RemoteAccessPolicyRule,
+ wsmantesting.DELETE,
+ "",
+ "Instance",
+ func() (Response, error) {
+ client.CurrentMessage = "Delete"
+ return elementUnderTest.Delete("Instance")
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, test.extraHeader, test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.NoError(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.Equal(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
+func TestNegativeAMT_RemoteAccessPolicyRule(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/remoteaccess/policyrule",
+ }
+ elementUnderTest := NewPolicyRuleWithClient(wsmanMessageCreator, &client)
+ t.Run("amt_* Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ extraHeader string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create a valid AMT_RemoteAccessPolicyRule Get wsman message",
+ AMT_RemoteAccessPolicyRule,
+ wsmantesting.GET,
+ "",
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ RemoteAccessPolicyRuleGetResponse: RemoteAccessPolicyRuleResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_RemoteAccessPolicyRule", Local: "AMT_RemoteAccessPolicyRule"},
+ CreationClassName: AMT_RemoteAccessPolicyRule,
+ ElementName: "Inte(r) AMT:Remote Access Policy",
+ ExtendedData: "AAAAAAAAABk=",
+ PolicyRuleName: "Periodic",
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "Intel(r) AMT",
+ Trigger: 2,
+ TunnelLifeTime: 0,
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create a valid AMT_RemoteAccessPolicyRule Enumerate wsman message",
+ AMT_RemoteAccessPolicyRule,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "D3000000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid AMT_RemoteAccessPolicyRule Pull wsman message",
+ AMT_RemoteAccessPolicyRule,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ RemotePolicyRuleItems: []RemoteAccessPolicyRuleResponse{
+ {
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_RemoteAccessPolicyRule", Local: "AMT_RemoteAccessPolicyRule"},
+ CreationClassName: "AMT_RemoteAccessPolicyRule",
+ ElementName: "Inte(r) AMT:Remote Access Policy",
+ ExtendedData: "AAAAAAAAABk=",
+ PolicyRuleName: "Periodic",
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "Intel(r) AMT",
+ Trigger: 2,
+ TunnelLifeTime: 0,
+ },
+ },
+ },
+ },
+ },
+
+ //DELETE
+ {
+ "should create a valid AMT_RemoteAccessPolicyRule Delete wsman message",
+ AMT_RemoteAccessPolicyRule,
+ wsmantesting.DELETE,
+ "",
+ "Instance",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Delete("Instance")
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, test.extraHeader, test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.Error(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.NotEqual(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
diff --git a/pkg/wsman/amt/remoteaccess/service.go b/pkg/wsman/amt/remoteaccess/service.go
new file mode 100644
index 00000000..29785541
--- /dev/null
+++ b/pkg/wsman/amt/remoteaccess/service.go
@@ -0,0 +1,150 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package remoteaccess
+
+import (
+ "encoding/xml"
+ "fmt"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/methods"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+)
+
+// NewRemoteAccessServiceWithClient instantiates a new Service
+func NewRemoteAccessServiceWithClient(wsmanMessageCreator *message.WSManMessageCreator, client client.WSMan) Service {
+ return Service{
+ base: message.NewBaseWithClient(wsmanMessageCreator, AMT_RemoteAccessService, client),
+ }
+}
+
+// Get retrieves the representation of the instance
+func (service Service) Get() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: service.base.Get(nil),
+ },
+ }
+ // send the message to AMT
+ err = service.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Enumerate returns an enumeration context which is used in a subsequent Pull call
+func (service Service) Enumerate() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: service.base.Enumerate(),
+ },
+ }
+ // send the message to AMT
+ err = service.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+
+ return
+}
+
+// Pull returns the instances of this class. An enumeration context provided by the Enumerate call is used as input.
+func (service Service) Pull(enumerationContext string) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: service.base.Pull(enumerationContext),
+ },
+ }
+ // send the message to AMT
+ err = service.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+
+ return
+}
+
+// AddMPS adds a Management Presence Server to the Intel® AMT subsystem.
+// Creates an AMT_ManagementPresenceRemoteSAP instance and an AMT_RemoteAccessCredentialContext association to a credential.
+// This credential may be an existing AMT_PublicKeyCertificate instance (if the created MPS is configured to use mutual authentication).
+// If the created MpServer is configured to use username password authentication, an AMT_MPSUsernamePassword instance is created and used as the associated credential.
+func (service Service) AddMPS(mpServer AddMpServerRequest) (response Response, err error) {
+ mpServer.H = fmt.Sprintf("%s%s", message.AMTSchema, AMT_RemoteAccessService)
+ header := service.base.WSManMessageCreator.CreateHeader(methods.GenerateAction(AMT_RemoteAccessService, AddMps), AMT_RemoteAccessService, nil, "", "")
+ body := service.base.WSManMessageCreator.CreateBody(methods.GenerateInputMethod(AddMps), AMT_RemoteAccessService, mpServer)
+ // body := fmt.Sprintf(`%s%d%d%d%s%s%s`, service.base.WSManMessageCreator.ResourceURIBase, AMT_RemoteAccessService, mpServer.AccessInfo, mpServer.InfoFormat, mpServer.Port, mpServer.AuthMethod, mpServer.Username, mpServer.Password, mpServer.CommonName)
+ response = Response{
+ Message: &client.Message{
+ XMLInput: service.base.WSManMessageCreator.CreateXML(header, body),
+ },
+ }
+ // send the message to AMT
+ err = service.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// AddRemoteAccessPolicyRule adds a Remote Access policy to the Intel® AMT subsystem.
+// The policy defines an event that will trigger an establishment of a tunnel between AMT and a pre-configured MPS.
+// Creates an AMT_RemoteAccessPolicyRule instance and associates it to a given list of AMT_ManagementPresenceRemoteSAP instances with AMT_PolicySetAppliesToElement association instances.
+// Returns an XML string representing the WS-Management message to be sent to the Intel® AMT subsystem.
+func (service Service) AddRemoteAccessPolicyRule(remoteAccessPolicyRule RemoteAccessPolicyRuleRequest, name string) (response Response, err error) {
+ selector := message.Selector{
+ Name: "Name",
+ Value: name,
+ }
+ header := service.base.WSManMessageCreator.CreateHeader(methods.GenerateAction(AMT_RemoteAccessService, AddRemoteAccessPolicyRule), AMT_RemoteAccessService, nil, "", "")
+ body := fmt.Sprintf(`%d%d%shttp://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous%s%s%s`,
+ service.base.WSManMessageCreator.ResourceURIBase,
+ AMT_RemoteAccessService,
+ remoteAccessPolicyRule.Trigger,
+ remoteAccessPolicyRule.TunnelLifeTime,
+ remoteAccessPolicyRule.ExtendedData,
+ service.base.WSManMessageCreator.ResourceURIBase,
+ "AMT_ManagementPresenceRemoteSAP", selector.Name, selector.Value)
+ response = Response{
+ Message: &client.Message{
+ XMLInput: service.base.WSManMessageCreator.CreateXML(header, body),
+ },
+ }
+ // send the message to AMT
+ err = service.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
diff --git a/pkg/wsman/amt/remoteaccess/service_test.go b/pkg/wsman/amt/remoteaccess/service_test.go
new file mode 100644
index 00000000..82f37848
--- /dev/null
+++ b/pkg/wsman/amt/remoteaccess/service_test.go
@@ -0,0 +1,459 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package remoteaccess
+
+import (
+ "encoding/xml"
+ "fmt"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/methods"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
+)
+
+const (
+ EnvelopeResponse = `http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous0`
+ GetBody = `AMT_RemoteAccessServiceIntel(r) AMT Remote Access ServiceIntel(r) AMT Remote Access ServiceCIM_ComputerSystemManagedSystem`
+)
+
+func TestPositiveAMT_RemoteAccessService(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/remoteaccess/service",
+ }
+ elementUnderTest := NewRemoteAccessServiceWithClient(wsmanMessageCreator, &client)
+ t.Run("amt_RemoteAccessService Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create a valid AMT_RemoteAccessService Get wsman message",
+ AMT_RemoteAccessService,
+ wsmantesting.GET,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Get"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ RemoteAccessServiceGetResponse: RemoteAccessServiceResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_RemoteAccessService", Local: "AMT_RemoteAccessService"},
+ CreationClassName: "AMT_RemoteAccessService",
+ ElementName: "Intel(r) AMT Remote Access Service",
+ Name: "Intel(r) AMT Remote Access Service",
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "Intel(r) AMT",
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create a valid AMT_RemoteAccessService Enumerate wsman message",
+ AMT_RemoteAccessService,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Enumerate"
+ if elementUnderTest.base.WSManMessageCreator == nil {
+ print("Error")
+ }
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "D3000000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid AMT_RemoteAccessService Pull wsman message",
+ AMT_RemoteAccessService,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Pull"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ RemoteAccessItems: []RemoteAccessServiceResponse{
+ {
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_RemoteAccessService", Local: "AMT_RemoteAccessService"},
+ CreationClassName: "AMT_RemoteAccessService",
+ ElementName: "Intel(r) AMT Remote Access Service",
+ Name: "Intel(r) AMT Remote Access Service",
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "Intel(r) AMT",
+ },
+ },
+ },
+ },
+ },
+ //AddMPS
+ {
+ "should create a valid AMT_RemoteAccessService AddMPS wsman message",
+ AMT_RemoteAccessService,
+ methods.GenerateAction(AMT_RemoteAccessService, AddMps),
+ fmt.Sprintf(`%s%d%d%d%s%s%s`, resourceUriBase, AMT_RemoteAccessService, "AccessInfo", 1, 2, 3, "Username", "Password", "CommonName"),
+ func() (Response, error) {
+ client.CurrentMessage = "AddMPSServer"
+ mpsServer := AddMpServerRequest{
+ H: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_RemoteAccessService",
+ AccessInfo: "AccessInfo",
+ InfoFormat: 1,
+ Port: 2,
+ AuthMethod: 3,
+ Username: "Username",
+ Password: "Password",
+ CommonName: "CommonName",
+ }
+ return elementUnderTest.AddMPS(mpsServer)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ AddMpServerResponse: AddMpServerResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_RemoteAccessService", Local: "AddMpServer_OUTPUT"},
+ MpServer: MpServer{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_RemoteAccessService", Local: "MpServer"},
+ Address: "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
+ ReferenceParameters: ReferenceParametersResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/08/addressing", Local: "ReferenceParameters"},
+ ResourceURI: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_ManagementPresenceRemoteSAP",
+ SelectorSet: SelectorSetResponse{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "SelectorSet"},
+ Selectors: []SelectorResponse{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "CreationClassName",
+ Text: "AMT_ManagementPresenceRemoteSAP",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "Name",
+ Text: "Intel(r) AMT:Management Presence Server 0",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "SystemCreationClassName",
+ Text: "CIM_ComputerSystem",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "SystemName",
+ Text: "Intel(r) AMT",
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ //AddRemoteAccessPolicyRule
+ {
+ "should create a valid AMT_RemoteAccessPolicyRule wsman message",
+ AMT_RemoteAccessService,
+ methods.GenerateAction(AMT_RemoteAccessService, AddRemoteAccessPolicyRule),
+ fmt.Sprintf(`%d%d%shttp://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous%s%strue`, resourceUriBase, AMT_RemoteAccessService, 2, 0, "0300", "http://intel.com/wbem/wscim/1/amt-schema/1/", "AMT_ManagementPresenceRemoteSAP"),
+ func() (Response, error) {
+ client.CurrentMessage = "AddRemoteAccessService"
+ remoteAccessPolicyRule := RemoteAccessPolicyRuleRequest{
+ H: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_RemoteAccessService",
+ Trigger: 2,
+ TunnelLifeTime: 0,
+ ExtendedData: "0300",
+ }
+ return elementUnderTest.AddRemoteAccessPolicyRule(remoteAccessPolicyRule, "true")
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ AddRemotePolicyRuleResponse: AddRemoteAccessPolicyRuleResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_RemoteAccessService", Local: "AddRemoteAccessPolicyRule_OUTPUT"},
+ PolicyRuleResponse: PolicyRuleResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_RemoteAccessService", Local: "PolicyRule"},
+ Address: "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
+ ReferenceParameters: ReferenceParametersResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/08/addressing", Local: "ReferenceParameters"},
+ ResourceURI: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_RemoteAccessPolicyRule",
+ SelectorSet: SelectorSetResponse{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "SelectorSet"},
+ Selectors: []SelectorResponse{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "CreationClassName",
+ Text: "AMT_RemoteAccessPolicyRule",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "PolicyRuleName",
+ Text: "Periodic",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "SystemCreationClassName",
+ Text: "CIM_ComputerSystem",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "SystemName",
+ Text: "Intel(r) AMT",
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ println(response.XMLOutput)
+ assert.NoError(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.Equal(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
+func TestNegativeAMT_RemoteAccessService(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/remoteaccess/service",
+ }
+ elementUnderTest := NewRemoteAccessServiceWithClient(wsmanMessageCreator, &client)
+ t.Run("amt_RemoteAccessService Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create a valid AMT_RemoteAccessService Get wsman message",
+ AMT_RemoteAccessService,
+ wsmantesting.GET,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ RemoteAccessServiceGetResponse: RemoteAccessServiceResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_RemoteAccessService", Local: "AMT_RemoteAccessService"},
+ CreationClassName: "AMT_RemoteAccessService",
+ ElementName: "Intel(r) AMT Remote Access Service",
+ Name: "Intel(r) AMT Remote Access Service",
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "Intel(r) AMT",
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create a valid AMT_RemoteAccessService Enumerate wsman message",
+ AMT_RemoteAccessService,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ if elementUnderTest.base.WSManMessageCreator == nil {
+ print("Error")
+ }
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "D3000000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid AMT_RemoteAccessService Pull wsman message",
+ AMT_RemoteAccessService,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ RemoteAccessItems: []RemoteAccessServiceResponse{
+ {
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_RemoteAccessService", Local: "AMT_RemoteAccessService"},
+ CreationClassName: "AMT_RemoteAccessService",
+ ElementName: "Intel(r) AMT Remote Access Service",
+ Name: "Intel(r) AMT Remote Access Service",
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "Intel(r) AMT",
+ },
+ },
+ },
+ },
+ },
+ //AddMPS
+ {
+ "should create a valid AMT_RemoteAccessService AddMPS wsman message",
+ AMT_RemoteAccessService,
+ methods.GenerateAction(AMT_RemoteAccessService, AddMps),
+ fmt.Sprintf(`%s%d%d%d%s%s%s`, resourceUriBase, AMT_RemoteAccessService, "AccessInfo", 1, 2, 3, "Username", "Password", "CommonName"),
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ mpsServer := AddMpServerRequest{
+ H: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_RemoteAccessService",
+ AccessInfo: "AccessInfo",
+ InfoFormat: 1,
+ Port: 2,
+ AuthMethod: 3,
+ Username: "Username",
+ Password: "Password",
+ CommonName: "CommonName",
+ }
+ return elementUnderTest.AddMPS(mpsServer)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ AddMpServerResponse: AddMpServerResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_RemoteAccessService", Local: "AddMpServer_OUTPUT"},
+ MpServer: MpServer{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_RemoteAccessService", Local: "MpServer"},
+ Address: "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
+ ReferenceParameters: ReferenceParametersResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/08/addressing", Local: "ReferenceParameters"},
+ ResourceURI: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_ManagementPresenceRemoteSAP",
+ SelectorSet: SelectorSetResponse{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "SelectorSet"},
+ Selectors: []SelectorResponse{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "CreationClassName",
+ Text: "AMT_ManagementPresenceRemoteSAP",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "Name",
+ Text: "Intel(r) AMT:Management Presence Server 0",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "SystemCreationClassName",
+ Text: "CIM_ComputerSystem",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "SystemName",
+ Text: "Intel(r) AMT",
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ //AddRemoteAccessPolicyRule
+ {
+ "should create a valid AMT_RemoteAccessPolicyRule wsman message",
+ AMT_RemoteAccessService,
+ methods.GenerateAction(AMT_RemoteAccessService, AddRemoteAccessPolicyRule),
+ fmt.Sprintf(`%d%d%shttp://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous%s%strue`, resourceUriBase, AMT_RemoteAccessService, 2, 0, "0300", "http://intel.com/wbem/wscim/1/amt-schema/1/", "AMT_ManagementPresenceRemoteSAP"),
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ remoteAccessPolicyRule := RemoteAccessPolicyRuleRequest{
+ H: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_RemoteAccessService",
+ Trigger: 2,
+ TunnelLifeTime: 0,
+ ExtendedData: "0300",
+ }
+ return elementUnderTest.AddRemoteAccessPolicyRule(remoteAccessPolicyRule, "true")
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ AddRemotePolicyRuleResponse: AddRemoteAccessPolicyRuleResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_RemoteAccessService", Local: "AddRemoteAccessPolicyRule_OUTPUT"},
+ PolicyRuleResponse: PolicyRuleResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_RemoteAccessService", Local: "PolicyRule"},
+ Address: "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
+ ReferenceParameters: ReferenceParametersResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/08/addressing", Local: "ReferenceParameters"},
+ ResourceURI: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_RemoteAccessPolicyRule",
+ SelectorSet: SelectorSetResponse{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "SelectorSet"},
+ Selectors: []SelectorResponse{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "CreationClassName",
+ Text: "AMT_RemoteAccessPolicyRule",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "PolicyRuleName",
+ Text: "Periodic",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "SystemCreationClassName",
+ Text: "CIM_ComputerSystem",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "SystemName",
+ Text: "Intel(r) AMT",
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ println(response.XMLOutput)
+ assert.Error(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.NotEqual(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
diff --git a/pkg/wsman/amt/remoteaccess/types.go b/pkg/wsman/amt/remoteaccess/types.go
new file mode 100644
index 00000000..1f12a90b
--- /dev/null
+++ b/pkg/wsman/amt/remoteaccess/types.go
@@ -0,0 +1,209 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package remoteaccess
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+)
+
+type PolicyAppliesToMPS struct {
+ base message.Base
+}
+
+type PolicyRule struct {
+ base message.Base
+}
+
+type Service struct {
+ base message.Base
+}
+
+// OUTPUTS
+// Response Types
+type (
+ Response struct {
+ *client.Message
+ XMLName xml.Name `xml:"Envelope"`
+ Header message.Header `xml:"Header"`
+ Body Body `xml:"Body"`
+ }
+ Body struct {
+ XMLName xml.Name `xml:"Body"`
+ RemoteAccessServiceGetResponse RemoteAccessServiceResponse
+ RemoteAccessPolicyRuleGetResponse RemoteAccessPolicyRuleResponse
+ RemoteAccessPolicyAppliesToMPSGetResponse RemoteAccessPolicyAppliesToMPSResponse
+ EnumerateResponse common.EnumerateResponse
+ PullResponse PullResponse
+ AddMpServerResponse AddMpServerResponse
+ AddRemotePolicyRuleResponse AddRemoteAccessPolicyRuleResponse
+ }
+ RemoteAccessServiceResponse struct {
+ XMLName xml.Name `xml:"AMT_RemoteAccessService"`
+ CreationClassName string `xml:"CreationClassName,omitempty"` // CreationClassName indicates the name of the class or the subclass that is used in the creation of an instance. When used with the other key properties of this class, this property allows all instances of this class and its subclasses to be uniquely identified.
+ ElementName string `xml:"ElementName,omitempty"` // A user-friendly name for the object. This property allows each instance to define a user-friendly name in addition to its key properties, identity data, and description information. Note that the Name property of ManagedSystemElement is also defined as a user-friendly name. But, it is often subclassed to be a Key. It is not reasonable that the same property can convey both identity and a user-friendly name, without inconsistencies. Where Name exists and is not a Key (such as for instances of LogicalDevice), the same information can be present in both the Name and ElementName properties. Note that if there is an associated instance of CIM_EnabledLogicalElementCapabilities, restrictions on this properties may exist as defined in ElementNameMask and MaxElementNameLen properties defined in that class.
+ Name string `xml:"Name,omitempty"` // The Name property uniquely identifies the Service and provides an indication of the functionality that is managed. This functionality is described in more detail in the Description property of the object.
+ SystemCreationClassName string `xml:"SystemCreationClassName,omitempty"` // The CreationClassName of the scoping System.
+ SystemName string `xml:"SystemName,omitempty"` // The Name of the scoping System.
+ IsRemoteTunnelConnected bool `xml:"IsRemoteTunnelConnected,omitempty"` // Reflects the connection status of the remote tunnel. Supported starting from Intel CSME 17.
+ RemoteTunnelKeepAliveTimeout int `xml:"RemoteTunnelKeepAliveTimeout,omitempty"` // Reflects the keep-alive timeout value of the remote tunnel (in seconds). Supported starting from Intel CSME 17.
+ }
+ RemoteAccessPolicyRuleResponse struct {
+ XMLName xml.Name `xml:"AMT_RemoteAccessPolicyRule"`
+ CreationClassName string `xml:"CreationClassName,omitempty"` // CreationClassName indicates the name of the class or the subclass used in the creation of an instance. When used with the other key properties of this class, this property allows all instances of this class and its subclasses to be uniquely identified.
+ ElementName string `xml:"ElementName,omitempty"` // A user-friendly name for the object. This property allows each instance to define a user-friendly name in addition to its key properties, identity data, and description information. Note that the Name property of ManagedSystemElement is also defined as a user-friendly name. But, it is often subclassed to be a Key. It is not reasonable that the same property can convey both identity and a user-friendly name, without inconsistencies. Where Name exists and is not a Key (such as for instances of LogicalDevice), the same information can be present in both the Name and ElementName properties. Note that if there is an associated instance of CIM_EnabledLogicalElementCapabilities, restrictions on this properties may exist as defined in ElementNameMask and MaxElementNameLen properties defined in that class.
+ ExtendedData string `xml:"ExtendedData,omitempty"` // Data associated with the policy, up to 32 bytes. The data should be in a network order. The extended data for a policy with a periodic trigger contains first a periodic type and after that the data for that type. For periodic type 0 [Interval - The CIRA connection will be established every fixed number of seconds] - the data should include a uint32 value that indicates the time period in seconds between tunnel establishments. For periodic type 1 [Daily - The CIRA connection will be established every day in a specific pre-defined time (hour and minutes)] - the data should include two uint32 values which define the wanted hour of the day and minutes of that hour. For the other triggers extended data is not defined and not needed. The length and data should be zero.
+ PolicyRuleName string `xml:"PolicyRuleName,omitempty"` // A user-friendly name of this PolicyRule. In Intel AMT Release 6.0 and later releases value is "%s %d" where %s is the policy type ("User Initiated" / "Alert" / "Periodic") and %d is the policy handle
+ SystemCreationClassName string `xml:"SystemCreationClassName,omitempty"` // The scoping System's CreationClassName.
+ SystemName string `xml:"SystemName,omitempty"` // The scoping System's Name.
+ Trigger Trigger `xml:"Trigger"` // The event that will trigger the establishment of the remote connection to the MpServer.
+ TunnelLifeTime int `xml:"TunnelLifeTime"` // Defines the tunnel lifetime in seconds, 0 means no lifetime- the tunnel should stay open until it is closed by CloseRemoteAccessConnection or when a different policy with higher priority needs to be processed.
+ }
+ RemoteAccessPolicyAppliesToMPSResponse struct {
+ XMLName xml.Name `xml:"AMT_RemoteAccessPolicyAppliesToMPS"`
+ ManagedElement ManagedElementResponse `xml:"ManagedElement"` // The MpServer to which the policy applies.
+ MpsType MPSType `xml:"MpsType"` // This field indicates if the MpServer is to be used inside or outside of the organization, or both. Default is outside (0).
+ OrderOfAccess int `xml:"OrderOfAccess"` // This field indicates in what order will the Intel® AMT subsystem attempt to connect to the referenced MpServer when the referenced Remote Access policy is triggered.
+ PolicySet PolicySetResponse `xml:"PolicySet"` // The Remote Access policy rule that is currently applied to the MpServer.
+ }
+ PullResponse struct {
+ XMLName xml.Name `xml:"PullResponse"`
+ RemoteAccessItems []RemoteAccessServiceResponse `xml:"Items>AMT_RemoteAccessService"`
+ RemotePolicyRuleItems []RemoteAccessPolicyRuleResponse `xml:"Items>AMT_RemoteAccessPolicyRule"`
+ PolicyAppliesItems []RemoteAccessPolicyAppliesToMPSResponse `xml:"Items>AMT_RemoteAccessPolicyAppliesToMPS"`
+ }
+ AddMpServerResponse struct {
+ XMLName xml.Name `xml:"AddMpServer_OUTPUT"`
+ MpServer MpServer `xml:"MpServer"` // A reference to the created MPS if the operation succeeded.
+ }
+ AddRemoteAccessPolicyRuleResponse struct {
+ XMLName xml.Name `xml:"AddRemoteAccessPolicyRule_OUTPUT"`
+ PolicyRuleResponse PolicyRuleResponse `xml:"PolicyRule"`
+ ReturnValue int `xml:"ReturnValue"` // ValueMap={0, 1, 36, 38, 2058} Values={PT_STATUS_SUCCESS, PT_STATUS_INTERNAL_ERROR, PT_STATUS_INVALID_PARAMETER, PT_STATUS_FLASH_WRITE_LIMIT_EXCEEDED, PT_STATUS_DUPLICATE}
+
+ }
+ MpServer struct {
+ XMLName xml.Name `xml:"MpServer"`
+ Address string `xml:"Address"`
+ ReferenceParameters ReferenceParametersResponse `xml:"ReferenceParameters"`
+ }
+ ManagedElementResponse struct {
+ XMLName xml.Name `xml:"ManagedElement"`
+ Address string `xml:"Address"`
+ ReferenceParameters ReferenceParametersResponse `xml:"ReferenceParameters"`
+ }
+ PolicySetResponse struct {
+ XMLName xml.Name `xml:"PolicySet"`
+ Address string `xml:"Address"`
+ ReferenceParameters ReferenceParametersResponse `xml:"ReferenceParameters"`
+ }
+ PolicyRuleResponse struct {
+ XMLName xml.Name `xml:"PolicyRule"`
+ Address string `xml:"Address"`
+ ReferenceParameters ReferenceParametersResponse `xml:"ReferenceParameters"`
+ }
+ ReferenceParametersResponse struct {
+ XMLName xml.Name `xml:"ReferenceParameters"`
+ ResourceURI string `xml:"ResourceURI"`
+ SelectorSet SelectorSetResponse `xml:"SelectorSet"`
+ }
+ SelectorSetResponse struct {
+ XMLName xml.Name `xml:"SelectorSet"`
+ Selectors []SelectorResponse `xml:"Selector"`
+ }
+ SelectorResponse struct {
+ XMLName xml.Name `xml:"Selector"`
+ Name string `xml:"Name,attr"`
+ Text string `xml:",chardata"`
+ }
+)
+
+// INPUTS
+// Request Types
+type (
+ AddMpServerRequest struct {
+ XMLName xml.Name `xml:"h:AddMpServer_INPUT"`
+ H string `xml:"xmlns:h,attr"`
+ AccessInfo string `xml:"h:AccessInfo"` // A string holding the IP address or FQDN of the server
+ InfoFormat MPServerInfoFormat `xml:"h:InfoFormat"` // An enumerated integer describing the format and interpretation of the AccessInfo property.
+ Port int `xml:"h:Port"` // The port to be used to establish a tunnel with the MPS.
+ AuthMethod MPServerAuthMethod `xml:"h:AuthMethod"` // Authentication method to be used when the Intel® AMT subsystem opens a tunnel to the MpServer
+ Username string `xml:"h:Username,omitempty"` // A Username to be used for the connection with the MPS if Username-Pwd authentication is used. Limited to 16 alphanumeric characters
+ Password string `xml:"h:Password,omitempty"` // A Password to be used for the connection with the MPS if Username-Pwd authentication is used. Limited to 16 characters
+ CommonName string `xml:"h:CN"` // A common name used when AccessInfo is an IP address.
+ Certificate string `xml:"h:Certificate,omitempty"` // A reference to a certificate. Required if AuthMethod is set to mutual authentication
+ }
+ RemoteAccessPolicyRuleRequest struct {
+ XMLName xml.Name `xml:"h:AddRemoteAccessPolicyRule_INPUT"`
+ H string `xml:"xmlns:h,attr"`
+ Trigger Trigger `xml:"h:Trigger"` // The event that will trigger the establishment of the remote connection to the MpServer.
+ TunnelLifeTime int `xml:"h:TunnelLifeTime"` // Defines the tunnel lifetime in seconds, 0 means no lifetime- the tunnel should stay open until it is closed by CloseRemoteAccessConnection or when a different policy with higher priority needs to be processed.
+ ExtendedData string `xml:"h:ExtendedData"` // Data associated with the policy, up to 32 bytes. The data should be in a network order. The extended data for a policy with a periodic trigger contains first a periodic type and after that the data for that type. For periodic type 0 [Interval - The CIRA connection will be established every fixed number of seconds] - the data should include a uint32 value that indicates the time period in seconds between tunnel establishments. For periodic type 1 [Daily - The CIRA connection will be established every day in a specific pre-defined time (hour and minutes)] - the data should include two uint32 values which define the wanted hour of the day and minutes of that hour. For the other triggers extended data is not defined and not needed. The length and data should be zero.
+ }
+ RemoteAccessPolicyAppliesToMPSRequest struct {
+ XMLName xml.Name `xml:"h:AMT_RemoteAccessPolicyAppliesToMPS"`
+ H string `xml:"xmlns:h,attr"`
+ ManagedElement ManagedElement `xml:"h:ManagedElement"` // The MpServer to which the policy applies.
+ OrderOfAccess int `xml:"h:OrderOfAccess"` // This field indicates in what order will the Intel® AMT subsystem attempt to connect to the referenced MpServer when the referenced Remote Access policy is triggered.
+ MPSType MPSType `xml:"h:MpsType"` // This field indicates if the MpServer is to be used inside or outside of the organization, or both. Default is outside (0).
+ PolicySet PolicySet `xml:"h:PolicySet"` // The Remote Access policy rule that is currently applied to the MpServer.
+ }
+ ManagedElement struct {
+ Address string `xml:"b:Address"`
+ B string `xml:"xmlns:b,attr"`
+ ReferenceParameters ReferenceParameters `xml:"b:ReferenceParameters"`
+ }
+ ReferenceParameters struct {
+ ResourceURI string `xml:"c:ResourceURI"`
+ C string `xml:"xmlns:c,attr"`
+ SelectorSet SelectorSet `xml:"c:SelectorSet"`
+ }
+ SelectorSet struct {
+ Selectors []Selector `xml:"c:Selector"`
+ }
+ Selector struct {
+ Name string `xml:"Name,attr"`
+ Text string `xml:",chardata"`
+ }
+ PolicySet struct {
+ Address string `xml:"b:Address"`
+ B string `xml:"xmlns:b,attr"`
+ ReferenceParameters ReferenceParameters `xml:"b:ReferenceParameters"`
+ }
+)
+
+// Property Types
+type (
+ RemoteAccessPolicyRuleSelector message.Selector
+ PolicyDecisionStrategy int // First Matching:1 | All:2
+ // An enumerated integer describing the format and interpretation of the AccessInfo property.
+ //
+ // ValueMap={3, 4, 201}
+ //
+ // Values={IPv4 Address, IPv6 Address, FQDN}
+ MPServerInfoFormat int
+ // Authentication method to be used when the Intel® AMT subsystem opens a tunnel to the MpServer
+ //
+ // ValueMap={1, 2}
+ //
+ // Values={Mutual Authentication, Username Password Authentication}
+ MPServerAuthMethod int
+ // The event that will trigger the establishment of the remote connection to the MpServer.
+ //
+ // ValueMap={0, 1, 2, 3}
+ //
+ // Values={User Initiated, Alert, Periodic, Home Provisioning}
+ Trigger int
+ // This field indicates if the MpServer is to be used inside or outside of the organization, or both. Default is outside (0).
+ //
+ // ValueMap={0, 1, 2}
+ //
+ // Values={External MPS, Internal MPS, Both}
+ MPSType int
+)
diff --git a/pkg/wsman/amt/setupandconfiguration/constants.go b/pkg/wsman/amt/setupandconfiguration/constants.go
new file mode 100644
index 00000000..67ddfb53
--- /dev/null
+++ b/pkg/wsman/amt/setupandconfiguration/constants.go
@@ -0,0 +1,57 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package setupandconfiguration
+
+const (
+ AMT_SetupAndConfigurationService string = "AMT_SetupAndConfigurationService"
+ CommitChanges string = "CommitChanges"
+ Unprovision string = "Unprovision"
+ SetMEBxPassword string = "SetMEBxPassword"
+ GetUuid string = "GetUuid"
+)
+
+const (
+ RequestedStateEnabled RequestedState = iota + 2
+ RequestedStateDisabled
+ RequestedStateShutDown
+ RequestedStateNoChange
+ RequestedStateOffline
+ RequestedStateTest
+ RequestedStateDeferred
+ RequestedStateQuiesce
+ RequestedStateReboot
+ RequestedStateReset
+ RequestedStateNotApplicable
+ RequestedStateUnknown RequestedState = 0
+)
+
+const (
+ EnabledStateUnknown EnabledState = iota
+ EnabledStateOther
+ EnabledStateEnabled
+ EnabledStateDisabled
+ EnabledStateShuttingDown
+ EnabledStateNotApplicable
+ EnabledStateEnabledbutOffline
+ EnabledStateInTest
+ EnabledStateDeferred
+ EnabledStateQuiesce
+ EnabledStateStarting
+)
+
+const (
+ AdminControlMode ProvisioningModeValue = 1
+ ClientControlMode ProvisioningModeValue = 4
+ PreProvisioning ProvisioningStateValue = 0
+ InProvisioning ProvisioningStateValue = 1
+ PostProvisioning ProvisioningStateValue = 2
+)
+
+const (
+ CoupledPasswordModel PasswordModelValue = iota
+ SeparatePasswordModel
+ SeparateHashPasswordModel
+)
diff --git a/pkg/wsman/amt/setupandconfiguration/marshal.go b/pkg/wsman/amt/setupandconfiguration/marshal.go
new file mode 100644
index 00000000..8f56a66f
--- /dev/null
+++ b/pkg/wsman/amt/setupandconfiguration/marshal.go
@@ -0,0 +1,30 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package setupandconfiguration
+
+import (
+ "encoding/json"
+
+ "gopkg.in/yaml.v3"
+)
+
+// JSON marshals the type into JSON format
+func (r *Response) JSON() string {
+ jsonOutput, err := json.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(jsonOutput)
+}
+
+// YAML marshals the type into YAML format
+func (r *Response) YAML() string {
+ yamlOutput, err := yaml.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(yamlOutput)
+}
diff --git a/pkg/wsman/amt/setupandconfiguration/service.go b/pkg/wsman/amt/setupandconfiguration/service.go
new file mode 100644
index 00000000..0933f4f5
--- /dev/null
+++ b/pkg/wsman/amt/setupandconfiguration/service.go
@@ -0,0 +1,284 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+// Package setupandconfiguration facilitiates communication with Intel® AMT devices to access and interact with the Setup and Configuration Service, which is the logic in Intel® AMT that responds to Setup and Configuration requests.
+package setupandconfiguration
+
+import (
+ "encoding/base64"
+ "encoding/xml"
+ "errors"
+ "fmt"
+
+ "github.com/google/uuid"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/methods"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+)
+
+// DecodeUUID formats the returned AMT base64 encoded UUID into a human readable UUID
+func (w *Response) DecodeUUID() (amtUuid string, err error) {
+ decodedBytes, err := base64.StdEncoding.DecodeString(w.Body.GetUuid_OUTPUT.UUID)
+ if err != nil {
+ return
+ }
+ rearrangeBytes := []byte{
+ decodedBytes[3], decodedBytes[2], decodedBytes[1], decodedBytes[0],
+ decodedBytes[5], decodedBytes[4],
+ decodedBytes[7], decodedBytes[6],
+ decodedBytes[8], decodedBytes[9],
+ decodedBytes[10], decodedBytes[11], decodedBytes[12], decodedBytes[13], decodedBytes[14], decodedBytes[15],
+ }
+ uuidSlice, err := uuid.FromBytes(rearrangeBytes)
+ if err != nil {
+ return
+ }
+ amtUuid = uuidSlice.String()
+ return
+}
+
+// NewSetupAndConfigurationServiceWithClient instantiates a new Service
+func NewSetupAndConfigurationServiceWithClient(wsmanMessageCreator *message.WSManMessageCreator, client client.WSMan) Service {
+ return Service{
+ base: message.NewBaseWithClient(wsmanMessageCreator, AMT_SetupAndConfigurationService, client),
+ }
+}
+
+// Gets the representation of the instance
+func (s Service) Get() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: s.base.Get(nil),
+ },
+ }
+ // send the message to AMT
+ err = s.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Enumerate returns an enumeration context which is used in a subsequent Pull call
+func (s Service) Enumerate() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: s.base.Enumerate(),
+ },
+ }
+ // send the message to AMT
+ err = s.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Pull returns the instances of this class. An enumeration context provided by the Enumerate call is used as input.
+func (s Service) Pull(enumerationContext string) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: s.base.Pull(enumerationContext),
+ },
+ }
+ // send the message to AMT
+ err = s.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Put will change properties of the selected instance
+func (s Service) Put(setupAndConfigurationService SetupAndConfigurationServiceRequest) (response Response, err error) {
+ setupAndConfigurationService.H = fmt.Sprintf("%s%s", message.AMTSchema, AMT_SetupAndConfigurationService)
+ response = Response{
+ Message: &client.Message{
+ XMLInput: s.base.Put(setupAndConfigurationService, false, nil),
+ },
+ }
+ // send the message to AMT
+ err = s.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// CommitChanges saves pending configuration commands made to the Intel® AMT device.
+// Completes configuration when in "IN-provisioning" state.
+// This routine commits pending configuration commands which are dependent on an internal restart sequence or a cumulative validity check.
+//
+// Failure to execute this command prevents the pending configurations (which are not stored in flash memory) to take effect.
+// Operations (or situations such as a power loss) that immediately change flash memory depend on a call to CommitChanges()to refresh the internal Firmware state.
+//
+// Note:
+//
+// 1. If TLS is enabled, RSA Key and Certificate must be configured in order to work properly with the changes being committed.
+//
+// 2. If DHCP is enabled, host-name must be set.
+//
+// 3. If mutual authentication is configured, then at least one trusted root certificate must exist.
+//
+// 4. When using TLS mutual authentication, the user must first configure the Intel AMT system time.
+//
+// 5. If in EnterpriseMode Provisioning, then caller must update the internal clock and change the PRNG.
+//
+// Since committing changes may cause an internal restart sequence, remote applications should allow sufficient time for Intel AMT to reload before issuing the next command.
+//
+// ValueMap={0, 1, 38, 2057}
+//
+// Values={PT_STATUS_SUCCESS, PT_STATUS_INTERNAL_ERROR, PT_STATUS_FLASH_WRITE_LIMIT_EXCEEDED, PT_STATUS_DATA_MISSING}
+func (s Service) CommitChanges() (response Response, err error) {
+ header := s.base.WSManMessageCreator.CreateHeader(methods.GenerateAction(AMT_SetupAndConfigurationService, CommitChanges), AMT_SetupAndConfigurationService, nil, "", "")
+ body := s.base.WSManMessageCreator.CreateBody(methods.GenerateInputMethod(CommitChanges), AMT_SetupAndConfigurationService, nil)
+ response = Response{
+ Message: &client.Message{
+ XMLInput: s.base.WSManMessageCreator.CreateXML(header, body),
+ },
+ }
+ // send the message to AMT
+ err = s.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// GetUuid gets the AMT UUID from the device.
+//
+// The returned value is in base64 format. DecodeUUID can be used to format this value into a human readable UUID
+//
+// ValueMap={0, 1}
+//
+// Values={PT_STATUS_SUCCESS, PT_STATUS_INTERNAL_ERROR}
+func (s Service) GetUuid() (response Response, err error) {
+ header := s.base.WSManMessageCreator.CreateHeader(methods.GenerateAction(AMT_SetupAndConfigurationService, GetUuid), AMT_SetupAndConfigurationService, nil, "", "")
+ body := s.base.WSManMessageCreator.CreateBody(methods.GenerateInputMethod(GetUuid), AMT_SetupAndConfigurationService, nil)
+ response = Response{
+ Message: &client.Message{
+ XMLInput: s.base.WSManMessageCreator.CreateXML(header, body),
+ },
+ }
+ // send the message to AMT
+ err = s.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+
+ return
+}
+
+// SetMEBXPassword changes the ME Bios extension password.
+// It allows a remote caller to change the ME access password for the BIOS extension screen.
+// This call succeeds depending on the password policy rule defined in MEBx (BIOS extension):
+//
+// "Default Password Only" - Method succeeds only when the current password is still the default value and only in PKI provisioning.
+//
+// "During Setup and Configuration" - Method succeeds only during provisioning, regardless of provisioning method or previous password value.
+//
+// "ANYTIME" - Method will always succeed. (i.e. even when configured).
+//
+// Note: API is blocked in client control mode
+//
+// ValueMap={0, 1, 16, 2054}
+//
+// Values={PT_STATUS_SUCCESS, PT_STATUS_INTERNAL_ERROR, PT_STATUS_NOT_PERMITTED, PT_STATUS_INVALID_PASSWORD}
+func (s Service) SetMEBXPassword(password string) (response Response, err error) {
+ header := s.base.WSManMessageCreator.CreateHeader(methods.GenerateAction(AMT_SetupAndConfigurationService, SetMEBxPassword), AMT_SetupAndConfigurationService, nil, "", "")
+ mebxPassword := MEBXPassword{
+ Password: password,
+ }
+ body := s.base.WSManMessageCreator.CreateBody(methods.GenerateInputMethod(SetMEBxPassword), AMT_SetupAndConfigurationService, &mebxPassword)
+ // body := fmt.Sprintf(`%s`, s.base.WSManMessageCreator.ResourceURIBase, AMT_SetupAndConfigurationService, password)
+ response = Response{
+ Message: &client.Message{
+ XMLInput: s.base.WSManMessageCreator.CreateXML(header, body),
+ },
+ }
+ // send the message to AMT
+ err = s.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Unprovision unconfigures and deactivates the Intel® AMT device. The device will need to be re-provisioned after this command before being able to use AMT features.
+//
+// In Client Control Mode, call will succeed even if auditor is blocking the operation.
+//
+// ValueMap={0, 1, 16, 36, 2076}
+//
+// Values={PT_STATUS_SUCCESS, PT_STATUS_INTERNAL_ERROR, PT_STATUS_NOT_PERMITTED, PT_STATUS_INVALID_PARAMETER, PT_STATUS_BLOCKING_COMPONENT}
+func (s Service) Unprovision(provisioningMode ProvisioningModeValue) (response Response, err error) {
+ if provisioningMode == 0 {
+ provisioningMode = 1
+ }
+ pMode := ProvisioningMode{
+ ProvisioningMode: provisioningMode,
+ }
+ header := s.base.WSManMessageCreator.CreateHeader(methods.GenerateAction(AMT_SetupAndConfigurationService, Unprovision), AMT_SetupAndConfigurationService, nil, "", "")
+ body := s.base.WSManMessageCreator.CreateBody(methods.GenerateInputMethod(Unprovision), AMT_SetupAndConfigurationService, &pMode)
+ // body := fmt.Sprintf(`%d`, s.base.WSManMessageCreator.ResourceURIBase, AMT_SetupAndConfigurationService, provisioningMode)
+ response = Response{
+ Message: &client.Message{
+ XMLInput: s.base.WSManMessageCreator.CreateXML(header, body),
+ },
+ }
+ // send the message to AMT
+ err = s.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ if response.Body.Unprovision_OUTPUT.ReturnValue != 0 {
+ // log.Error("Status: Failed to deactivate. ReturnValue: ", response.Body.Unprovision_OUTPUT.ReturnValue)
+ err = errors.New("Status: Failed to deactivate. ReturnValue: " + fmt.Sprintf("%d", response.Body.Unprovision_OUTPUT.ReturnValue))
+ return
+ }
+
+ return
+}
diff --git a/pkg/wsman/amt/setupandconfiguration/service_test.go b/pkg/wsman/amt/setupandconfiguration/service_test.go
new file mode 100644
index 00000000..b3a06450
--- /dev/null
+++ b/pkg/wsman/amt/setupandconfiguration/service_test.go
@@ -0,0 +1,323 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package setupandconfiguration
+
+import (
+ "encoding/xml"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/methods"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
+)
+
+const GetUuid_BODY = ""
+
+func TestPositiveAMT_SetupAndConfigurationService(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/setupandconfiguration",
+ }
+ elementUnderTest := NewSetupAndConfigurationServiceWithClient(wsmanMessageCreator, &client)
+
+ t.Run("amt_SetupAndConfiguration Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create a valid AMT_SetupAndConfigurationService Get wsman message",
+ AMT_SetupAndConfigurationService,
+ wsmantesting.GET, "",
+ func() (Response, error) {
+ client.CurrentMessage = "Get"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GetResponse: SetupAndConfigurationServiceResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_SetupAndConfigurationService", Local: "AMT_SetupAndConfigurationService"},
+ CreationClassName: AMT_SetupAndConfigurationService,
+ ElementName: "Intel(r) AMT Setup and Configuration Service",
+ EnabledState: 5,
+ Name: "Intel(r) AMT Setup and Configuration Service",
+ PasswordModel: 1,
+ ProvisioningMode: 1,
+ ProvisioningServerOTP: "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=",
+ ProvisioningState: 2,
+ RequestedState: 12,
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "Intel(r) AMT",
+ ZeroTouchConfigurationEnabled: true,
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create a valid AMT_SetupAndConfigurationService Enumerate wsman message",
+ AMT_SetupAndConfigurationService,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Enumerate"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "D3000000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid AMT_SetupAndConfigurationService Pull wsman message",
+ AMT_SetupAndConfigurationService,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Pull"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ SetupAndConfigurationServiceItems: []SetupAndConfigurationServiceResponse{
+ {
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_SetupAndConfigurationService", Local: "AMT_SetupAndConfigurationService"},
+ CreationClassName: AMT_SetupAndConfigurationService,
+ ElementName: "Intel(r) AMT Setup and Configuration Service",
+ EnabledState: 5,
+ Name: "Intel(r) AMT Setup and Configuration Service",
+ PasswordModel: 1,
+ ProvisioningMode: 1,
+ ProvisioningServerOTP: "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=",
+ ProvisioningState: 2,
+ RequestedState: 12,
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "Intel(r) AMT",
+ ZeroTouchConfigurationEnabled: true,
+ },
+ },
+ },
+ },
+ },
+ //GetUuid
+ {
+ "should return a valid AMT_GetUuid response",
+ AMT_SetupAndConfigurationService,
+ methods.GenerateAction(AMT_SetupAndConfigurationService, GetUuid),
+ GetUuid_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "getuuid"
+ return elementUnderTest.GetUuid()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GetUuid_OUTPUT: GetUuid_OUTPUT{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_SetupAndConfigurationService", Local: "GetUuid_OUTPUT"},
+ UUID: "E67jVdK/u2EXoIiu3XA36g==",
+ },
+ },
+ },
+ //CommitChanges
+ {
+ "should create a valid AMT_SetupAndConfigurationService CommitChanges wsman message",
+ AMT_SetupAndConfigurationService,
+ methods.GenerateAction(AMT_SetupAndConfigurationService, CommitChanges),
+ ``,
+ func() (Response, error) {
+ client.CurrentMessage = "CommitChanges"
+ return elementUnderTest.CommitChanges()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ CommitChanges_OUTPUT: CommitChanges_OUTPUT{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_SetupAndConfigurationService", Local: "CommitChanges_OUTPUT"},
+ ReturnValue: 0,
+ },
+ },
+ },
+ //SetMEBxPassword
+ {
+ "should create a valid AMT_SetupAndConfigurationService SetMEBxPassword wsman message",
+ AMT_SetupAndConfigurationService,
+ methods.GenerateAction(AMT_SetupAndConfigurationService, SetMEBxPassword),
+ `P@ssw0rd`,
+ func() (Response, error) {
+ client.CurrentMessage = "SetMEBxPassword"
+ return elementUnderTest.SetMEBXPassword("P@ssw0rd")
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ SetMEBxPassword_OUTPUT: SetMEBxPassword_OUTPUT{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_SetupAndConfigurationService", Local: "SetMEBxPassword_OUTPUT"},
+ ReturnValue: 0,
+ },
+ },
+ },
+ //Unprovision
+ {
+ "should create a valid AMT_SetupAndConfigurationService Unprovision wsman message",
+ AMT_SetupAndConfigurationService,
+ methods.GenerateAction(AMT_SetupAndConfigurationService, Unprovision),
+ `1`,
+ func() (Response, error) {
+ client.CurrentMessage = "Unprovision"
+ return elementUnderTest.Unprovision(1)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ Unprovision_OUTPUT: Unprovision_OUTPUT{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_SetupAndConfigurationService", Local: "Unprovision_OUTPUT"},
+ ReturnValue: 0,
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.NoError(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.Equal(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+
+ t.Run("decodeUuid Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ responseFunc func() (string, error, error)
+ expectedResponse string
+ }{{
+ "should properly decode AMT GetUuid Response to a UUID string",
+ func() (string, error, error) {
+ client.CurrentMessage = "getuuid"
+ response, err1 := elementUnderTest.GetUuid()
+ uuid, err2 := response.DecodeUUID()
+ return uuid, err1, err2
+ },
+ "55e3ae13-bfd2-61bb-17a0-88aedd7037ea",
+ },
+ }
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ response, err1, err2 := test.responseFunc()
+ assert.NoError(t, err1)
+ assert.NoError(t, err2)
+ assert.Equal(t, test.expectedResponse, response)
+ })
+ }
+ })
+
+}
+
+func TestNegativeAMT_SetupAndConfigurationService(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/setupandconfiguration",
+ }
+ elementUnderTest := NewSetupAndConfigurationServiceWithClient(wsmanMessageCreator, &client)
+ t.Run("amt_* Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ extraHeader string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ {
+ "should create an invalid AMT_SetupAndConfigurationService Pull wsman message",
+ "AMT_EthernetPortSettings",
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ response, err := elementUnderTest.Pull("")
+ return response, err
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ SetupAndConfigurationServiceItems: []SetupAndConfigurationServiceResponse{
+ {
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_SetupAndConfigurationService", Local: "AMT_SetupAndConfigurationService"},
+ CreationClassName: AMT_SetupAndConfigurationService,
+ ElementName: "Intel(r) AMT Setup and Configuration Service",
+ EnabledState: 5,
+ Name: "Intel(r) AMT Setup and Configuration Service",
+ PasswordModel: 1,
+ ProvisioningMode: 1,
+ ProvisioningServerOTP: "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=",
+ ProvisioningState: 2,
+ RequestedState: 12,
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "Intel(r) AMT",
+ ZeroTouchConfigurationEnabled: true,
+ },
+ },
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, test.extraHeader, test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.Error(t, err)
+ assert.NotEqual(t, expectedXMLInput, response.XMLInput)
+ assert.NotEqual(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+ t.Run("decodeUuid tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ responseFunc func() (string, error)
+ expectedResponse string
+ }{{
+ "should return error due to bad UUID returned",
+ func() (string, error) {
+ client.CurrentMessage = "getuuid-bad"
+ response, _ := elementUnderTest.GetUuid()
+ uuid, err := response.DecodeUUID()
+ return uuid, err
+ },
+ "55e3ae13-bfd2-61bb-17a0-88aedd7037ea",
+ },
+ }
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ response, err := test.responseFunc()
+ assert.Error(t, err)
+ assert.NotEqual(t, test.expectedResponse, response)
+ })
+ }
+ })
+}
diff --git a/pkg/wsman/amt/setupandconfiguration/types.go b/pkg/wsman/amt/setupandconfiguration/types.go
new file mode 100644
index 00000000..68e0ab25
--- /dev/null
+++ b/pkg/wsman/amt/setupandconfiguration/types.go
@@ -0,0 +1,205 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package setupandconfiguration
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+)
+
+type Service struct {
+ base message.Base
+}
+
+// Response Types
+type (
+ Response struct {
+ *client.Message
+ XMLName xml.Name `xml:"Envelope"`
+ Header message.Header `xml:"Header"`
+ Body Body `xml:"Body"`
+ }
+ Body struct {
+ XMLName xml.Name `xml:"Body"`
+ GetResponse SetupAndConfigurationServiceResponse
+ EnumerateResponse common.EnumerateResponse
+ PullResponse PullResponse
+ GetUuid_OUTPUT GetUuid_OUTPUT `xml:"GetUuid_OUTPUT"`
+ Unprovision_OUTPUT Unprovision_OUTPUT `xml:"Unprovision_OUTPUT"`
+ CommitChanges_OUTPUT CommitChanges_OUTPUT `xml:"CommitChanges_OUTPUT"`
+ SetMEBxPassword_OUTPUT SetMEBxPassword_OUTPUT `xml:"SetMEBxPassword_OUTPUT"`
+ }
+
+ SetupAndConfigurationServiceResponse struct {
+ XMLName xml.Name `xml:"AMT_SetupAndConfigurationService"`
+ RequestedState RequestedState `xml:"RequestedState,omitempty"` // RequestedState is an integer enumeration that indicates the last requested or desired state for the element, irrespective of the mechanism through which it was requested.
+ EnabledState EnabledState `xml:"EnabledState,omitempty"` // EnabledState is an integer enumeration that indicates the enabled and disabled states of an element.
+ ElementName string `xml:"ElementName,omitempty"` // A user-friendly name for the object. This property allows each instance to define a user-friendly name in addition to its key properties, identity data, and description information. Note that the Name property of ManagedSystemElement is also defined as a user-friendly name. But, it is often subclassed to be a Key. It is not reasonable that the same property can convey both identity and a user-friendly name, without inconsistencies. Where Name exists and is not a Key (such as for instances of LogicalDevice), the same information can be present in both the Name and ElementName properties. Note that if there is an associated instance of CIM_EnabledLogicalElementCapabilities, restrictions on this properties may exist as defined in ElementNameMask and MaxElementNameLen properties defined in that class.
+ SystemCreationClassName string `xml:"SystemCreationClassName,omitempty"` // The CreationClassName of the scoping System.
+ SystemName string `xml:"SystemName,omitempty"` // The Name of the scoping System.
+ CreationClassName string `xml:"CreationClassName,omitempty"` // CreationClassName indicates the name of the class or the subclass that is used in the creation of an instance. When used with the other key properties of this class, this property allows all instances of this class and its subclasses to be uniquely identified.
+ Name string `xml:"Name,omitempty"` // The Name property uniquely identifies the Service and provides an indication of the functionality that is managed. This functionality is described in more detail in the Description property of the object.
+ ProvisioningMode ProvisioningModeValue `xml:"ProvisioningMode,omitempty"` // A Read-Only enumeration value that determines the behavior of Intel® AMT when it is deployed.
+ ProvisioningState ProvisioningStateValue `xml:"ProvisioningState,omitempty"` // An enumeration value that indicates the state of the Intel® AMT subsystem in the provisioning process"Pre" - the setup operation has not started."In" - the setup operation is in progress."Post" - Intel® AMT is configured.
+ ZeroTouchConfigurationEnabled bool `xml:"ZeroTouchConfigurationEnabled,omitempty"` // Indicates if Zero Touch Configuration (Remote Configuration) is enabled or disabled. This property affects only enterprise mode. It can be modified while in SMB mode
+ ProvisioningServerOTP string `xml:"ProvisioningServerOTP,omitempty"` // A optional binary data value containing 8-32 characters,that represents a one-time password (OTP), used to authenticate the Intel® AMT to the configuration server. This property can be retrieved only in IN Provisioning state, nevertheless, it is settable also in POST provisioning state.
+ ConfigurationServerFQDN string `xml:"ConfigurationServerFQDN,omitempty"` // The FQDN of the configuration server.
+ PasswordModel PasswordModelValue `xml:"PasswordModel,omitempty"` // An enumeration value that determines the password model of Intel® AMT.
+ DhcpDNSSuffix string `xml:"DhcpDNSSuffix,omitempty"` // Domain name received from DHCP
+ TrustedDNSSuffix string `xml:"TrustedDNSSuffix,omitempty"` // Trusted domain name configured in MEBX
+ }
+ PullResponse struct {
+ XMLName xml.Name `xml:"PullResponse"`
+ SetupAndConfigurationServiceItems []SetupAndConfigurationServiceResponse `xml:"Items>AMT_SetupAndConfigurationService"`
+ }
+
+ // UUID of the system. If the value is all FFh, the ID is not currently present in the system, but is settable. If the value is all 00h, the ID is not present in the system. Corresponds to the UUID field of the SMBIOS Type 1 structure
+ GetUuid_OUTPUT struct {
+ XMLName xml.Name `xml:"GetUuid_OUTPUT"`
+ UUID string `xml:"UUID"`
+ }
+
+ // ValueMap={0, 1, 16, 36, 2076}
+ //
+ // Values={PT_STATUS_SUCCESS, PT_STATUS_INTERNAL_ERROR, PT_STATUS_NOT_PERMITTED, PT_STATUS_INVALID_PARAMETER, PT_STATUS_BLOCKING_COMPONENT}
+ Unprovision_OUTPUT struct {
+ XMLName xml.Name `xml:"Unprovision_OUTPUT"`
+ ReturnValue int
+ }
+
+ // ValueMap={0, 1, 38, 2057}
+ //
+ // Values={PT_STATUS_SUCCESS, PT_STATUS_INTERNAL_ERROR, PT_STATUS_FLASH_WRITE_LIMIT_EXCEEDED, PT_STATUS_DATA_MISSING}
+ CommitChanges_OUTPUT struct {
+ XMLName xml.Name `xml:"CommitChanges_OUTPUT"`
+ ReturnValue int
+ }
+
+ // ValueMap={0, 1, 16, 2054}
+ //
+ // Values={PT_STATUS_SUCCESS, PT_STATUS_INTERNAL_ERROR, PT_STATUS_NOT_PERMITTED, PT_STATUS_INVALID_PASSWORD}
+ SetMEBxPassword_OUTPUT struct {
+ XMLName xml.Name `xml:"SetMEBxPassword_OUTPUT"`
+ ReturnValue int
+ }
+)
+
+// Request Types
+type (
+ SetupAndConfigurationServiceRequest struct {
+ XMLName xml.Name `xml:"h:AMT_SetupAndConfigurationService"`
+ H string `xml:"xmlns:h,attr"`
+ RequestedState RequestedState `xml:"h:RequestedState,omitempty"` // RequestedState is an integer enumeration that indicates the last requested or desired state for the element, irrespective of the mechanism through which it was requested.
+ EnabledState EnabledState `xml:"h:EnabledState,omitempty"` // EnabledState is an integer enumeration that indicates the enabled and disabled states of an element.
+ ElementName string `xml:"h:ElementName,omitempty"` // A user-friendly name for the object. This property allows each instance to define a user-friendly name in addition to its key properties, identity data, and description information. Note that the Name property of ManagedSystemElement is also defined as a user-friendly name. But, it is often subclassed to be a Key. It is not reasonable that the same property can convey both identity and a user-friendly name, without inconsistencies. Where Name exists and is not a Key (such as for instances of LogicalDevice), the same information can be present in both the Name and ElementName properties. Note that if there is an associated instance of CIM_EnabledLogicalElementCapabilities, restrictions on this properties may exist as defined in ElementNameMask and MaxElementNameLen properties defined in that class.
+ SystemCreationClassName string `xml:"h:SystemCreationClassName,omitempty"` // The CreationClassName of the scoping System.
+ SystemName string `xml:"h:SystemName,omitempty"` // The Name of the scoping System.
+ CreationClassName string `xml:"h:CreationClassName,omitempty"` // CreationClassName indicates the name of the class or the subclass that is used in the creation of an instance. When used with the other key properties of this class, this property allows all instances of this class and its subclasses to be uniquely identified.
+ Name string `xml:"h:Name,omitempty"` // The Name property uniquely identifies the Service and provides an indication of the functionality that is managed. This functionality is described in more detail in the Description property of the object.
+ ProvisioningMode ProvisioningModeValue `xml:"h:ProvisioningMode,omitempty"` // A Read-Only enumeration value that determines the behavior of Intel® AMT when it is deployed.
+ ProvisioningState ProvisioningStateValue `xml:"h:ProvisioningState,omitempty"` // An enumeration value that indicates the state of the Intel® AMT subsystem in the provisioning process"Pre" - the setup operation has not started."In" - the setup operation is in progress."Post" - Intel® AMT is configured.
+ ZeroTouchConfigurationEnabled bool `xml:"h:ZeroTouchConfigurationEnabled,omitempty"` // Indicates if Zero Touch Configuration (Remote Configuration) is enabled or disabled. This property affects only enterprise mode. It can be modified while in SMB mode
+ ProvisioningServerOTP string `xml:"h:ProvisioningServerOTP,omitempty"` // A optional binary data value containing 8-32 characters,that represents a one-time password (OTP), used to authenticate the Intel® AMT to the configuration server. This property can be retrieved only in IN Provisioning state, nevertheless, it is settable also in POST provisioning state.
+ ConfigurationServerFQDN string `xml:"h:ConfigurationServerFQDN,omitempty"` // The FQDN of the configuration server.
+ PasswordModel PasswordModelValue `xml:"h:PasswordModel,omitempty"` // An enumeration value that determines the password model of Intel® AMT.
+ DhcpDNSSuffix string `xml:"h:DhcpDNSSuffix,omitempty"` // Domain name received from DHCP
+ TrustedDNSSuffix string `xml:"h:TrustedDNSSuffix,omitempty"` // Trusted domain name configured in MEBX
+ }
+
+ // Password needs to be strong: Contain at least one of: upper-case, lower-case, digit and special character
+ //
+ // MinLen=8, MaxLen=32
+ MEBXPassword struct {
+ XMLName xml.Name `xml:"h:SetMEBxPassword_INPUT"`
+ H string `xml:"xmlns:h,attr"`
+ Password string `xml:"h:Password,omitempty"`
+ }
+
+ // Indicates the provisioning mode (Enterprise , Small Business or Remote Connectivity) the device will enter following successful completion of the command. Starting from Release 6.0 only effective value is ProvisioningModeEnterprise
+ //
+ // ValueMap={0, 1, 2, 3}
+ //
+ // Values={ProvisioningModeCurrent, ProvisioningModeEnterprise, ProvisioningModeSmallBusiness, ProvisioningRemoteConnectivity}
+ ProvisioningMode struct {
+ XMLName xml.Name `xml:"h:Unprovision_INPUT"`
+ H string `xml:"xmlns:h,attr"`
+ ProvisioningMode ProvisioningModeValue `xml:"h:ProvisioningMode,omitempty"`
+ }
+
+ // EnabledState is an integer enumeration that indicates the enabled and disabled states of an element. It can also indicate the transitions between these requested states. For example, shutting down (value=4) and starting (value=10) are transient states between enabled and disabled.
+ //
+ // The following text briefly summarizes the various enabled and disabled states:
+ //
+ // Enabled (2) indicates that the element is or could be executing commands, will process any queued commands, and queues new requests.
+ //
+ // Disabled (3) indicates that the element will not execute commands and will drop any new requests.
+ //
+ // Shutting Down (4) indicates that the element is in the process of going to a Disabled state.
+ //
+ // Not Applicable (5) indicates the element does not support being enabled or disabled.
+ //
+ // Enabled but Offline (6) indicates that the element might be completing commands, and will drop any new requests.
+ //
+ // Test (7) indicates that the element is in a test state.
+ //
+ // Deferred (8) indicates that the element might be completing commands, but will queue any new requests.
+ //
+ // Quiesce (9) indicates that the element is enabled but in a restricted mode.
+ //
+ // Starting (10) indicates that the element is in the process of going to an Enabled state. New requests are queued.
+ //
+ // Value 6 ("Enabled but Offline") can be recieved also if the Audit Log is in locked state.
+ //
+ // ValueMap={0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11..32767, 32768..65535}
+ //
+ // Values={Unknown, Other, Enabled, Disabled, Shutting Down, Not Applicable, Enabled but Offline, In Test, Deferred, Quiesce, Starting, DMTF Reserved, Vendor Reserved}
+ EnabledState int
+ // RequestedState is an integer enumeration that indicates the last requested or desired state for the element, irrespective of the mechanism through which it was requested. The actual state of the element is represented by EnabledState. This property is provided to compare the last requested and current enabled or disabled states. Note that when EnabledState is set to 5 ("Not Applicable"), then this property has no meaning. Refer to the EnabledState property description for explanations of the values in the RequestedState enumeration.
+ //
+ // "Unknown" (0) indicates the last requested state for the element is unknown.
+ //
+ // Note that the value "No Change" (5) has been deprecated in lieu of indicating the last requested state is "Unknown" (0). If the last requested or desired state is unknown, RequestedState should have the value "Unknown" (0), but may have the value "No Change" (5).Offline (6) indicates that the element has been requested to transition to the Enabled but Offline EnabledState. It should be noted that there are two new values in RequestedState that build on the statuses of EnabledState. These are "Reboot" (10) and "Reset" (11). Reboot refers to doing a "Shut Down" and then moving to an "Enabled" state. Reset indicates that the element is first "Disabled" and then "Enabled". The distinction between requesting "Shut Down" and "Disabled" should also be noted. Shut Down requests an orderly transition to the Disabled state, and might involve removing power, to completely erase any existing state. The Disabled state requests an immediate disabling of the element, such that it will not execute or accept any commands or processing requests.
+ //
+ // This property is set as the result of a method invocation (such as Start or StopService on CIM_Service), or can be overridden and defined as WRITEable in a subclass. The method approach is considered superior to a WRITEable property, because it allows an explicit invocation of the operation and the return of a result code.
+ //
+ // If knowledge of the last RequestedState is not supported for the EnabledLogicalElement, the property shall be NULL or have the value 12 "Not Applicable".
+ //
+ // ValueMap={0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, .., 32768..65535}
+ //
+ // Values={Unknown, Enabled, Disabled, Shut Down, No Change, Offline, Test, Deferred, Quiesce, Reboot, Reset, Not Applicable, DMTF Reserved, Vendor Reserved}
+ RequestedState int
+ // A Read-Only enumeration value that determines the behavior of Intel® AMT when it is deployed. Starting from Release 7.0, this enumeration indicates whether AMT is deployed in "Admin control mode" or "Client control mode". In "Admin" mode, AMT functionality is on the same level of previous releases. In "Client" mode functionality is limited or requires user consent.
+ //
+ // In AMT Release 7.0, the value map has changed to "Admin Control Mode" (1 - matches the previous "enterprise" mode) and "Client Control Mode" (4).
+ //
+ // From Intel CSME 19.0, available also in pre-provisioning after IPS_HostBasedSetupService.Setup is called, before calling CommitChanges.
+ //
+ // ValueMap={1, .., 4, ..}
+ //
+ // Values={Admin Control Mode, Reserved1, Client Control Mode, Reserved2}
+ ProvisioningModeValue int
+ // An enumeration value that indicates the state of the Intel® AMT subsystem in the provisioning process"Pre" - the setup operation has not started."In" - the setup operation is in progress."Post" - Intel® AMT is configured.
+ //
+ // This is a read-only property.
+ //
+ // ValueMap={0, 1, 2}
+ //
+ // Values={Pre, In, Post}
+ ProvisioningStateValue int
+ // An enumeration value that determines the password model of Intel® AMT.
+ //
+ // This is a read-only property.
+ //
+ // While in post-provisioning state, value is 'Separate password model' (1), otherwise value is 'Coupled password model' (0)
+ //
+ // ValueMap={0, 1, 2}
+ //
+ // Values={Coupled password model (the password of the network and the local interfaces are identical), Separate password model (the password of the network and the local interfaces are separate), Separate-Hash password model}
+ PasswordModelValue int
+)
diff --git a/pkg/wsman/amt/timesynchronization/constants.go b/pkg/wsman/amt/timesynchronization/constants.go
new file mode 100644
index 00000000..c7ec4972
--- /dev/null
+++ b/pkg/wsman/amt/timesynchronization/constants.go
@@ -0,0 +1,52 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package timesynchronization
+
+const (
+ AMT_TimeSynchronizationService string = "AMT_TimeSynchronizationService"
+ GetLowAccuracyTimeSynch string = "GetLowAccuracyTimeSynch"
+ SetHighAccuracyTimeSynch string = "SetHighAccuracyTimeSynch"
+)
+
+const (
+ RequestedStateEnabled RequestedState = iota + 2
+ RequestedStateDisabled
+ RequestedStateShutDown
+ RequestedStateNoChange
+ RequestedStateOffline
+ RequestedStateTest
+ RequestedStateDeferred
+ RequestedStateQuiesce
+ RequestedStateReboot
+ RequestedStateReset
+ RequestedStateNotApplicable
+ RequestedStateUnknown RequestedState = 0
+)
+
+const (
+ EnabledStateUnknown EnabledState = iota
+ EnabledStateOther
+ EnabledStateEnabled
+ EnabledStateDisabled
+ EnabledStateShuttingDown
+ EnabledStateNotApplicable
+ EnabledStateEnabledbutOffline
+ EnabledStateInTest
+ EnabledStateDeferred
+ EnabledStateQuiesce
+ EnabledStateStarting
+)
+
+const (
+ LocalTimeSyncEnabledDefaultTrue LocalTimeSyncEnabled = iota
+ LocalTimeSyncEnabledConfiguredTrue
+ LocalTimeSyncEnabledFalse
+)
+
+const (
+ TimeSourceBiosRTC TimeSource = iota
+ TimeSourceConfigured
+)
diff --git a/pkg/wsman/amt/timesynchronization/marshal.go b/pkg/wsman/amt/timesynchronization/marshal.go
new file mode 100644
index 00000000..ad17d67f
--- /dev/null
+++ b/pkg/wsman/amt/timesynchronization/marshal.go
@@ -0,0 +1,30 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package timesynchronization
+
+import (
+ "encoding/json"
+
+ "gopkg.in/yaml.v3"
+)
+
+// JSON marshals the type into JSON format
+func (r *Response) JSON() string {
+ jsonOutput, err := json.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(jsonOutput)
+}
+
+// YAML marshals the type into YAML format
+func (r *Response) YAML() string {
+ yamlOutput, err := yaml.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(yamlOutput)
+}
diff --git a/pkg/wsman/amt/timesynchronization/service.go b/pkg/wsman/amt/timesynchronization/service.go
new file mode 100644
index 00000000..c05ef633
--- /dev/null
+++ b/pkg/wsman/amt/timesynchronization/service.go
@@ -0,0 +1,141 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+// Package timesynchronization facilitiates communication with Intel® AMT devices to synchronize the AMT internal clock with an external clock
+package timesynchronization
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/methods"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+)
+
+// NewTimeSynchronizationServiceWithClient instantiates a new Service
+func NewTimeSynchronizationServiceWithClient(wsmanMessageCreator *message.WSManMessageCreator, client client.WSMan) Service {
+ return Service{
+ base: message.NewBaseWithClient(wsmanMessageCreator, AMT_TimeSynchronizationService, client),
+ }
+}
+
+// Get retrieves the representation of the instance
+func (service Service) Get() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: service.base.Get(nil),
+ },
+ }
+ // send the message to AMT
+ err = service.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Enumerate returns an enumeration context which is used in a subsequent Pull call
+func (service Service) Enumerate() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: service.base.Enumerate(),
+ },
+ }
+ // send the message to AMT
+ err = service.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Pull returns the instances of this class. An enumeration context provided by the Enumerate call is used as input.
+func (service Service) Pull(enumerationContext string) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: service.base.Pull(enumerationContext),
+ },
+ }
+ // send the message to AMT
+ err = service.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// SetHighAccuracyTimeSynch is used to synchronize the Intel® AMT device's internal clock with an external clock.
+//
+// ta0: The time value received from invoking GetLowAccuracyTimeSynch().
+//
+// tm1: The remote client timestamp after getting a response from GetLowAccuracyTimeSynch().
+//
+// tm2: The remote client timestamp obtained immediately prior to invoking this method.
+//
+// ValueMap={0, 1, 36, 38}
+//
+// Values={PT_STATUS_SUCCESS, PT_STATUS_INTERNAL_ERROR, PT_STATUS_INVALID_PARAMETER, PT_STATUS_FLASH_WRITE_LIMIT_EXCEEDED}
+func (service Service) SetHighAccuracyTimeSynch(ta0, tm1, tm2 int64) (response Response, err error) {
+ header := service.base.WSManMessageCreator.CreateHeader(methods.GenerateAction(AMT_TimeSynchronizationService, SetHighAccuracyTimeSynch), AMT_TimeSynchronizationService, nil, "", "")
+ body := service.base.WSManMessageCreator.CreateBody(methods.GenerateInputMethod(SetHighAccuracyTimeSynch), AMT_TimeSynchronizationService, &SetHighAccuracyTimeSynch_INPUT{
+ H: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_TimeSynchronizationService",
+ Ta0: ta0,
+ Tm1: tm1,
+ Tm2: tm2,
+ })
+ response = Response{
+ Message: &client.Message{
+ XMLInput: service.base.WSManMessageCreator.CreateXML(header, body),
+ },
+ }
+ // send the message to AMT
+ err = service.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// GetLowAccuracyTimeSynch is used for reading the Intel® AMT device's internal clock.
+func (service Service) GetLowAccuracyTimeSynch() (response Response, err error) {
+ header := service.base.WSManMessageCreator.CreateHeader(methods.GenerateAction(AMT_TimeSynchronizationService, GetLowAccuracyTimeSynch), AMT_TimeSynchronizationService, nil, "", "")
+ body := service.base.WSManMessageCreator.CreateBody(methods.GenerateInputMethod(GetLowAccuracyTimeSynch), AMT_TimeSynchronizationService, nil)
+ response = Response{
+ Message: &client.Message{
+ XMLInput: service.base.WSManMessageCreator.CreateXML(header, body),
+ },
+ }
+ // send the message to AMT
+ err = service.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
diff --git a/pkg/wsman/amt/timesynchronization/service_test.go b/pkg/wsman/amt/timesynchronization/service_test.go
new file mode 100644
index 00000000..dc670a3e
--- /dev/null
+++ b/pkg/wsman/amt/timesynchronization/service_test.go
@@ -0,0 +1,305 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package timesynchronization
+
+import (
+ "encoding/xml"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/methods"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
+)
+
+func TestPositiveAMT_TimeSynchronizationService(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/timesynchronization",
+ }
+ elementUnderTest := NewTimeSynchronizationServiceWithClient(wsmanMessageCreator, &client)
+
+ t.Run("amt_TimeSynchronizationService Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create a valid AMT_TimeSynchronizationService Get wsman message",
+ AMT_TimeSynchronizationService,
+ wsmantesting.GET,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Get"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GetResponse: TimeSynchronizationServiceResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_TimeSynchronizationService", Local: "AMT_TimeSynchronizationService"},
+ CreationClassName: "AMT_TimeSynchronizationService",
+ ElementName: "Intel(r) AMT Time Synchronization Service",
+ EnabledState: 5,
+ LocalTimeSyncEnabled: 0,
+ Name: "Intel(r) AMT Time Synchronization Service",
+ RequestedState: 12,
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "Intel(r) AMT",
+ TimeSource: 1,
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create a valid AMT_TimeSynchronizationService Enumerate wsman message",
+ AMT_TimeSynchronizationService,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Enumerate"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "3B080000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid AMT_TimeSynchronizationService Pull wsman message",
+ AMT_TimeSynchronizationService,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Pull"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ TimeSynchronizationServiceItems: []TimeSynchronizationServiceResponse{
+ {
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_TimeSynchronizationService", Local: "AMT_TimeSynchronizationService"},
+ CreationClassName: "AMT_TimeSynchronizationService",
+ ElementName: "Intel(r) AMT Time Synchronization Service",
+ EnabledState: 5,
+ LocalTimeSyncEnabled: 0,
+ Name: "Intel(r) AMT Time Synchronization Service",
+ RequestedState: 12,
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "Intel(r) AMT",
+ TimeSource: 1,
+ },
+ },
+ },
+ },
+ },
+ {
+ //GetLowAccuracyTimeSynch
+ "should create a valid AMT_TimeSynchronizationService GetLowAccuracyTimeSynch wsman message",
+ AMT_TimeSynchronizationService,
+ methods.GenerateAction(AMT_TimeSynchronizationService, GetLowAccuracyTimeSynch),
+ ``,
+ func() (Response, error) {
+ client.CurrentMessage = "GetLowAccuracyTimeSynch"
+ return elementUnderTest.GetLowAccuracyTimeSynch()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GetLowAccuracyTimeSynchResponse: GetLowAccuracyTimeSynchResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_TimeSynchronizationService", Local: "GetLowAccuracyTimeSynch_OUTPUT"},
+ Ta0: 1704586865,
+ ReturnValue: 0,
+ },
+ },
+ },
+ {
+ //SetHighAccuracyTimeSynch
+ "should create a valid AMT_TimeSynchronizationService SetHighAccuracyTimeSynch wsman message",
+ AMT_TimeSynchronizationService,
+ methods.GenerateAction(AMT_TimeSynchronizationService, SetHighAccuracyTimeSynch),
+ "164424091116442409431644240943",
+ func() (Response, error) {
+ client.CurrentMessage = "SetHighAccuracyTimeSynch"
+ return elementUnderTest.SetHighAccuracyTimeSynch(1644240911, 1644240943, 1644240943)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ SetHighAccuracyTimeSynchResponse: SetHighAccuracyTimeSynchResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_TimeSynchronizationService", Local: "SetHighAccuracyTimeSynch_OUTPUT"},
+ ReturnValue: 0,
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.NoError(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.Equal(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
+func TestNegativeAMT_TimeSynchronizationService(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/timesynchronization",
+ }
+ elementUnderTest := NewTimeSynchronizationServiceWithClient(wsmanMessageCreator, &client)
+
+ t.Run("amt_TimeSynchronizationService Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create a valid AMT_TimeSynchronizationService Get wsman message",
+ AMT_TimeSynchronizationService,
+ wsmantesting.GET,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GetResponse: TimeSynchronizationServiceResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_TimeSynchronizationService", Local: "AMT_TimeSynchronizationService"},
+ CreationClassName: "AMT_TimeSynchronizationService",
+ ElementName: "Intel(r) AMT Time Synchronization Service",
+ EnabledState: 5,
+ LocalTimeSyncEnabled: 0,
+ Name: "Intel(r) AMT Time Synchronization Service",
+ RequestedState: 12,
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "Intel(r) AMT",
+ TimeSource: 1,
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create a valid AMT_TimeSynchronizationService Enumerate wsman message",
+ AMT_TimeSynchronizationService,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "3B080000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid AMT_TimeSynchronizationService Pull wsman message",
+ AMT_TimeSynchronizationService,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ TimeSynchronizationServiceItems: []TimeSynchronizationServiceResponse{
+ {
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_TimeSynchronizationService", Local: "AMT_TimeSynchronizationService"},
+ CreationClassName: "AMT_TimeSynchronizationService",
+ ElementName: "Intel(r) AMT Time Synchronization Service",
+ EnabledState: 5,
+ LocalTimeSyncEnabled: 0,
+ Name: "Intel(r) AMT Time Synchronization Service",
+ RequestedState: 12,
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "Intel(r) AMT",
+ TimeSource: 1,
+ },
+ },
+ },
+ },
+ },
+ {
+ //GetLowAccuracyTimeSynch
+ "should create a valid AMT_TimeSynchronizationService GetLowAccuracyTimeSynch wsman message",
+ AMT_TimeSynchronizationService,
+ methods.GenerateAction(AMT_TimeSynchronizationService, GetLowAccuracyTimeSynch),
+ ``,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.GetLowAccuracyTimeSynch()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GetLowAccuracyTimeSynchResponse: GetLowAccuracyTimeSynchResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_TimeSynchronizationService", Local: "GetLowAccuracyTimeSynch_OUTPUT"},
+ Ta0: 1704586865,
+ ReturnValue: 0,
+ },
+ },
+ },
+ {
+ //SetHighAccuracyTimeSynch
+ "should create a valid AMT_TimeSynchronizationService SetHighAccuracyTimeSynch wsman message",
+ AMT_TimeSynchronizationService,
+ methods.GenerateAction(AMT_TimeSynchronizationService, SetHighAccuracyTimeSynch),
+ "164424091116442409431644240943",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.SetHighAccuracyTimeSynch(1644240911, 1644240943, 1644240943)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ SetHighAccuracyTimeSynchResponse: SetHighAccuracyTimeSynchResponse{
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_TimeSynchronizationService", Local: "SetHighAccuracyTimeSynch_OUTPUT"},
+ ReturnValue: 0,
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.Error(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.NotEqual(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
diff --git a/pkg/wsman/amt/timesynchronization/types.go b/pkg/wsman/amt/timesynchronization/types.go
new file mode 100644
index 00000000..b05de6f8
--- /dev/null
+++ b/pkg/wsman/amt/timesynchronization/types.go
@@ -0,0 +1,148 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package timesynchronization
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+)
+
+type Service struct {
+ base message.Base
+}
+
+// Response Types
+type (
+ Response struct {
+ *client.Message
+ XMLName xml.Name `xml:"Envelope"`
+ Header message.Header `xml:"Header"`
+ Body Body `xml:"Body"`
+ }
+ Body struct {
+ XMLName xml.Name `xml:"Body"`
+ GetResponse TimeSynchronizationServiceResponse
+ EnumerateResponse common.EnumerateResponse
+ PullResponse PullResponse
+ GetLowAccuracyTimeSynchResponse GetLowAccuracyTimeSynchResponse
+ SetHighAccuracyTimeSynchResponse SetHighAccuracyTimeSynchResponse
+ }
+
+ PullResponse struct {
+ XMLName xml.Name `xml:"PullResponse"`
+ TimeSynchronizationServiceItems []TimeSynchronizationServiceResponse `xml:"Items>AMT_TimeSynchronizationService"`
+ }
+
+ TimeSynchronizationServiceResponse struct {
+ XMLName xml.Name `xml:"AMT_TimeSynchronizationService"`
+ Name string `xml:"Name,omitempty"` // The Name property uniquely identifies the Service and provides an indication of the functionality that is managed. This functionality is described in more detail in the Description property of the object.
+ CreationClassName string `xml:"CreationClassName,omitempty"` // CreationClassName indicates the name of the class or the subclass that is used in the creation of an instance. When used with the other key properties of this class, this property allows all instances of this class and its subclasses to be uniquely identified.
+ SystemName string `xml:"SystemName,omitempty"` // The Name of the scoping System.
+ SystemCreationClassName string `xml:"SystemCreationClassName,omitempty"` // The CreationClassName of the scoping System.
+ ElementName string `xml:"ElementName,omitempty"` // A user-friendly name for the object. This property allows each instance to define a user-friendly name in addition to its key properties, identity data, and description information. Note that the Name property of ManagedSystemElement is also defined as a user-friendly name. But, it is often subclassed to be a Key. It is not reasonable that the same property can convey both identity and a user-friendly name, without inconsistencies. Where Name exists and is not a Key (such as for instances of LogicalDevice), the same information can be present in both the Name and ElementName properties. Note that if there is an associated instance of CIM_EnabledLogicalElementCapabilities, restrictions on this properties may exist as defined in ElementNameMask and MaxElementNameLen properties defined in that class.
+ EnabledState EnabledState `xml:"EnabledState,omitempty"` // EnabledState is an integer enumeration that indicates the enabled and disabled states of an element.
+ RequestedState RequestedState `xml:"RequestedState,omitempty"` // RequestedState is an integer enumeration that indicates the last requested or desired state for the element, irrespective of the mechanism through which it was requested.
+ LocalTimeSyncEnabled LocalTimeSyncEnabled `xml:"LocalTimeSyncEnabled,omitempty"` // Determines if user with LOCAL_SYSTEM_REALM permission can set the time.
+ TimeSource TimeSource `xml:"TimeSource,omitempty"` // Determines if RTC was set to UTC by any configuration SW.
+ }
+
+ // EnabledState is an integer enumeration that indicates the enabled and disabled states of an element. It can also indicate the transitions between these requested states. For example, shutting down (value=4) and starting (value=10) are transient states between enabled and disabled.
+ //
+ // The following text briefly summarizes the various enabled and disabled states:
+ //
+ // Enabled (2) indicates that the element is or could be executing commands, will process any queued commands, and queues new requests.
+ //
+ // Disabled (3) indicates that the element will not execute commands and will drop any new requests.
+ //
+ // Shutting Down (4) indicates that the element is in the process of going to a Disabled state.
+ //
+ // Not Applicable (5) indicates the element does not support being enabled or disabled.
+ //
+ // Enabled but Offline (6) indicates that the element might be completing commands, and will drop any new requests.
+ //
+ // Test (7) indicates that the element is in a test state.
+ //
+ // Deferred (8) indicates that the element might be completing commands, but will queue any new requests.
+ //
+ // Quiesce (9) indicates that the element is enabled but in a restricted mode.
+ //
+ // Starting (10) indicates that the element is in the process of going to an Enabled state. New requests are queued.
+ //
+ // Value 6 ("Enabled but Offline") can be recieved also if the Audit Log is in locked state.
+ //
+ // ValueMap={0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11..32767, 32768..65535}
+ //
+ // Values={Unknown, Other, Enabled, Disabled, Shutting Down, Not Applicable, Enabled but Offline, In Test, Deferred, Quiesce, Starting, DMTF Reserved, Vendor Reserved}
+ EnabledState int
+ // RequestedState is an integer enumeration that indicates the last requested or desired state for the element, irrespective of the mechanism through which it was requested. The actual state of the element is represented by EnabledState. This property is provided to compare the last requested and current enabled or disabled states. Note that when EnabledState is set to 5 ("Not Applicable"), then this property has no meaning. Refer to the EnabledState property description for explanations of the values in the RequestedState enumeration.
+ //
+ // "Unknown" (0) indicates the last requested state for the element is unknown.
+ //
+ // Note that the value "No Change" (5) has been deprecated in lieu of indicating the last requested state is "Unknown" (0). If the last requested or desired state is unknown, RequestedState should have the value "Unknown" (0), but may have the value "No Change" (5).Offline (6) indicates that the element has been requested to transition to the Enabled but Offline EnabledState. It should be noted that there are two new values in RequestedState that build on the statuses of EnabledState. These are "Reboot" (10) and "Reset" (11). Reboot refers to doing a "Shut Down" and then moving to an "Enabled" state. Reset indicates that the element is first "Disabled" and then "Enabled". The distinction between requesting "Shut Down" and "Disabled" should also be noted. Shut Down requests an orderly transition to the Disabled state, and might involve removing power, to completely erase any existing state. The Disabled state requests an immediate disabling of the element, such that it will not execute or accept any commands or processing requests.
+ //
+ // This property is set as the result of a method invocation (such as Start or StopService on CIM_Service), or can be overridden and defined as WRITEable in a subclass. The method approach is considered superior to a WRITEable property, because it allows an explicit invocation of the operation and the return of a result code.
+ //
+ // If knowledge of the last RequestedState is not supported for the EnabledLogicalElement, the property shall be NULL or have the value 12 "Not Applicable".
+ //
+ // ValueMap={0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, .., 32768..65535}
+ //
+ // Values={Unknown, Enabled, Disabled, Shut Down, No Change, Offline, Test, Deferred, Quiesce, Reboot, Reset, Not Applicable, DMTF Reserved, Vendor Reserved}
+ RequestedState int
+ // Determines if user with LOCAL_SYSTEM_REALM permission can set the time. The values are:
+ //
+ // - DEFAULT_TRUE - Time sync is enabled by default. Was not configured to enabled or disabled by the configuration SW.
+ //
+ // - CONFIGURED_TRUE - Time Sync is enabled and configured by configuration SW to TRUE. This option is required in order to differentiate between legacy configuration SW that do not support this setting and new SW that can configure it to TRUE.
+ //
+ // - FALSE - Time Sync is disabled.
+ //
+ // ValueMap={0, 1, 2, 3..}
+ //
+ // Values={DEFAULT_TRUE, CONFIGURED_TRUE, FALSE, RESERVED}
+ LocalTimeSyncEnabled int
+ // Determines if RTC was set to UTC by any configuration SW.
+ //
+ // ValueMap={0, 1, 2..}
+ //
+ // Values={BIOS_RTC, CONFIGURED, RESERVED}
+ TimeSource int
+
+ // ValueMap={0, 1}
+ //
+ // Values={PT_STATUS_SUCCESS, PT_STATUS_INTERNAL_ERROR}
+ GetLowAccuracyTimeSynchResponse struct {
+ XMLName xml.Name `xml:"GetLowAccuracyTimeSynch_OUTPUT"`
+ Ta0 int64 `xml:"Ta0"`
+ ReturnValue int `xml:"ReturnValue"`
+ }
+
+ // ValueMap={0, 1, 36, 38}
+ //
+ // Values={PT_STATUS_SUCCESS, PT_STATUS_INTERNAL_ERROR, PT_STATUS_INVALID_PARAMETER, PT_STATUS_FLASH_WRITE_LIMIT_EXCEEDED}
+ SetHighAccuracyTimeSynchResponse struct {
+ XMLName xml.Name `xml:"SetHighAccuracyTimeSynch_OUTPUT"`
+ ReturnValue int `xml:"ReturnValue"`
+ }
+)
+
+// Request Types
+type (
+ // Ta0: The time value received from invoking GetLowAccuracyTimeSynch().
+ //
+ // Tm1: The remote client timestamp after getting a response from GetLowAccuracyTimeSynch().
+ //
+ // Tm2: The remote client timestamp obtained immediately prior to invoking this method.
+ SetHighAccuracyTimeSynch_INPUT struct {
+ XMLName xml.Name `xml:"h:SetHighAccuracyTimeSynch_INPUT"`
+ H string `xml:"xmlns:h,attr"`
+ Ta0 int64 `xml:"h:Ta0"`
+ Tm1 int64 `xml:"h:Tm1"`
+ Tm2 int64 `xml:"h:Tm2"`
+ }
+)
diff --git a/pkg/wsman/amt/tls/constants.go b/pkg/wsman/amt/tls/constants.go
new file mode 100644
index 00000000..4f1cf447
--- /dev/null
+++ b/pkg/wsman/amt/tls/constants.go
@@ -0,0 +1,12 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package tls
+
+const (
+ AMT_TLSCredentialContext string = "AMT_TLSCredentialContext"
+ AMT_TLSSettingData string = "AMT_TLSSettingData"
+ AMT_TLSProtocolEndpointCollection string = "AMT_TLSProtocolEndpointCollection"
+)
diff --git a/pkg/wsman/amt/tls/credentialcontext.go b/pkg/wsman/amt/tls/credentialcontext.go
new file mode 100644
index 00000000..f6eb1d0f
--- /dev/null
+++ b/pkg/wsman/amt/tls/credentialcontext.go
@@ -0,0 +1,136 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+// Package tls facilitiates communication with Intel® AMT devices to access and configure TLS Credential Context, TLS Protocol Endpoint Collection, and TLS Setting Data features of AMT
+//
+// Credential Context:
+// This class represents the credential of the TLSProtocolEndpointCollection, by connecting a certficate to the service.
+// The connected certificate must be a leaf certificate, and must have a matching private key.
+// You can't enable the TLS service without a credential.
+// When TLS is enabled the certificate can be changed using the Put method.
+//
+// Protocol Endpoint Collection:
+// This class connects the 2 instances of AMT_TLSProtocolEndpoint and can be used in order to enable/disable TLS in the system.
+//
+// Setting Data:
+// This class represents configuration-related and operational parameters for the TLS service in the Intel® AMT.
+package tls
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+)
+
+// NewTLSCredentialContextWithClient instantiates a new CredentialContext
+func NewTLSCredentialContextWithClient(wsmanMessageCreator *message.WSManMessageCreator, client client.WSMan) CredentialContext {
+ return CredentialContext{
+ base: message.NewBaseWithClient(wsmanMessageCreator, AMT_TLSCredentialContext, client),
+ }
+}
+
+// Get retrieves the representation of the instance
+func (credentialContext CredentialContext) Get() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: credentialContext.base.Get(nil),
+ },
+ }
+ // send the message to AMT
+ err = credentialContext.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Enumerate returns an enumeration context which is used in a subsequent Pull call
+func (credentialContext CredentialContext) Enumerate() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: credentialContext.base.Enumerate(),
+ },
+ }
+ // send the message to AMT
+ err = credentialContext.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Pull returns the instances of this class. An enumeration context provided by the Enumerate call is used as input.
+func (credentialContext CredentialContext) Pull(enumerationContext string) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: credentialContext.base.Pull(enumerationContext),
+ },
+ }
+ // send the message to AMT
+ err = credentialContext.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// // Delete removes a the specified instance
+// func (credentialContext CredentialContext) Delete(handle string) (response Response, err error) {
+// selector := message.Selector{Name: "Name", Value: handle}
+// response = Response{
+// Message: &client.Message{
+// XMLInput: credentialContext.base.Delete(selector),
+// },
+// }
+// // send the message to AMT
+// err = credentialContext.base.Execute(response.Message)
+// if err != nil {
+// return
+// }
+// // put the xml response into the go struct
+// err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+// if err != nil {
+// return
+// }
+// return
+// }
+
+// // Creates a new instance of this class
+// func (credentialContext CredentialContext) Create(certHandle string) (response Response, err error) {
+// header := credentialContext.base.WSManMessageCreator.CreateHeader(string(actions.Create), AMT_TLSCredentialContext, nil, "", "")
+// body := fmt.Sprintf(`/wsman%sAMT_PublicKeyCertificate%s/wsman%sAMT_TLSProtocolEndpointCollectionTLSProtocolEndpointInstances Collection`, credentialContext.base.WSManMessageCreator.ResourceURIBase, credentialContext.base.WSManMessageCreator.ResourceURIBase, certHandle, credentialContext.base.WSManMessageCreator.ResourceURIBase)
+// response = Response{
+// Message: &client.Message{
+// XMLInput: credentialContext.base.WSManMessageCreator.CreateXML(header, body),
+// },
+// }
+// // send the message to AMT
+// err = credentialContext.base.Execute(response.Message)
+// if err != nil {
+// return
+// }
+// // put the xml response into the go struct
+// err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+// if err != nil {
+// return
+// }
+// return
+// }
diff --git a/pkg/wsman/amt/tls/credentialcontext_test.go b/pkg/wsman/amt/tls/credentialcontext_test.go
new file mode 100644
index 00000000..d0f4f4c9
--- /dev/null
+++ b/pkg/wsman/amt/tls/credentialcontext_test.go
@@ -0,0 +1,125 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package tls
+
+import (
+ "encoding/xml"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
+)
+
+func TestPositiveAMT_TLSCredentialContext(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/tls/credentialcontext",
+ }
+ elementUnderTest := NewTLSCredentialContextWithClient(wsmanMessageCreator, &client)
+
+ t.Run("amt_TLSCredentialContext Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ extraHeader string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ // {
+ // "should create a valid AMT_TLSCredentialContext Get wsman message",
+ // AMT_TLSCredentialContext,
+ // wsmantesting.GET,
+ // "",
+ // "",
+ // func() (Response, error) {
+ // client.CurrentMessage = "Get"
+ // return elementUnderTest.Get()
+ // },
+ // Body{},
+ // },
+ //ENUMERATES
+ {
+ "should create a valid AMT_TLSCredentialContext Enumerate wsman message",
+ AMT_TLSCredentialContext,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Enumerate"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "6B080000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ // {
+ // "should create a valid AMT_TLSCredentialContext Pull wsman message",
+ // AMT_TLSCredentialContext,
+ // wsmantesting.PULL,
+ // wsmantesting.PULL_BODY,
+ // "",
+ // func() (Response, error) {
+ // client.CurrentMessage = "Pull"
+ // return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ // },
+ // Body{
+ // PullResponse: PullResponse{
+ // XMLName: xml.Name{Space: message.XMLPullResponseSpace, Local: "PullResponse"},
+
+ // },
+ // },
+ // },
+ //DELETE
+ // {
+ // "should create a valid AMT_TLSCredentialContext Delete wsman message",
+ // AMT_TLSCredentialContext,
+ // wsmantesting.DELETE,
+ // "",
+ // "instanceID123",
+ // func() (Response, error) {
+ // client.CurrentMessage = "Delete"
+ // return elementUnderTest.Delete("instanceID123")
+ // },
+ // Body{},
+ // },
+ //Create
+ // {
+ // "should create a valid AMT_TLSCredentialContext Create wsman message",
+ // AMT_TLSCredentialContext,
+ // wsmantesting.CREATE,
+ // "",
+ // "", //fmt.Sprintf(`/wsman%sAMT_PublicKeyCertificate%s/wsman%sAMT_TLSProtocolEndpointCollectionTLSProtocolEndpointInstances Collection`, credentialContext.base.WSManMessageCreator.ResourceURIBase, credentialContext.base.WSManMessageCreator.ResourceURIBase, certHandle, credentialContext.base.WSManMessageCreator.ResourceURIBase),
+ // func() (Response, error) {
+ // client.CurrentMessage = "Create"
+ // return elementUnderTest.Create("test")
+ // },
+ // Body{},
+ // },
+ }
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, test.extraHeader, test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.NoError(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.Equal(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
diff --git a/pkg/wsman/amt/tls/marshal.go b/pkg/wsman/amt/tls/marshal.go
new file mode 100644
index 00000000..5d85fa40
--- /dev/null
+++ b/pkg/wsman/amt/tls/marshal.go
@@ -0,0 +1,30 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package tls
+
+import (
+ "encoding/json"
+
+ "gopkg.in/yaml.v3"
+)
+
+// JSON marshals the type into JSON format
+func (r *Response) JSON() string {
+ jsonOutput, err := json.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(jsonOutput)
+}
+
+// YAML marshals the type into YAML format
+func (r *Response) YAML() string {
+ yamlOutput, err := yaml.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(yamlOutput)
+}
diff --git a/pkg/wsman/amt/tls/protocolendpointcollection.go b/pkg/wsman/amt/tls/protocolendpointcollection.go
new file mode 100644
index 00000000..d4b285a6
--- /dev/null
+++ b/pkg/wsman/amt/tls/protocolendpointcollection.go
@@ -0,0 +1,80 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package tls
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+)
+
+// NewTLSProtocolEndpointCollectionWithClient instantiates a new ProtocolEndpointCollection
+func NewTLSProtocolEndpointCollectionWithClient(wsmanMessageCreator *message.WSManMessageCreator, client client.WSMan) ProtocolEndpointCollection {
+ return ProtocolEndpointCollection{
+ base: message.NewBaseWithClient(wsmanMessageCreator, AMT_TLSProtocolEndpointCollection, client),
+ }
+}
+
+// Get retrieves the representation of the instance
+func (collection ProtocolEndpointCollection) Get() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: collection.base.Get(nil),
+ },
+ }
+ // send the message to AMT
+ err = collection.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Enumerate returns an enumeration context which is used in a subsequent Pull call
+func (collection ProtocolEndpointCollection) Enumerate() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: collection.base.Enumerate(),
+ },
+ }
+ // send the message to AMT
+ err = collection.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Pull returns the instances of this class. An enumeration context provided by the Enumerate call is used as input.
+func (collection ProtocolEndpointCollection) Pull(enumerationContext string) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: collection.base.Pull(enumerationContext),
+ },
+ }
+ // send the message to AMT
+ err = collection.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
diff --git a/pkg/wsman/amt/tls/protocolendpointcollection_test.go b/pkg/wsman/amt/tls/protocolendpointcollection_test.go
new file mode 100644
index 00000000..993c5f70
--- /dev/null
+++ b/pkg/wsman/amt/tls/protocolendpointcollection_test.go
@@ -0,0 +1,205 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package tls
+
+import (
+ "encoding/xml"
+ "fmt"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
+)
+
+func TestPositiveAMT_TLSProtocolEndpointCollection(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/tls/protocolendpointcollection",
+ }
+ elementUnderTest := NewTLSProtocolEndpointCollectionWithClient(wsmanMessageCreator, &client)
+
+ t.Run("amt_TLSProtocolEndpointCollection Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ extraHeader string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create a valid AMT_TLSProtocolEndpointCollection Get wsman message",
+ AMT_TLSProtocolEndpointCollection,
+ wsmantesting.GET,
+ "",
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Get"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ ProtocolEndpointCollectionGetResponse: ProtocolEndpointCollectionResponse{
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_TLSProtocolEndpointCollection), Local: AMT_TLSProtocolEndpointCollection},
+ ElementName: "TLSProtocolEndpoint Instances Collection",
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create a valid AMT_TLSProtocolEndpointCollection Enumerate wsman message",
+ AMT_TLSProtocolEndpointCollection,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Enumerate"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "8B080000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid AMT_TLSProtocolEndpointCollection Pull wsman message",
+ AMT_TLSProtocolEndpointCollection,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Pull"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: message.XMLPullResponseSpace, Local: "PullResponse"},
+ ProtocolEndpointCollectionItems: []ProtocolEndpointCollectionResponse{
+ {
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_TLSProtocolEndpointCollection), Local: AMT_TLSProtocolEndpointCollection},
+ ElementName: "TLSProtocolEndpoint Instances Collection",
+ },
+ },
+ },
+ },
+ },
+ }
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, test.extraHeader, test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.NoError(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.Equal(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
+func TestNegativeAMT_TLSProtocolEndpointCollection(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/tls/protocolendpointcollection",
+ }
+ elementUnderTest := NewTLSProtocolEndpointCollectionWithClient(wsmanMessageCreator, &client)
+
+ t.Run("amt_TLSProtocolEndpointCollection Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ extraHeader string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create a valid AMT_TLSProtocolEndpointCollection Get wsman message",
+ AMT_TLSProtocolEndpointCollection,
+ wsmantesting.GET,
+ "",
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ ProtocolEndpointCollectionGetResponse: ProtocolEndpointCollectionResponse{
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_TLSProtocolEndpointCollection), Local: AMT_TLSProtocolEndpointCollection},
+ ElementName: "TLSProtocolEndpoint Instances Collection",
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create a valid AMT_TLSProtocolEndpointCollection Enumerate wsman message",
+ AMT_TLSProtocolEndpointCollection,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "8B080000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid AMT_TLSProtocolEndpointCollection Pull wsman message",
+ AMT_TLSProtocolEndpointCollection,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: message.XMLPullResponseSpace, Local: "PullResponse"},
+ ProtocolEndpointCollectionItems: []ProtocolEndpointCollectionResponse{
+ {
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_TLSProtocolEndpointCollection), Local: AMT_TLSProtocolEndpointCollection},
+ ElementName: "TLSProtocolEndpoint Instances Collection",
+ },
+ },
+ },
+ },
+ },
+ }
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, test.extraHeader, test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.Error(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.NotEqual(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
diff --git a/pkg/wsman/amt/tls/settingdata.go b/pkg/wsman/amt/tls/settingdata.go
new file mode 100644
index 00000000..bb28db45
--- /dev/null
+++ b/pkg/wsman/amt/tls/settingdata.go
@@ -0,0 +1,119 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package tls
+
+import (
+ "encoding/xml"
+ "fmt"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+)
+
+// NewTLSSettingDataWithClient instantiates a new SettingData
+func NewTLSSettingDataWithClient(wsmanMessageCreator *message.WSManMessageCreator, client client.WSMan) SettingData {
+ return SettingData{
+ base: message.NewBaseWithClient(wsmanMessageCreator, AMT_TLSSettingData, client),
+ }
+}
+
+// Get retrieves the representation of the instance
+func (settingData SettingData) Get(instanceID string) (response Response, err error) {
+ selector := message.Selector{
+ Name: "InstanceID",
+ Value: instanceID,
+ }
+ response = Response{
+ Message: &client.Message{
+ XMLInput: settingData.base.Get(&selector),
+ },
+ }
+ // send the message to AMT
+ err = settingData.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Enumerate returns an enumeration context which is used in a subsequent Pull call
+func (settingData SettingData) Enumerate() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: settingData.base.Enumerate(),
+ },
+ }
+ // send the message to AMT
+ err = settingData.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Pull returns the instances of this class. An enumeration context provided by the Enumerate call is used as input.
+func (settingData SettingData) Pull(enumerationContext string) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: settingData.base.Pull(enumerationContext),
+ },
+ }
+ // send the message to AMT
+ err = settingData.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Put changes properties of the selected instance.
+// The following properties must be included in any representation of SettingDataRequest:
+//
+// - ElementName(cannot be modified)
+//
+// - InstanceID (cannot be modified)
+//
+// - Enabled.
+//
+// This method will not modify the flash ("Enabled" property) until setupandconfiguration.CommitChanges() is issued and performed successfully.
+func (settingData SettingData) Put(instanceID string, tlsSettingData SettingDataRequest) (response Response, err error) {
+ tlsSettingData.H = fmt.Sprintf("%s%s", message.AMTSchema, AMT_TLSSettingData)
+ selector := message.Selector{
+ Name: "InstanceID",
+ Value: instanceID,
+ }
+ response = Response{
+ Message: &client.Message{
+ XMLInput: settingData.base.Put(tlsSettingData, true, &selector),
+ },
+ }
+ // send the message to AMT
+ err = settingData.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
diff --git a/pkg/wsman/amt/tls/settingdata_test.go b/pkg/wsman/amt/tls/settingdata_test.go
new file mode 100644
index 00000000..e825fcc7
--- /dev/null
+++ b/pkg/wsman/amt/tls/settingdata_test.go
@@ -0,0 +1,303 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package tls
+
+import (
+ "encoding/xml"
+ "fmt"
+ "testing"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
+ "github.com/stretchr/testify/assert"
+)
+
+const (
+ EnvelopeResponse = `http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous0`
+ GetBody = `AMT_TLSSettingDataIntel(r) TLS Setting DataIntel(r) AMT TLS Setting DataCIM_ComputerSystemManagedSystem`
+)
+
+func TestPositiveAMT_TLSSettingData(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/tls/settingdata",
+ }
+ elementUnderTest := NewTLSSettingDataWithClient(wsmanMessageCreator, &client)
+
+ t.Run("amt_TLSSettingData Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ extraHeader string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create a valid AMT_TLSSettingData Get wsman message",
+ AMT_TLSSettingData,
+ wsmantesting.GET,
+ "Intel(r) AMT 802.3 TLS Settings",
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Get"
+ return elementUnderTest.Get("Intel(r) AMT 802.3 TLS Settings")
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ SettingDataGetAndPutResponse: SettingDataResponse{
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_TLSSettingData), Local: AMT_TLSSettingData},
+ AcceptNonSecureConnections: false,
+ ElementName: "Intel(r) AMT 802.3 TLS Settings",
+ Enabled: false,
+ InstanceID: "Intel(r) AMT 802.3 TLS Settings",
+ MutualAuthentication: false,
+ },
+ },
+ },
+
+ //ENUMERATES
+ {
+ "should create a valid AMT_TLSSettingData Enumerate wsman message",
+ AMT_TLSSettingData,
+ wsmantesting.ENUMERATE,
+ "",
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Enumerate"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "CA000000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid AMT_TLSSettingData Pull wsman message",
+ AMT_TLSSettingData,
+ wsmantesting.PULL,
+ "",
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Pull"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: message.XMLPullResponseSpace, Local: "PullResponse"},
+ SettingDataItems: []SettingDataResponse{
+ {
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_TLSSettingData), Local: AMT_TLSSettingData},
+ AcceptNonSecureConnections: false,
+ ElementName: "Intel(r) AMT 802.3 TLS Settings",
+ Enabled: false,
+ InstanceID: "Intel(r) AMT 802.3 TLS Settings",
+ MutualAuthentication: false,
+ },
+ {
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_TLSSettingData), Local: AMT_TLSSettingData},
+ AcceptNonSecureConnections: true,
+ ElementName: "Intel(r) AMT LMS TLS Settings",
+ Enabled: false,
+ InstanceID: "Intel(r) AMT LMS TLS Settings",
+ MutualAuthentication: false,
+ },
+ },
+ },
+ },
+ },
+
+ //PUTS
+ {
+ "should create a valid AMT_TLSSettingData Put wsman message",
+ AMT_TLSSettingData,
+ wsmantesting.PUT,
+ "Intel(r) AMT 802.3 TLS Settings",
+ "Intel(r) AMT 802.3 TLS SettingsIntel(r) AMT 802.3 TLS Settingsfalsetruefalsefalse",
+ func() (Response, error) {
+ client.CurrentMessage = "Put"
+ tlsSettingData := SettingDataRequest{
+ ElementName: "Intel(r) AMT 802.3 TLS Settings",
+ InstanceID: "Intel(r) AMT 802.3 TLS Settings",
+ Enabled: true,
+ }
+ return elementUnderTest.Put("Intel(r) AMT 802.3 TLS Settings", tlsSettingData)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ SettingDataGetAndPutResponse: SettingDataResponse{
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_TLSSettingData), Local: AMT_TLSSettingData},
+ AcceptNonSecureConnections: false,
+ ElementName: "Intel(r) AMT 802.3 TLS Settings",
+ Enabled: false,
+ InstanceID: "Intel(r) AMT 802.3 TLS Settings",
+ MutualAuthentication: false,
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, test.extraHeader, test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.NoError(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.Equal(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
+func TestNegativeAMT_TLSSettingData(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/tls/settingdata",
+ }
+ elementUnderTest := NewTLSSettingDataWithClient(wsmanMessageCreator, &client)
+
+ t.Run("amt_TLSSettingData Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ extraHeader string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create a valid AMT_TLSSettingData Get wsman message",
+ AMT_TLSSettingData,
+ wsmantesting.GET,
+ "Intel(r) AMT 802.3 TLS Settings",
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Get("Intel(r) AMT 802.3 TLS Settings")
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ SettingDataGetAndPutResponse: SettingDataResponse{
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_TLSSettingData), Local: AMT_TLSSettingData},
+ AcceptNonSecureConnections: false,
+ ElementName: "Intel(r) AMT 802.3 TLS Settings",
+ Enabled: false,
+ InstanceID: "Intel(r) AMT 802.3 TLS Settings",
+ MutualAuthentication: false,
+ },
+ },
+ },
+
+ //ENUMERATES
+ {
+ "should create a valid AMT_TLSSettingData Enumerate wsman message",
+ AMT_TLSSettingData,
+ wsmantesting.ENUMERATE,
+ "",
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "CA000000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid AMT_TLSSettingData Pull wsman message",
+ AMT_TLSSettingData,
+ wsmantesting.PULL,
+ "",
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: message.XMLPullResponseSpace, Local: "PullResponse"},
+ SettingDataItems: []SettingDataResponse{
+ {
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_TLSSettingData), Local: AMT_TLSSettingData},
+ AcceptNonSecureConnections: false,
+ ElementName: "Intel(r) AMT 802.3 TLS Settings",
+ Enabled: false,
+ InstanceID: "Intel(r) AMT 802.3 TLS Settings",
+ MutualAuthentication: false,
+ },
+ {
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_TLSSettingData), Local: AMT_TLSSettingData},
+ AcceptNonSecureConnections: true,
+ ElementName: "Intel(r) AMT LMS TLS Settings",
+ Enabled: false,
+ InstanceID: "Intel(r) AMT LMS TLS Settings",
+ MutualAuthentication: false,
+ },
+ },
+ },
+ },
+ },
+
+ //PUTS
+ {
+ "should create a valid AMT_TLSSettingData Put wsman message",
+ AMT_TLSSettingData,
+ wsmantesting.PUT,
+ "Intel(r) AMT 802.3 TLS Settings",
+ "Intel(r) AMT 802.3 TLS SettingsIntel(r) AMT 802.3 TLS Settingsfalsetruefalsefalse",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ tlsSettingData := SettingDataRequest{
+ ElementName: "Intel(r) AMT 802.3 TLS Settings",
+ InstanceID: "Intel(r) AMT 802.3 TLS Settings",
+ Enabled: true,
+ }
+ return elementUnderTest.Put("Intel(r) AMT 802.3 TLS Settings", tlsSettingData)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ SettingDataGetAndPutResponse: SettingDataResponse{
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_TLSSettingData), Local: AMT_TLSSettingData},
+ AcceptNonSecureConnections: false,
+ ElementName: "Intel(r) AMT 802.3 TLS Settings",
+ Enabled: false,
+ InstanceID: "Intel(r) AMT 802.3 TLS Settings",
+ MutualAuthentication: false,
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, test.extraHeader, test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.Error(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.NotEqual(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
diff --git a/pkg/wsman/amt/tls/types.go b/pkg/wsman/amt/tls/types.go
new file mode 100644
index 00000000..7f10721c
--- /dev/null
+++ b/pkg/wsman/amt/tls/types.go
@@ -0,0 +1,82 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package tls
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+)
+
+type (
+ SettingData struct {
+ base message.Base
+ }
+ CredentialContext struct {
+ base message.Base
+ }
+ ProtocolEndpointCollection struct {
+ base message.Base
+ }
+)
+
+// OUTPUT
+// Response Types
+type (
+ Response struct {
+ *client.Message
+ XMLName xml.Name `xml:"Envelope"`
+ Header message.Header `xml:"Header"`
+ Body Body `xml:"Body"`
+ }
+ Body struct {
+ XMLName xml.Name `xml:"Body"`
+ SettingDataGetAndPutResponse SettingDataResponse `xml:"AMT_TLSSettingData"`
+ CredentialContextGetResponse CredentialContextResponse `xml:"AMT_TLSCredentialContext"`
+ ProtocolEndpointCollectionGetResponse ProtocolEndpointCollectionResponse `xml:"AMT_TLSProtocolEndpointCollection"`
+ EnumerateResponse common.EnumerateResponse
+ PullResponse PullResponse
+ }
+ SettingDataResponse struct {
+ XMLName xml.Name `xml:"AMT_TLSSettingData"`
+ ElementName string `xml:"ElementName,omitempty"` // The user-friendly name for this instance of SettingData. In addition, the user-friendly name can be used as an index property for a search or query. (Note: The name does not have to be unique within a namespace.)
+ InstanceID string `xml:"InstanceID,omitempty"` // Within the scope of the instantiating Namespace, InstanceID opaquely and uniquely identifies an instance of this class. To ensure uniqueness within the NameSpace, the value of InstanceID should be constructed using the following "preferred" algorithm: : Where and are separated by a colon (:), and where must include a copyrighted, trademarked, or otherwise unique name that is owned by the business entity that is creating or defining the InstanceID or that is a registered ID assigned to the business entity by a recognized global authority. (This requirement is similar to the _ structure of Schema class names.) In addition, to ensure uniqueness, must not contain a colon (:). When using this algorithm, the first colon to appear in InstanceID must appear between and . is chosen by the business entity and should not be reused to identify different underlying (real-world) elements. If the above "preferred" algorithm is not used, the defining entity must assure that the resulting InstanceID is not reused across any InstanceIDs produced by this or other providers for the NameSpace of this instance. For DMTF-defined instances, the "preferred" algorithm must be used with the set to CIM.
+ MutualAuthentication bool `xml:"MutualAuthentication"` // Adminstrator-settable property that determines whether or not mutual authentication is used at the TLS layer is used on the associated service access point. If False, then only the server authenticates itself at the TLS layer. Use of Mutual Authentication on the local interface is deprecated in Release 6.0. The feature will be removed in a future release. This property is only visible / usable for users of ADMIN_SECURITY_ADMINISTRATION realm. This property must be supplied if Enabled property is True.
+ Enabled bool `xml:"Enabled"` // Administrator-settable property that determines whether or not TLS is used on the associated service access point.
+ TrustedCN []string `xml:"TrustedCN,omitempty"` // An array of strings, used to validate the CN subfield of the subject field in X.509 certificates presented to Intel® AMT in the TLS handshake. This value must comply with the requirements of RFC 1035.
+ AcceptNonSecureConnections bool `xml:"AcceptNonSecureConnections"` // This setting defines once TLS is enabled and configured whether non-secure EOI/WSMAN connections are still accepted by FW on ports 16992 and 623. If AcceptNonSecureConnections is set to TRUE then non-secure connections are still accepted. If set to FALSE then non-secure connections are rejected. This setting may be set per interface for the local and network interfaces. AMT_TLSSettingData.AcceptNonSecureConnections may only be modified for the remote interface. It is a read-only property for the local interface instance.
+ NonSecureConnectionsSupported bool `xml:"NonSecureConnectionsSupported"` // Indicates the removal of support for the non-TLS WS-MAN ports for the remote interface. Available starting Intel CSME 16.1 firmware on Raptor Lake platforms. If this read-only field exists and its value is True, changing the value of the AcceptNonSecureConnections field is allowed only for the local interface. Note that this class and field can be accessed locally as well as remotely. Invoking the AMT_TLSSettingData.Put() command on the remote instance with AcceptNonSecureConnections set to True will fail with error code AMT_STATUS_NOT_PERMITTED. Setting AMT_TLSSettingData.Enabled to False will also fail for the remote interface.
+ }
+ CredentialContextResponse struct {
+ XMLName xml.Name `xml:"AMT_TLSCredentialContext"`
+ }
+ ProtocolEndpointCollectionResponse struct {
+ XMLName xml.Name `xml:"AMT_TLSProtocolEndpointCollection"`
+ ElementName string `xml:"ElementName"`
+ }
+ PullResponse struct {
+ XMLName xml.Name `xml:"PullResponse"`
+ SettingDataItems []SettingDataResponse `xml:"Items>AMT_TLSSettingData"`
+ ProtocolEndpointCollectionItems []ProtocolEndpointCollectionResponse `xml:"Items>AMT_TLSProtocolEndpointCollection"`
+ CredentialContextItems []CredentialContextResponse `xml:"Items>AMT_TLSCredentialContext"`
+ }
+)
+
+type (
+ SettingDataRequest struct {
+ XMLName xml.Name `xml:"h:AMT_TLSSettingData"`
+ H string `xml:"xmlns:h,attr"`
+ ElementName string `xml:"h:ElementName,omitempty"` // The user-friendly name for this instance of SettingData. In addition, the user-friendly name can be used as an index property for a search or query. (Note: The name does not have to be unique within a namespace.)
+ InstanceID string `xml:"h:InstanceID,omitempty"` // Within the scope of the instantiating Namespace, InstanceID opaquely and uniquely identifies an instance of this class. To ensure uniqueness within the NameSpace, the value of InstanceID should be constructed using the following "preferred" algorithm: : Where and are separated by a colon (:), and where must include a copyrighted, trademarked, or otherwise unique name that is owned by the business entity that is creating or defining the InstanceID or that is a registered ID assigned to the business entity by a recognized global authority. (This requirement is similar to the _ structure of Schema class names.) In addition, to ensure uniqueness, must not contain a colon (:). When using this algorithm, the first colon to appear in InstanceID must appear between and . is chosen by the business entity and should not be reused to identify different underlying (real-world) elements. If the above "preferred" algorithm is not used, the defining entity must assure that the resulting InstanceID is not reused across any InstanceIDs produced by this or other providers for the NameSpace of this instance. For DMTF-defined instances, the "preferred" algorithm must be used with the set to CIM.
+ MutualAuthentication bool `xml:"h:MutualAuthentication"` // Adminstrator-settable property that determines whether or not mutual authentication is used at the TLS layer is used on the associated service access point. If False, then only the server authenticates itself at the TLS layer. Use of Mutual Authentication on the local interface is deprecated in Release 6.0. The feature will be removed in a future release. This property is only visible / usable for users of ADMIN_SECURITY_ADMINISTRATION realm. This property must be supplied if Enabled property is True.
+ Enabled bool `xml:"h:Enabled"` // Administrator-settable property that determines whether or not TLS is used on the associated service access point.
+ TrustedCN []string `xml:"h:TrustedCN,omitempty"` // An array of strings, used to validate the CN subfield of the subject field in X.509 certificates presented to Intel® AMT in the TLS handshake. This value must comply with the requirements of RFC 1035.
+ AcceptNonSecureConnections bool `xml:"h:AcceptNonSecureConnections"` // This setting defines once TLS is enabled and configured whether non-secure EOI/WSMAN connections are still accepted by FW on ports 16992 and 623. If AcceptNonSecureConnections is set to TRUE then non-secure connections are still accepted. If set to FALSE then non-secure connections are rejected. This setting may be set per interface for the local and network interfaces. AMT_TLSSettingData.AcceptNonSecureConnections may only be modified for the remote interface. It is a read-only property for the local interface instance.
+ NonSecureConnectionsSupported bool `xml:"h:NonSecureConnectionsSupported"` // Indicates the removal of support for the non-TLS WS-MAN ports for the remote interface. Available starting Intel CSME 16.1 firmware on Raptor Lake platforms. If this read-only field exists and its value is True, changing the value of the AcceptNonSecureConnections field is allowed only for the local interface. Note that this class and field can be accessed locally as well as remotely. Invoking the AMT_TLSSettingData.Put() command on the remote instance with AcceptNonSecureConnections set to True will fail with error code AMT_STATUS_NOT_PERMITTED. Setting AMT_TLSSettingData.Enabled to False will also fail for the remote interface.
+ }
+)
diff --git a/pkg/wsman/amt/userinitiatedconnection/constants.go b/pkg/wsman/amt/userinitiatedconnection/constants.go
new file mode 100644
index 00000000..b7bd7352
--- /dev/null
+++ b/pkg/wsman/amt/userinitiatedconnection/constants.go
@@ -0,0 +1,35 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package userinitiatedconnection
+
+const (
+ AMT_UserInitiatedConnectionService string = "AMT_UserInitiatedConnectionService"
+)
+
+const (
+ AllInterfacesDisabled RequestedState = 32768
+ BIOSInterfaceEnabled RequestedState = 32769
+ OSInterfaceEnabled RequestedState = 32770
+ BIOSandOSInterfacesEnabled RequestedState = 32771
+)
+
+const (
+ EnabledStateUnknown EnabledState = iota
+ EnabledStateOther
+ EnabledStateEnabled
+ EnabledStateDisabled
+ EnabledStateShuttingDown
+ EnabledStateNotApplicable
+ EnabledStateEnabledbutOffline
+ EnabledStateInTest
+ EnabledStateDeferred
+ EnabledStateQuiesce
+ EnabledStateStarting
+ EnabledStateAllInterfacesdisabled EnabledState = 32768
+ EnabledStateBIOSInterfaceenabled EnabledState = 32769
+ EnabledStateOSInterfaceenabled EnabledState = 32770
+ EnabledStateBIOSandOSInterfacesenabled EnabledState = 32771
+)
diff --git a/pkg/wsman/amt/userinitiatedconnection/marshal.go b/pkg/wsman/amt/userinitiatedconnection/marshal.go
new file mode 100644
index 00000000..1fa1b009
--- /dev/null
+++ b/pkg/wsman/amt/userinitiatedconnection/marshal.go
@@ -0,0 +1,30 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package userinitiatedconnection
+
+import (
+ "encoding/json"
+
+ "gopkg.in/yaml.v3"
+)
+
+// JSON marshals the type into JSON format
+func (r *Response) JSON() string {
+ jsonOutput, err := json.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(jsonOutput)
+}
+
+// YAML marshals the type into YAML format
+func (r *Response) YAML() string {
+ yamlOutput, err := yaml.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(yamlOutput)
+}
diff --git a/pkg/wsman/amt/userinitiatedconnection/service.go b/pkg/wsman/amt/userinitiatedconnection/service.go
new file mode 100644
index 00000000..0f399938
--- /dev/null
+++ b/pkg/wsman/amt/userinitiatedconnection/service.go
@@ -0,0 +1,119 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+// Package userinitiatedconnection facilitiates communication with Intel® AMT devices to access and change the state of the user initiated connection feature of AMT.
+package userinitiatedconnection
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/methods"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+)
+
+func NewUserInitiatedConnectionServiceWithClient(wsmanMessageCreator *message.WSManMessageCreator, client client.WSMan) Service {
+ return Service{
+ base: message.NewBaseWithClient(wsmanMessageCreator, AMT_UserInitiatedConnectionService, client),
+ }
+}
+
+// Get retrieves the representation of the instance
+func (service Service) Get() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: service.base.Get(nil),
+ },
+ }
+ // send the message to AMT
+ err = service.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Enumerate returns an enumeration context which is used in a subsequent Pull call
+func (service Service) Enumerate() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: service.base.Enumerate(),
+ },
+ }
+ // send the message to AMT
+ err = service.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Pull returns the instances of this class. An enumeration context provided by the Enumerate call is used as input.
+func (service Service) Pull(enumerationContext string) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: service.base.Pull(enumerationContext),
+ },
+ }
+ // send the message to AMT
+ err = service.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Requests that the state of the element be changed to the value specified in the RequestedState parameter.
+// When the requested state change takes place, the EnabledState and RequestedState of the element will be the same.
+// Invoking the RequestStateChange method multiple times could result in earlier requests being overwritten or lost.
+// If 0 is returned, then the task completed successfully and the use of ConcreteJob was not required.
+// If 4096 (0x1000) is returned, then the task will take some time to complete, ConcreteJob will be created, and its reference returned in the output parameter Job.
+// Any other return code indicates an error condition.
+//
+// Additional Notes:
+//
+// 1) In Intel AMT Release 5.0 and earlier releases 'datetime' format is simple string. In Intel AMT Release 5.1 and later releases 'datetime' format is as defined in DSP0230 'DMTF WS-CIM Mapping Specification'.
+//
+// 2) AMT doesn't support the TimeoutPeriod parameter (only value 0 is valid).
+//
+// 3) The supported values in RequestedState are 32768-32771.
+//
+// ValueMap={0, 1, 2, 3, 4, 5, 6, .., 4096, 4097, 4098, 4099, 4100..32767, 32768..65535}
+//
+// Values={Completed with No Error, Not Supported, Unknown or Unspecified Error, Cannot complete within Timeout Period, Failed, Invalid Parameter, In Use, DMTF Reserved, Method Parameters Checked - Job Started, Invalid State Transition, Use of Timeout Parameter Not Supported, Busy, Method Reserved, Vendor Specific}
+func (service Service) RequestStateChange(requestedState RequestedState) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: service.base.RequestStateChange(methods.RequestStateChange(AMT_UserInitiatedConnectionService), int(requestedState)),
+ },
+ }
+ // send the message to AMT
+ err = service.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+
+}
diff --git a/pkg/wsman/amt/userinitiatedconnection/service_test.go b/pkg/wsman/amt/userinitiatedconnection/service_test.go
new file mode 100644
index 00000000..c0790d53
--- /dev/null
+++ b/pkg/wsman/amt/userinitiatedconnection/service_test.go
@@ -0,0 +1,253 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package userinitiatedconnection
+
+import (
+ "encoding/xml"
+ "fmt"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
+)
+
+func TestPositiveAMT_UserInitiatedConnectionService(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/userinitiatedconnection",
+ }
+ elementUnderTest := NewUserInitiatedConnectionServiceWithClient(wsmanMessageCreator, &client)
+ t.Run("amt_UserInitiatedConnectionService Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create a valid AMT_UserInitiatedConnectionService Get wsman message",
+ AMT_UserInitiatedConnectionService,
+ wsmantesting.GET,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Get"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GetResponse: UserResponse{
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_UserInitiatedConnectionService), Local: AMT_UserInitiatedConnectionService},
+ CreationClassName: AMT_UserInitiatedConnectionService,
+ ElementName: "Intel(r) AMT User Initiated Connection Service",
+ EnabledState: 32771,
+ Name: "Intel(r) AMT User Initiated Connection Service",
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "Intel(r) AMT",
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create a valid AMT_UserInitiatedConnectionService Enumerate wsman message",
+ AMT_UserInitiatedConnectionService,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Enumerate"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "D3000000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid AMT_UserInitiatedConnectionService Pull wsman message",
+ AMT_UserInitiatedConnectionService,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Pull"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: message.XMLPullResponseSpace, Local: "PullResponse"},
+ UserItems: []UserResponse{
+ {
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_UserInitiatedConnectionService), Local: AMT_UserInitiatedConnectionService},
+ CreationClassName: AMT_UserInitiatedConnectionService,
+ ElementName: "Intel(r) AMT User Initiated Connection Service",
+ EnabledState: 32771,
+ Name: "Intel(r) AMT User Initiated Connection Service",
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "Intel(r) AMT",
+ },
+ },
+ },
+ },
+ },
+ //REQUEST STATE CHANGE
+ {
+ "should create a valid AMT_UserInitiatedConnectionService RequestStateChange wsman message",
+ AMT_UserInitiatedConnectionService,
+ fmt.Sprintf("%s%s/%s", message.AMTSchema, AMT_UserInitiatedConnectionService, "RequestStateChange"),
+ "32771",
+ func() (Response, error) {
+ client.CurrentMessage = "Request"
+ return elementUnderTest.RequestStateChange(32771)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ RequestStateChange_OUTPUT: RequestStateChange_OUTPUT{
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_UserInitiatedConnectionService), Local: "RequestStateChange_OUTPUT"},
+ ReturnValue: 0,
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.NoError(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.Equal(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
+func TestNegativeAMT_UserInitiatedConnectionService(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/userinitiatedconnection",
+ }
+ elementUnderTest := NewUserInitiatedConnectionServiceWithClient(wsmanMessageCreator, &client)
+ t.Run("amt_UserInitiatedConnectionService Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create a valid AMT_UserInitiatedConnectionService Get wsman message",
+ AMT_UserInitiatedConnectionService,
+ wsmantesting.GET,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GetResponse: UserResponse{
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_UserInitiatedConnectionService), Local: AMT_UserInitiatedConnectionService},
+ CreationClassName: AMT_UserInitiatedConnectionService,
+ ElementName: "Intel(r) AMT User Initiated Connection Service",
+ EnabledState: 32771,
+ Name: "Intel(r) AMT User Initiated Connection Service",
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "Intel(r) AMT",
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create a valid AMT_UserInitiatedConnectionService Enumerate wsman message",
+ AMT_UserInitiatedConnectionService,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "D3000000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid AMT_UserInitiatedConnectionService Pull wsman message",
+ AMT_UserInitiatedConnectionService,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: message.XMLPullResponseSpace, Local: "PullResponse"},
+ UserItems: []UserResponse{
+ {
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_UserInitiatedConnectionService), Local: AMT_UserInitiatedConnectionService},
+ CreationClassName: AMT_UserInitiatedConnectionService,
+ ElementName: "Intel(r) AMT User Initiated Connection Service",
+ EnabledState: 32771,
+ Name: "Intel(r) AMT User Initiated Connection Service",
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "Intel(r) AMT",
+ },
+ },
+ },
+ },
+ },
+ //REQUEST STATE CHANGE
+ {
+ "should create a valid AMT_UserInitiatedConnectionService RequestStateChange wsman message",
+ AMT_UserInitiatedConnectionService,
+ fmt.Sprintf("%s%s/%s", message.AMTSchema, AMT_UserInitiatedConnectionService, "RequestStateChange"),
+ "32771",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.RequestStateChange(32771)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ RequestStateChange_OUTPUT: RequestStateChange_OUTPUT{
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_UserInitiatedConnectionService), Local: "RequestStateChange_OUTPUT"},
+ ReturnValue: 0,
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.Error(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.NotEqual(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
diff --git a/pkg/wsman/amt/userinitiatedconnection/types.go b/pkg/wsman/amt/userinitiatedconnection/types.go
new file mode 100644
index 00000000..82b1eadc
--- /dev/null
+++ b/pkg/wsman/amt/userinitiatedconnection/types.go
@@ -0,0 +1,86 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package userinitiatedconnection
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+)
+
+type Service struct {
+ base message.Base
+}
+
+type RequestedState int
+
+// OUTPUTS
+// Response Types
+type (
+ Response struct {
+ *client.Message
+ XMLName xml.Name `xml:"Envelope"`
+ Header message.Header `xml:"Header"`
+ Body Body `xml:"Body"`
+ }
+ Body struct {
+ XMLName xml.Name `xml:"Body"`
+ RequestStateChange_OUTPUT RequestStateChange_OUTPUT `xml:"RequestStateChange_OUTPUT"`
+ GetResponse UserResponse
+ EnumerateResponse common.EnumerateResponse
+ PullResponse PullResponse
+ }
+ UserResponse struct {
+ XMLName xml.Name `xml:"AMT_UserInitiatedConnectionService"`
+ CreationClassName string `xml:"CreationClassName,omitempty"` // CreationClassName indicates the name of the class or the subclass that is used in the creation of an instance. When used with the other key properties of this class, this property allows all instances of this class and its subclasses to be uniquely identified.
+ ElementName string `xml:"ElementName,omitempty"` // A user-friendly name for the object. This property allows each instance to define a user-friendly name in addition to its key properties, identity data, and description information. Note that the Name property of ManagedSystemElement is also defined as a user-friendly name. But, it is often subclassed to be a Key. It is not reasonable that the same property can convey both identity and a user-friendly name, without inconsistencies. Where Name exists and is not a Key (such as for instances of LogicalDevice), the same information can be present in both the Name and ElementName properties. Note that if there is an associated instance of CIM_EnabledLogicalElementCapabilities, restrictions on this properties may exist as defined in ElementNameMask and MaxElementNameLen properties defined in that class.
+ EnabledState EnabledState `xml:"EnabledState"` // EnabledState is an integer enumeration that indicates the enabled and disabled states of an element.
+ Name string `xml:"Name,omitempty"` // The Name property uniquely identifies the Service and provides an indication of the functionality that is managed. This functionality is described in more detail in the Description property of the object.
+ SystemCreationClassName string `xml:"SystemCreationClassName,omitempty"` // The CreationClassName of the scoping System.
+ SystemName string `xml:"SystemName,omitempty"` // The Name of the scoping System.
+ }
+ PullResponse struct {
+ XMLName xml.Name `xml:"PullResponse"`
+ UserItems []UserResponse `xml:"Items>AMT_UserInitiatedConnectionService"`
+ }
+
+ // The state requested for the element. This information will be placed into the RequestedState property of the instance if the return code of the RequestStateChange method is 0 ('Completed with No Error'), 3 ('Timeout'), or 4096 (0x1000) ('Job Started'). Refer to the description of the EnabledState and RequestedState properties for the detailed explanations of the RequestedState values.
+ //
+ // ValueMap={2, 3, 4, 6, 7, 8, 9, 10, 11, .., 32768, 32769, 32770, 32771, 32772..65535}
+ //
+ // Values={Enabled, Disabled, Shut Down, Offline, Test, Defer, Quiesce, Reboot, Reset, DMTF Reserved, All Interfaces disabled, BIOS Interface enabled, OS Interface enabled, BIOS and OS Interfaces enabled, Vendor Reserved}
+ RequestStateChange_OUTPUT struct {
+ XMLName xml.Name `xml:"RequestStateChange_OUTPUT"`
+ ReturnValue int `xml:"ReturnValue"`
+ }
+ //EnabledState is an integer enumeration that indicates the enabled and disabled states of an element. It can also indicate the transitions between these requested states. For example, shutting down (value=4) and starting (value=10) are transient states between enabled and disabled. The following text briefly summarizes the various enabled and disabled states:
+ // Enabled (2) indicates that the element is or could be executing commands, will process any queued commands, and queues new requests.
+ //
+ // Disabled (3) indicates that the element will not execute commands and will drop any new requests.
+ //
+ // Shutting Down (4) indicates that the element is in the process of going to a Disabled state.
+ //
+ // Not Applicable (5) indicates the element does not support being enabled or disabled.
+ //
+ // Enabled but Offline (6) indicates that the element might be completing commands, and will drop any new requests.
+ //
+ // Test (7) indicates that the element is in a test state.
+ //
+ // Deferred (8) indicates that the element might be completing commands, but will queue any new requests.
+ //
+ // Quiesce (9) indicates that the element is enabled but in a restricted mode. The behavior of the element is similar to the Enabled state, but it processes only a restricted set of commands. All other requests are queued.
+ //
+ // Starting (10) indicates that the element is in the process of going to an Enabled state. New requests are queued.
+ //
+ // The supported values are 32768-32771.
+ //
+ // ValueMap={0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11..32767, 32768, 32769, 32770, 32771, 32772..65535}
+ //
+ // Values={Unknown, Other, Enabled, Disabled, Shutting Down, Not Applicable, Enabled but Offline, In Test, Deferred, Quiesce, Starting, DMTF Reserved, All Interfaces disabled, BIOS Interface enabled, OS Interface enabled, BIOS and OS Interfaces enabled, Vendor Reserved}
+ EnabledState int
+)
diff --git a/pkg/wsman/amt/wifiportconfiguration/constants.go b/pkg/wsman/amt/wifiportconfiguration/constants.go
new file mode 100644
index 00000000..ff9381a6
--- /dev/null
+++ b/pkg/wsman/amt/wifiportconfiguration/constants.go
@@ -0,0 +1,66 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package wifiportconfiguration
+
+const (
+ AMT_WiFiPortConfigurationService string = "AMT_WiFiPortConfigurationService"
+ AddWiFiSettings string = "AddWiFiSettings"
+)
+
+const (
+ LocalSyncDisabled LocalProfileSynchronizationEnabled = 0
+ UnrestrictedSync LocalProfileSynchronizationEnabled = 3
+)
+
+const (
+ RelaxedPolicy NoHostCsmeSoftwarePolicy = iota
+ AggressivePolicy
+ Reserved
+)
+
+const (
+ Disabled UEFIWiFiProfileShareEnabled = iota
+ Enabled
+)
+
+const (
+ HealthStateUnknown HealthState = 0
+ HealthStateOK HealthState = 5
+ HealthStateDegradedWarning HealthState = 10
+ HealthStateMinorFailure HealthState = 15
+ HealthStateMajorFailure HealthState = 20
+ HealthStateCriticalFailure HealthState = 25
+ HealthStateNonRecoverableError HealthState = 30
+)
+
+const (
+ EnabledStateUnknown EnabledState = iota
+ EnabledStateOther
+ EnabledStateEnabled
+ EnabledStateDisabled
+ EnabledStateShuttingDown
+ EnabledStateNotApplicable
+ EnabledStateEnabledbutOffline
+ EnabledStateInTest
+ EnabledStateDeferred
+ EnabledStateQuiesce
+ EnabledStateStarting
+)
+
+const (
+ RequestedStateEnabled RequestedState = iota + 2
+ RequestedStateDisabled
+ RequestedStateShutDown
+ RequestedStateNoChange
+ RequestedStateOffline
+ RequestedStateTest
+ RequestedStateDeferred
+ RequestedStateQuiesce
+ RequestedStateReboot
+ RequestedStateReset
+ RequestedStateNotApplicable
+ RequestedStateUnknown RequestedState = 0
+)
diff --git a/pkg/wsman/amt/wifiportconfiguration/marshal.go b/pkg/wsman/amt/wifiportconfiguration/marshal.go
new file mode 100644
index 00000000..c8d6249d
--- /dev/null
+++ b/pkg/wsman/amt/wifiportconfiguration/marshal.go
@@ -0,0 +1,30 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package wifiportconfiguration
+
+import (
+ "encoding/json"
+
+ "gopkg.in/yaml.v3"
+)
+
+// JSON marshals the type into JSON format
+func (r *Response) JSON() string {
+ jsonOutput, err := json.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(jsonOutput)
+}
+
+// YAML marshals the type into YAML format
+func (r *Response) YAML() string {
+ yamlOutput, err := yaml.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(yamlOutput)
+}
diff --git a/pkg/wsman/amt/wifiportconfiguration/service.go b/pkg/wsman/amt/wifiportconfiguration/service.go
new file mode 100644
index 00000000..52d386bc
--- /dev/null
+++ b/pkg/wsman/amt/wifiportconfiguration/service.go
@@ -0,0 +1,224 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+// Package wifiportconfiguration facilitiates communication with Intel® AMT devices to provides management of the Wi-Fi network interfaces associated with a Wi-Fi network port.
+package wifiportconfiguration
+
+import (
+ "encoding/xml"
+ "errors"
+ "fmt"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/amt/methods"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/models"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/wifi"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+)
+
+// NewWiFiPortConfigurationServiceWithClient instantiates a new Service
+func NewWiFiPortConfigurationServiceWithClient(wsmanMessageCreator *message.WSManMessageCreator, client client.WSMan) Service {
+ return Service{
+ base: message.NewBaseWithClient(wsmanMessageCreator, AMT_WiFiPortConfigurationService, client),
+ }
+}
+
+// Get retrieves the representation of the instance
+func (service Service) Get() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: service.base.Get(nil),
+ },
+ }
+ // send the message to AMT
+ err = service.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Enumerate returns an enumeration context which is used in a subsequent Pull call
+func (service Service) Enumerate() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: service.base.Enumerate(),
+ },
+ }
+ // send the message to AMT
+ err = service.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Pull returns the instances of this class. An enumeration context provided by the Enumerate call is used as input.
+func (service Service) Pull(enumerationContext string) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: service.base.Pull(enumerationContext),
+ },
+ }
+ // send the message to AMT
+ err = service.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Put will change properties of the selected instance
+func (service Service) Put(wiFiPortConfigurationService WiFiPortConfigurationServiceRequest) (response Response, err error) {
+ //wiFiPortConfigurationService.XMLSchema = "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_WiFiPortConfigurationService"
+ wiFiPortConfigurationService.H = fmt.Sprintf("%s%s", message.AMTSchema, AMT_WiFiPortConfigurationService)
+ response = Response{
+ Message: &client.Message{
+ XMLInput: service.base.Put(wiFiPortConfigurationService, false, nil),
+ },
+ }
+ // send the message to AMT
+ err = service.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+
+ if response.Body.WiFiPortConfigurationService.LocalProfileSynchronizationEnabled == 0 {
+ err = errors.New("failed to enable wifi local profile synchronization")
+ }
+ return
+}
+
+// AddWiFiSettings atomically creates an instance of CIM_WifiEndpointSettings from the embedded instance parameter
+// and optionally an instance of CIM_IEEE8021xSettings from the embedded instance parameter (if provided),
+// associates the CIM_WiFiEndpointSettings instance with the referenced instance of CIM_WiFiEndpoint using
+// an instance of CIM_ElementSettingData optionally associates the newly created or referenced by parameter
+// instance of CIM_IEEE8021xSettings with the instance of CIM_WiFiEndpointSettings using an instance of CIM_ConcreteComponent
+// and optionally associates the referenced instance of AMT_PublicKeyCertificate (if provided) with the instance of
+// CIM_IEEE8021xSettings (if provided) using an instance of CIM_CredentialContext.
+//
+// Additional Notes:
+//
+// 1) 'AddWiFiSettings' in Intel AMT Release 6.0 and later releases is permitted only to 'ADMIN_SECURITY_ADMINISTRATION_REALM' and 'ADMIN_SECURITY_LOCAL_SYSTEM_REALM '
+//
+// 2) When selecting the value EAP-TLS or EAP-FAST/TLS in AuthenticationProtocol property in IEEE8021xSettings - ClientCredential is mandatory.
+//
+// ValueMap={0, 1, 2, 3, 4, .., 32768..65535}
+//
+// Values={Completed with No Error, Not Supported, Failed, Invalid Parameter, Invalid Reference, Method Reserved, Vendor Specific}
+func (service Service) AddWiFiSettings(wifiEndpointSettings wifi.WiFiEndpointSettingsRequest, ieee8021xSettingsInput models.IEEE8021xSettings, wifiEndpoint, clientCredential, caCredential string) (response Response, err error) {
+ header := service.base.WSManMessageCreator.CreateHeader(methods.GenerateAction(AMT_WiFiPortConfigurationService, AddWiFiSettings), AMT_WiFiPortConfigurationService, nil, "", "")
+ input := AddWiFiSettings_INPUT{
+ WifiEndpoint: WiFiEndpoint{
+ Address: "/wsman",
+ ReferenceParameters: ReferenceParameters{
+ H: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd",
+ ResourceURI: fmt.Sprintf("%s%s", message.CIMSchema, wifi.CIM_WiFiEndpoint),
+ SelectorSet: SelectorSet{
+ H: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd",
+ Selector: []Selector{
+ {
+ H: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd",
+ Name: "Name",
+ Value: wifiEndpoint,
+ },
+ },
+ },
+ },
+ },
+ WiFiEndpointSettings: wifiEndpointSettings,
+ }
+ input.WiFiEndpointSettings.H = "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_WiFiEndpointSettings"
+ if wifiEndpointSettings.AuthenticationMethod == wifi.AuthenticationMethod_WPA_IEEE8021x ||
+ wifiEndpointSettings.AuthenticationMethod == wifi.AuthenticationMethod_WPA2_IEEE8021x {
+ input.IEEE8021xSettings = ieee8021xSettingsInput
+ input.IEEE8021xSettings.H = "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_IEEE8021xSettings"
+ input.CACredential = &CACredentialRequest{
+ H: "http://schemas.xmlsoap.org/ws/2004/08/addressing",
+ Address: "default",
+ ReferenceParameters: ReferenceParameters{
+ H: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd",
+ ResourceURI: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyCertificate",
+ SelectorSet: SelectorSet{
+ H: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd",
+ Selector: []Selector{
+ {
+ H: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd",
+ Name: "InstanceID",
+ Value: caCredential,
+ },
+ },
+ },
+ },
+ }
+ if clientCredential != "" {
+ input.ClientCredential = &ClientCredentialRequest{
+ H: "http://schemas.xmlsoap.org/ws/2004/08/addressing",
+ Address: "default",
+ ReferenceParameters: ReferenceParameters{
+ H: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd",
+ ResourceURI: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyCertificate",
+ SelectorSet: SelectorSet{
+ H: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd",
+ Selector: []Selector{
+ {
+ H: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd",
+ Name: "InstanceID",
+ Value: clientCredential,
+ },
+ },
+ },
+ },
+ }
+ }
+ }
+
+ body := service.base.WSManMessageCreator.CreateBody(methods.GenerateInputMethod(AddWiFiSettings), AMT_WiFiPortConfigurationService, &input)
+ response = Response{
+ Message: &client.Message{
+ XMLInput: service.base.WSManMessageCreator.CreateXML(header, body),
+ },
+ }
+ // send the message to AMT
+ err = service.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ if response.Body.AddWiFiSettings_OUTPUT.ReturnValue != 0 {
+ err = fmt.Errorf("AddWiFiSettings_OUTPUT.ReturnValue: %d", response.Body.AddWiFiSettings_OUTPUT.ReturnValue)
+ }
+
+ return
+}
+
+// TODO: Add UpdateWiFiSettings
+// TODO: Add DeleteAllITProfiles
+// TODO: Add DeleteAllUserProfiles
+// TODO: Add SetApplicationRequestedRfKill
diff --git a/pkg/wsman/amt/wifiportconfiguration/service_test.go b/pkg/wsman/amt/wifiportconfiguration/service_test.go
new file mode 100644
index 00000000..60ee336a
--- /dev/null
+++ b/pkg/wsman/amt/wifiportconfiguration/service_test.go
@@ -0,0 +1,192 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package wifiportconfiguration
+
+import (
+ "encoding/xml"
+ "fmt"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
+)
+
+func TestPositiveAMT_WiFiPortConfigurationService(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://intel.com/wbem/wscim/1/amt-schema/1/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "amt/wifiportconfiguration",
+ }
+ elementUnderTest := NewWiFiPortConfigurationServiceWithClient(wsmanMessageCreator, &client)
+
+ t.Run("amt_WiFiPortConfigurationService Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ extraHeader string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create a valid AMT_WiFiPortConfigurationService Get wsman message",
+ AMT_WiFiPortConfigurationService,
+ wsmantesting.GET,
+ "",
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Get"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ WiFiPortConfigurationService: WiFiPortConfigurationServiceResponse{
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_WiFiPortConfigurationService), Local: AMT_WiFiPortConfigurationService},
+ CreationClassName: "AMT_WiFiPortConfigurationService",
+ ElementName: "Intel(r) AMT WiFiPort Configuration Service",
+ EnabledState: 5,
+ HealthState: 5,
+ LastConnectedSsidUnderMeControl: "",
+ Name: "Intel(r) AMT WiFi Port Configuration Service",
+ NoHostCsmeSoftwarePolicy: 0,
+ RequestedState: 12,
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "Intel(r) AMT",
+ LocalProfileSynchronizationEnabled: 1,
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create a valid AMT_WiFiPortConfigurationService Enumerate wsman message",
+ AMT_WiFiPortConfigurationService,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Enumerate"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "71080000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid AMT_WiFiPortConfigurationService Pull wsman message",
+ AMT_WiFiPortConfigurationService,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Pull"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: message.XMLPullResponseSpace, Local: "PullResponse"},
+ WiFiPortConfigurationItems: []WiFiPortConfigurationServiceResponse{
+ {
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_WiFiPortConfigurationService), Local: AMT_WiFiPortConfigurationService},
+ CreationClassName: "AMT_WiFiPortConfigurationService",
+ ElementName: "Intel(r) AMT WiFiPort Configuration Service",
+ EnabledState: 5,
+ HealthState: 5,
+ LastConnectedSsidUnderMeControl: "",
+ Name: "Intel(r) AMT WiFi Port Configuration Service",
+ NoHostCsmeSoftwarePolicy: 0,
+ RequestedState: 12,
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "Intel(r) AMT",
+ LocalProfileSynchronizationEnabled: 1,
+ },
+ },
+ },
+ },
+ },
+ // PUTS
+ {
+ "should create a valid AMT_WiFiPortConfigurationService Put wsman message",
+ AMT_WiFiPortConfigurationService,
+ wsmantesting.PUT,
+ "1255Intel(r) AMT WiFiPort Configuration ServiceCIM_ComputerSystemIntel(r) AMTAMT_WiFiPortConfigurationServiceIntel(r) AMT WiFi Port Configuration Service1",
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Put"
+ wifiConfiguration := WiFiPortConfigurationServiceRequest{
+ RequestedState: 12,
+ EnabledState: 5,
+ HealthState: 5,
+ ElementName: "Intel(r) AMT WiFiPort Configuration Service",
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "Intel(r) AMT",
+ CreationClassName: "AMT_WiFiPortConfigurationService",
+ Name: "Intel(r) AMT WiFi Port Configuration Service",
+ LocalProfileSynchronizationEnabled: 1,
+ LastConnectedSsidUnderMeControl: "",
+ NoHostCsmeSoftwarePolicy: 0,
+ }
+ return elementUnderTest.Put(wifiConfiguration)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ WiFiPortConfigurationService: WiFiPortConfigurationServiceResponse{
+ XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.AMTSchema, AMT_WiFiPortConfigurationService), Local: AMT_WiFiPortConfigurationService},
+ CreationClassName: "AMT_WiFiPortConfigurationService",
+ ElementName: "Intel(r) AMT WiFiPort Configuration Service",
+ EnabledState: 5,
+ HealthState: 5,
+ LastConnectedSsidUnderMeControl: "",
+ Name: "Intel(r) AMT WiFi Port Configuration Service",
+ NoHostCsmeSoftwarePolicy: 0,
+ RequestedState: 12,
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "Intel(r) AMT",
+ LocalProfileSynchronizationEnabled: 1,
+ },
+ },
+ },
+ // WIFI PORT CONFIGURATION SERVICE
+ // {
+ // "should return a valid amt_WiFiPortConfigurationService ADD_WIFI_SETTINGS wsman message",
+ // AMT_WiFiPortConfigurationService,
+ // `http://intel.com/wbem/wscim/1/amt-schema/1/AMT_WiFiPortConfigurationService/AddWiFiSettings`, `/wsmanhttp://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_WiFiEndpointWiFi Endpoint 0homeIntel(r) AMT:WiFi Endpoint Settings home64admin1p'ass<>&"code`,
+ // "",
+ // func() (Response, error) {
+ // client.CurrentMessage = "AddWiFiSettings"
+ // wifiEndpointSettings := wifi.WiFiEndpointSettings_INPUT{}
+ // ieee8021xSettings := &models.IEEE8021xSettings{}
+ // wifiEndpoint := "t"
+ // clientCredential := "t"
+ // caCredential := "t"
+ // return elementUnderTest.AddWiFiSettings(wifiEndpointSettings, ieee8021xSettings, wifiEndpoint, clientCredential, caCredential)
+ // },
+ // Body{},
+ // },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, test.extraHeader, test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.NoError(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.Equal(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
diff --git a/pkg/wsman/amt/wifiportconfiguration/types.go b/pkg/wsman/amt/wifiportconfiguration/types.go
new file mode 100644
index 00000000..644b6bd8
--- /dev/null
+++ b/pkg/wsman/amt/wifiportconfiguration/types.go
@@ -0,0 +1,240 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package wifiportconfiguration
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/models"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/wifi"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+)
+
+type Service struct {
+ base message.Base
+}
+
+// OUTPUT
+// Response Types
+type (
+ Response struct {
+ *client.Message
+ XMLName xml.Name `xml:"Envelope"`
+ Header message.Header `xml:"Header"`
+ Body Body
+ }
+
+ Body struct {
+ XMLName xml.Name `xml:"Body"`
+ WiFiPortConfigurationService WiFiPortConfigurationServiceResponse
+ PullResponse PullResponse
+ EnumerateResponse common.EnumerateResponse
+ AddWiFiSettings_OUTPUT AddWiFiSettings_OUTPUT
+ }
+ WiFiPortConfigurationServiceResponse struct {
+ XMLName xml.Name `xml:"AMT_WiFiPortConfigurationService"`
+ RequestedState RequestedState `xml:"RequestedState"` // RequestedState is an integer enumeration that indicates the last requested or desired state for the element, irrespective of the mechanism through which it was requested.
+ EnabledState EnabledState `xml:"EnabledState"` // EnabledState is an integer enumeration that indicates the enabled and disabled states of an element.
+ HealthState HealthState `xml:"HealthState"` // Indicates the current health of the element.
+ ElementName string `xml:"ElementName,omitempty"` // A user-friendly name for the object. This property allows each instance to define a user-friendly name in addition to its key properties, identity data, and description information. Note that the Name property of ManagedSystemElement is also defined as a user-friendly name. But, it is often subclassed to be a Key. It is not reasonable that the same property can convey both identity and a user-friendly name, without inconsistencies. Where Name exists and is not a Key (such as for instances of LogicalDevice), the same information can be present in both the Name and ElementName properties. Note that if there is an associated instance of CIM_EnabledLogicalElementCapabilities, restrictions on this properties may exist as defined in ElementNameMask and MaxElementNameLen properties defined in that class.
+ SystemCreationClassName string `xml:"SystemCreationClassName,omitempty"` // The CreationClassName of the scoping System.
+ SystemName string `xml:"SystemName,omitempty"` // The Name of the scoping System.
+ CreationClassName string `xml:"CreationClassName,omitempty"` // CreationClassName indicates the name of the class or the subclass that is used in the creation of an instance. When used with the other key properties of this class, this property allows all instances of this class and its subclasses to be uniquely identified.
+ Name string `xml:"Name,omitempty"` // The Name property uniquely identifies the Service and provides an indication of the functionality that is managed. This functionality is described in more detail in the Description property of the object.
+ LocalProfileSynchronizationEnabled LocalProfileSynchronizationEnabled `xml:"localProfileSynchronizationEnabled"` // Administrator's policy regarding enablement of local profile synchronization.Remote profile synchronization is always enabled.
+ LastConnectedSsidUnderMeControl string `xml:"LastConnectedSsidUnderMeControl,omitempty"` // The SSID of the Wireless network that was last connected in ME Control state
+ NoHostCsmeSoftwarePolicy NoHostCsmeSoftwarePolicy `xml:"NoHostCsmeSoftwarePolicy"` // Setting Policy regarding no HOST CSME software.
+ UEFIWiFiProfileShareEnabled UEFIWiFiProfileShareEnabled `xml:"UEFIWiFiProfileShareEnabled"` // Enables or disables UEFI/CSME Wi-Fi Profile Sharing.
+ }
+ PullResponse struct {
+ XMLName xml.Name `xml:"PullResponse"`
+ WiFiPortConfigurationItems []WiFiPortConfigurationServiceResponse `xml:"Items>AMT_WiFiPortConfigurationService"`
+ }
+
+ // ValueMap={0, 1, 2, 3, 4, .., 32768..65535}
+ //
+ // Values={Completed with No Error, Not Supported, Failed, Invalid Parameter, Invalid Reference, Method Reserved, Vendor Specific}
+ AddWiFiSettings_OUTPUT struct {
+ XMLName xml.Name `xml:"AddWiFiSettings_OUTPUT"`
+ // not concerned with these entries on OUTPUT
+ //IEEE8021xSettings *models.IEEE8021xSettings `xml:"g:IEEE8021xSettingsInput,omitempty"`
+ //ClientCredential *ClientCredential `xml:"g:ClientCredential,omitempty"`
+ //CACredential *CACredential `xml:"g:CACredential,omitempty"`
+ ReturnValue int `xml:"ReturnValue"`
+ }
+)
+
+type (
+ // Administrator's policy regarding enablement of local profile synchronization.Remote profile synchronization is always enabled.
+ //
+ // 1) 'localProfileSynchronizationEnabled' is only supported in Intel AMT Release 6.0 and later releases.
+ //
+ // ValueMap={0, 1, 2, 3, 4..}
+ //
+ // Values={Local synchronization disabled, Local user profile synchronization enabled, Vendor Reserved, Unrestricted synchronization, Reserved}
+ LocalProfileSynchronizationEnabled int
+ // Setting Policy regarding no HOST CSME software.
+ //
+ // ValueMap={0, 1, 2}
+ //
+ // Values={NoHostCsmeSoftwareRelaxedPolicy, NoHostCsmeSoftwareAggressivePolicy, Reserved}
+ NoHostCsmeSoftwarePolicy int
+ // Enables or disables UEFI/CSME Wi-Fi Profile Sharing.
+ //
+ // The feature is available from Intel® CSME 16.0.
+ //
+ // The feature can be disabled even if the value of AMT_BootCapabilities.UEFIWiFiCoExistenceAndProfileShare is False.
+ //
+ // Valid Values:
+ //
+ // 1: Enable
+ //
+ // 0: Disable
+ UEFIWiFiProfileShareEnabled int
+ // RequestedState is an integer enumeration that indicates the last requested or desired state for the element, irrespective of the mechanism through which it was requested. The actual state of the element is represented by EnabledState. This property is provided to compare the last requested and current enabled or disabled states. Note that when EnabledState is set to 5 ("Not Applicable"), then this property has no meaning. Refer to the EnabledState property description for explanations of the values in the RequestedState enumeration.
+ //
+ // "Unknown" (0) indicates the last requested state for the element is unknown.
+ //
+ // Note that the value "No Change" (5) has been deprecated in lieu of indicating the last requested state is "Unknown" (0). If the last requested or desired state is unknown, RequestedState should have the value "Unknown" (0), but may have the value "No Change" (5).Offline (6) indicates that the element has been requested to transition to the Enabled but Offline EnabledState.
+ //
+ // It should be noted that there are two new values in RequestedState that build on the statuses of EnabledState. These are "Reboot" (10) and "Reset" (11). Reboot refers to doing a "Shut Down" and then moving to an "Enabled" state. Reset indicates that the element is first "Disabled" and then "Enabled". The distinction between requesting "Shut Down" and "Disabled" should also be noted. Shut Down requests an orderly transition to the Disabled state, and might involve removing power, to completely erase any existing state. The Disabled state requests an immediate disabling of the element, such that it will not execute or accept any commands or processing requests.
+ //
+ // This property is set as the result of a method invocation (such as Start or StopService on CIM_Service), or can be overridden and defined as WRITEable in a subclass. The method approach is considered superior to a WRITEable property, because it allows an explicit invocation of the operation and the return of a result code.
+ //
+ // If knowledge of the last RequestedState is not supported for the EnabledLogicalElement, the property shall be NULL or have the value 12 "Not Applicable".
+ //
+ // ValueMap={0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, .., 32768..65535}
+ //
+ // Values={Unknown, Enabled, Disabled, Shut Down, No Change, Offline, Test, Deferred, Quiesce, Reboot, Reset, Not Applicable, DMTF Reserved, Vendor Reserved}
+ RequestedState int
+ // EnabledState is an integer enumeration that indicates the enabled and disabled states of an element. It can also indicate the transitions between these requested states. For example, shutting down (value=4) and starting (value=10) are transient states between enabled and disabled. The following text briefly summarizes the various enabled and disabled states:
+ //
+ // Enabled (2) indicates that the element is or could be executing commands, will process any queued commands, and queues new requests.
+ //
+ // Disabled (3) indicates that the element will not execute commands and will drop any new requests.
+ //
+ // Shutting Down (4) indicates that the element is in the process of going to a Disabled state.
+ //
+ // Not Applicable (5) indicates the element does not support being enabled or disabled.
+ //
+ // Enabled but Offline (6) indicates that the element might be completing commands, and will drop any new requests.
+ //
+ // Test (7) indicates that the element is in a test state.
+ //
+ // Deferred (8) indicates that the element might be completing commands, but will queue any new requests.
+ //
+ // Quiesce (9) indicates that the element is enabled but in a restricted mode.
+ //
+ // Starting (10) indicates that the element is in the process of going to an Enabled state. New requests are queued.
+ //
+ // ValueMap={0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11..32767, 32768..65535}
+ //
+ // Values={Unknown, Other, Enabled, Disabled, Shutting Down, Not Applicable, Enabled but Offline, In Test, Deferred, Quiesce, Starting, DMTF Reserved, Vendor Reserved}
+ EnabledState int
+ // Indicates the current health of the element. This attribute expresses the health of this element but not necessarily that of its subcomponents. The possible values are 0 to 30, where 5 means the element is entirely healthy and 30 means the element is completely non-functional. The following continuum is defined:
+ //
+ // "Non-recoverable Error" (30) - The element has completely failed, and recovery is not possible. All functionality provided by this element has been lost.
+ //
+ // "Critical Failure" (25) - The element is non-functional and recovery might not be possible.
+ //
+ // "Major Failure" (20) - The element is failing. It is possible that some or all of the functionality of this component is degraded or not working.
+ //
+ // "Minor Failure" (15) - All functionality is available but some might be degraded.
+ //
+ // "Degraded/Warning" (10) - The element is in working order and all functionality is provided. However, the element is not working to the best of its abilities. For example, the element might not be operating at optimal performance or it might be reporting recoverable errors.
+ //
+ // "OK" (5) - The element is fully functional and is operating within normal operational parameters and without error.
+ //
+ // "Unknown" (0) - The implementation cannot report on HealthState at this time.
+ //
+ // DMTF has reserved the unused portion of the continuum for additional HealthStates in the future.
+ //
+ // ValueMap={0, 5, 10, 15, 20, 25, 30, .., 32768..65535}
+ //
+ // Values={Unknown, OK, Degraded/Warning, Minor failure, Major failure, Critical failure, Non-recoverable error, DMTF Reserved, Vendor Specific}
+ HealthState int
+)
+
+// INPUT
+// Request Types
+type (
+ AddWiFiSettings_INPUT struct {
+ XMLName xml.Name `xml:"h:AddWiFiSettings_INPUT"`
+ H string `xml:"xmlns:h,attr"`
+ WifiEndpoint WiFiEndpoint
+ WiFiEndpointSettings wifi.WiFiEndpointSettingsRequest
+ IEEE8021xSettings models.IEEE8021xSettings `xml:"h:IEEE8021xSettingsInput,omitempty"`
+ ClientCredential *ClientCredentialRequest `xml:"h:ClientCredential,omitempty"`
+ CACredential *CACredentialRequest `xml:"h:CACredential,omitempty"`
+ }
+ WiFiPortConfigurationServiceRequest struct {
+ XMLName xml.Name `xml:"h:AMT_WiFiPortConfigurationService"`
+ H string `xml:"xmlns:h,attr"`
+ RequestedState RequestedState `xml:"h:RequestedState,omitempty"` // RequestedState is an integer enumeration that indicates the last requested or desired state for the element, irrespective of the mechanism through which it was requested.
+ EnabledState EnabledState `xml:"h:EnabledState,omitempty"` // EnabledState is an integer enumeration that indicates the enabled and disabled states of an element.
+ HealthState HealthState `xml:"h:HealthState,omitempty"` // Indicates the current health of the element.
+ ElementName string `xml:"h:ElementName,omitempty"` // A user-friendly name for the object. This property allows each instance to define a user-friendly name in addition to its key properties, identity data, and description information. Note that the Name property of ManagedSystemElement is also defined as a user-friendly name. But, it is often subclassed to be a Key. It is not reasonable that the same property can convey both identity and a user-friendly name, without inconsistencies. Where Name exists and is not a Key (such as for instances of LogicalDevice), the same information can be present in both the Name and ElementName properties. Note that if there is an associated instance of CIM_EnabledLogicalElementCapabilities, restrictions on this properties may exist as defined in ElementNameMask and MaxElementNameLen properties defined in that class.
+ SystemCreationClassName string `xml:"h:SystemCreationClassName,omitempty"` // The CreationClassName of the scoping System.
+ SystemName string `xml:"h:SystemName,omitempty"` // The Name of the scoping System.
+ CreationClassName string `xml:"h:CreationClassName,omitempty"` // CreationClassName indicates the name of the class or the subclass that is used in the creation of an instance. When used with the other key properties of this class, this property allows all instances of this class and its subclasses to be uniquely identified.
+ Name string `xml:"h:Name,omitempty"` // The Name property uniquely identifies the Service and provides an indication of the functionality that is managed. This functionality is described in more detail in the Description property of the object.
+ LocalProfileSynchronizationEnabled LocalProfileSynchronizationEnabled `xml:"h:localProfileSynchronizationEnabled"` // Administrator's policy regarding enablement of local profile synchronization.Remote profile synchronization is always enabled.
+ LastConnectedSsidUnderMeControl string `xml:"h:LastConnectedSsidUnderMeControl,omitempty"` // The SSID of the Wireless network that was last connected in ME Control state
+ NoHostCsmeSoftwarePolicy NoHostCsmeSoftwarePolicy `xml:"h:NoHostCsmeSoftwarePolicy,omitempty"` // Setting Policy regarding no HOST CSME software.
+ UEFIWiFiProfileShareEnabled UEFIWiFiProfileShareEnabled `xml:"h:UEFIWiFiProfileShareEnabled,omitempty"` // Enables or disables UEFI/CSME Wi-Fi Profile Sharing.
+ }
+
+ // a Reference to an AMT_PublicKeyCertificate, which represents the CA certificate
+ CACredentialRequest struct {
+ XMLName xml.Name `xml:"h:CACredential,omitempty"`
+ H string `xml:"xmlns:a,attr"`
+ Address string `xml:"a:Address,omitempty"`
+ ReferenceParameters ReferenceParameters `xml:"a:ReferenceParameters,omitempty"`
+ }
+
+ // a Reference to an AMT_PublicKeyCertificate, which represents the client certificate
+ ClientCredentialRequest struct {
+ XMLName xml.Name `xml:"h:ClientCredential,omitempty"`
+ H string `xml:"xmlns:a,attr"`
+ Address string `xml:"a:Address,omitempty"`
+ ReferenceParameters ReferenceParameters `xml:"a:ReferenceParameters,omitempty"`
+ }
+
+ ReferenceParameters struct {
+ XMLName xml.Name `xml:"a:ReferenceParameters"`
+ H string `xml:"xmlns:c,attr"`
+ ResourceURI string `xml:"c:ResourceURI,omitempty"`
+ SelectorSet SelectorSet `xml:"c:SelectorSet,omitempty"`
+ }
+
+ SelectorSet struct {
+ H string `xml:"xmlns:c,attr"`
+ XMLName xml.Name `xml:"c:SelectorSet,omitempty"`
+ Selector []Selector
+ }
+
+ Selector struct {
+ H string `xml:"xmlns:c,attr"`
+ XMLName xml.Name `xml:"c:Selector,omitempty"`
+ Name string `xml:"Name,attr"`
+ Value string `xml:",chardata"`
+ }
+)
+
+// The endpoint to associate the new settings with
+type WiFiEndpoint struct {
+ XMLName xml.Name `xml:"h:WiFiEndpoint,omitempty"`
+ Address string `xml:"a:Address,omitempty"`
+ ReferenceParameters ReferenceParameters `xml:"a:ReferenceParameters,omitempty"`
+}
+
+// A reference to a new CIM_WiFiEndpointSettings instance that shall be created by the method using the property values in WiFiEndpointSettingsInput.
+type AddWiFiSettingsResponse struct {
+ XMLName xml.Name `xml:"Body"`
+ AddWiFiSettings_OUTPUT AddWiFiSettings_OUTPUT
+}
diff --git a/pkg/cim/actions/constants.go b/pkg/wsman/cim/actions/constants.go
similarity index 86%
rename from pkg/cim/actions/constants.go
rename to pkg/wsman/cim/actions/constants.go
index 9c950230..13a2bb03 100644
--- a/pkg/cim/actions/constants.go
+++ b/pkg/wsman/cim/actions/constants.go
@@ -3,10 +3,9 @@
* SPDX-License-Identifier: Apache-2.0
**********************************************************************/
+// Package actions holds generic action constants for various AMT commands
package actions
-import "fmt"
-
type Actions string
const (
@@ -15,11 +14,8 @@ const (
Get Actions = "http://schemas.xmlsoap.org/ws/2004/09/transfer/Get"
Put Actions = "http://schemas.xmlsoap.org/ws/2004/09/transfer/Put"
Delete Actions = "http://schemas.xmlsoap.org/ws/2004/09/transfer/Delete"
+ Create Actions = "http://schemas.xmlsoap.org/ws/2004/09/transfer/Create"
SetBootConfigRole Actions = "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_BootService/SetBootConfigRole"
ChangeBootOrder Actions = "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_BootConfigSetting/ChangeBootOrder"
RequestPowerStateChange Actions = "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_PowerManagementService/RequestPowerStateChange"
)
-
-func RequestStateChange(className string) string {
- return fmt.Sprintf("http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/%s/RequestStateChange", className)
-}
diff --git a/pkg/wsman/cim/bios/constants.go b/pkg/wsman/cim/bios/constants.go
new file mode 100644
index 00000000..b033c385
--- /dev/null
+++ b/pkg/wsman/cim/bios/constants.go
@@ -0,0 +1,157 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package bios
+
+const (
+ CIM_BIOSElement string = "CIM_BIOSElement"
+)
+
+const (
+ Unknown TargetOperatingSystem = iota
+ Other
+ MACOS
+ ATTUNIX
+ DGUX
+ DECNT
+ Tru64UNIX
+ OpenVMS
+ HPUX
+ AIX
+ MVS
+ OS400
+ OS2
+ JavaVM
+ MSDOS
+ WIN3x
+ WIN95
+ WIN98
+ WINNT
+ WINCE
+ NCR3000
+ NetWare
+ OSF
+ DCOS
+ ReliantUNIX
+ SCOUnixWare
+ SCOOpenServer
+ Sequent
+ IRIX
+ Solaris
+ SunOS
+ U6000
+ ASERIES
+ HPNonStopOS
+ HPNonStopOSS
+ BS2000
+ LINUX
+ Lynx
+ XENIX
+ VM
+ InteractiveUNIX
+ BSDUNIX
+ FreeBSD
+ NetBSD
+ GNUHurd
+ OS9
+ MACHKernel
+ Inferno
+ QNX
+ EPOC
+ IxWorks
+ VxWorks
+ MiNT
+ BeOS
+ HPMPE
+ NextStep
+ PalmPilot
+ Rhapsody
+ Windows2000
+ Dedicated
+ OS390
+ VSE
+ TPF
+ WindowsMe
+ CalderaOpenUNIX
+ OpenBSD
+ NotApplicable
+ WindowsXP
+ ZOS
+ MicrosoftWindowsServer2003
+ MicrosoftWindowsServer200364Bit
+ WindowsXP64Bit
+ WindowsXPEmbedded
+ WindowsVista
+ WindowsVista64Bit
+ WindowsEmbeddedforPointofService
+ MicrosoftWindowsServer2008
+ MicrosoftWindowsServer200864Bit
+ FreeBSD64Bit
+ RedHatEnterpriseLinux
+ RedHatEnterpriseLinux64Bit
+ Solaris64Bit
+ SUSE
+ SUSE64Bit
+ SLES
+ SLES64Bit
+ NovellOES
+ NovellLinuxDesktop
+ SunJavaDesktopSystem
+ Mandriva
+ Mandriva64Bit
+ TurboLinux
+ TurboLinux64Bit
+ Ubuntu
+ Ubuntu64Bit
+ Debian
+ Debian64Bit
+ Linux24x
+ Linux24x64Bit
+ Linux26x
+ Linux26x64Bit
+ Linux64Bit
+ Other64Bit
+ MicrosoftWindowsServer2008R2
+ VMwareESXi
+ MicrosoftWindows7
+ CentOS32bit
+ CentOS64bit
+ OracleEnterpriseLinux32bit
+ OracleEnterpriseLinux64bit
+ EComStation32bitx
+ MicrosoftWindowsServer2011
+ MicrosoftWindowsServer201164Bit
+ MicrosoftWindowsServer8
+)
+
+const (
+ Deployable SoftwareElementState = iota
+ Installable
+ Executable
+ Running
+)
+
+const (
+ OperationalStatusUnknown OperationalStatus = iota
+ OperationalStatusOther
+ OperationalStatusOK
+ OperationalStatusDegraded
+ OperationalStatusStressed
+ OperationalStatusPredictiveFailure
+ OperationalStatusError
+ OperationalStatusNonRecoverableError
+ OperationalStatusStarting
+ OperationalStatusStopping
+ OperationalStatusStopped
+ OperationalStatusInService
+ OperationalStatusNoContact
+ OperationalStatusLostCommunication
+ OperationalStatusAborted
+ OperationalStatusDormant
+ OperationalStatusSupportingEntityinError
+ OperationalStatusCompleted
+ OperationalStatusPowerMode
+ OperationalStatusRelocating
+)
diff --git a/pkg/wsman/cim/bios/element.go b/pkg/wsman/cim/bios/element.go
new file mode 100644
index 00000000..46b449bc
--- /dev/null
+++ b/pkg/wsman/cim/bios/element.go
@@ -0,0 +1,79 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+// Package bios facilitiates communication with Intel® AMT devices to get information about the device bios element
+package bios
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+)
+
+// NewBIOSElementWithClient instantiates a new Element
+func NewBIOSElementWithClient(wsmanMessageCreator *message.WSManMessageCreator, client client.WSMan) Element {
+ return Element{
+ base: message.NewBaseWithClient(wsmanMessageCreator, CIM_BIOSElement, client),
+ }
+}
+
+// Get retrieves the representation of the instance
+func (element Element) Get() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: element.base.Get(nil),
+ },
+ }
+
+ err = element.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Enumerate returns an enumeration context which is used in a subsequent Pull call
+func (element Element) Enumerate() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: element.base.Enumerate(),
+ },
+ }
+
+ err = element.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Pull returns the instances of this class. An enumeration context provided by the Enumerate call is used as input.
+func (element Element) Pull(enumerationContext string) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: element.base.Pull(enumerationContext),
+ },
+ }
+ err = element.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
diff --git a/pkg/wsman/cim/bios/element_test.go b/pkg/wsman/cim/bios/element_test.go
new file mode 100644
index 00000000..786b855f
--- /dev/null
+++ b/pkg/wsman/cim/bios/element_test.go
@@ -0,0 +1,235 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package bios
+
+import (
+ "encoding/xml"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
+)
+
+func TestPositiveCIMBIOSElement(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "cim/bios/element",
+ }
+ elementUnderTest := NewBIOSElementWithClient(wsmanMessageCreator, &client)
+
+ t.Run("cim_BIOSElement Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create and parse a valid cim_BIOSElement Get call",
+ CIM_BIOSElement,
+ wsmantesting.GET,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Get"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GetResponse: BiosElement{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_BIOSElement", Local: CIM_BIOSElement},
+ TargetOperatingSystem: 66,
+ SoftwareElementID: "QNCFLX70.0054.2020.0810.2227",
+ SoftwareElementState: 2,
+ Name: "Primary BIOS",
+ OperationalStatus: 0,
+ ElementName: "Primary BIOS",
+ Version: "QNCFLX70.0054.2020.0810.2227",
+ Manufacturer: "Intel Corp.",
+ PrimaryBIOS: true,
+ ReleaseDate: Time{DateTime: "2020-08-10T00:00:00Z"},
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create and parse a valid cim_BIOSElement Enumerate call",
+ CIM_BIOSElement,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Enumerate"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "C4020000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create and parse a valid cim_BIOSElement Pull call",
+ CIM_BIOSElement,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Pull"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ BiosElementItems: []BiosElement{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_BIOSElement", Local: CIM_BIOSElement},
+ TargetOperatingSystem: 66,
+ SoftwareElementID: "QNCFLX70.0054.2020.0810.2227",
+ SoftwareElementState: 2,
+ Name: "Primary BIOS",
+ OperationalStatus: 0,
+ ElementName: "Primary BIOS",
+ Version: "QNCFLX70.0054.2020.0810.2227",
+ Manufacturer: "Intel Corp.",
+ PrimaryBIOS: true,
+ ReleaseDate: Time{DateTime: "2020-08-10T00:00:00Z"},
+ },
+ },
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.NoError(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.Equal(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
+
+func TestNegativeCIMBIOSElement(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "cim/bios/element",
+ }
+ elementUnderTest := NewBIOSElementWithClient(wsmanMessageCreator, &client)
+
+ t.Run("cim_BIOSElement Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create and parse a valid cim_BIOSElement Get call",
+ CIM_BIOSElement,
+ wsmantesting.GET,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GetResponse: BiosElement{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_BIOSElement", Local: CIM_BIOSElement},
+ TargetOperatingSystem: 66,
+ SoftwareElementID: "QNCFLX70.0054.2020.0810.2227",
+ SoftwareElementState: 2,
+ Name: "Primary BIOS",
+ OperationalStatus: 0,
+ ElementName: "Primary BIOS",
+ Version: "QNCFLX70.0054.2020.0810.2227",
+ Manufacturer: "Intel Corp.",
+ PrimaryBIOS: true,
+ ReleaseDate: Time{DateTime: "2020-08-10T00:00:00Z"},
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create and parse a valid cim_BIOSElement Enumerate call",
+ CIM_BIOSElement,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "C4020000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create and parse a valid cim_BIOSElement Pull call",
+ CIM_BIOSElement,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ BiosElementItems: []BiosElement{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_BIOSElement", Local: CIM_BIOSElement},
+ TargetOperatingSystem: 66,
+ SoftwareElementID: "QNCFLX70.0054.2020.0810.2227",
+ SoftwareElementState: 2,
+ Name: "Primary BIOS",
+ OperationalStatus: 0,
+ ElementName: "Primary BIOS",
+ Version: "QNCFLX70.0054.2020.0810.2227",
+ Manufacturer: "Intel Corp.",
+ PrimaryBIOS: true,
+ ReleaseDate: Time{DateTime: "2020-08-10T00:00:00Z"},
+ },
+ },
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.Error(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.NotEqual(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
diff --git a/pkg/wsman/cim/bios/marshal.go b/pkg/wsman/cim/bios/marshal.go
new file mode 100644
index 00000000..76284f41
--- /dev/null
+++ b/pkg/wsman/cim/bios/marshal.go
@@ -0,0 +1,30 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package bios
+
+import (
+ "encoding/json"
+
+ "gopkg.in/yaml.v3"
+)
+
+// JSON marshals the type into JSON format
+func (r *Response) JSON() string {
+ jsonOutput, err := json.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(jsonOutput)
+}
+
+// YAML marshals the type into YAML format
+func (r *Response) YAML() string {
+ yamlOutput, err := yaml.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(yamlOutput)
+}
diff --git a/pkg/wsman/cim/bios/types.go b/pkg/wsman/cim/bios/types.go
new file mode 100644
index 00000000..6022ac7d
--- /dev/null
+++ b/pkg/wsman/cim/bios/types.go
@@ -0,0 +1,126 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package bios
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+)
+
+type Element struct {
+ base message.Base
+}
+
+// Response Types
+type (
+ Response struct {
+ *client.Message
+ XMLName xml.Name `xml:"Envelope"`
+ Header message.Header `xml:"Header"`
+ Body Body `xml:"Body"`
+ }
+
+ Body struct {
+ XMLName xml.Name `xml:"Body"`
+ GetResponse BiosElement
+ EnumerateResponse common.EnumerateResponse
+ PullResponse PullResponse
+ }
+
+ BiosElement struct {
+ XMLName xml.Name `xml:"CIM_BIOSElement"`
+ TargetOperatingSystem TargetOperatingSystem `xml:"TargetOperatingSystem"` // The TargetOperatingSystem property specifies the element's operating system environment.
+ SoftwareElementID string `xml:"SoftwareElementID"` // This is an identifier for the SoftwareElement and is designed to be used in conjunction with other keys to create a unique representation of the element.
+ SoftwareElementState SoftwareElementState `xml:"SoftwareElementState"` // The SoftwareElementState is defined in this model to identify various states of a SoftwareElement's life cycle.
+ Name string `xml:"Name"` // The name used to identify this SoftwareElement.
+ OperationalStatus OperationalStatus `xml:"OperationalStatus"` // Indicates the current statuses of the element.
+ ElementName string `xml:"ElementName"` // A user-friendly name for the object. This property allows each instance to define a user-friendly name in addition to its key properties, identity data, and description information. Note that the Name property of ManagedSystemElement is also defined as a user-friendly name. But, it is often subclassed to be a Key. It is not reasonable that the same property can convey both identity and a user-friendly name, without inconsistencies. Where Name exists and is not a Key (such as for instances of LogicalDevice), the same information can be present in both the Name and ElementName properties. Note that if there is an associated instance of CIM_EnabledLogicalElementCapabilities, restrictions on this properties may exist as defined in ElementNameMask and MaxElementNameLen properties defined in that class.
+ Version string `xml:"Version"` // The version of the BIOS software image.
+ Manufacturer string `xml:"Manufacturer"` // The manufacturer of the BIOS software image.
+ PrimaryBIOS bool `xml:"PrimaryBIOS"` // If true, this is the primary BIOS of the ComputerSystem.
+ ReleaseDate Time `xml:"ReleaseDate"` // Date that this BIOS was released.
+ }
+
+ Time struct {
+ DateTime string `xml:"Datetime"`
+ }
+
+ PullResponse struct {
+ XMLName xml.Name `xml:"PullResponse"`
+ BiosElementItems []BiosElement `xml:"Items>CIM_BIOSElement"`
+ }
+)
+
+type (
+ // The TargetOperatingSystem property specifies the element's operating system environment.
+ // The value of this property does not ensure that it is binary executable.
+ // Two other pieces of information are needed.
+ // First, the version of the OS needs to be specified using the class, CIM_OSVersion Check.
+ // The second piece of information is the architecture that the OS runs on.
+ // This information is verified using CIM_ArchitectureCheck.
+ // The combination of these constructs clearly identifies the level of OS required for a particular SoftwareElement.
+ //
+ // ValueMap={0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113}
+ //
+ // Values={Unknown, Other, MACOS, ATTUNIX, DGUX, DECNT, Tru64 UNIX, OpenVMS, HPUX, AIX, MVS, OS400, OS/2, JavaVM, MSDOS, WIN3x, WIN95, WIN98, WINNT, WINCE, NCR3000, NetWare, OSF, DC/OS, Reliant UNIX, SCO UnixWare, SCO OpenServer, Sequent, IRIX, Solaris, SunOS, U6000, ASERIES, HP NonStop OS, HP NonStop OSS, BS2000, LINUX, Lynx, XENIX, VM, Interactive UNIX, BSDUNIX, FreeBSD, NetBSD, GNU Hurd, OS9, MACH Kernel, Inferno, QNX, EPOC, IxWorks, VxWorks, MiNT, BeOS, HP MPE, NextStep, PalmPilot, Rhapsody, Windows 2000, Dedicated, OS/390, VSE, TPF, Windows (R) Me, Caldera Open UNIX, OpenBSD, Not Applicable, Windows XP, z/OS, Microsoft Windows Server 2003, Microsoft Windows Server 2003 64-Bit, Windows XP 64-Bit, Windows XP Embedded, Windows Vista, Windows Vista 64-Bit, Windows Embedded for Point of Service, Microsoft Windows Server 2008, Microsoft Windows Server 2008 64-Bit, FreeBSD 64-Bit, RedHat Enterprise Linux, RedHat Enterprise Linux 64-Bit, Solaris 64-Bit, SUSE, SUSE 64-Bit, SLES, SLES 64-Bit, Novell OES, Novell Linux Desktop, Sun Java Desktop System, Mandriva, Mandriva 64-Bit, TurboLinux, TurboLinux 64-Bit, Ubuntu, Ubuntu 64-Bit, Debian, Debian 64-Bit, Linux 2.4.x, Linux 2.4.x 64-Bit, Linux 2.6.x, Linux 2.6.x 64-Bit, Linux 64-Bit, Other 64-Bit, Microsoft Windows Server 2008 R2, VMware ESXi, Microsoft Windows 7, CentOS 32-bit, CentOS 64-bit, Oracle Enterprise Linux 32-bit, Oracle Enterprise Linux 64-bit, eComStation 32-bitx, Microsoft Windows Server 2011, Microsoft Windows Server 2011 64-Bit, Microsoft Windows Server 8}
+ TargetOperatingSystem int
+
+ // The SoftwareElementState is defined in this model to identify various states of a SoftwareElement's life cycle.
+ //
+ // - A SoftwareElement in the deployable state describes the details necessary to successfully distribute it and the details (Checks and Actions) required to move it to the installable state (i.e, the next state).
+ //
+ // - A SoftwareElement in the installable state describes the details necessary to successfully install it and the details (Checks and Actions) required to create an element in the executable state (i.e., the next state).
+ //
+ // - A SoftwareElement in the executable state describes the details necessary to successfully start it and the details (Checks and Actions) required to move it to the running state (i.e., the next state).
+ //
+ // - A SoftwareElement in the running state describes the details necessary to manage the started element.
+ //
+ // ValueMap={0, 1, 2, 3}
+ //
+ // Values={Deployable, Installable, Executable, Running}
+ SoftwareElementState int
+
+ // Indicates the current statuses of the element.
+ // Various operational statuses are defined.
+ // Many of the enumeration's values are self-explanatory.
+ // However, a few are not and are described here in more detail.
+ //
+ // "Stressed" indicates that the element is functioning, but needs attention. Examples of "Stressed" states are overload, overheated, and so on.
+ //
+ // "Predictive Failure" indicates that an element is functioning nominally but predicting a failure in the near future.
+ //
+ // "In Service" describes an element being configured, maintained, cleaned, or otherwise administered.
+ //
+ // "No Contact" indicates that the monitoring system has knowledge of this element, but has never been able to establish communications with it.
+ //
+ // "Lost Communication" indicates that the ManagedSystem Element is known to exist and has been contacted successfully in the past, but is currently unreachable.
+ //
+ // "Stopped" and "Aborted" are similar, although the former implies a clean and orderly stop, while the latter implies an abrupt stop where the state and configuration of the element might need to be updated.
+ //
+ // "Dormant" indicates that the element is inactive or quiesced.
+ //
+ // "Supporting Entity in Error" indicates that this element might be "OK" but that another element, on which it is dependent, is in error. An example is a network service or endpoint that cannot function due to lower-layer networking problems.
+ //
+ // "Completed" indicates that the element has completed its operation. This value should be combined with either OK, Error, or Degraded so that a client can tell if the complete operation Completed with OK (passed), Completed with Error (failed), or Completed with Degraded (the operation finished, but it did not complete OK or did not report an error).
+ //
+ // "Power Mode" indicates that the element has additional power model information contained in the Associated PowerManagementService association.
+ //
+ // "Relocating" indicates the element is being relocated.
+ //
+ // OperationalStatus replaces the Status property on ManagedSystemElement to provide a consistent approach to enumerations, to address implementation needs for an array property, and to provide a migration path from today's environment to the future.
+ // This change was not made earlier because it required the deprecated qualifier.
+ // Due to the widespread use of the existing Status property in management applications, it is strongly recommended that providers or instrumentation provide both the Status and OperationalStatus properties.
+ // Further, the first value of OperationalStatus should contain the primary status for the element.
+ // When instrumented, Status (because it is single-valued) should also provide the primary status of the element.
+ //
+ // ValueMap={0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, .., 0x8000..}
+ //
+ // Values={Unknown, Other, OK, Degraded, Stressed, Predictive Failure, Error, Non-Recoverable Error, Starting, Stopping, Stopped, In Service, No Contact, Lost Communication, Aborted, Dormant, Supporting Entity in Error, Completed, Power Mode, Relocating, DMTF Reserved, Vendor Reserved}
+ OperationalStatus int
+)
diff --git a/pkg/wsman/cim/boot/configsetting.go b/pkg/wsman/cim/boot/configsetting.go
new file mode 100644
index 00000000..5513031f
--- /dev/null
+++ b/pkg/wsman/cim/boot/configsetting.go
@@ -0,0 +1,135 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+// Package boot facilitates communication with Intel® AMT devices to access and configure Boot Config Setting, Boot Service, and Boot Source Setting features of AMT.
+//
+// ConfigSetting:
+// A class derived from SettingData that provides the container to arrange all the BootSourceSetting instances in an ordered sequence.
+// There can be one or more of the BootConfigSetting instances associated to a ComputerSystem.
+// For example, one such BootConfigSetting could be a default boot configuration supplied by the manufacturer, a second one could be a configuration recommended by the IT Administrator.
+// A third one could be the one actually to be used on next system boot.
+//
+// Service:
+// A class derived from Service that provides the controls to manage the boot configuration of a managed computer system or device.
+// This includes changing the order of the boot devices and affecting settings on managed elements during the boot process.
+// This service can also affect the load of a specific operating system on the computer system through a BootSourceSetting that points to a specific operating system image.
+//
+// SourceSetting:
+// A class derived from SettingData that provides the information necessary to describe a boot source.
+// This may be optionally associated to a bootable logical device, such as a hard disk partition, or a network device.
+// The information from this class instance is used by the boot manager, such as BIOS/EFI or OS Loader to initiate the boot process, when this instance appears in a BootConfigSetting collection.
+package boot
+
+import (
+ "encoding/xml"
+ "fmt"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/methods"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+)
+
+// NewBootConfigSettingWithClient instantiates a new ConfigSetting
+func NewBootConfigSettingWithClient(wsmanMessageCreator *message.WSManMessageCreator, client client.WSMan) ConfigSetting {
+ return ConfigSetting{
+ base: message.NewBaseWithClient(wsmanMessageCreator, CIM_BootConfigSetting, client),
+ client: client,
+ }
+}
+
+// Get retrieves the representation of the instance
+func (configSetting ConfigSetting) Get() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: configSetting.base.Get(nil),
+ },
+ }
+
+ err = configSetting.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Enumerate returns an enumeration context which is used in a subsequent Pull call
+func (configSetting ConfigSetting) Enumerate() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: configSetting.base.Enumerate(),
+ },
+ }
+
+ err = configSetting.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Pull returns the instances of this class. An enumeration context provided by the Enumerate call is used as input.
+func (configSetting ConfigSetting) Pull(enumerationContext string) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: configSetting.base.Pull(enumerationContext),
+ },
+ }
+ err = configSetting.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// ChangeBootOrder sets the boot order within a boot configuration.
+//
+// An ordered array of BootSourceSetting instances is passed to this method.
+// Each BootSourceSetting instance MUST already be associated with this BootConfigSetting instance via an instance of OrderedComponent.
+// If not, the implementation MUST return a value of "Invalid Parameter" Upon execution of this method,
+// the value of the AssignedSequence property on each instance of OrderedComponent will be updated such that the values are monotonically increasing in correlation with the position of the referenced BootSourceSetting instance in the source input parameter.
+// That is, the first position in the array will have the lowest value for AssignedSequence.
+// The second position will have the second lowest value, and so on.
+// For BootSourceSetting instances which are associated with the BootConfigSetting instance via OrderedComponent and not present in the input array, the AssignedSequence property on the OrderedComponent association will be assigned a value of 0.
+//
+// Additional Notes:
+//
+// 1) A boot source cannot be set if some special boot options were set in AMT_BootSettingData (such as UseSOL, UseIDER, ReflashBIOS, BIOSPause, BIOSSetup)
+//
+// 2) Parameter 'Source' changed in capitalization. Intel AMT Release 5.0 and earlier releases use 2.13.0 MOF version and therefor expect 'Source' parameter as 'source'.
+//
+// 3) Intel AMT Release 7.0: Returns WSMAN Fault = “access denied” if user consent is required but IPS_OptInService.OptInState value is not 'Received' or 'In Session'. An exception to this rule is when the Source parameter is an empty array.
+func (configSetting ConfigSetting) ChangeBootOrder(source Source) (response Response, err error) {
+ header := configSetting.base.WSManMessageCreator.CreateHeader(methods.GenerateAction(CIM_BootConfigSetting, ChangeBootOrder), CIM_BootConfigSetting, nil, "", "")
+ body := fmt.Sprintf(`http://schemas.xmlsoap.org/ws/2004/08/addressinghttp://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_BootSourceSetting%s`, source)
+ response = Response{
+ Message: &client.Message{
+ XMLInput: configSetting.base.WSManMessageCreator.CreateXML(header, body),
+ },
+ }
+ err = configSetting.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
diff --git a/pkg/wsman/cim/boot/configsetting_test.go b/pkg/wsman/cim/boot/configsetting_test.go
new file mode 100644
index 00000000..a6b16b5b
--- /dev/null
+++ b/pkg/wsman/cim/boot/configsetting_test.go
@@ -0,0 +1,236 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package boot
+
+import (
+ "encoding/xml"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/methods"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
+)
+
+func TestPositiveConfigSetting(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "cim/boot/configsetting",
+ }
+ elementUnderTest := NewBootConfigSettingWithClient(wsmanMessageCreator, &client)
+
+ t.Run("cim_* Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create and parse a valid cim_BootConfigSetting Get call",
+ CIM_BootConfigSetting,
+ wsmantesting.GET,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Get"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ ConfigSettingGetResponse: BootConfigSetting{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_BootConfigSetting", Local: CIM_BootConfigSetting},
+ InstanceID: "Intel(r) AMT: Boot Configuration 0",
+ ElementName: "Intel(r) AMT: Boot Configuration",
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create and parse a valid cim_BootConfigSetting Enumerate call",
+ CIM_BootConfigSetting,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Enumerate"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "14000000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create and parse a valid cim_BootConfigSetting Pull call",
+ CIM_BootConfigSetting,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Pull"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ BootConfigSettingItems: []BootConfigSetting{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_BootConfigSetting", Local: CIM_BootConfigSetting},
+ InstanceID: "Intel(r) AMT: Boot Configuration 0",
+ ElementName: "Intel(r) AMT: Boot Configuration",
+ },
+ },
+ },
+ },
+ },
+ //Change Boot Order
+ {
+ "should create and parse a valid cim_BootConfigSetting ChangeBootOrder call",
+ CIM_BootConfigSetting,
+ methods.GenerateAction(CIM_BootConfigSetting, ChangeBootOrder),
+ "http://schemas.xmlsoap.org/ws/2004/08/addressinghttp://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_BootSourceSettingCIM:Hard-Disk:1",
+ func() (Response, error) {
+ client.CurrentMessage = "ChangeBootOrder"
+ return elementUnderTest.ChangeBootOrder(HardDrive)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ ChangeBootOrder_OUTPUT: ChangeBootOrder_OUTPUT{
+ ReturnValue: 0,
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.NoError(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.Equal(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
+
+func TestNegativeConfigSetting(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "cim/boot/configsetting",
+ }
+ elementUnderTest := NewBootConfigSettingWithClient(wsmanMessageCreator, &client)
+
+ t.Run("cim_* Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should handle error when cim_BootConfigSetting Get call",
+ CIM_BootConfigSetting,
+ wsmantesting.GET,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ ConfigSettingGetResponse: BootConfigSetting{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_BootConfigSetting", Local: CIM_BootConfigSetting},
+ InstanceID: "Intel(r) AMT: Boot Configuration 0",
+ ElementName: "Intel(r) AMT: Boot Configuration",
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should handle error when cim_BootConfigSetting Enumerate call",
+ CIM_BootConfigSetting,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "14000000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should handle error when cim_BootConfigSetting Pull call",
+ CIM_BootConfigSetting,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ BootConfigSettingItems: []BootConfigSetting{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_BootConfigSetting", Local: CIM_BootConfigSetting},
+ InstanceID: "Intel(r) AMT: Boot Configuration 0",
+ ElementName: "Intel(r) AMT: Boot Configuration",
+ },
+ },
+ },
+ },
+ },
+ //Change Boot Order
+ {
+ "should handle error when cim_BootConfigSetting ChangeBootOrder call",
+ CIM_BootConfigSetting,
+ methods.GenerateAction(CIM_BootConfigSetting, ChangeBootOrder),
+ "http://schemas.xmlsoap.org/ws/2004/08/addressinghttp://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_BootSourceSettingCIM:Hard-Disk:1",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.ChangeBootOrder(HardDrive)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ ChangeBootOrder_OUTPUT: ChangeBootOrder_OUTPUT{
+ ReturnValue: 0,
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.Error(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.NotEqual(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
diff --git a/pkg/wsman/cim/boot/constants.go b/pkg/wsman/cim/boot/constants.go
new file mode 100644
index 00000000..db2e2b0f
--- /dev/null
+++ b/pkg/wsman/cim/boot/constants.go
@@ -0,0 +1,88 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package boot
+
+const (
+ CIM_BootConfigSetting string = "CIM_BootConfigSetting"
+ CIM_BootSourceSetting string = "CIM_BootSourceSetting"
+ CIM_BootService string = "CIM_BootService"
+ ChangeBootOrder string = "ChangeBootOrder"
+)
+
+const (
+ HardDrive Source = "CIM:Hard-Disk:1"
+ CD Source = "CIM:CD/DVD:1"
+ PXE Source = "CIM:Network:1"
+ OCR_UEFI_HTTPS Source = "Intel(r)AMT:OCR-UEFI-Boot-Option-HTTPS:1"
+ OCR_UEFI_BootOption1 Source = "Intel(r)AMT:OCR-UEFI-Boot-Option:1"
+ OCR_UEFI_BootOption2 Source = "Intel(r)AMT:OCR-UEFI-Boot-Option:2"
+ OCR_UEFI_BootOption3 Source = "Intel(r)AMT:OCR-UEFI-Boot-Option:3"
+ OCR_UEFI_BootOption4 Source = "Intel(r)AMT:OCR-UEFI-Boot-Option:4"
+ OCR_UEFI_BootOption5 Source = "Intel(r)AMT:OCR-UEFI-Boot-Option:5"
+ OCR_UEFI_BootOption6 Source = "Intel(r)AMT:OCR-UEFI-Boot-Option:6"
+ OCR_UEFI_BootOption7 Source = "Intel(r)AMT:OCR-UEFI-Boot-Option:7"
+ OCR_UEFI_BootOption8 Source = "Intel(r)AMT:OCR-UEFI-Boot-Option:8"
+ OCR_UEFI_BootOption9 Source = "Intel(r)AMT:OCR-UEFI-Boot-Option:9"
+ OCR_UEFI_BootOption10 Source = "Intel(r)AMT:OCR-UEFI-Boot-Option:10"
+)
+
+const (
+ FailThroughSupportedUnknown FailThroughSupported = iota
+ IsSupported
+ NotSupported
+)
+
+const (
+ EnabledStateUnknown EnabledState = iota
+ EnabledStateOther
+ EnabledStateEnabled
+ EnabledStateDisabled
+ EnabledStateShuttingDown
+ EnabledStateNotApplicable
+ EnabledStateEnabledbutOffline
+ EnabledStateInTest
+ EnabledStateDeferred
+ EnabledStateQuiesce
+ EnabledStateStarting
+)
+
+const (
+ RequestedStateEnabled RequestedState = iota + 2
+ RequestedStateDisabled
+ RequestedStateShutDown
+ RequestedStateNoChange
+ RequestedStateOffline
+ RequestedStateTest
+ RequestedStateDeferred
+ RequestedStateQuiesce
+ RequestedStateReboot
+ RequestedStateReset
+ RequestedStateNotApplicable
+ RequestedStateUnknown RequestedState = 0
+)
+
+const (
+ OperationalStatusUnknown OperationalStatus = iota
+ OperationalStatusOther
+ OperationalStatusOK
+ OperationalStatusDegraded
+ OperationalStatusStressed
+ OperationalStatusPredictiveFailure
+ OperationalStatusError
+ OperationalStatusNonRecoverableError
+ OperationalStatusStarting
+ OperationalStatusStopping
+ OperationalStatusStopped
+ OperationalStatusInService
+ OperationalStatusNoContact
+ OperationalStatusLostCommunication
+ OperationalStatusAborted
+ OperationalStatusDormant
+ OperationalStatusSupportingEntityinError
+ OperationalStatusCompleted
+ OperationalStatusPowerMode
+ OperationalStatusRelocating
+)
diff --git a/pkg/wsman/cim/boot/marshal.go b/pkg/wsman/cim/boot/marshal.go
new file mode 100644
index 00000000..8b27da02
--- /dev/null
+++ b/pkg/wsman/cim/boot/marshal.go
@@ -0,0 +1,30 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package boot
+
+import (
+ "encoding/json"
+
+ "gopkg.in/yaml.v3"
+)
+
+// JSON marshals the type into JSON format
+func (r *Response) JSON() string {
+ jsonOutput, err := json.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(jsonOutput)
+}
+
+// YAML marshals the type into YAML format
+func (r *Response) YAML() string {
+ yamlOutput, err := yaml.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(yamlOutput)
+}
diff --git a/pkg/wsman/cim/boot/service.go b/pkg/wsman/cim/boot/service.go
new file mode 100644
index 00000000..cc15dfdd
--- /dev/null
+++ b/pkg/wsman/cim/boot/service.go
@@ -0,0 +1,79 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package boot
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+)
+
+// NewBootService returns a new instance of the BootService struct.
+func NewBootServiceWithClient(wsmanMessageCreator *message.WSManMessageCreator, client client.WSMan) Service {
+ return Service{
+ base: message.NewBaseWithClient(wsmanMessageCreator, CIM_BootService, client),
+ client: client,
+ }
+}
+
+// Get retrieves the representation of the instance
+func (service Service) Get() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: service.base.Get(nil),
+ },
+ }
+
+ err = service.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Enumerate returns an enumeration context which is used in a subsequent Pull call
+func (service Service) Enumerate() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: service.base.Enumerate(),
+ },
+ }
+
+ err = service.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Pull returns the instances of this class. An enumeration context provided by the Enumerate call is used as input.
+func (service Service) Pull(enumerationContext string) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: service.base.Pull(enumerationContext),
+ },
+ }
+ err = service.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
diff --git a/pkg/wsman/cim/boot/service_test.go b/pkg/wsman/cim/boot/service_test.go
new file mode 100644
index 00000000..090736ce
--- /dev/null
+++ b/pkg/wsman/cim/boot/service_test.go
@@ -0,0 +1,225 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package boot
+
+import (
+ "encoding/xml"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
+)
+
+func TestPositiveService(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "cim/boot/service",
+ }
+ elementUnderTest := NewBootServiceWithClient(wsmanMessageCreator, &client)
+
+ t.Run("cim_* Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create and parse a valid cim_BootService Get call",
+ CIM_BootService,
+ wsmantesting.GET,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Get"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ ServiceGetResponse: BootService{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_BootService", Local: CIM_BootService},
+ Name: "Intel(r) AMT Boot Service",
+ CreationClassName: "CIM_BootService",
+ SystemName: "Intel(r) AMT",
+ SystemCreationClassName: "CIM_ComputerSystem",
+ ElementName: "Intel(r) AMT Boot Service",
+ OperationalStatus: []OperationalStatus{0},
+ EnabledState: 2,
+ RequestedState: 12,
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create and parse a valid cim_BootService Enumerate call",
+ CIM_BootService,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Enumerate"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "14000000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create and parse a valid cim_BootService Pull call",
+ CIM_BootService,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Pull"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ BootServiceItems: []BootService{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_BootService", Local: CIM_BootService},
+ Name: "Intel(r) AMT Boot Service",
+ CreationClassName: "CIM_BootService",
+ SystemName: "Intel(r) AMT",
+ SystemCreationClassName: "CIM_ComputerSystem",
+ ElementName: "Intel(r) AMT Boot Service",
+ OperationalStatus: []OperationalStatus{0},
+ EnabledState: 2,
+ RequestedState: 12,
+ },
+ },
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.NoError(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.Equal(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
+
+func TestNegativeService(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "cim/boot/service",
+ }
+ elementUnderTest := NewBootServiceWithClient(wsmanMessageCreator, &client)
+
+ t.Run("cim_* Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should handle error when making cim_BootService Get call",
+ CIM_BootService,
+ wsmantesting.GET,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ ServiceGetResponse: BootService{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_BootService", Local: CIM_BootService},
+ Name: "Intel(r) AMT Boot Service",
+ CreationClassName: "CIM_BootService",
+ SystemName: "Intel(r) AMT",
+ SystemCreationClassName: "CIM_ComputerSystem",
+ ElementName: "Intel(r) AMT Boot Service",
+ OperationalStatus: []OperationalStatus{0},
+ EnabledState: 2,
+ RequestedState: 12,
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should handle error when making cim_BootService Enumerate call",
+ CIM_BootService,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "14000000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should handle error when making cim_BootService Pull wsman message",
+ CIM_BootService,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ BootServiceItems: []BootService{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_BootService", Local: CIM_BootService},
+ Name: "Intel(r) AMT Boot Service",
+ CreationClassName: "CIM_BootService",
+ SystemName: "Intel(r) AMT",
+ SystemCreationClassName: "CIM_ComputerSystem",
+ ElementName: "Intel(r) AMT Boot Service",
+ OperationalStatus: []OperationalStatus{0},
+ EnabledState: 2,
+ RequestedState: 12,
+ },
+ },
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.Error(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.NotEqual(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
diff --git a/pkg/wsman/cim/boot/sourcesetting.go b/pkg/wsman/cim/boot/sourcesetting.go
new file mode 100644
index 00000000..d56258c2
--- /dev/null
+++ b/pkg/wsman/cim/boot/sourcesetting.go
@@ -0,0 +1,83 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package boot
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+)
+
+// NewBootSourceSetting returns a new instance of the BootSourceSetting struct.
+func NewBootSourceSettingWithClient(wsmanMessageCreator *message.WSManMessageCreator, client client.WSMan) SourceSetting {
+ return SourceSetting{
+ base: message.NewBaseWithClient(wsmanMessageCreator, CIM_BootSourceSetting, client),
+ client: client,
+ }
+}
+
+// Get retrieves the representation of the instance
+func (sourceSetting SourceSetting) Get(instanceID string) (response Response, err error) {
+ selector := message.Selector{
+ Name: "InstanceID",
+ Value: instanceID,
+ }
+ response = Response{
+ Message: &client.Message{
+ XMLInput: sourceSetting.base.Get(&selector),
+ },
+ }
+
+ err = sourceSetting.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Enumerate returns an enumeration context which is used in a subsequent Pull call
+func (sourceSetting SourceSetting) Enumerate() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: sourceSetting.base.Enumerate(),
+ },
+ }
+
+ err = sourceSetting.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Pull returns the instances of this class. An enumeration context provided by the Enumerate call is used as input.
+func (sourceSetting SourceSetting) Pull(enumerationContext string) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: sourceSetting.base.Pull(enumerationContext),
+ },
+ }
+ err = sourceSetting.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
diff --git a/pkg/wsman/cim/boot/sourcesetting_test.go b/pkg/wsman/cim/boot/sourcesetting_test.go
new file mode 100644
index 00000000..e1d3b1d5
--- /dev/null
+++ b/pkg/wsman/cim/boot/sourcesetting_test.go
@@ -0,0 +1,245 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package boot
+
+import (
+ "encoding/xml"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
+)
+
+func TestPositiveSourceSetting(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "cim/boot/sourcesetting",
+ }
+ elementUnderTest := NewBootSourceSettingWithClient(wsmanMessageCreator, &client)
+
+ t.Run("cim_* Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ extraHeader string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create and parse a valid cim_BootSourceSetting Get call",
+ CIM_BootSourceSetting,
+ wsmantesting.GET,
+ "Intel(r) AMT: Force Hard-drive Boot",
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Get"
+ return elementUnderTest.Get("Intel(r) AMT: Force Hard-drive Boot")
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ SourceSettingGetResponse: BootSourceSetting{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_BootSourceSetting", Local: CIM_BootSourceSetting},
+ ElementName: "Intel(r) AMT: Boot Source",
+ InstanceID: "Intel(r) AMT: Force Hard-drive Boot",
+ StructuredBootString: "CIM:Hard-Disk:1",
+ FailThroughSupported: 2,
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create and parse a valid cim_BootSourceSetting Enumerate call",
+ CIM_BootSourceSetting,
+ wsmantesting.ENUMERATE,
+ "",
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Enumerate"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "14000000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create and parse a valid cim_BootSourceSetting Pull call",
+ CIM_BootSourceSetting,
+ wsmantesting.PULL,
+ "",
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Pull"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ BootSourceSettingItems: []BootSourceSetting{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_BootSourceSetting", Local: CIM_BootSourceSetting},
+ InstanceID: "Intel(r) AMT: Force Hard-drive Boot",
+ ElementName: "Intel(r) AMT: Boot Source",
+ StructuredBootString: "CIM:Hard-Disk:1",
+ FailThroughSupported: 2,
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_BootSourceSetting", Local: CIM_BootSourceSetting},
+ InstanceID: "Intel(r) AMT: Force PXE Boot",
+ ElementName: "Intel(r) AMT: Boot Source",
+ StructuredBootString: "CIM:Network:1",
+ FailThroughSupported: 2,
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_BootSourceSetting", Local: CIM_BootSourceSetting},
+ InstanceID: "Intel(r) AMT: Force CD/DVD Boot",
+ ElementName: "Intel(r) AMT: Boot Source",
+ StructuredBootString: "CIM:CD/DVD:1",
+ FailThroughSupported: 2,
+ },
+ },
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, test.extraHeader, test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.NoError(t, err)
+ assert.Equal(t, expectedResponse, response.XMLInput)
+ assert.Equal(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
+
+func TestNegativeSourceSetting(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "cim/boot/sourcesetting",
+ }
+ elementUnderTest := NewBootSourceSettingWithClient(wsmanMessageCreator, &client)
+
+ t.Run("cim_* Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ extraHeader string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should handle error when cim_BootSourceSetting Get call",
+ CIM_BootSourceSetting,
+ wsmantesting.GET,
+ "Intel(r) AMT: Force Hard-drive Boot",
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Get("Intel(r) AMT: Force Hard-drive Boot")
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ SourceSettingGetResponse: BootSourceSetting{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_BootSourceSetting", Local: CIM_BootSourceSetting},
+ ElementName: "Intel(r) AMT: Boot Source",
+ InstanceID: "Intel(r) AMT: Force Hard-drive Boot",
+ StructuredBootString: "CIM:Hard-Disk:1",
+ FailThroughSupported: 2,
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should handle error when cim_BootSourceSetting Enumerate call",
+ CIM_BootSourceSetting,
+ wsmantesting.ENUMERATE,
+ "",
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "14000000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should handle error when cim_BootSourceSetting Pull call",
+ CIM_BootSourceSetting,
+ wsmantesting.PULL,
+ "",
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ BootSourceSettingItems: []BootSourceSetting{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_BootSourceSetting", Local: CIM_BootSourceSetting},
+ InstanceID: "Intel(r) AMT: Force Hard-drive Boot",
+ ElementName: "Intel(r) AMT: Boot Source",
+ StructuredBootString: "CIM:Hard-Disk:1",
+ FailThroughSupported: 2,
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_BootSourceSetting", Local: CIM_BootSourceSetting},
+ InstanceID: "Intel(r) AMT: Force PXE Boot",
+ ElementName: "Intel(r) AMT: Boot Source",
+ StructuredBootString: "CIM:Network:1",
+ FailThroughSupported: 2,
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_BootSourceSetting", Local: CIM_BootSourceSetting},
+ InstanceID: "Intel(r) AMT: Force CD/DVD Boot",
+ ElementName: "Intel(r) AMT: Boot Source",
+ StructuredBootString: "CIM:CD/DVD:1",
+ FailThroughSupported: 2,
+ },
+ },
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedResponse := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, test.extraHeader, test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.Error(t, err)
+ assert.Equal(t, expectedResponse, response.XMLInput)
+ assert.NotEqual(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
diff --git a/pkg/wsman/cim/boot/types.go b/pkg/wsman/cim/boot/types.go
new file mode 100644
index 00000000..ebe7d757
--- /dev/null
+++ b/pkg/wsman/cim/boot/types.go
@@ -0,0 +1,207 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package boot
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+)
+
+type ConfigSetting struct {
+ base message.Base
+ client client.WSMan
+}
+
+type SourceSetting struct {
+ base message.Base
+ client client.WSMan
+}
+
+type Service struct {
+ base message.Base
+ client client.WSMan
+}
+
+type Source string
+
+// Response Types
+type (
+ Response struct {
+ *client.Message
+ XMLName xml.Name `xml:"Envelope"`
+ Header message.Header `xml:"Header"`
+ Body Body `xml:"Body"`
+ }
+
+ Body struct {
+ XMLName xml.Name `xml:"Body"`
+ ConfigSettingGetResponse BootConfigSetting `xml:"CIM_BootConfigSetting"`
+ SourceSettingGetResponse BootSourceSetting `xml:"CIM_BootSourceSetting"`
+ ServiceGetResponse BootService `xml:"CIM_BootService"`
+ EnumerateResponse common.EnumerateResponse
+ PullResponse PullResponse `xml:"PullResponse"`
+ ChangeBootOrder_OUTPUT ChangeBootOrder_OUTPUT `xml:"ChangeBootOrder_OUTPUT"`
+ }
+
+ BootConfigSetting struct {
+ XMLName xml.Name `xml:"CIM_BootConfigSetting"`
+ InstanceID string `xml:"InstanceID"` // Within the scope of the instantiating Namespace, InstanceID opaquely and uniquely identifies an instance of this class. To ensure uniqueness within the NameSpace, the value of InstanceID should be constructed using the following "preferred" algorithm: : Where and are separated by a colon (:), and where must include a copyrighted, trademarked, or otherwise unique name that is owned by the business entity that is creating or defining the InstanceID or that is a registered ID assigned to the business entity by a recognized global authority. (This requirement is similar to the _ structure of Schema class names.) In addition, to ensure uniqueness, must not contain a colon (:). When using this algorithm, the first colon to appear in InstanceID must appear between and . is chosen by the business entity and should not be reused to identify different underlying (real-world) elements. If the above "preferred" algorithm is not used, the defining entity must assure that the resulting InstanceID is not reused across any InstanceIDs produced by this or other providers for the NameSpace of this instance. For DMTF-defined instances, the "preferred" algorithm must be used with the set to CIM.
+ ElementName string `xml:"ElementName"` // The user-friendly name for this instance of SettingData. In addition, the user-friendly name can be used as an index property for a search or query. (Note: The name does not have to be unique within a namespace.)
+ }
+
+ BootSourceSetting struct {
+ XMLName xml.Name `xml:"CIM_BootSourceSetting"`
+ ElementName string `xml:"ElementName"` // he user-friendly name for this instance of SettingData. In addition, the user-friendly name can be used as an index property for a search or query. (Note: The name does not have to be unique within a namespace.)
+ InstanceID string `xml:"InstanceID"` // Within the scope of the instantiating Namespace, InstanceID opaquely and uniquely identifies an instance of this class. To ensure uniqueness within the NameSpace, the value of InstanceID should be constructed using the following "preferred" algorithm: : Where and are separated by a colon (:), and where must include a copyrighted, trademarked, or otherwise unique name that is owned by the business entity that is creating or defining the InstanceID or that is a registered ID assigned to the business entity by a recognized global authority. (This requirement is similar to the _ structure of Schema class names.) In addition, to ensure uniqueness, must not contain a colon (:). When using this algorithm, the first colon to appear in InstanceID must appear between and . is chosen by the business entity and should not be reused to identify different underlying (real-world) elements. If the above "preferred" algorithm is not used, the defining entity must assure that the resulting InstanceID is not reused across any InstanceIDs produced by this or other providers for the NameSpace of this instance. For DMTF-defined instances, the "preferred" algorithm must be used with the set to CIM.
+ StructuredBootString string `xml:"StructuredBootString"` // A string identifying the boot source using the format "::", in which neither , or contains a colon (":"). The value of is a copyrighted, trademarked or otherwise unique name that is owned by the entity defining the , or is a registered ID that is assigned to the entity by a recognized global authority. For DMTF defined identifiers, the is set to 'CIM'. The are "Floppy", "Hard-Disk", "CD/DVD", "Network", "PCMCIA", "USB". The value of shall be a non-zero integer.
+ BIOSBootString string `xml:"BIOSBootString"` // BIOS description of the boot option. UTF8 null-terminated string, relevant only to One-Click Recovery WinRE and PBA (pre-boot application) boot options.
+ BootString string `xml:"BootString"` // BIOS description of the EFI device path. UTF8 null-terminated string, relevant only to One-Click Recovery WinRE and PBA (pre-boot application) boot options.
+ FailThroughSupported FailThroughSupported `xml:"FailThroughSupported"` // An enumeration indicating the behavior when the attempt to boot using the boot source fails (no media, timeout).
+ }
+
+ BootService struct {
+ XMLName xml.Name `xml:"CIM_BootService"`
+ Name string `xml:"Name"` // The Name property uniquely identifies the Service and provides an indication of the functionality that is managed. This functionality is described in more detail in the Description property of the object.
+ CreationClassName string `xml:"CreationClassName"` // CreationClassName indicates the name of the class or the subclass that is used in the creation of an instance. When used with the other key properties of this class, this property allows all instances of this class and its subclasses to be uniquely identified.
+ SystemName string `xml:"SystemName"` // The Name of the scoping System.
+ SystemCreationClassName string `xml:"SystemCreationClassName"` // The CreationClassName of the scoping System.
+ ElementName string `xml:"ElementName"` // A user-friendly name for the object. This property allows each instance to define a user-friendly name in addition to its key properties, identity data, and description information. Note that the Name property of ManagedSystemElement is also defined as a user-friendly name. But, it is often subclassed to be a Key. It is not reasonable that the same property can convey both identity and a user-friendly name, without inconsistencies. Where Name exists and is not a Key (such as for instances of LogicalDevice), the same information can be present in both the Name and ElementName properties. Note that if there is an associated instance of CIM_EnabledLogicalElementCapabilities, restrictions on this properties may exist as defined in ElementNameMask and MaxElementNameLen properties defined in that class.
+ OperationalStatus []OperationalStatus `xml:"OperationalStatus"` // Indicates the current statuses of the element. Various operational statuses are defined.
+ EnabledState EnabledState `xml:"EnabledState"` // EnabledState is an integer enumeration that indicates the enabled and disabled states of an element.
+ RequestedState RequestedState `xml:"RequestedState"` // RequestedState is an integer enumeration that indicates the last requested or desired state for the element, irrespective of the mechanism through which it was requested.
+ }
+
+ PullResponse struct {
+ BootSourceSettingItems []BootSourceSetting `xml:"Items>CIM_BootSourceSetting"`
+ BootConfigSettingItems []BootConfigSetting `xml:"Items>CIM_BootConfigSetting"`
+ BootServiceItems []BootService `xml:"Items>CIM_BootService"`
+ }
+
+ ChangeBootOrder_OUTPUT struct {
+ ReturnValue int `xml:"ReturnValue"`
+ }
+)
+
+type (
+ // An enumeration indicating the behavior when the attempt to boot using the boot source fails (no media, timeout). The current values in the enumeration are:
+ //
+ // 0 = Unknown
+ //
+ // 1 = Is Supported
+ //
+ // 2 = Is Not Supported.
+ //
+ // A value of 1 (Is Supported) indicates that next boot source the boot order is used.
+ // A value of 2 (Is Not Supported) indicates that the boot order is terminated and no other boot sources associated to the same CIM_BootConfigSetting are used).
+ // The default is 1 (Is Supported).
+ // In Intel (r) AMT the default value is 2 (Is Not Supported)
+ //
+ // ValueMap={0, 1, 2}
+ //
+ // Values={Unknown, Is Supported, Not Supported}
+ FailThroughSupported int
+ // Indicates the current statuses of the element. Various operational statuses are defined.
+ // Many of the enumeration's values are self-explanatory.
+ // However, a few are not and are described here in more detail.
+ //
+ // "Stressed" indicates that the element is functioning, but needs attention. Examples of "Stressed" states are overload, overheated, and so on.
+ //
+ // "Predictive Failure" indicates that an element is functioning nominally but predicting a failure in the near future.
+ //
+ // "In Service" describes an element being configured, maintained, cleaned, or otherwise administered.
+ //
+ // "No Contact" indicates that the monitoring system has knowledge of this element, but has never been able to establish communications with it.
+ //
+ // "Lost Communication" indicates that the ManagedSystem Element is known to exist and has been contacted successfully in the past, but is currently unreachable.
+ //
+ // "Stopped" and "Aborted" are similar, although the former implies a clean and orderly stop, while the latter implies an abrupt stop where the state and configuration of the element might need to be updated.
+ //
+ // "Dormant" indicates that the element is inactive or quiesced.
+ //
+ // "Supporting Entity in Error" indicates that this element might be "OK" but that another element, on which it is dependent, is in error. An example is a network service or endpoint that cannot function due to lower-layer networking problems.
+ //
+ // "Completed" indicates that the element has completed its operation. This value should be combined with either OK, Error, or Degraded so that a client can tell if the complete operation Completed with OK (passed), Completed with Error (failed), or Completed with Degraded (the operation finished, but it did not complete OK or did not report an error).
+ //
+ // "Power Mode" indicates that the element has additional power model information contained in the Associated PowerManagementService association.
+ //
+ // "Relocating" indicates the element is being relocated.
+ //
+ // OperationalStatus replaces the Status property on ManagedSystemElement to provide a consistent approach to enumerations, to address implementation needs for an array property, and to provide a migration path from today's environment to the future.
+ // This change was not made earlier because it required the deprecated qualifier.
+ // Due to the widespread use of the existing Status property in management applications, it is strongly recommended that providers or instrumentation provide both the Status and OperationalStatus properties.
+ // Further, the first value of OperationalStatus should contain the primary status for the element.
+ // When instrumented, Status (because it is single-valued) should also provide the primary status of the element.
+ //
+ // ValueMap={0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, .., 0x8000..}
+ //
+ // Values={Unknown, Other, OK, Degraded, Stressed, Predictive Failure, Error, Non-Recoverable Error, Starting, Stopping, Stopped, In Service, No Contact, Lost Communication, Aborted, Dormant, Supporting Entity in Error, Completed, Power Mode, Relocating, DMTF Reserved, Vendor Reserved}
+ OperationalStatus int
+ // EnabledState is an integer enumeration that indicates the enabled and disabled states of an element.
+ // It can also indicate the transitions between these requested states.
+ // For example, shutting down (value=4) and starting (value=10) are transient states between enabled and disabled.
+ // The following text briefly summarizes the various enabled and disabled states:
+ //
+ // Enabled (2) indicates that the element is or could be executing commands, will process any queued commands, and queues new requests.
+ //
+ // Disabled (3) indicates that the element will not execute commands and will drop any new requests.
+ //
+ // Shutting Down (4) indicates that the element is in the process of going to a Disabled state.
+ //
+ // Not Applicable (5) indicates the element does not support being enabled or disabled.
+ //
+ // Enabled but Offline (6) indicates that the element might be completing commands, and will drop any new requests.
+ //
+ // Test (7) indicates that the element is in a test state.
+ //
+ // Deferred (8) indicates that the element might be completing commands, but will queue any new requests.
+ //
+ // Quiesce (9) indicates that the element is enabled but in a restricted mode.
+ //
+ // Starting (10) indicates that the element is in the process of going to an Enabled state. New requests are queued.
+ //
+ // Values of 32768 and 32769 (relevant from Intel CSME 15 onwards) indicate whether the Intel® One-Click Recovery feature is enabled (32769) or disabled (32768).
+ // In Intel CSME 16 onwards, 32768 and 32769 have additional meaning, and 32771 and 32770 indicate whether Intel RPE is enabled or disabled.
+ // See Qualifiers below for details.
+ //
+ // Default: 32769 (Intel One-Click Recovery enabled, Intel RPE is disabled, and all other boot options are enabled.
+ // Note that Intel RPE is relevant from Intel CSME 16 onwards.)
+ //
+ // ValueMap={0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11..32767, 32768, 32769, 32770, 32771, 32772..65535}
+ //
+ // Values={ Unknown, Other, Enabled, Disabled, Shutting Down, Not Applicable, Enabled but Offline, In Test, Deferred, Quiesce, Starting, DMTF Reserved, Intel One-Click Recovery and Intel RPE are disabled and all other boot options are enabled, Intel One-Click Recovery is enabled and Intel RPE is disabled and all other boot options are enabled, Intel RPE is enabled and Intel One-Click Recovery is disabled and all other boot options are enabled, Intel One-Click Recovery and Intel RPE are enabled and all other boot options are enabled, Vendor Reserved }
+ EnabledState int
+ // RequestedState is an integer enumeration that indicates the last requested or desired state for the element, irrespective of the mechanism through which it was requested.
+ // The actual state of the element is represented by EnabledState.
+ // This property is provided to compare the last requested and current enabled or disabled states.
+ // Note that when EnabledState is set to 5 ("Not Applicable"), then this property has no meaning.
+ // Refer to the EnabledState property description for explanations of the values in the RequestedState enumeration.
+ //
+ // "Unknown" (0) indicates the last requested state for the element is unknown.
+ //
+ // Note that the value "No Change" (5) has been deprecated in lieu of indicating the last requested state is "Unknown" (0).
+ // If the last requested or desired state is unknown, RequestedState should have the value "Unknown" (0), but may have the value "No Change" (5).
+ // Offline (6) indicates that the element has been requested to transition to the Enabled but Offline EnabledState.
+ //
+ // It should be noted that there are two new values in RequestedState that build on the statuses of EnabledState. These are "Reboot" (10) and "Reset" (11). Reboot refers to doing a "Shut Down" and then moving to an "Enabled" state. Reset indicates that the element is first "Disabled" and then "Enabled". The distinction between requesting "Shut Down" and "Disabled" should also be noted. Shut Down requests an orderly transition to the Disabled state, and might involve removing power, to completely erase any existing state. The Disabled state requests an immediate disabling of the element, such that it will not execute or accept any commands or processing requests.
+ //
+ // This property is set as the result of a method invocation (such as Start or StopService on CIM_Service), or can be overridden and defined as WRITEable in a subclass.
+ // The method approach is considered superior to a WRITEable property, because it allows an explicit invocation of the operation and the return of a result code.
+ //
+ // If knowledge of the last RequestedState is not supported for the EnabledLogicalElement, the property shall be NULL or have the value 12 "Not Applicable".
+ //
+ // Values of 32768 and 32769 (relevant from Intel CSME 15 onwards) indicate whether the Intel® One-Click Recovery feature is enabled (32769) or disabled (32768). In Intel CSME 16 onwards, 32768 and 32769 have additional meaning, and 32771 and 32770 indicate whether Intel RPE is enabled or disabled. See Qualifiers below for details.
+ //
+ // Default: 32769 (Intel One-Click Recovery enabled, Intel RPE is disabled, and all other boot options are enabled.
+ // Note that Intel RPE is relevant from Intel CSME 16 onwards.)
+ //
+ // ValueMap={0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, .., 32768, 32769, 32770, 32771, 32772..65535 }
+ //
+ // Values={ Unknown, Enabled, Disabled, Shut Down, No Change, Offline, Test, Deferred, Quiesce, Reboot, Reset, Not Applicable, DMTF Reserved, Disable Intel One-Click Recovery and Intel RPE and enable all other boot options, disable Intel RPE and enable Intel One-Click Recovery and all other boot options, disable Intel One-Click Recovery and enable Intel RPE and all other boot options, Enable all boot options, Vendor Reserved }
+ RequestedState int
+)
diff --git a/pkg/wsman/cim/card/card.go b/pkg/wsman/cim/card/card.go
new file mode 100644
index 00000000..0521461e
--- /dev/null
+++ b/pkg/wsman/cim/card/card.go
@@ -0,0 +1,84 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+// Package card facilitates communication with Intel® AMT devices to represent a type of physical container that can be plugged into another Card or HostingBoard, or is itself a HostingBoard/Motherboard in a Chassis
+//
+// The CIM_Card class includes any package capable of carrying signals and providing a mounting point for PhysicalComponents, such as Chips, or other PhysicalPackages, such as other Cards.
+package card
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+)
+
+// NewCard returns a new instance of the Card struct.
+func NewCardWithClient(wsmanMessageCreator *message.WSManMessageCreator, client client.WSMan) Package {
+ return Package{
+ base: message.NewBaseWithClient(wsmanMessageCreator, CIM_Card, client),
+ client: client,
+ }
+}
+
+// Get retrieves the representation of the instance
+func (card Package) Get() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: card.base.Get(nil),
+ },
+ }
+
+ err = card.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+
+}
+
+// Enumerate returns an enumeration context which is used in a subsequent Pull call
+func (card Package) Enumerate() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: card.base.Enumerate(),
+ },
+ }
+
+ err = card.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+
+}
+
+// Pull returns the instances of this class. An enumeration context provided by the Enumerate call is used as input.
+func (card Package) Pull(enumerationContext string) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: card.base.Pull(enumerationContext),
+ },
+ }
+ err = card.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
diff --git a/pkg/wsman/cim/card/card_test.go b/pkg/wsman/cim/card/card_test.go
new file mode 100644
index 00000000..19305db6
--- /dev/null
+++ b/pkg/wsman/cim/card/card_test.go
@@ -0,0 +1,234 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package card
+
+import (
+ "encoding/xml"
+ "testing"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
+ "github.com/stretchr/testify/assert"
+)
+
+func TestPositiveCIMCard(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "cim/card",
+ }
+ elementUnderTest := NewCardWithClient(wsmanMessageCreator, &client)
+
+ t.Run("cim_Card Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create a valid cim_Card Get wsman message",
+ CIM_Card,
+ wsmantesting.GET,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Get"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PackageResponse: PackageResponse{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_Card", Local: "CIM_Card"},
+ CanBeFRUed: true,
+ CreationClassName: "CIM_Card",
+ ElementName: "Managed System Base Board",
+ Manufacturer: "Intel Corporation",
+ Model: "NUC9V7QNB",
+ OperationalStatus: 0,
+ PackageType: 9,
+ SerialNumber: "KNQN0221020W",
+ Tag: "CIM_Card",
+ Version: "K47180-402",
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create a valid cim_Card Enumerate wsman message",
+ CIM_Card,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Enumerate"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "CF020000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid cim_Card Pull wsman message",
+ CIM_Card,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Pull"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ CardItems: []PackageResponse{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_Card", Local: "CIM_Card"},
+ CanBeFRUed: true,
+ CreationClassName: "CIM_Card",
+ ElementName: "Managed System Base Board",
+ Manufacturer: "Intel Corporation",
+ Model: "NUC9V7QNB",
+ OperationalStatus: 0,
+ PackageType: 9,
+ SerialNumber: "KNQN0221020W",
+ Tag: "CIM_Card",
+ Version: "K47180-402",
+ },
+ },
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.NoError(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.Equal(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
+
+func TestNegativeCIMCard(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "cim/card",
+ }
+ elementUnderTest := NewCardWithClient(wsmanMessageCreator, &client)
+
+ t.Run("cim_Card* Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create a valid cim_Card Get wsman message",
+ CIM_Card,
+ wsmantesting.GET,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PackageResponse: PackageResponse{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_Card", Local: "CIM_Card"},
+ CanBeFRUed: true,
+ CreationClassName: "CIM_Card",
+ ElementName: "Managed System Base Board",
+ Manufacturer: "Intel Corporation",
+ Model: "NUC9V7QNB",
+ OperationalStatus: 0,
+ PackageType: 9,
+ SerialNumber: "KNQN0221020W",
+ Tag: "CIM_Card",
+ Version: "K47180-402",
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create a valid cim_Card Enumerate wsman message",
+ CIM_Card,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "CF020000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid cim_Card Pull wsman message",
+ CIM_Card,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ CardItems: []PackageResponse{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_Card", Local: "CIM_Card"},
+ CanBeFRUed: true,
+ CreationClassName: "CIM_Card",
+ ElementName: "Managed System Base Board",
+ Manufacturer: "Intel Corporation",
+ Model: "NUC9V7QNB",
+ OperationalStatus: 0,
+ PackageType: 9,
+ SerialNumber: "KNQN0221020W",
+ Tag: "CIM_Card",
+ Version: "K47180-402",
+ },
+ },
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.Error(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.NotEqual(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
diff --git a/pkg/wsman/cim/card/constants.go b/pkg/wsman/cim/card/constants.go
new file mode 100644
index 00000000..6dc03031
--- /dev/null
+++ b/pkg/wsman/cim/card/constants.go
@@ -0,0 +1,52 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package card
+
+const CIM_Card string = "CIM_Card"
+
+const (
+ OperationalStatusUnknown OperationalStatus = iota
+ OperationalStatusOther
+ OperationalStatusOK
+ OperationalStatusDegraded
+ OperationalStatusStressed
+ OperationalStatusPredictiveFailure
+ OperationalStatusError
+ OperationalStatusNonRecoverableError
+ OperationalStatusStarting
+ OperationalStatusStopping
+ OperationalStatusStopped
+ OperationalStatusInService
+ OperationalStatusNoContact
+ OperationalStatusLostCommunication
+ OperationalStatusAborted
+ OperationalStatusDormant
+ OperationalStatusSupportingEntityinError
+ OperationalStatusCompleted
+ OperationalStatusPowerMode
+ OperationalStatusRelocating
+)
+
+const (
+ PackageTypeUnknown PackageType = iota
+ PackageTypeOther
+ PackageTypeRack
+ PackageTypeChassisFrame
+ PackageTypeCrossConnectBackplane
+ PackageTypeContainerFrameSlot
+ PackageTypePowerSupply
+ PackageTypeFan
+ PackageTypeSensor
+ PackageTypeModuleCard
+ PackageTypePortConnector
+ PackageTypeBattery
+ PackageTypeProcessor
+ PackageTypeMemory
+ PackageTypePowerSourceGenerator
+ PackageTypeStorageMediaPackage
+ PackageTypeBlade
+ PackageTypeBladeExpansion
+)
diff --git a/pkg/wsman/cim/card/marshal.go b/pkg/wsman/cim/card/marshal.go
new file mode 100644
index 00000000..17abd662
--- /dev/null
+++ b/pkg/wsman/cim/card/marshal.go
@@ -0,0 +1,30 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package card
+
+import (
+ "encoding/json"
+
+ "gopkg.in/yaml.v3"
+)
+
+// JSON marshals the type into JSON format
+func (r *Response) JSON() string {
+ jsonOutput, err := json.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(jsonOutput)
+}
+
+// YAML marshals the type into YAML format
+func (r *Response) YAML() string {
+ yamlOutput, err := yaml.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(yamlOutput)
+}
diff --git a/pkg/wsman/cim/card/types.go b/pkg/wsman/cim/card/types.go
new file mode 100644
index 00000000..205e33ab
--- /dev/null
+++ b/pkg/wsman/cim/card/types.go
@@ -0,0 +1,104 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package card
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+)
+
+type Package struct {
+ base message.Base
+ client client.WSMan
+}
+
+// Response Types
+type (
+ Response struct {
+ *client.Message
+ XMLName xml.Name `xml:"Envelope"`
+ Header message.Header `xml:"Header"`
+ Body Body `xml:"Body"`
+ }
+
+ Body struct {
+ XMLName xml.Name `xml:"Body"`
+ PullResponse PullResponse
+ EnumerateResponse common.EnumerateResponse
+ PackageResponse PackageResponse
+ }
+
+ PullResponse struct {
+ XMLName xml.Name `xml:"PullResponse"`
+ CardItems []PackageResponse `xml:"Items>CIM_Card"`
+ }
+
+ PackageResponse struct {
+ XMLName xml.Name `xml:"CIM_Card"`
+ CanBeFRUed bool `xml:"CanBeFRUed"` // Boolean that indicates whether this PhysicalElement can be FRUed (TRUE) or not (FALSE).
+ CreationClassName string `xml:"CreationClassName"` // CreationClassName indicates the name of the class or the subclass used in the creation of an instance.
+ ElementName string `xml:"ElementName"`
+ Manufacturer string `xml:"Manufacturer"` // The name of the organization responsible for producing the PhysicalElement.
+ Model string `xml:"Model"` // The name by which the PhysicalElement is generally known.
+ OperationalStatus OperationalStatus `xml:"OperationalStatus"` // Indicates the current statuses of the element
+ PackageType PackageType `xml:"PackageType"` // Enumeration defining the type of the PhysicalPackage. Note that this enumeration expands on the list in the Entity MIB (the attribute, entPhysicalClass). The numeric values are consistent with CIM's enum numbering guidelines, but are slightly different than the MIB's values.
+ SerialNumber string `xml:"SerialNumber"` // A manufacturer-allocated number used to identify the Physical Element.
+ Tag string `xml:"Tag"` // An arbitrary string that uniquely identifies the Physical Element and serves as the key of the Element.
+ Version string `xml:"Version"` // A string that indicates the version of the PhysicalElement.
+ }
+)
+
+// Indicates the current statuses of the element. Various operational statuses are defined. Many of the enumeration's values are self-explanatory. However, a few are not and are described here in more detail:
+//
+// - "Stressed" indicates that the element is functioning, but needs attention. Examples of "Stressed" states are overload, overheated, and so on.
+//
+// - "Predictive Failure" indicates that an element is functioning nominally but predicting a failure in the near future.
+//
+// - "In Service" describes an element being configured, maintained, cleaned, or otherwise administered.
+//
+// - "No Contact" indicates that the monitoring system has knowledge of this element, but has never been able to establish communications with it.
+//
+// - "Lost Communication" indicates that the ManagedSystem Element is known to exist and has been contacted successfully in the past, but is currently unreachable.
+//
+// - "Stopped" and "Aborted" are similar, although the former implies a clean and orderly stop, while the latter implies an abrupt stop where the state and configuration of the element might need to be updated.
+//
+// - "Dormant" indicates that the element is inactive or quiesced.
+//
+// - "Supporting Entity in Error" indicates that this element might be "OK" but that another element, on which it is dependent, is in error. An example is a network service or endpoint that cannot function due to lower-layer networking problems.
+//
+// - "Completed" indicates that the element has completed its operation. This value should be combined with either OK, Error, or Degraded so that a client can tell if the complete operation Completed with OK (passed), Completed with Error (failed), or Completed with Degraded (the operation finished, but it did not complete OK or did not report an error).
+//
+// - "Power Mode" indicates that the element has additional power model information contained in the Associated PowerManagementService association.
+//
+// - "Relocating" indicates the element is being relocated.
+//
+// OperationalStatus replaces the Status property on ManagedSystemElement to provide a consistent approach to enumerations, to address implementation needs for an array property, and to provide a migration path from today's environment to the future. This change was not made earlier because it required the deprecated qualifier. Due to the widespread use of the existing Status property in management applications, it is strongly recommended that providers or instrumentation provide both the Status and OperationalStatus properties. Further, the first value of OperationalStatus should contain the primary status for the element. When instrumented, Status (because it is single-valued) should also provide the primary status of the element.
+//
+// ValueMap={0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, .., 0x8000..}
+//
+// Values={Unknown, Other, OK, Degraded, Stressed, Predictive Failure, Error, Non-Recoverable Error, Starting, Stopping, Stopped, In Service, No Contact, Lost Communication, Aborted, Dormant, Supporting Entity in Error, Completed, Power Mode, Relocating, DMTF Reserved, Vendor Reserved}
+type OperationalStatus int
+
+// Enumeration defining the type of the PhysicalPackage. Note that this enumeration expands on the list in the Entity MIB (the attribute, entPhysicalClass). The numeric values are consistent with CIM's enum numbering guidelines, but are slightly different than the MIB's values.
+//
+// Unknown - indicates that the package type is not known.
+//
+// Other - The package type does not correspond to an existing enumerated value. The value is specified using the OtherPackageType property.
+//
+// - "Rack" through "Port/Connector" are defined per the Entity-MIB (where the semantics of rack are equivalent to the MIB's 'stack' value). The other values (for battery, processor, memory, power source/generator and storage media package) are self-explanatory.
+//
+// - "Blade" should be used when the PhysicalPackage contains the operational hardware aspects of a ComputerSystem, without the supporting mechanicals such as power and cooling. For example, a Blade Server includes processor(s) and memory, and relies on the containing chassis to supply power and cooling. In many respects, a Blade can be considered a "Module/Card". However, it is tracked differently by inventory systems and differs in terms of service philosophy. For example, a Blade is intended to be hot-plugged into a hosting enclosure without requiring additional cabling, and does not require a cover to be removed from the enclosure for installation.
+//
+// - "Blade Expansion" has characteristics of a "Blade" and a "Module/Card". However, it is distinct from both due to inventory tracking and service philosophy, and because of its hardware dependence on a Blade. A Blade Expansion must be attached to a Blade prior to inserting the resultant assembly into an enclosure.
+//
+// ValueMap={0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}
+//
+// Values={Unknown, Other, Rack, Chassis/Frame, Cross Connect/Backplane, Container/Frame Slot, Power Supply, Fan, Sensor, Module/Card, Port/Connector, Battery, Processor, Memory, Power Source/Generator, Storage Media Package (e.g., Disk or Tape Drive), Blade, Blade Expansion}
+
+type PackageType int
diff --git a/pkg/wsman/cim/chassis/chassis.go b/pkg/wsman/cim/chassis/chassis.go
new file mode 100644
index 00000000..cccd1439
--- /dev/null
+++ b/pkg/wsman/cim/chassis/chassis.go
@@ -0,0 +1,82 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+// Package card facilitates communication with Intel® AMT devices to represent the PhysicalElements that enclose other Elements and provide definable functionality, such as a desktop, processing node, UPS, disk or tape storage, or a combination of these.
+package chassis
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+)
+
+// NewChassis returns a new instance of the Chassis struct.
+func NewChassisWithClient(wsmanMessageCreator *message.WSManMessageCreator, client client.WSMan) Package {
+ return Package{
+ base: message.NewBaseWithClient(wsmanMessageCreator, CIM_Chassis, client),
+ client: client,
+ }
+}
+
+// Get retrieves the representation of the instance
+func (chassis Package) Get() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: chassis.base.Get(nil),
+ },
+ }
+
+ err = chassis.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+
+}
+
+// Enumerate returns an enumeration context which is used in a subsequent Pull call
+func (chassis Package) Enumerate() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: chassis.base.Enumerate(),
+ },
+ }
+
+ err = chassis.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+
+}
+
+// Pull returns the instances of this class. An enumeration context provided by the Enumerate call is used as input.
+func (chassis Package) Pull(enumerationContext string) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: chassis.base.Pull(enumerationContext),
+ },
+ }
+ err = chassis.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
diff --git a/pkg/wsman/cim/chassis/chassis_test.go b/pkg/wsman/cim/chassis/chassis_test.go
new file mode 100644
index 00000000..6859647d
--- /dev/null
+++ b/pkg/wsman/cim/chassis/chassis_test.go
@@ -0,0 +1,231 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package chassis
+
+import (
+ "encoding/xml"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
+)
+
+func TestPositiveCIMChassis(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "cim/chassis",
+ }
+ elementUnderTest := NewChassisWithClient(wsmanMessageCreator, &client)
+
+ t.Run("cim_* Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create and parse a valid cim_Chassis Get call",
+ CIM_Chassis,
+ wsmantesting.GET,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Get"
+ return elementUnderTest.Get()
+ }, Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PackageResponse: PackageResponse{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_Chassis", Local: "CIM_Chassis"},
+ ChassisPackageType: 0,
+ CreationClassName: "CIM_Chassis",
+ ElementName: "Managed System Chassis",
+ Manufacturer: "Intel(R) Client Systems",
+ Model: "NUC9V7QNX",
+ OperationalStatus: 0,
+ PackageType: 3,
+ SerialNumber: "JRQN0243007J",
+ Tag: "CIM_Chassis",
+ Version: "K47174-402",
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create and parse a valid cim_Chassis Enumerate call",
+ CIM_Chassis,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Enumerate"
+ return elementUnderTest.Enumerate()
+ }, Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "D1020000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create and parse a valid cim_Chassis Pull call",
+ CIM_Chassis,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Pull"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ PackageItems: []PackageResponse{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_Chassis", Local: "CIM_Chassis"},
+ ChassisPackageType: 0,
+ CreationClassName: "CIM_Chassis",
+ ElementName: "Managed System Chassis",
+ Manufacturer: "Intel(R) Client Systems",
+ Model: "NUC9V7QNX",
+ OperationalStatus: 0,
+ PackageType: 3,
+ SerialNumber: "JRQN0243007J",
+ Tag: "CIM_Chassis",
+ Version: "K47174-402",
+ },
+ },
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.NoError(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.Equal(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
+
+func TestNegativeCIMChassis(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "cim/chassis",
+ }
+ elementUnderTest := NewChassisWithClient(wsmanMessageCreator, &client)
+
+ t.Run("cim_Chassis Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create and parse a valid cim_Chassis Get call",
+ CIM_Chassis,
+ wsmantesting.GET,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Get()
+ }, Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PackageResponse: PackageResponse{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_Chassis", Local: "CIM_Chassis"},
+ ChassisPackageType: 0,
+ CreationClassName: "CIM_Chassis",
+ ElementName: "Managed System Chassis",
+ Manufacturer: "Intel(R) Client Systems",
+ Model: "NUC9V7QNX",
+ OperationalStatus: 0,
+ PackageType: 3,
+ SerialNumber: "JRQN0243007J",
+ Tag: "CIM_Chassis",
+ Version: "K47174-402",
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create and parse a valid cim_Chassis Enumerate call",
+ CIM_Chassis,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Enumerate()
+ }, Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "D1020000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create and parse a valid cim_Chassis Pull call",
+ CIM_Chassis,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ PackageItems: []PackageResponse{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_Chassis", Local: "CIM_Chassis"},
+ ChassisPackageType: 0,
+ CreationClassName: "CIM_Chassis",
+ ElementName: "Managed System Chassis",
+ Manufacturer: "Intel(R) Client Systems",
+ Model: "NUC9V7QNX",
+ OperationalStatus: 0,
+ PackageType: 3,
+ SerialNumber: "JRQN0243007J",
+ Tag: "CIM_Chassis",
+ Version: "K47174-402",
+ },
+ },
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.Error(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.NotEqual(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
diff --git a/pkg/wsman/cim/chassis/constants.go b/pkg/wsman/cim/chassis/constants.go
new file mode 100644
index 00000000..9b0f5bd6
--- /dev/null
+++ b/pkg/wsman/cim/chassis/constants.go
@@ -0,0 +1,91 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package chassis
+
+const CIM_Chassis string = "CIM_Chassis"
+
+const (
+ OperationalStatusUnknown OperationalStatus = iota
+ OperationalStatusOther
+ OperationalStatusOK
+ OperationalStatusDegraded
+ OperationalStatusStressed
+ OperationalStatusPredictiveFailure
+ OperationalStatusError
+ OperationalStatusNonRecoverableError
+ OperationalStatusStarting
+ OperationalStatusStopping
+ OperationalStatusStopped
+ OperationalStatusInService
+ OperationalStatusNoContact
+ OperationalStatusLostCommunication
+ OperationalStatusAborted
+ OperationalStatusDormant
+ OperationalStatusSupportingEntityinError
+ OperationalStatusCompleted
+ OperationalStatusPowerMode
+ OperationalStatusRelocating
+)
+
+const (
+ PackageTypeUnknown PackageType = iota
+ PackageTypeOther
+ PackageTypeRack
+ PackageTypeChassisFrame
+ PackageTypeCrossConnectBackplane
+ PackageTypeContainerFrameSlot
+ PackageTypePowerSupply
+ PackageTypeFan
+ PackageTypeSensor
+ PackageTypeModuleCard
+ PackageTypePortConnector
+ PackageTypeBattery
+ PackageTypeProcessor
+ PackageTypeMemory
+ PackageTypePowerSourceGenerator
+ PackageTypeStorageMediaPackage
+ PackageTypeBlade
+ PackageTypeBladeExpansion
+)
+
+const (
+ ChassisPackageTypeUnknown ChassisPackageType = iota
+ ChassisPackageTypeOther
+ ChassisPackageTypeSMBIOSReserved
+ ChassisPackageTypeDesktop
+ ChassisPackageTypeLowProfileDesktop
+ ChassisPackageTypePizzaBox
+ ChassisPackageTypeMiniTower
+ ChassisPackageTypeTower
+ ChassisPackageTypePortable
+ ChassisPackageTypeLapTop
+ ChassisPackageTypeNotebook
+ ChassisPackageTypeHandHeld
+ ChassisPackageTypeDockingStation
+ ChassisPackageTypeAllinOne
+ ChassisPackageTypeSubNotebook
+ ChassisPackageTypeSpaceSaving
+ ChassisPackageTypeLunchBox
+ ChassisPackageTypeMainSystemChassis
+ ChassisPackageTypeExpansionChassis
+ ChassisPackageTypeSubChassis
+ ChassisPackageTypeBusExpansionChassis
+ ChassisPackageTypePeripheralChassis
+ ChassisPackageTypeStorageChassis
+ ChassisPackageTypeSealedCasePC
+ ChassisPackageTypeCompactPCI
+ ChassisPackageTypeAdvancedTCA
+ ChassisPackageTypeBladeEnclosure
+ ChassisPackageTypeTablet
+ ChassisPackageTypeConvertible
+ ChassisPackageTypeDetachable
+ ChassisPackageTypeIoTGateway
+ ChassisPackageTypeEmbeddedPC
+ ChassisPackageTypeMiniPC
+ ChassisPackageTypeStickPC
+ ChassisPackageTypeDMTFReserved
+ ChassisPackageTypeVendorReserved
+)
diff --git a/pkg/wsman/cim/chassis/marshal.go b/pkg/wsman/cim/chassis/marshal.go
new file mode 100644
index 00000000..c8655196
--- /dev/null
+++ b/pkg/wsman/cim/chassis/marshal.go
@@ -0,0 +1,30 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package chassis
+
+import (
+ "encoding/json"
+
+ "gopkg.in/yaml.v3"
+)
+
+// JSON marshals the type into JSON format
+func (r *Response) JSON() string {
+ jsonOutput, err := json.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(jsonOutput)
+}
+
+// YAML marshals the type into YAML format
+func (r *Response) YAML() string {
+ yamlOutput, err := yaml.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(yamlOutput)
+}
diff --git a/pkg/wsman/cim/chassis/types.go b/pkg/wsman/cim/chassis/types.go
new file mode 100644
index 00000000..136c58d2
--- /dev/null
+++ b/pkg/wsman/cim/chassis/types.go
@@ -0,0 +1,114 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package chassis
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+)
+
+type Package struct {
+ base message.Base
+ client client.WSMan
+}
+
+type (
+ Response struct {
+ *client.Message
+ XMLName xml.Name `xml:"Envelope"`
+ Header message.Header `xml:"Header"`
+ Body Body `xml:"Body"`
+ }
+
+ Body struct {
+ XMLName xml.Name `xml:"Body"`
+ PullResponse PullResponse
+ EnumerateResponse common.EnumerateResponse
+ PackageResponse PackageResponse
+ }
+
+ PullResponse struct {
+ XMLName xml.Name `xml:"PullResponse"`
+ PackageItems []PackageResponse `xml:"Items>CIM_Chassis"`
+ }
+
+ PackageResponse struct {
+ XMLName xml.Name `xml:"CIM_Chassis"`
+ Version string `xml:"Version"` // A string that indicates the version of the PhysicalElement.
+ SerialNumber string `xml:"SerialNumber"` // A manufacturer-allocated number used to identify the Physical Element.
+ Model string `xml:"Model"` // The name by which the PhysicalElement is generally known.
+ Manufacturer string `xml:"Manufacturer"` // The name of the organization responsible for producing the PhysicalElement. This organization might be the entity from whom the Element is purchased, but this is not necessarily true. The latter information is contained in the Vendor property of CIM_Product.
+ ElementName string `xml:"ElementName"`
+ CreationClassName string `xml:"CreationClassName"` // CreationClassName indicates the name of the class or the subclass used in the creation of an instance. When used with the other key properties of this class, this property allows all instances of this class and its subclasses to be uniquely identified.
+ Tag string `xml:"Tag"` // An arbitrary string that uniquely identifies the Physical Element and serves as the key of the Element. The Tag property can contain information such as asset tag or serial number data. The key for PhysicalElement is placed very high in the object hierarchy in order to independently identify the hardware or entity, regardless of physical placement in or on Cabinets, Adapters, and so on. For example, a hotswappable or removable component can be taken from its containing (scoping) Package and be temporarily unused. The object still continues to exist and can even be inserted into a different scoping container. Therefore, the key for Physical Element is an arbitrary string and is defined independently of any placement or location-oriented hierarchy.
+ OperationalStatus OperationalStatus `xml:"OperationalStatus"` // Indicates the current statuses of the element.
+ PackageType PackageType `xml:"PackageType"` // Enumeration defining the type of the PhysicalPackage. Note that this enumeration expands on the list in the Entity MIB (the attribute, entPhysicalClass). The numeric values are consistent with CIM's enum numbering guidelines, but are slightly different than the MIB's values.
+ ChassisPackageType ChassisPackageType `xml:"ChassisPackageType"` // ChassisPackageType indicates the physical form factor for the type of Chassis.
+ }
+)
+
+// Indicates the current statuses of the element. Various operational statuses are defined. Many of the enumeration's values are self-explanatory. However, a few are not and are described here in more detail:
+//
+// - "Stressed" indicates that the element is functioning, but needs attention. Examples of "Stressed" states are overload, overheated, and so on.
+//
+// - "Predictive Failure" indicates that an element is functioning nominally but predicting a failure in the near future.
+//
+// - "In Service" describes an element being configured, maintained, cleaned, or otherwise administered.
+//
+// - "No Contact" indicates that the monitoring system has knowledge of this element, but has never been able to establish communications with it.
+//
+// - "Lost Communication" indicates that the ManagedSystem Element is known to exist and has been contacted successfully in the past, but is currently unreachable.
+//
+// - "Stopped" and "Aborted" are similar, although the former implies a clean and orderly stop, while the latter implies an abrupt stop where the state and configuration of the element might need to be updated.
+//
+// - "Dormant" indicates that the element is inactive or quiesced.
+//
+// - "Supporting Entity in Error" indicates that this element might be "OK" but that another element, on which it is dependent, is in error. An example is a network service or endpoint that cannot function due to lower-layer networking problems.
+//
+// - "Completed" indicates that the element has completed its operation. This value should be combined with either OK, Error, or Degraded so that a client can tell if the complete operation Completed with OK (passed), Completed with Error (failed), or Completed with Degraded (the operation finished, but it did not complete OK or did not report an error).
+//
+// - "Power Mode" indicates that the element has additional power model information contained in the Associated PowerManagementService association.
+//
+// - "Relocating" indicates the element is being relocated.
+//
+// OperationalStatus replaces the Status property on ManagedSystemElement to provide a consistent approach to enumerations, to address implementation needs for an array property, and to provide a migration path from today's environment to the future. This change was not made earlier because it required the deprecated qualifier. Due to the widespread use of the existing Status property in management applications, it is strongly recommended that providers or instrumentation provide both the Status and OperationalStatus properties. Further, the first value of OperationalStatus should contain the primary status for the element. When instrumented, Status (because it is single-valued) should also provide the primary status of the element.
+//
+// ValueMap={0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, .., 0x8000..}
+//
+// Values={Unknown, Other, OK, Degraded, Stressed, Predictive Failure, Error, Non-Recoverable Error, Starting, Stopping, Stopped, In Service, No Contact, Lost Communication, Aborted, Dormant, Supporting Entity in Error, Completed, Power Mode, Relocating, DMTF Reserved, Vendor Reserved}
+type OperationalStatus int
+
+// Enumeration defining the type of the PhysicalPackage. Note that this enumeration expands on the list in the Entity MIB (the attribute, entPhysicalClass). The numeric values are consistent with CIM's enum numbering guidelines, but are slightly different than the MIB's values.
+//
+// Unknown - indicates that the package type is not known.
+//
+// Other - The package type does not correspond to an existing enumerated value. The value is specified using the OtherPackageType property.
+//
+// - "Rack" through "Port/Connector" are defined per the Entity-MIB (where the semantics of rack are equivalent to the MIB's 'stack' value). The other values (for battery, processor, memory, power source/generator and storage media package) are self-explanatory.
+//
+// - "Blade" should be used when the PhysicalPackage contains the operational hardware aspects of a ComputerSystem, without the supporting mechanicals such as power and cooling. For example, a Blade Server includes processor(s) and memory, and relies on the containing chassis to supply power and cooling. In many respects, a Blade can be considered a "Module/Card". However, it is tracked differently by inventory systems and differs in terms of service philosophy. For example, a Blade is intended to be hot-plugged into a hosting enclosure without requiring additional cabling, and does not require a cover to be removed from the enclosure for installation.
+//
+// - "Blade Expansion" has characteristics of a "Blade" and a "Module/Card". However, it is distinct from both due to inventory tracking and service philosophy, and because of its hardware dependence on a Blade. A Blade Expansion must be attached to a Blade prior to inserting the resultant assembly into an enclosure.
+//
+// ValueMap={0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}
+//
+// Values={Unknown, Other, Rack, Chassis/Frame, Cross Connect/Backplane, Container/Frame Slot, Power Supply, Fan, Sensor, Module/Card, Port/Connector, Battery, Processor, Memory, Power Source/Generator, Storage Media Package (e.g., Disk or Tape Drive), Blade, Blade Expansion}
+
+type PackageType int
+
+// ChassisPackageType indicates the physical form factor for the type of Chassis.
+//
+// This property may have a value when the PackageType property contains the value 3 "Chassis Frame".
+//
+// A value of 28 "Blade Enclosure" shall indicate the Chassis is designed to contain one or more PhysicalPackage(s) of PackageType 16 "Blade" or PackageType 17 "Blade Expansion".
+//
+// ValueMap={0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, .., 0x8000..0xFFFF}
+//
+// Values={Unknown, Other, SMBIOS Reserved, Desktop, Low Profile Desktop, Pizza Box, Mini Tower, Tower, Portable, LapTop, Notebook, Hand Held, Docking Station, All in One, Sub Notebook, Space-Saving, Lunch Box, Main System Chassis, Expansion Chassis, SubChassis, Bus Expansion Chassis, Peripheral Chassis, Storage Chassis, SMBIOS Reserved, Sealed-Case PC, SMBIOS Reserved, CompactPCI, AdvancedTCA, Blade Enclosure, SMBIOS Reserved, Tablet, Convertible, Detachable, IoT Gateway, Embedded PC, Mini PC, Stick PC, DMTF Reserved, Vendor Reserved}
+type ChassisPackageType int
diff --git a/pkg/wsman/cim/chip/chip.go b/pkg/wsman/cim/chip/chip.go
new file mode 100644
index 00000000..eda1e75b
--- /dev/null
+++ b/pkg/wsman/cim/chip/chip.go
@@ -0,0 +1,82 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+// Package chip facilitates communication with Intel® AMT devices to represent any type of integrated circuit hardware, including ASICs, processors, memory chips, etc.
+package chip
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+)
+
+// NewChip returns a new instance of the Chip struct.
+func NewChipWithClient(wsmanMessageCreator *message.WSManMessageCreator, client client.WSMan) Package {
+ return Package{
+ base: message.NewBaseWithClient(wsmanMessageCreator, CIM_Chip, client),
+ client: client,
+ }
+}
+
+// Get retrieves the representation of the instance
+func (chip Package) Get() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: chip.base.Get(nil),
+ },
+ }
+
+ err = chip.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+
+}
+
+// Enumerate returns an enumeration context which is used in a subsequent Pull call
+func (chip Package) Enumerate() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: chip.base.Enumerate(),
+ },
+ }
+
+ err = chip.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+
+}
+
+// Pull returns the instances of this class. An enumeration context provided by the Enumerate call is used as input.
+func (chip Package) Pull(enumerationContext string) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: chip.base.Pull(enumerationContext),
+ },
+ }
+ err = chip.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
diff --git a/pkg/wsman/cim/chip/chip_test.go b/pkg/wsman/cim/chip/chip_test.go
new file mode 100644
index 00000000..33de7eeb
--- /dev/null
+++ b/pkg/wsman/cim/chip/chip_test.go
@@ -0,0 +1,212 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package chip
+
+import (
+ "encoding/xml"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
+)
+
+func TestPositiveCIMChip(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "cim/chip",
+ }
+ elementUnderTest := NewChipWithClient(wsmanMessageCreator, &client)
+
+ t.Run("cim_Chip Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create and parse a valid cim_Chip Get call",
+ CIM_Chip, wsmantesting.GET,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Get"
+ return elementUnderTest.Get()
+ }, Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PackageResponse: PackageResponse{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_Chip", Local: "CIM_Chip"},
+ CanBeFRUed: true,
+ CreationClassName: "CIM_Chip",
+ ElementName: "Managed System Processor Chip",
+ Manufacturer: "Intel(R) Corporation",
+ OperationalStatus: 0,
+ Tag: "CPU 0",
+ Version: "Intel(R) Core(TM) i7-9850H CPU @ 2.60GHz",
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create and parse a valid cim_Chip Enumerate call",
+ CIM_Chip, wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Enumerate"
+ return elementUnderTest.Enumerate()
+ }, Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "D3020000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create and parse a valid cim_Chip Pull call",
+ CIM_Chip, wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Pull"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ ChipItems: []PackageResponse{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_Chip", Local: "CIM_Chip"},
+ CanBeFRUed: true,
+ CreationClassName: "CIM_Chip",
+ ElementName: "Managed System Processor Chip",
+ Manufacturer: "Intel(R) Corporation",
+ OperationalStatus: 0,
+ Tag: "CPU 0",
+ Version: "Intel(R) Core(TM) i7-9850H CPU @ 2.60GHz",
+ },
+ },
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.NoError(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.Equal(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
+func TestNegativeCIMChip(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "cim/chip",
+ }
+ elementUnderTest := NewChipWithClient(wsmanMessageCreator, &client)
+
+ t.Run("cim_Chip Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create and parse a valid cim_Chip Get call",
+ CIM_Chip, wsmantesting.GET,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Get()
+ }, Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PackageResponse: PackageResponse{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_Chip", Local: "CIM_Chip"},
+ CanBeFRUed: true,
+ CreationClassName: "CIM_Chip",
+ ElementName: "Managed System Processor Chip",
+ Manufacturer: "Intel(R) Corporation",
+ OperationalStatus: 0,
+ Tag: "CPU 0",
+ Version: "Intel(R) Core(TM) i7-9850H CPU @ 2.60GHz",
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create and parse a valid cim_Chip Enumerate call",
+ CIM_Chip, wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Enumerate()
+ }, Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "D3020000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create and parse a valid cim_Chip Pull call",
+ CIM_Chip, wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ ChipItems: []PackageResponse{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_Chip", Local: "CIM_Chip"},
+ CanBeFRUed: true,
+ CreationClassName: "CIM_Chip",
+ ElementName: "Managed System Processor Chip",
+ Manufacturer: "Intel(R) Corporation",
+ OperationalStatus: 0,
+ Tag: "CPU 0",
+ Version: "Intel(R) Core(TM) i7-9850H CPU @ 2.60GHz",
+ },
+ },
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.Error(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.NotEqual(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
diff --git a/pkg/wsman/cim/chip/constants.go b/pkg/wsman/cim/chip/constants.go
new file mode 100644
index 00000000..55c89944
--- /dev/null
+++ b/pkg/wsman/cim/chip/constants.go
@@ -0,0 +1,31 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package chip
+
+const CIM_Chip string = "CIM_Chip"
+
+const (
+ OperationalStatusUnknown OperationalStatus = iota
+ OperationalStatusOther
+ OperationalStatusOK
+ OperationalStatusDegraded
+ OperationalStatusStressed
+ OperationalStatusPredictiveFailure
+ OperationalStatusError
+ OperationalStatusNonRecoverableError
+ OperationalStatusStarting
+ OperationalStatusStopping
+ OperationalStatusStopped
+ OperationalStatusInService
+ OperationalStatusNoContact
+ OperationalStatusLostCommunication
+ OperationalStatusAborted
+ OperationalStatusDormant
+ OperationalStatusSupportingEntityinError
+ OperationalStatusCompleted
+ OperationalStatusPowerMode
+ OperationalStatusRelocating
+)
diff --git a/pkg/wsman/cim/chip/marshal.go b/pkg/wsman/cim/chip/marshal.go
new file mode 100644
index 00000000..73b3c50a
--- /dev/null
+++ b/pkg/wsman/cim/chip/marshal.go
@@ -0,0 +1,30 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package chip
+
+import (
+ "encoding/json"
+
+ "gopkg.in/yaml.v3"
+)
+
+// JSON marshals the type into JSON format
+func (r *Response) JSON() string {
+ jsonOutput, err := json.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(jsonOutput)
+}
+
+// YAML marshals the type into YAML format
+func (r *Response) YAML() string {
+ yamlOutput, err := yaml.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(yamlOutput)
+}
diff --git a/pkg/wsman/cim/chip/types.go b/pkg/wsman/cim/chip/types.go
new file mode 100644
index 00000000..4e18f28c
--- /dev/null
+++ b/pkg/wsman/cim/chip/types.go
@@ -0,0 +1,83 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package chip
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+)
+
+type Package struct {
+ base message.Base
+ client client.WSMan
+}
+
+// Response Types
+type (
+ Response struct {
+ *client.Message
+ XMLName xml.Name `xml:"Envelope"`
+ Header message.Header `xml:"Header"`
+ Body Body `xml:"Body"`
+ }
+
+ Body struct {
+ XMLName xml.Name `xml:"Body"`
+ PullResponse PullResponse
+ EnumerateResponse common.EnumerateResponse
+ PackageResponse PackageResponse
+ }
+
+ PullResponse struct {
+ XMLName xml.Name `xml:"PullResponse"`
+ ChipItems []PackageResponse `xml:"Items>CIM_Chip"`
+ }
+
+ PackageResponse struct {
+ XMLName xml.Name `xml:"CIM_Chip"`
+ CanBeFRUed bool `xml:"CanBeFRUed"` // Boolean that indicates whether this PhysicalElement can be FRUed (TRUE) or not (FALSE).
+ CreationClassName string `xml:"CreationClassName"` // CreationClassName indicates the name of the class or the subclass used in the creation of an instance. When used with the other key properties of this class, this property allows all instances of this class and its subclasses to be uniquely identified.
+ ElementName string `xml:"ElementName"`
+ Manufacturer string `xml:"Manufacturer"` // The name of the organization responsible for producing the PhysicalElement. This organization might be the entity from whom the Element is purchased, but this is not necessarily true. The latter information is contained in the Vendor property of CIM_Product.
+ OperationalStatus OperationalStatus `xml:"OperationalStatus"` // Indicates the current statuses of the element.
+ Tag string `xml:"Tag"` // An arbitrary string that uniquely identifies the Physical Element and serves as the key of the Element. The Tag property can contain information such as asset tag or serial number data. The key for PhysicalElement is placed very high in the object hierarchy in order to independently identify the hardware or entity, regardless of physical placement in or on Cabinets, Adapters, and so on. For example, a hotswappable or removable component can be taken from its containing (scoping) Package and be temporarily unused. The object still continues to exist and can even be inserted into a different scoping container. Therefore, the key for Physical Element is an arbitrary string and is defined independently of any placement or location-oriented hierarchy.
+ Version string `xml:"Version"` // A string that indicates the version of the PhysicalElement.
+ }
+)
+
+// Indicates the current statuses of the element. Various operational statuses are defined. Many of the enumeration's values are self-explanatory. However, a few are not and are described here in more detail:
+//
+// - "Stressed" indicates that the element is functioning, but needs attention. Examples of "Stressed" states are overload, overheated, and so on.
+//
+// - "Predictive Failure" indicates that an element is functioning nominally but predicting a failure in the near future.
+//
+// - "In Service" describes an element being configured, maintained, cleaned, or otherwise administered.
+//
+// - "No Contact" indicates that the monitoring system has knowledge of this element, but has never been able to establish communications with it.
+//
+// - "Lost Communication" indicates that the ManagedSystem Element is known to exist and has been contacted successfully in the past, but is currently unreachable.
+//
+// - "Stopped" and "Aborted" are similar, although the former implies a clean and orderly stop, while the latter implies an abrupt stop where the state and configuration of the element might need to be updated.
+//
+// - "Dormant" indicates that the element is inactive or quiesced.
+//
+// - "Supporting Entity in Error" indicates that this element might be "OK" but that another element, on which it is dependent, is in error. An example is a network service or endpoint that cannot function due to lower-layer networking problems.
+//
+// - "Completed" indicates that the element has completed its operation. This value should be combined with either OK, Error, or Degraded so that a client can tell if the complete operation Completed with OK (passed), Completed with Error (failed), or Completed with Degraded (the operation finished, but it did not complete OK or did not report an error).
+//
+// - "Power Mode" indicates that the element has additional power model information contained in the Associated PowerManagementService association.
+//
+// - "Relocating" indicates the element is being relocated.
+//
+// OperationalStatus replaces the Status property on ManagedSystemElement to provide a consistent approach to enumerations, to address implementation needs for an array property, and to provide a migration path from today's environment to the future. This change was not made earlier because it required the deprecated qualifier. Due to the widespread use of the existing Status property in management applications, it is strongly recommended that providers or instrumentation provide both the Status and OperationalStatus properties. Further, the first value of OperationalStatus should contain the primary status for the element. When instrumented, Status (because it is single-valued) should also provide the primary status of the element.
+//
+// ValueMap={0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, .., 0x8000..}
+//
+// Values={Unknown, Other, OK, Degraded, Stressed, Predictive Failure, Error, Non-Recoverable Error, Starting, Stopping, Stopped, In Service, No Contact, Lost Communication, Aborted, Dormant, Supporting Entity in Error, Completed, Power Mode, Relocating, DMTF Reserved, Vendor Reserved}
+type OperationalStatus int
diff --git a/pkg/wsman/cim/computer/constants.go b/pkg/wsman/cim/computer/constants.go
new file mode 100644
index 00000000..a8d63f64
--- /dev/null
+++ b/pkg/wsman/cim/computer/constants.go
@@ -0,0 +1,8 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package computer
+
+const CIM_ComputerSystemPackage string = "CIM_ComputerSystemPackage"
diff --git a/pkg/wsman/cim/computer/marshal.go b/pkg/wsman/cim/computer/marshal.go
new file mode 100644
index 00000000..14829d3e
--- /dev/null
+++ b/pkg/wsman/cim/computer/marshal.go
@@ -0,0 +1,30 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package computer
+
+import (
+ "encoding/json"
+
+ "gopkg.in/yaml.v3"
+)
+
+// JSON marshals the type into JSON format
+func (r *Response) JSON() string {
+ jsonOutput, err := json.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(jsonOutput)
+}
+
+// YAML marshals the type into YAML format
+func (r *Response) YAML() string {
+ yamlOutput, err := yaml.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(yamlOutput)
+}
diff --git a/pkg/wsman/cim/computer/systempackage.go b/pkg/wsman/cim/computer/systempackage.go
new file mode 100644
index 00000000..2ccc888b
--- /dev/null
+++ b/pkg/wsman/cim/computer/systempackage.go
@@ -0,0 +1,81 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package computer
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+)
+
+// NewComputerSystemPackage returns a new instance of the ComputerSystemPackage struct.
+func NewComputerSystemPackageWithClient(wsmanMessageCreator *message.WSManMessageCreator, client client.WSMan) SystemPackage {
+ return SystemPackage{
+ base: message.NewBaseWithClient(wsmanMessageCreator, CIM_ComputerSystemPackage, client),
+ client: client,
+ }
+}
+
+// Get retrieves the representation of the instance
+func (systemPackage SystemPackage) Get() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: systemPackage.base.Get(nil),
+ },
+ }
+
+ err = systemPackage.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+
+}
+
+// Enumerate returns an enumeration context which is used in a subsequent Pull call
+func (systemPackage SystemPackage) Enumerate() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: systemPackage.base.Enumerate(),
+ },
+ }
+
+ err = systemPackage.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+
+}
+
+// Pull returns the instances of this class. An enumeration context provided by the Enumerate call is used as input.
+func (systemPackage SystemPackage) Pull(enumerationContext string) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: systemPackage.base.Pull(enumerationContext),
+ },
+ }
+ err = systemPackage.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
diff --git a/pkg/wsman/cim/computer/systempackage_test.go b/pkg/wsman/cim/computer/systempackage_test.go
new file mode 100644
index 00000000..af7c76b9
--- /dev/null
+++ b/pkg/wsman/cim/computer/systempackage_test.go
@@ -0,0 +1,375 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package computer
+
+import (
+ "encoding/xml"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
+)
+
+func TestPositiveSystemPackage(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "cim/computer/systempackage",
+ }
+ elementUnderTest := NewComputerSystemPackageWithClient(wsmanMessageCreator, &client)
+
+ t.Run("cim_SystemPackage Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create and parse a valid cim_ComputerSystemPackage Get call",
+ CIM_ComputerSystemPackage,
+ wsmantesting.GET,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Get"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GetResponse: ComputerSystemPackage{
+ Antecedent: Antecedent{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ComputerSystemPackage", Local: "Antecedent"},
+ Address: "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
+ ReferenceParameters: ReferenceParameters{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/08/addressing", Local: "ReferenceParameters"},
+ ResourceURI: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_Chassis",
+ SelectorSet: SelectorSet{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "SelectorSet"},
+ Selector: []Selector{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "CreationClassName",
+ Value: "CIM_Chassis",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "Tag",
+ Value: "CIM_Chassis",
+ },
+ },
+ },
+ },
+ },
+ Dependent: Dependent{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ComputerSystemPackage", Local: "Dependent"},
+ Address: "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
+ ReferenceParameters: ReferenceParameters{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/08/addressing", Local: "ReferenceParameters"},
+ ResourceURI: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ComputerSystem",
+ SelectorSet: SelectorSet{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "SelectorSet"},
+ Selector: []Selector{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "CreationClassName",
+ Value: "CIM_ComputerSystem",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "Name",
+ Value: "ManagedSystem",
+ },
+ },
+ },
+ },
+ },
+ PlatformGUID: "13AEE355D2BFBB6117A088AEDD7037EA",
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create and parse a valid cim_ComputerSystemPackage Enumerate call",
+ CIM_ComputerSystemPackage,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Enumerate"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "16000000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create and parse a valid cim_ComputerSystemPackage Pull call",
+ CIM_ComputerSystemPackage,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Pull"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ Items: []ComputerSystemPackage{
+ {
+ Antecedent: Antecedent{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ComputerSystemPackage", Local: "Antecedent"},
+ Address: "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
+ ReferenceParameters: ReferenceParameters{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/08/addressing", Local: "ReferenceParameters"},
+ ResourceURI: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_Chassis",
+ SelectorSet: SelectorSet{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "SelectorSet"},
+ Selector: []Selector{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "CreationClassName",
+ Value: "CIM_Chassis",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "Tag",
+ Value: "CIM_Chassis",
+ },
+ },
+ },
+ },
+ },
+ Dependent: Dependent{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ComputerSystemPackage", Local: "Dependent"},
+ Address: "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
+ ReferenceParameters: ReferenceParameters{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/08/addressing", Local: "ReferenceParameters"},
+ ResourceURI: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ComputerSystem",
+ SelectorSet: SelectorSet{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "SelectorSet"},
+ Selector: []Selector{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "CreationClassName",
+ Value: "CIM_ComputerSystem",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "Name",
+ Value: "ManagedSystem",
+ },
+ },
+ },
+ },
+ },
+ PlatformGUID: "13AEE355D2BFBB6117A088AEDD7037EA",
+ },
+ },
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.NoError(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.Equal(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
+
+func TestNegativeSystemPackage(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "cim/computer/systempackage",
+ }
+ elementUnderTest := NewComputerSystemPackageWithClient(wsmanMessageCreator, &client)
+
+ t.Run("cim_SystemPackage Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should handle error when cim_ComputerSystemPackage Get call",
+ CIM_ComputerSystemPackage,
+ wsmantesting.GET,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GetResponse: ComputerSystemPackage{
+ Antecedent: Antecedent{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ComputerSystemPackage", Local: "Antecedent"},
+ Address: "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
+ ReferenceParameters: ReferenceParameters{
+ ResourceURI: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_Chassis",
+ SelectorSet: SelectorSet{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "SelectorSet"},
+ Selector: []Selector{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "CreationClassName",
+ Value: "CIM_Chassis",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "Tag",
+ Value: "CIM_Chassis",
+ },
+ },
+ },
+ },
+ },
+ Dependent: Dependent{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ComputerSystemPackage", Local: "Dependent"},
+ Address: "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
+ ReferenceParameters: ReferenceParameters{
+ ResourceURI: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ComputerSystem",
+ SelectorSet: SelectorSet{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "SelectorSet"},
+ Selector: []Selector{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "CreationClassName",
+ Value: "CIM_ComputerSystem",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "Name",
+ Value: "ManagedSystem",
+ },
+ },
+ },
+ },
+ },
+ PlatformGUID: "13AEE355D2BFBB6117A088AEDD7037EA",
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should handle error when cim_ComputerSystemPackage Enumerate call",
+ CIM_ComputerSystemPackage,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "16000000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should handle error when cim_ComputerSystemPackage Pull call",
+ CIM_ComputerSystemPackage,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ Items: []ComputerSystemPackage{
+ {
+ Antecedent: Antecedent{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ComputerSystemPackage", Local: "Antecedent"},
+ Address: "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
+ ReferenceParameters: ReferenceParameters{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/08/addressing", Local: "ReferenceParameters"},
+ ResourceURI: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_Chassis",
+ SelectorSet: SelectorSet{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "SelectorSet"},
+ Selector: []Selector{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "CreationClassName",
+ Value: "CIM_Chassis",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "Tag",
+ Value: "CIM_Chassis",
+ },
+ },
+ },
+ },
+ },
+ Dependent: Dependent{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ComputerSystemPackage", Local: "Dependent"},
+ Address: "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
+ ReferenceParameters: ReferenceParameters{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/08/addressing", Local: "ReferenceParameters"},
+ ResourceURI: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ComputerSystem",
+ SelectorSet: SelectorSet{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "SelectorSet"},
+ Selector: []Selector{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "CreationClassName",
+ Value: "CIM_ComputerSystem",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "Name",
+ Value: "ManagedSystem",
+ },
+ },
+ },
+ },
+ },
+ PlatformGUID: "13AEE355D2BFBB6117A088AEDD7037EA",
+ },
+ },
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.Error(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.NotEqual(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
diff --git a/pkg/wsman/cim/computer/types.go b/pkg/wsman/cim/computer/types.go
new file mode 100644
index 00000000..4dda6f99
--- /dev/null
+++ b/pkg/wsman/cim/computer/types.go
@@ -0,0 +1,70 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package computer
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+)
+
+type SystemPackage struct {
+ base message.Base
+ client client.WSMan
+}
+
+// Response Types
+type (
+ Response struct {
+ *client.Message
+ XMLName xml.Name `xml:"Envelope"`
+ Header message.Header `xml:"Header"`
+ Body Body `xml:"Body"`
+ }
+
+ Body struct {
+ XMLName xml.Name `xml:"Body"`
+ GetResponse ComputerSystemPackage `xml:"CIM_ComputerSystemPackage"`
+ EnumerateResponse common.EnumerateResponse
+ PullResponse PullResponse `xml:"PullResponse"`
+ }
+
+ PullResponse struct {
+ Items []ComputerSystemPackage `xml:"Items>CIM_ComputerSystemPackage"`
+ }
+
+ Antecedent struct {
+ XMLName xml.Name `xml:"Antecedent,omitempty"`
+ Address string `xml:"Address,omitempty"`
+ ReferenceParameters ReferenceParameters
+ }
+ Dependent struct {
+ XMLName xml.Name `xml:"Dependent,omitempty"`
+ Address string `xml:"Address,omitempty"`
+ ReferenceParameters ReferenceParameters
+ }
+ ComputerSystemPackage struct {
+ Antecedent Antecedent
+ Dependent Dependent
+ PlatformGUID string `xml:"PlatformGUID,omitempty"`
+ }
+ ReferenceParameters struct {
+ XMLName xml.Name `xml:"ReferenceParameters"`
+ ResourceURI string `xml:"ResourceURI,omitempty"`
+ SelectorSet SelectorSet `xml:"SelectorSet,omitempty"`
+ }
+ SelectorSet struct {
+ XMLName xml.Name `xml:"SelectorSet,omitempty"`
+ Selector []Selector
+ }
+ Selector struct {
+ XMLName xml.Name `xml:"Selector,omitempty"`
+ Name string `xml:"Name,attr"`
+ Value string `xml:",chardata"`
+ }
+)
diff --git a/pkg/wsman/cim/concrete/constants.go b/pkg/wsman/cim/concrete/constants.go
new file mode 100644
index 00000000..22ccb803
--- /dev/null
+++ b/pkg/wsman/cim/concrete/constants.go
@@ -0,0 +1,8 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package concrete
+
+const CIM_ConcreteDependency string = "CIM_ConcreteDependency"
diff --git a/pkg/wsman/cim/concrete/dependency.go b/pkg/wsman/cim/concrete/dependency.go
new file mode 100644
index 00000000..16d90913
--- /dev/null
+++ b/pkg/wsman/cim/concrete/dependency.go
@@ -0,0 +1,63 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package concrete
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+)
+
+// NewDependency returns a new instance of the NewDependency struct.
+// should be NewDependency() because concrete is scoped already as package name.
+func NewDependencyWithClient(wsmanMessageCreator *message.WSManMessageCreator, client client.WSMan) Dependency {
+ return Dependency{
+ base: message.NewBaseWithClient(wsmanMessageCreator, CIM_ConcreteDependency, client),
+ client: client,
+ }
+}
+
+// TODO: Figure out how to call GET requiring resourceURIs and Selectors
+
+// Enumerate the instances of this class
+func (dependency Dependency) Enumerate() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: dependency.base.Enumerate(),
+ },
+ }
+
+ err = dependency.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+
+}
+
+// Pull instances of this class, following an Enumerate operation
+func (dependency Dependency) Pull(enumerationContext string) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: dependency.base.Pull(enumerationContext),
+ },
+ }
+ err = dependency.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
diff --git a/pkg/wsman/cim/concrete/dependency_test.go b/pkg/wsman/cim/concrete/dependency_test.go
new file mode 100644
index 00000000..a4e312e9
--- /dev/null
+++ b/pkg/wsman/cim/concrete/dependency_test.go
@@ -0,0 +1,221 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package concrete
+
+import (
+ "encoding/xml"
+ "testing"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/models"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
+ "github.com/stretchr/testify/assert"
+)
+
+func TestPositiveCIMConcreteDependency(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "cim/concrete/dependency",
+ }
+ elementUnderTest := NewDependencyWithClient(wsmanMessageCreator, &client)
+
+ t.Run("cim_Concrete Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ extraHeader string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //ENUMERATES
+ {
+ "should create and parse a valid cim_Concrete Enumerate call",
+ CIM_ConcreteDependency,
+ wsmantesting.ENUMERATE,
+ "",
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Enumerate"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "AC070000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+
+ //PULLS
+ {
+ "should create and parse a valid cim_Concrete Pull call",
+ CIM_ConcreteDependency,
+ wsmantesting.PULL,
+ "",
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Pull"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ Items: []ConcreteDependency{
+ {
+ Antecedent: models.AssociationReference{
+ Address: "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
+ ReferenceParameters: models.ReferenceParmetersNoNamespace{
+ ResourceURI: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_Identity",
+ SelectorSet: []models.SelectorNoNamespace{
+ {
+ Name: "InstanceID",
+ Value: "Intel(r) AMT:$$OsAdmin",
+ },
+ },
+ },
+ },
+ Dependent: models.AssociationReference{
+ Address: "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
+ ReferenceParameters: models.ReferenceParmetersNoNamespace{
+ ResourceURI: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_Role",
+ SelectorSet: []models.SelectorNoNamespace{
+ {
+ Name: "CreationClassName",
+ Value: "CIM_Role",
+ },
+ {
+ Name: "Name",
+ Value: "Intel(r) AMT:$$OsAdmin",
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.NoError(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.Equal(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
+
+func TestNegativeCIMConcreteDependency(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "cim/concrete/dependency",
+ }
+ elementUnderTest := NewDependencyWithClient(wsmanMessageCreator, &client)
+
+ t.Run("cim_Concrete Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ extraHeader string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //ENUMERATES
+ {
+ "should handle error when cim_ConcreteDependency Enumerate call",
+ CIM_ConcreteDependency,
+ wsmantesting.ENUMERATE,
+ "",
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "AC070000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+
+ //PULLS
+ {
+ "should handle error when cim_ConcreteDependency Pull call",
+ CIM_ConcreteDependency,
+ wsmantesting.PULL,
+ "",
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ Items: []ConcreteDependency{
+ {
+ Antecedent: models.AssociationReference{
+ Address: "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
+ ReferenceParameters: models.ReferenceParmetersNoNamespace{
+ ResourceURI: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_Identity",
+ SelectorSet: []models.SelectorNoNamespace{
+ {
+ Name: "InstanceID",
+ Value: "Intel(r) AMT:$$OsAdmin",
+ },
+ },
+ },
+ },
+ Dependent: models.AssociationReference{
+ Address: "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
+ ReferenceParameters: models.ReferenceParmetersNoNamespace{
+ ResourceURI: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_Role",
+ SelectorSet: []models.SelectorNoNamespace{
+ {
+ Name: "CreationClassName",
+ Value: "CIM_Role",
+ },
+ {
+ Name: "Name",
+ Value: "Intel(r) AMT:$$OsAdmin",
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.Error(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.NotEqual(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
diff --git a/pkg/wsman/cim/concrete/marshal.go b/pkg/wsman/cim/concrete/marshal.go
new file mode 100644
index 00000000..5d57cdb2
--- /dev/null
+++ b/pkg/wsman/cim/concrete/marshal.go
@@ -0,0 +1,30 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package concrete
+
+import (
+ "encoding/json"
+
+ "gopkg.in/yaml.v3"
+)
+
+// JSON marshals the type into JSON format
+func (r *Response) JSON() string {
+ jsonOutput, err := json.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(jsonOutput)
+}
+
+// YAML marshals the type into YAML format
+func (r *Response) YAML() string {
+ yamlOutput, err := yaml.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(yamlOutput)
+}
diff --git a/pkg/wsman/cim/concrete/types.go b/pkg/wsman/cim/concrete/types.go
new file mode 100644
index 00000000..f2f57ae5
--- /dev/null
+++ b/pkg/wsman/cim/concrete/types.go
@@ -0,0 +1,43 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package concrete
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/models"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+)
+
+type Dependency struct {
+ base message.Base
+ client client.WSMan
+}
+
+// Response Types
+type (
+ Response struct {
+ *client.Message
+ XMLName xml.Name `xml:"Envelope"`
+ Header message.Header `xml:"Header"`
+ Body Body `xml:"Body"`
+ }
+ Body struct {
+ XMLName xml.Name `xml:"Body"`
+ PullResponse PullResponse
+ EnumerateResponse common.EnumerateResponse
+ }
+ PullResponse struct {
+ XMLName xml.Name `xml:"PullResponse"`
+ Items []ConcreteDependency `xml:"Items>CIM_ConcreteDependency"`
+ }
+ ConcreteDependency struct {
+ Antecedent models.AssociationReference `xml:"Antecedent"`
+ Dependent models.AssociationReference `xml:"Dependent"`
+ }
+)
diff --git a/pkg/cim/constants.go b/pkg/wsman/cim/constants.go
similarity index 100%
rename from pkg/cim/constants.go
rename to pkg/wsman/cim/constants.go
diff --git a/pkg/wsman/cim/credential/constants.go b/pkg/wsman/cim/credential/constants.go
new file mode 100644
index 00000000..e07197db
--- /dev/null
+++ b/pkg/wsman/cim/credential/constants.go
@@ -0,0 +1,8 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package credential
+
+const CIM_CredentialContext string = "CIM_CredentialContext"
diff --git a/pkg/wsman/cim/credential/context.go b/pkg/wsman/cim/credential/context.go
new file mode 100644
index 00000000..af036b1d
--- /dev/null
+++ b/pkg/wsman/cim/credential/context.go
@@ -0,0 +1,74 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+// Package credential facilitates communication with Intel® AMT devices in order to define a context (e.g., a System or Service) of a Credential.
+//
+// One example is a shared secret/ password which is defined within the context of an application (or Service).
+//
+// Generally, there is one scoping element for a Credential, however the multiplicities of the association allow a Credential to be scoped by more than one element.
+//
+// If this association is not instantiated for a Credential, that Credential is assumed to be scoped to the Namespace.
+//
+// This association may also be used to indicate that a Credential is valid in some other environment.
+//
+// For instance associating the Credential to a RemoteServiceAccessPoint would indicate that the Credential is used to access the remote service.
+
+package credential
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+)
+
+// NewContext returns a new instance of the NewContext struct.
+func NewContextWithClient(wsmanMessageCreator *message.WSManMessageCreator, client client.WSMan) Context {
+ return Context{
+ base: message.NewBaseWithClient(wsmanMessageCreator, CIM_CredentialContext, client),
+ client: client,
+ }
+}
+
+// TODO: Figure out how to call GET requiring resourceURIs and Selectors
+
+// Enumerate the instances of this class
+func (context Context) Enumerate() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: context.base.Enumerate(),
+ },
+ }
+
+ err = context.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+
+}
+
+// Pull instances of this class, following an Enumerate operation
+func (context Context) Pull(enumerationContext string) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: context.base.Pull(enumerationContext),
+ },
+ }
+ err = context.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
diff --git a/pkg/wsman/cim/credential/context_test.go b/pkg/wsman/cim/credential/context_test.go
new file mode 100644
index 00000000..ee07b983
--- /dev/null
+++ b/pkg/wsman/cim/credential/context_test.go
@@ -0,0 +1,207 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package credential
+
+import (
+ "encoding/xml"
+ "testing"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/models"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
+ "github.com/stretchr/testify/assert"
+)
+
+func TestPositiveCIMCredentialContext(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "cim/credential/context",
+ }
+ elementUnderTest := NewContextWithClient(wsmanMessageCreator, &client)
+
+ t.Run("cim_* Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //ENUMERATES
+ {
+ "should create and parse a valid cim_IEEE8021xSettings Enumerate call",
+ CIM_CredentialContext,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Enumerate"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "19000000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create and parse a valid cim_IEEE8021xSettings Pull call",
+ CIM_CredentialContext,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Pull"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ Items: []CredentialContext{
+ {
+ ElementInContext: models.AssociationReference{
+ Address: "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
+ ReferenceParameters: models.ReferenceParmetersNoNamespace{
+ ResourceURI: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyCertificate",
+ SelectorSet: []models.SelectorNoNamespace{
+ {
+ Name: "InstanceID",
+ Value: "Intel(r) AMT Certificate: Handle: 0",
+ },
+ },
+ },
+ },
+ ElementProvidingContext: models.AssociationReference{
+ Address: "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
+ ReferenceParameters: models.ReferenceParmetersNoNamespace{
+ ResourceURI: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_TLSProtocolEndpointCollection",
+ SelectorSet: []models.SelectorNoNamespace{
+ {
+ Name: "ElementName",
+ Value: "TLSProtocolEndpoint Instances Collection",
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.NoError(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.Equal(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
+
+func TestNegativeCIMCredentialContext(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "cim/credential/context",
+ }
+ elementUnderTest := NewContextWithClient(wsmanMessageCreator, &client)
+
+ t.Run("cim_* Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //ENUMERATES
+ {
+ "should handle error when cim_IEEE8021xSettings Enumerate call",
+ CIM_CredentialContext,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "19000000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should handle error when cim_IEEE8021xSettings Pull call",
+ CIM_CredentialContext,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ Items: []CredentialContext{
+ {
+ ElementInContext: models.AssociationReference{
+ Address: "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
+ ReferenceParameters: models.ReferenceParmetersNoNamespace{
+ ResourceURI: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyCertificate",
+ SelectorSet: []models.SelectorNoNamespace{
+ {
+ Name: "InstanceID",
+ Value: "Intel(r) AMT Certificate: Handle: 0",
+ },
+ },
+ },
+ },
+ ElementProvidingContext: models.AssociationReference{
+ Address: "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
+ ReferenceParameters: models.ReferenceParmetersNoNamespace{
+ ResourceURI: "http://intel.com/wbem/wscim/1/amt-schema/1/AMT_TLSProtocolEndpointCollection",
+ SelectorSet: []models.SelectorNoNamespace{
+ {
+ Name: "ElementName",
+ Value: "TLSProtocolEndpoint Instances Collection",
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.Error(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.NotEqual(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
diff --git a/pkg/wsman/cim/credential/marshal.go b/pkg/wsman/cim/credential/marshal.go
new file mode 100644
index 00000000..80c9b234
--- /dev/null
+++ b/pkg/wsman/cim/credential/marshal.go
@@ -0,0 +1,30 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package credential
+
+import (
+ "encoding/json"
+
+ "gopkg.in/yaml.v3"
+)
+
+// JSON marshals the type into JSON format
+func (r *Response) JSON() string {
+ jsonOutput, err := json.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(jsonOutput)
+}
+
+// YAML marshals the type into YAML format
+func (r *Response) YAML() string {
+ yamlOutput, err := yaml.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(yamlOutput)
+}
diff --git a/pkg/wsman/cim/credential/types.go b/pkg/wsman/cim/credential/types.go
new file mode 100644
index 00000000..79bf2c68
--- /dev/null
+++ b/pkg/wsman/cim/credential/types.go
@@ -0,0 +1,46 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package credential
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/models"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+)
+
+type Context struct {
+ base message.Base
+ client client.WSMan
+}
+
+// Response Types
+type (
+ Response struct {
+ *client.Message
+ XMLName xml.Name `xml:"Envelope"`
+ Header message.Header `xml:"Header"`
+ Body Body `xml:"Body"`
+ }
+
+ Body struct {
+ XMLName xml.Name `xml:"Body"`
+ PullResponse PullResponse
+ EnumerateResponse common.EnumerateResponse
+ }
+
+ PullResponse struct {
+ XMLName xml.Name `xml:"PullResponse"`
+ Items []CredentialContext `xml:"Items>AMT_TLSCredentialContext"`
+ }
+
+ CredentialContext struct {
+ ElementInContext models.AssociationReference `xml:"ElementInContext"` // A Credential whose context is defined.
+ ElementProvidingContext models.AssociationReference `xml:"ElementProvidingContext"` // The ManagedElement that provides context or scope for the Credential.
+ }
+)
diff --git a/pkg/wsman/cim/ieee8021x/constants.go b/pkg/wsman/cim/ieee8021x/constants.go
new file mode 100644
index 00000000..394a88b2
--- /dev/null
+++ b/pkg/wsman/cim/ieee8021x/constants.go
@@ -0,0 +1,8 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package ieee8021x
+
+const CIM_IEEE8021xSettings string = "CIM_IEEE8021xSettings"
diff --git a/pkg/wsman/cim/ieee8021x/marshal.go b/pkg/wsman/cim/ieee8021x/marshal.go
new file mode 100644
index 00000000..e23c3e2d
--- /dev/null
+++ b/pkg/wsman/cim/ieee8021x/marshal.go
@@ -0,0 +1,30 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package ieee8021x
+
+import (
+ "encoding/json"
+
+ "gopkg.in/yaml.v3"
+)
+
+// JSON marshals the type into JSON format
+func (r *Response) JSON() string {
+ jsonOutput, err := json.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(jsonOutput)
+}
+
+// YAML marshals the type into YAML format
+func (r *Response) YAML() string {
+ yamlOutput, err := yaml.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(yamlOutput)
+}
diff --git a/pkg/wsman/cim/ieee8021x/settings.go b/pkg/wsman/cim/ieee8021x/settings.go
new file mode 100644
index 00000000..07ffaa24
--- /dev/null
+++ b/pkg/wsman/cim/ieee8021x/settings.go
@@ -0,0 +1,62 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package ieee8021x
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+)
+
+// NewIEEE8021xSettings returns a new instance of the IEEE8021xSettings struct.
+func NewIEEE8021xSettingsWithClient(wsmanMessageCreator *message.WSManMessageCreator, client client.WSMan) Settings {
+ return Settings{
+ base: message.NewBaseWithClient(wsmanMessageCreator, CIM_IEEE8021xSettings, client),
+ client: client,
+ }
+}
+
+// TODO: Figure out how to call GET requiring resourceURIs and Selectors
+
+// Enumerate returns an enumeration context which is used in a subsequent Pull call
+func (settings Settings) Enumerate() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: settings.base.Enumerate(),
+ },
+ }
+
+ err = settings.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+
+}
+
+// Pull returns the instances of this class. An enumeration context provided by the Enumerate call is used as input.
+func (settings Settings) Pull(enumerationContext string) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: settings.base.Pull(enumerationContext),
+ },
+ }
+ err = settings.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
diff --git a/pkg/wsman/cim/ieee8021x/settings_test.go b/pkg/wsman/cim/ieee8021x/settings_test.go
new file mode 100644
index 00000000..1e7a6a69
--- /dev/null
+++ b/pkg/wsman/cim/ieee8021x/settings_test.go
@@ -0,0 +1,171 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package ieee8021x
+
+import (
+ "encoding/xml"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
+)
+
+func TestPositiveCIMIEEE8021xSettings(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "cim/ieee8021x/settings",
+ }
+ elementUnderTest := NewIEEE8021xSettingsWithClient(wsmanMessageCreator, &client)
+
+ t.Run("cim_* Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //ENUMERATES
+ {
+ "should create and parse a valid cim_IEEE8021xSettings Enumerate call",
+ CIM_IEEE8021xSettings,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Enumerate"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "1A000000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create and parse a valid cim_IEEE8021xSettings Pull call",
+ CIM_IEEE8021xSettings,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Pull"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ IEEE8021xSettingsItems: []IEEE8021xSettingsResponse{
+ {
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/ips-schema/1/IPS_IEEE8021xSettings", Local: "IPS_IEEE8021xSettings"},
+ ElementName: "Intel(r) AMT: 8021X Settings",
+ InstanceID: "Intel(r) AMT: 8021X Settings",
+ Enabled: 3,
+ AvailableInS0: true,
+ PxeTimeout: 0,
+ },
+ },
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.NoError(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.Equal(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
+
+func TestNegativeCIMIEEE8021xSettings(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "cim/ieee8021x/settings",
+ }
+ elementUnderTest := NewIEEE8021xSettingsWithClient(wsmanMessageCreator, &client)
+
+ t.Run("cim_* Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //ENUMERATES
+ {
+ "should handle error when cim_IEEE8021xSettings Enumerate wsman message",
+ CIM_IEEE8021xSettings,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "1A000000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should handle error when cim_IEEE8021xSettings Pull wsman message",
+ CIM_IEEE8021xSettings,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ IEEE8021xSettingsItems: []IEEE8021xSettingsResponse{
+ {
+ XMLName: xml.Name{Space: "http://intel.com/wbem/wscim/1/ips-schema/1/IPS_IEEE8021xSettings", Local: "IPS_IEEE8021xSettings"},
+ ElementName: "Intel(r) AMT: 8021X Settings",
+ InstanceID: "Intel(r) AMT: 8021X Settings",
+ Enabled: 3,
+ AvailableInS0: true,
+ PxeTimeout: 0,
+ },
+ },
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.Error(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.NotEqual(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
diff --git a/pkg/wsman/cim/ieee8021x/types.go b/pkg/wsman/cim/ieee8021x/types.go
new file mode 100644
index 00000000..76b4eff9
--- /dev/null
+++ b/pkg/wsman/cim/ieee8021x/types.go
@@ -0,0 +1,60 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package ieee8021x
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/ips/ieee8021x"
+)
+
+type Settings struct {
+ base message.Base
+ client client.WSMan
+}
+
+// Response Types
+type (
+ Response struct {
+ *client.Message
+ XMLName xml.Name `xml:"Envelope"`
+ Header message.Header `xml:"Header"`
+ Body Body `xml:"Body"`
+ }
+
+ Body struct {
+ XMLName xml.Name `xml:"Body"`
+ EnumerateResponse common.EnumerateResponse
+ PullResponse PullResponse `xml:"PullResponse"`
+ GetResponse IEEE8021xSettingsResponse
+ }
+
+ IEEE8021xSettingsResponse ieee8021x.IEEE8021xSettingsResponse // calls return IPS version of IEEE8021xSettings
+
+ Time struct {
+ DateTime string `xml:"Datetime"`
+ }
+
+ PullResponse struct {
+ XMLName xml.Name `xml:"PullResponse"`
+ IEEE8021xSettingsItems []IEEE8021xSettingsResponse `xml:"Items>IPS_IEEE8021xSettings"`
+ }
+)
+
+type (
+ IEEE8021xSettingsRequest struct {
+ H string `xml:"xmlns:w,attr"`
+ XMLName xml.Name `xml:"CIM_IEEE8021xSettings"`
+ ElementName string `xml:"w:ElementName"`
+ InstanceID string `xml:"w:InstanceID"`
+ Enabled int `xml:"w:Enabled"`
+ AvailableInS0 bool `xml:"w:AvailableInS0"`
+ PxeTimeout int `xml:"w:PxeTimeout"`
+ }
+)
diff --git a/pkg/wsman/cim/kvm/constants.go b/pkg/wsman/cim/kvm/constants.go
new file mode 100644
index 00000000..d40e770e
--- /dev/null
+++ b/pkg/wsman/cim/kvm/constants.go
@@ -0,0 +1,44 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package kvm
+
+const CIM_KVMRedirectionSAP string = "CIM_KVMRedirectionSAP"
+
+const (
+ KVMRedirectionSAPEEnabledInput KVMRedirectionSAPRequestedStateInputs = 2
+ KVMRedirectionSAPEDisabledInput KVMRedirectionSAPRequestedStateInputs = 3
+ KVMRedirectionSAPRShutDownInput KVMRedirectionSAPRequestedStateInputs = 4
+ KVMRedirectionSAPOfflineInput KVMRedirectionSAPRequestedStateInputs = 6
+ KVMRedirectionSAPRTestInput KVMRedirectionSAPRequestedStateInputs = 7
+ KVMRedirectionSAPEDeferredInput KVMRedirectionSAPRequestedStateInputs = 8
+ KVMRedirectionSAPEQuiesceInput KVMRedirectionSAPRequestedStateInputs = 9
+ KVMRedirectionSAPRRebootInput KVMRedirectionSAPRequestedStateInputs = 10
+ KVMRedirectionSAPRResetInput KVMRedirectionSAPRequestedStateInputs = 11
+)
+const (
+ KVMRedirectionSAPKUnknown KVMRedirectionSAPKVMProtocol = iota
+ KVMRedirectionSAPKOther
+ KVMRedirectionSAPKRaw
+ KVMRedirectionSAPKRDP
+ KVMRedirectionSAPKVNC_RFB
+ KVMRedirectionSAPDMTFReserved
+ KVMRedirectionSAPVendorSpecified
+)
+const (
+ EnabledStateUnknown EnabledState = iota
+ EnabledStateOther
+ EnabledStateEnabled
+ EnabledStateDisabled
+ EnabledStateShuttingDown
+ EnabledStateNotApplicable
+ EnabledStateEnabledButOffline
+ EnabledStateInTest
+ EnabledStateDeferred
+ EnabledStateQuiesce
+ EnabledStateStarting
+ EnabledStateDMTFReserved
+ EnabledStateVendorReserved
+)
diff --git a/pkg/wsman/cim/kvm/marshal.go b/pkg/wsman/cim/kvm/marshal.go
new file mode 100644
index 00000000..0ecb0581
--- /dev/null
+++ b/pkg/wsman/cim/kvm/marshal.go
@@ -0,0 +1,30 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package kvm
+
+import (
+ "encoding/json"
+
+ "gopkg.in/yaml.v3"
+)
+
+// JSON marshals the type into JSON format
+func (r *Response) JSON() string {
+ jsonOutput, err := json.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(jsonOutput)
+}
+
+// YAML marshals the type into YAML format
+func (r *Response) YAML() string {
+ yamlOutput, err := yaml.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(yamlOutput)
+}
diff --git a/pkg/wsman/cim/kvm/redirectionsap.go b/pkg/wsman/cim/kvm/redirectionsap.go
new file mode 100644
index 00000000..f3acc527
--- /dev/null
+++ b/pkg/wsman/cim/kvm/redirectionsap.go
@@ -0,0 +1,88 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+// Package kvm facilitates communication with Intel® AMT devices derived from Service Access Point, that describes an access point to start the KVM redirection. One access point represents access to a single KVM redirection stream.
+package kvm
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/methods"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+)
+
+// NewKVMRedirectionSAP returns a new instance of the KVMRedirectionSAP struct.
+func NewKVMRedirectionSAPWithClient(wsmanMessageCreator *message.WSManMessageCreator, client client.WSMan) RedirectionSAP {
+ return RedirectionSAP{
+ base: message.NewBaseWithClient(wsmanMessageCreator, CIM_KVMRedirectionSAP, client),
+ client: client,
+ }
+}
+
+// RequestStateChange requests that the state of the element be changed to the value specified in the RequestedState parameter . . .
+func (redirectionSAP RedirectionSAP) RequestStateChange(requestedState KVMRedirectionSAPRequestedStateInputs) string {
+ return redirectionSAP.base.RequestStateChange(methods.RequestStateChange(CIM_KVMRedirectionSAP), int(requestedState))
+}
+
+// Get retrieves the representation of the instance
+func (redirectionSAP RedirectionSAP) Get() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: redirectionSAP.base.Get(nil),
+ },
+ }
+
+ err = redirectionSAP.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+
+}
+
+// Enumerate returns an enumeration context which is used in a subsequent Pull call
+func (redirectionSAP RedirectionSAP) Enumerate() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: redirectionSAP.base.Enumerate(),
+ },
+ }
+
+ err = redirectionSAP.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+
+}
+
+// Pull returns the instances of this class. An enumeration context provided by the Enumerate call is used as input.
+func (redirectionSAP RedirectionSAP) Pull(enumerationContext string) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: redirectionSAP.base.Pull(enumerationContext),
+ },
+ }
+ err = redirectionSAP.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
diff --git a/pkg/wsman/cim/kvm/redirectionsap_test.go b/pkg/wsman/cim/kvm/redirectionsap_test.go
new file mode 100644
index 00000000..a58c5b0f
--- /dev/null
+++ b/pkg/wsman/cim/kvm/redirectionsap_test.go
@@ -0,0 +1,221 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package kvm
+
+import (
+ "encoding/xml"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
+)
+
+func TestPositiveCIMKVMRedirectionSAP(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "cim/kvm",
+ }
+ elementUnderTest := NewKVMRedirectionSAPWithClient(wsmanMessageCreator, &client)
+
+ t.Run("cim_* Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create and parse a valid cim_KVMRedirectionSAP Get call",
+ CIM_KVMRedirectionSAP,
+ wsmantesting.GET,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Get"
+ return elementUnderTest.Get()
+ }, Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GetResponse: KVMRedirectionSAP{
+ CreationClassName: "CIM_KVMRedirectionSAP",
+ ElementName: "KVM Redirection Service Access Point",
+ Name: "KVM Redirection Service Access Point",
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "ManagedSystem",
+ KVMProtocol: 4,
+ EnabledState: 6,
+ RequestedState: 2,
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create and parse a valid cim_KVMRedirectionSAP Enumerate call",
+ CIM_KVMRedirectionSAP,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Enumerate"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "CB020000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create and parse a valid cim_KVMRedirectionSAP Pull call",
+ CIM_KVMRedirectionSAP,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Pull"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ Items: []KVMRedirectionSAP{
+ {
+ CreationClassName: "CIM_KVMRedirectionSAP",
+ ElementName: "KVM Redirection Service Access Point",
+ Name: "KVM Redirection Service Access Point",
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "ManagedSystem",
+ KVMProtocol: 4,
+ EnabledState: 6,
+ RequestedState: 5,
+ },
+ },
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.NoError(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.Equal(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
+
+func TestNegativeCIMKVMRedirectionSAP(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "cim/kvm",
+ }
+ elementUnderTest := NewKVMRedirectionSAPWithClient(wsmanMessageCreator, &client)
+
+ t.Run("cim_* Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should handle error when cim_KVMRedirectionSAP Get call",
+ CIM_KVMRedirectionSAP,
+ wsmantesting.GET,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Get()
+ }, Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GetResponse: KVMRedirectionSAP{
+ CreationClassName: "CIM_KVMRedirectionSAP",
+ ElementName: "KVM Redirection Service Access Point",
+ Name: "KVM Redirection Service Access Point",
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "ManagedSystem",
+ KVMProtocol: 4,
+ EnabledState: 6,
+ RequestedState: 2,
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should handle error when cim_KVMRedirectionSAP Enumerate call",
+ CIM_KVMRedirectionSAP,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "CB020000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should handle error when cim_KVMRedirectionSAP Pull call",
+ CIM_KVMRedirectionSAP,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ Items: []KVMRedirectionSAP{
+ {
+ CreationClassName: "CIM_KVMRedirectionSAP",
+ ElementName: "KVM Redirection Service Access Point",
+ Name: "KVM Redirection Service Access Point",
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "ManagedSystem",
+ KVMProtocol: 4,
+ EnabledState: 6,
+ RequestedState: 5,
+ },
+ },
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.Error(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.NotEqual(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
diff --git a/pkg/wsman/cim/kvm/types.go b/pkg/wsman/cim/kvm/types.go
new file mode 100644
index 00000000..1527ea5e
--- /dev/null
+++ b/pkg/wsman/cim/kvm/types.go
@@ -0,0 +1,119 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package kvm
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+)
+
+type RedirectionSAP struct {
+ base message.Base
+ client client.WSMan
+}
+
+// Response Types
+type (
+ Response struct {
+ *client.Message
+ XMLName xml.Name `xml:"Envelope"`
+ Header message.Header `xml:"Header"`
+ Body Body `xml:"Body"`
+ }
+
+ Body struct {
+ XMLName xml.Name `xml:"Body"`
+ GetResponse KVMRedirectionSAP `xml:"CIM_KVMRedirectionSAP"`
+ EnumerateResponse common.EnumerateResponse
+ PullResponse PullResponse `xml:"PullResponse"`
+ }
+
+ KVMRedirectionSAP struct {
+ CreationClassName string `xml:"CreationClassName"` // CreationClassName indicates the name of the class or the subclass used in the creation of an instance. When used with the other key properties of this class, this property allows all instances of this class and its subclasses to be uniquely identified.
+ ElementName string `xml:"ElementName"` // A user-friendly name for the object. This property allows each instance to define a user-friendly name in addition to its key properties, identity data, and description information. Note that the Name property of ManagedSystemElement is also defined as a user-friendly name. But, it is often subclassed to be a Key. It is not reasonable that the same property can convey both identity and a user-friendly name, without inconsistencies. Where Name exists and is not a Key (such as for instances of LogicalDevice), the same information can be present in both the Name and ElementName properties. Note that if there is an associated instance of CIM_EnabledLogicalElementCapabilities, restrictions on this properties may exist as defined in ElementNameMask and MaxElementNameLen properties defined in that class.
+ Name string `xml:"Name"` // The Name property uniquely identifies the ServiceAccessPoint and provides an indication of the functionality that is managed. This functionality is described in more detail in the Description property of the object.
+ SystemCreationClassName string `xml:"SystemCreationClassName"` // The CreationClassName of the scoping System.
+ SystemName string `xml:"SystemName"` // The Name of the scoping System.
+ EnabledState EnabledState `xml:"EnabledState,omitempty"` // EnabledState is an integer enumeration that indicates the enabled and disabled states of an element.
+ RequestedState KVMRedirectionSAPRequestedStateInputs `xml:"RequestedState,omitempty"` // RequestedState is an integer enumeration that indicates the last requested or desired state for the element, irrespective of the mechanism through which it was requested.
+ KVMProtocol KVMRedirectionSAPKVMProtocol `xml:"KVMProtocol,omitempty"` // An enumeration specifying the type of the KVM stream supported on this SAP.
+ }
+
+ Time struct {
+ DateTime string `xml:"Datetime"`
+ }
+
+ PullResponse struct {
+ XMLName xml.Name `xml:"PullResponse"`
+ Items []KVMRedirectionSAP `xml:"Items>CIM_KVMRedirectionSAP"`
+ }
+)
+
+// EnabledState is an integer enumeration that indicates the enabled and disabled states of an element. It can also indicate the transitions between these requested states. For example, shutting down (value=4) and starting (value=10) are transient states between enabled and disabled. The following text briefly summarizes the various enabled and disabled states:
+//
+// - Enabled (2) indicates that the element is or could be executing commands, will process any queued commands, and queues new requests.
+//
+// - Disabled (3) indicates that the element will not execute commands and will drop any new requests.
+//
+// - Shutting Down (4) indicates that the element is in the process of going to a Disabled state.
+//
+// - Not Applicable (5) indicates the element does not support being enabled or disabled.
+//
+// - Enabled but Offline (6) indicates that the element might be completing commands, and will drop any new requests.
+//
+// - Test (7) indicates that the element is in a test state.
+//
+// - Deferred (8) indicates that the element might be completing commands, but will queue any new requests.
+//
+// - Quiesce (9) indicates that the element is enabled but in a restricted mode.
+//
+// - Starting (10) indicates that the element is in the process of going to an Enabled state. New requests are queued.
+//
+// ValueMap={0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11..32767, 32768..65535}
+//
+// Values={Unknown, Other, Enabled, Disabled, Shutting Down, Not Applicable, Enabled but Offline, In Test, Deferred, Quiesce, Starting, DMTF Reserved, Vendor Reserved}
+type EnabledState int
+
+// RequestedState is an integer enumeration that indicates the last requested or desired state for the element, irrespective of the mechanism through which it was requested. The actual state of the element is represented by EnabledState. This property is provided to compare the last requested and current enabled or disabled states. Note that when EnabledState is set to 5 ("Not Applicable"), then this property has no meaning. Refer to the EnabledState property description for explanations of the values in the RequestedState enumeration.
+//
+// -"Unknown" (0) indicates the last requested state for the element is unknown.
+//
+// Note that the value "No Change" (5) has been deprecated in lieu of indicating the last requested state is "Unknown" (0).
+//
+// If the last requested or desired state is unknown, RequestedState should have the value "Unknown" (0), but may have the value "No Change" (5).
+//
+// - Offline (6) indicates that the element has been requested to transition to the Enabled but Offline EnabledState.
+//
+// It should be noted that there are two new values in RequestedState that build on the statuses of EnabledState. These are "Reboot" (10) and "Reset" (11).
+//
+// - Reboot refers to doing a "Shut Down" and then moving to an "Enabled" state.
+//
+// - Reset indicates that the element is first "Disabled" and then "Enabled".
+//
+// The distinction between requesting "Shut Down" and "Disabled" should also be noted. Shut Down requests an orderly transition to the Disabled state, and might involve removing power, to completely erase any existing state. The Disabled state requests an immediate disabling of the element, such that it will not execute or accept any commands or processing requests.
+//
+// This property is set as the result of a method invocation (such as Start or StopService on CIM_Service), or can be overridden and defined as WRITEable in a subclass. The method approach is considered superior to a WRITEable property, because it allows an explicit invocation of the operation and the return of a result code.
+//
+// If knowledge of the last RequestedState is not supported for the EnabledLogicalElement, the property shall be NULL or have the value 12 "Not Applicable".
+type KVMRedirectionSAPRequestedStateInputs int
+
+// An enumeration specifying the type of the KVM stream supported on this SAP. In some cases this may be a raw video steam, with the characters having no special meaning. However, in other cases it may support a protocol where some messages have a predefined structure.
+//
+// - 0 "Unknown" shall indicate the protocol is unknown.
+//
+// - 1 "Other" shall indicate the protocol is specified in OtherKVMProtocol.
+//
+// - 2 "Raw" shall indicate the protocol is a raw and uncompressed data stream. 3 "RDP" shall indicate the protocol is the Remote Desktop Protocol.
+//
+// - 4 "VNC" shall indicate the protocol is the VNC Protocol.
+//
+// ValueMap={0, 1, 2, 3, 4, 5..32767, 32768..65535}
+//
+// Values={Unknown, Other, Raw, RDP, VNC-RFB, DMTF Reserved, Vendor Specified}
+type KVMRedirectionSAPKVMProtocol int
diff --git a/pkg/wsman/cim/mediaaccess/constants.go b/pkg/wsman/cim/mediaaccess/constants.go
new file mode 100644
index 00000000..05b195b5
--- /dev/null
+++ b/pkg/wsman/cim/mediaaccess/constants.go
@@ -0,0 +1,34 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package mediaaccess
+
+const CIM_MediaAccessDevice string = "CIM_MediaAccessDevice"
+
+const (
+ CapabilitiesValuesUnknown CapabilitiesValues = iota
+ CapabilitiesValuesOther
+ CapabilitiesValuesSequentialAccess
+ CapabilitiesValuesRandomAccess
+ CapabilitiesValuesSupportsWriting
+ CapabilitiesValuesEncryption
+ CapabilitiesValuesCompression
+ CapabilitiesValuesSupportsRemoveableMedia
+ CapabilitiesValuesManualCleaning
+ CapabilitiesValuesAutomaticCleaning
+ CapabilitiesValuesSMARTNotification
+ CapabilitiesValuesSupportsDualSidedMedia
+ CapabilitiesValuesPredismountEjectNotRequired
+)
+
+const (
+ SecurityValuesOther SecurityValues = iota + 1
+ SecurityValuesUnknown
+ SecurityValuesNone
+ SecurityValuesReadOnly
+ SecurityValuesLockedOut
+ SecurityValuesBootBypass
+ SecurityValuesBootBypassAndReadOnly
+)
diff --git a/pkg/wsman/cim/mediaaccess/device.go b/pkg/wsman/cim/mediaaccess/device.go
new file mode 100644
index 00000000..f747d895
--- /dev/null
+++ b/pkg/wsman/cim/mediaaccess/device.go
@@ -0,0 +1,63 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package mediaaccess
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+)
+
+// NewMediaAccessDevice returns a new instance of the MediaAccessDevice struct.
+func NewMediaAccessDeviceWithClient(wsmanMessageCreator *message.WSManMessageCreator, client client.WSMan) Device {
+ return Device{
+ base: message.NewBaseWithClient(wsmanMessageCreator, CIM_MediaAccessDevice, client),
+ client: client,
+ }
+}
+
+// TODO: Figure out how to call GET requiring resourceURIs and Selectors
+// Get retrieves the representation of the instance
+
+// Enumerate returns an enumeration context which is used in a subsequent Pull call
+func (device Device) Enumerate() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: device.base.Enumerate(),
+ },
+ }
+
+ err = device.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+
+}
+
+// Pull returns the instances of this class. An enumeration context provided by the Enumerate call is used as input.
+func (device Device) Pull(enumerationContext string) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: device.base.Pull(enumerationContext),
+ },
+ }
+ err = device.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
diff --git a/pkg/wsman/cim/mediaaccess/device_test.go b/pkg/wsman/cim/mediaaccess/device_test.go
new file mode 100644
index 00000000..8fb391eb
--- /dev/null
+++ b/pkg/wsman/cim/mediaaccess/device_test.go
@@ -0,0 +1,217 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package mediaaccess
+
+import (
+ "encoding/xml"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
+)
+
+func TestPositiveCIMMediaAccessDevice(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "cim/mediaaccess",
+ }
+ elementUnderTest := NewMediaAccessDeviceWithClient(wsmanMessageCreator, &client)
+
+ t.Run("cim_MediaAccessDevice Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ extraHeaders string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+
+ //ENUMERATES
+ {
+ "should create and parse a valid cim_MediaAccessDevice Enumerate call",
+ CIM_MediaAccessDevice,
+ wsmantesting.ENUMERATE,
+ "",
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Enumerate"
+ return elementUnderTest.Enumerate()
+ }, Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "CE020000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create and parse a valid cim_MediaAccessDevice Pull call",
+ CIM_MediaAccessDevice,
+ wsmantesting.PULL,
+ "",
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Pull"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ MediaAccessDevices: []MediaAccessDevice{
+ {
+ Capabilities: 4,
+ CreationClassName: "CIM_MediaAccessDevice",
+ DeviceID: "MEDIA DEV 0",
+ ElementName: "Managed System Media Access Device",
+ EnabledDefault: 2,
+ EnabledState: 0,
+ MaxMediaSize: 960197124,
+ OperationalStatus: 0,
+ RequestedState: 12,
+ Security: 2,
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "ManagedSystem",
+ },
+ {
+ Capabilities: 4,
+ CreationClassName: "CIM_MediaAccessDevice",
+ DeviceID: "MEDIA DEV 1",
+ ElementName: "Managed System Media Access Device",
+ EnabledDefault: 2,
+ EnabledState: 0,
+ MaxMediaSize: 500107862,
+ OperationalStatus: 0,
+ RequestedState: 12,
+ Security: 2,
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "ManagedSystem",
+ },
+ },
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.NoError(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.Equal(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
+
+func TestNegativeCIMMediaAccessDevice(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "cim/mediaaccess",
+ }
+ elementUnderTest := NewMediaAccessDeviceWithClient(wsmanMessageCreator, &client)
+
+ t.Run("cim_MediaAccessDevice Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ extraHeaders string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+
+ //ENUMERATES
+ {
+ "should handle error when cim_MediaAccessDevice Enumerate call",
+ CIM_MediaAccessDevice,
+ wsmantesting.ENUMERATE,
+ "",
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Enumerate()
+ }, Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "CE020000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should handle error when cim_MediaAccessDevice Pull call",
+ CIM_MediaAccessDevice,
+ wsmantesting.PULL,
+ "",
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ MediaAccessDevices: []MediaAccessDevice{
+ {
+ Capabilities: 4,
+ CreationClassName: "CIM_MediaAccessDevice",
+ DeviceID: "MEDIA DEV 0",
+ ElementName: "Managed System Media Access Device",
+ EnabledDefault: 2,
+ EnabledState: 0,
+ MaxMediaSize: 960197124,
+ OperationalStatus: 0,
+ RequestedState: 12,
+ Security: 2,
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "ManagedSystem",
+ },
+ {
+ Capabilities: 4,
+ CreationClassName: "CIM_MediaAccessDevice",
+ DeviceID: "MEDIA DEV 1",
+ ElementName: "Managed System Media Access Device",
+ EnabledDefault: 2,
+ EnabledState: 0,
+ MaxMediaSize: 500107862,
+ OperationalStatus: 0,
+ RequestedState: 12,
+ Security: 2,
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "ManagedSystem",
+ },
+ },
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.Error(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.NotEqual(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
diff --git a/pkg/wsman/cim/mediaaccess/marshal.go b/pkg/wsman/cim/mediaaccess/marshal.go
new file mode 100644
index 00000000..0da6029d
--- /dev/null
+++ b/pkg/wsman/cim/mediaaccess/marshal.go
@@ -0,0 +1,30 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package mediaaccess
+
+import (
+ "encoding/json"
+
+ "gopkg.in/yaml.v3"
+)
+
+// JSON marshals the type into JSON format
+func (r *Response) JSON() string {
+ jsonOutput, err := json.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(jsonOutput)
+}
+
+// YAML marshals the type into YAML format
+func (r *Response) YAML() string {
+ yamlOutput, err := yaml.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(yamlOutput)
+}
diff --git a/pkg/wsman/cim/mediaaccess/types.go b/pkg/wsman/cim/mediaaccess/types.go
new file mode 100644
index 00000000..e8cf00af
--- /dev/null
+++ b/pkg/wsman/cim/mediaaccess/types.go
@@ -0,0 +1,60 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package mediaaccess
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/models"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+)
+
+type Device struct {
+ base message.Base
+ client client.WSMan
+}
+
+// Response Types
+type (
+ Response struct {
+ *client.Message
+ XMLName xml.Name `xml:"Envelope"`
+ Header message.Header `xml:"Header"`
+ Body Body `xml:"Body"`
+ }
+
+ Body struct {
+ XMLName xml.Name `xml:"Body"`
+ PullResponse PullResponse
+ EnumerateResponse common.EnumerateResponse
+ }
+
+ PullResponse struct {
+ XMLName xml.Name `xml:"PullResponse"`
+ MediaAccessDevices []MediaAccessDevice `xml:"Items>CIM_MediaAccessDevice"`
+ }
+
+ // TODO: Capabilities and OperationalStatus can return multiple items with the same tag, need to handle this
+ MediaAccessDevice struct {
+ Capabilities CapabilitiesValues `xml:"Capabilities,omitempty"` // ValueMap={0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12} Values={Unknown, Other, Sequential Access, Random Access, Supports Writing, Encryption, Compression, Supports Removeable Media, Manual Cleaning, Automatic Cleaning, SMART Notification, Supports Dual Sided Media, Predismount Eject Not Required} ArrayType=Indexed
+ CreationClassName string `xml:"CreationClassName"`
+ DeviceID string `xml:"DeviceID"`
+ ElementName string `xml:"ElementName"`
+ EnabledDefault models.EnabledDefault `xml:"EnabledDefault"`
+ EnabledState models.EnabledState `xml:"EnabledState"`
+ MaxMediaSize int `xml:"MaxMediaSize,omitempty"`
+ OperationalStatus models.OperationalStatus `xml:"OperationalStatus"`
+ RequestedState models.RequestedState `xml:"RequestedState"`
+ Security SecurityValues `xml:"Security,omitempty"` // ValueMap={1, 2, 3, 4, 5, 6, 7} Values={Other, Unknown, None, Read Only, Locked Out, Boot Bypass, Boot Bypass and Read Only}
+ SystemCreationClassName string `xml:"SystemCreationClassName"`
+ SystemName string `xml:"SystemName"`
+ }
+
+ CapabilitiesValues int
+ SecurityValues int
+)
diff --git a/pkg/wsman/cim/messages.go b/pkg/wsman/cim/messages.go
new file mode 100644
index 00000000..133c2414
--- /dev/null
+++ b/pkg/wsman/cim/messages.go
@@ -0,0 +1,86 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package cim
+
+import (
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/bios"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/boot"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/card"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/chassis"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/chip"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/computer"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/concrete"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/credential"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/ieee8021x"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/kvm"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/mediaaccess"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/physical"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/power"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/processor"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/service"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/software"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/system"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/wifi"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+)
+
+type Messages struct {
+ wsmanMessageCreator *message.WSManMessageCreator
+ BIOSElement bios.Element
+ BootConfigSetting boot.ConfigSetting
+ BootService boot.Service
+ BootSourceSetting boot.SourceSetting
+ Card card.Package
+ Chassis chassis.Package
+ Chip chip.Package
+ ComputerSystemPackage computer.SystemPackage
+ ConcreteDependency concrete.Dependency
+ CredentialContext credential.Context
+ IEEE8021xSettings ieee8021x.Settings
+ KVMRedirectionSAP kvm.RedirectionSAP
+ MediaAccessDevice mediaaccess.Device
+ PhysicalMemory physical.Memory
+ PhysicalPackage physical.Package
+ PowerManagementService power.ManagementService
+ Processor processor.Package
+ ServiceAvailableToElement service.AvailableToElement
+ SoftwareIdentity software.Identity
+ SystemPackaging system.Package
+ WiFiEndpointSettings wifi.EndpointSettings
+ WiFiPort wifi.Port
+}
+
+func NewMessages(client client.WSMan) Messages {
+ resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ m := Messages{
+ wsmanMessageCreator: wsmanMessageCreator,
+ }
+ m.BIOSElement = bios.NewBIOSElementWithClient(wsmanMessageCreator, client)
+ m.BootConfigSetting = boot.NewBootConfigSettingWithClient(wsmanMessageCreator, client)
+ m.BootService = boot.NewBootServiceWithClient(wsmanMessageCreator, client)
+ m.BootSourceSetting = boot.NewBootSourceSettingWithClient(wsmanMessageCreator, client)
+ m.Card = card.NewCardWithClient(wsmanMessageCreator, client)
+ m.Chassis = chassis.NewChassisWithClient(wsmanMessageCreator, client)
+ m.Chip = chip.NewChipWithClient(wsmanMessageCreator, client)
+ m.ComputerSystemPackage = computer.NewComputerSystemPackageWithClient(wsmanMessageCreator, client)
+ m.ConcreteDependency = concrete.NewDependencyWithClient(wsmanMessageCreator, client)
+ m.CredentialContext = credential.NewContextWithClient(wsmanMessageCreator, client)
+ m.IEEE8021xSettings = ieee8021x.NewIEEE8021xSettingsWithClient(wsmanMessageCreator, client)
+ m.KVMRedirectionSAP = kvm.NewKVMRedirectionSAPWithClient(wsmanMessageCreator, client)
+ m.MediaAccessDevice = mediaaccess.NewMediaAccessDeviceWithClient(wsmanMessageCreator, client)
+ m.PhysicalMemory = physical.NewPhysicalMemoryWithClient(wsmanMessageCreator, client)
+ m.PhysicalPackage = physical.NewPhysicalPackageWithClient(wsmanMessageCreator, client)
+ m.PowerManagementService = power.NewPowerManagementServiceWithClient(wsmanMessageCreator, client)
+ m.Processor = processor.NewProcessorWithClient(wsmanMessageCreator, client)
+ m.ServiceAvailableToElement = service.NewServiceAvailableToElementWithClient(wsmanMessageCreator, client)
+ m.SoftwareIdentity = software.NewSoftwareIdentityWithClient(wsmanMessageCreator, client)
+ m.SystemPackaging = system.NewSystemPackageWithClient(wsmanMessageCreator, client)
+ m.WiFiEndpointSettings = wifi.NewWiFiEndpointSettingsWithClient(wsmanMessageCreator, client)
+ m.WiFiPort = wifi.NewWiFiPortWithClient(wsmanMessageCreator, client)
+ return m
+}
diff --git a/pkg/cim/messages_test.go b/pkg/wsman/cim/messages_test.go
similarity index 58%
rename from pkg/cim/messages_test.go
rename to pkg/wsman/cim/messages_test.go
index fdeb1401..0cfcd1df 100644
--- a/pkg/cim/messages_test.go
+++ b/pkg/wsman/cim/messages_test.go
@@ -6,28 +6,33 @@
package cim
import (
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/cim/concrete"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/cim/credential"
"reflect"
"testing"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/cim/bios"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/cim/boot"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/cim/computer"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/cim/kvm"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/cim/mediaaccess"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/cim/physical"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/cim/power"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/cim/service"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/cim/software"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/cim/system"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/cim/wifi"
- "github.com/open-amt-cloud-toolkit/go-wsman-messages/pkg/ips/ieee8021x"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/bios"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/boot"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/card"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/chassis"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/chip"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/computer"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/concrete"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/credential"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/kvm"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/mediaaccess"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/physical"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/power"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/processor"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/service"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/software"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/system"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/wifi"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/ips/ieee8021x"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
)
func TestNewMessages(t *testing.T) {
- m := NewMessages()
-
+ mock := &wsmantesting.MockClient{}
+ m := NewMessages(mock)
if m.wsmanMessageCreator == nil {
t.Error("wsmanMessageCreator is not initialized")
}
@@ -43,13 +48,13 @@ func TestNewMessages(t *testing.T) {
if reflect.DeepEqual(m.BootSourceSetting, boot.SourceSetting{}) {
t.Error("BootSourceSetting is not initialized")
}
- if reflect.DeepEqual(m.Card, physical.Card{}) {
+ if reflect.DeepEqual(m.Card, card.Package{}) {
t.Error("Card is not initialized")
}
- if reflect.DeepEqual(m.Chassis, physical.Chassis{}) {
+ if reflect.DeepEqual(m.Chassis, chassis.Package{}) {
t.Error("Chassis is not initialized")
}
- if reflect.DeepEqual(m.Chip, physical.Chip{}) {
+ if reflect.DeepEqual(m.Chip, chip.Package{}) {
t.Error("Chip is not initialized")
}
if reflect.DeepEqual(m.ComputerSystemPackage, computer.SystemPackage{}) {
@@ -61,7 +66,7 @@ func TestNewMessages(t *testing.T) {
if reflect.DeepEqual(m.CredentialContext, credential.Context{}) {
t.Error("Context is not initialized")
}
- if reflect.DeepEqual(m.IEEE8021xSettings, ieee8021x.IEEE8021xSettings{}) {
+ if reflect.DeepEqual(m.IEEE8021xSettings, ieee8021x.IEEE8021xSettingsRequest{}) {
t.Error("IEEE8021xSettings is not initialized")
}
if reflect.DeepEqual(m.KVMRedirectionSAP, kvm.RedirectionSAP{}) {
@@ -79,7 +84,7 @@ func TestNewMessages(t *testing.T) {
if reflect.DeepEqual(m.PowerManagementService, power.ManagementService{}) {
t.Error("PowerManagementService is not initialized")
}
- if reflect.DeepEqual(m.Processor, physical.Processor{}) {
+ if reflect.DeepEqual(m.Processor, processor.Package{}) {
t.Error("Processor is not initialized")
}
if reflect.DeepEqual(m.ServiceAvailableToElement, service.AvailableToElement{}) {
@@ -88,7 +93,7 @@ func TestNewMessages(t *testing.T) {
if reflect.DeepEqual(m.SoftwareIdentity, software.Identity{}) {
t.Error("SoftwareIdentity is not initialized")
}
- if reflect.DeepEqual(m.SystemPackaging, system.Packaging{}) {
+ if reflect.DeepEqual(m.SystemPackaging, system.Package{}) {
t.Error("SystemPackaging is not initialized")
}
if reflect.DeepEqual(m.WiFiEndpointSettings, wifi.EndpointSettings{}) {
diff --git a/pkg/wsman/cim/methods/methods.go b/pkg/wsman/cim/methods/methods.go
new file mode 100644
index 00000000..8be70fee
--- /dev/null
+++ b/pkg/wsman/cim/methods/methods.go
@@ -0,0 +1,22 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package methods
+
+import (
+ "fmt"
+)
+
+func RequestStateChange(className string) string {
+ return fmt.Sprintf("http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/%s/RequestStateChange", className)
+}
+
+func GenerateAction(className string, methodName string) string {
+ return fmt.Sprintf("http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/%s/%s", className, methodName)
+}
+
+func GenerateInputMethod(methodName string) string {
+ return fmt.Sprintf("%s_INPUT", methodName)
+}
diff --git a/pkg/wsman/cim/methods/methods_test.go b/pkg/wsman/cim/methods/methods_test.go
new file mode 100644
index 00000000..868ad57a
--- /dev/null
+++ b/pkg/wsman/cim/methods/methods_test.go
@@ -0,0 +1,34 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package methods
+
+import (
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+)
+
+func TestMethods(t *testing.T) {
+ t.Run("GenerateAction Test", func(t *testing.T) {
+ expectedResult := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_Test/TestMethod"
+ className := "CIM_Test"
+ methodName := "TestMethod"
+ result := GenerateAction(className, methodName)
+ assert.Equal(t, expectedResult, result)
+ })
+ t.Run("GenerateMethod Test", func(t *testing.T) {
+ expectedResult := "TestMethod_INPUT"
+ methodName := "TestMethod"
+ result := GenerateInputMethod(methodName)
+ assert.Equal(t, expectedResult, result)
+ })
+ t.Run("RequestStateChange Test", func(t *testing.T) {
+ expectedResult := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_Test/RequestStateChange"
+ className := "CIM_Test"
+ result := RequestStateChange(className)
+ assert.Equal(t, expectedResult, result)
+ })
+}
diff --git a/pkg/wsman/cim/models/constants.go b/pkg/wsman/cim/models/constants.go
new file mode 100644
index 00000000..896de8b1
--- /dev/null
+++ b/pkg/wsman/cim/models/constants.go
@@ -0,0 +1,433 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package models
+
+const (
+ RoleCharacteristicsStatic RoleCharacteristics = 2
+ RoleCharacteristicsOpaque RoleCharacteristics = 3
+)
+
+const (
+ UsageRestrictionUnknown int = iota
+ UsageRestrictionFrontEndOnly
+ UsageRestrictionBackEndOnly
+ UsageRestrictionNotRestricted
+)
+
+const (
+ PortTypeUnknown int = iota
+ PortTypeOther
+ PortTypeNotApplicable
+)
+
+const (
+ EnabledEnabled Enabled = 1
+ EnabledDisabled Enabled = 2
+ EnabledEnabledForDebug Enabled = 3
+)
+
+const (
+ AuthenticationProtocolEAPTLS AuthenticationProtocol = iota
+ AuthenticationProtocolEAPTTLS_MSCHAPv2
+ AuthenticationProtocolPEAPv0_EAPMSCHAPv2
+ AuthenticationProtocolPEAPv1_EAPGTC
+ AuthenticationProtocolEAPFAST_MSCHAPv2
+ AuthenticationProtocolEAPFAST_GTC
+ AuthenticationProtocolEAP_MD5
+ AuthenticationProtocolEAP_PSK
+ AuthenticationProtocolEAP_SIM
+ AuthenticationProtocolEAP_AKA
+ AuthenticationProtocolEAPFAST_TLS
+)
+
+const (
+ ConcreteJobStateNew ConcreteJobState = 2
+ ConcreteJobStateStarting ConcreteJobState = 3
+ ConcreteJobStateRunning ConcreteJobState = 4
+ ConcreteJobStateSuspended ConcreteJobState = 5
+ ConcreteJobStateShuttingDown ConcreteJobState = 6
+ ConcreteJobStateCompleted ConcreteJobState = 7
+ ConcreteJobStateTerminated ConcreteJobState = 8
+ ConcreteJobStateKilled ConcreteJobState = 9
+ ConcreteJobStateException ConcreteJobState = 10
+ ConcreteJobStateService ConcreteJobState = 11
+ ConcreteJobStateQueryPending ConcreteJobState = 12
+)
+const (
+ UnknownCS CommunicationStatus = iota
+ NotAvailableCS
+ CommunicationOK
+ LostCommunication
+ NoContact
+)
+const (
+ NotAvailableDS DetailedStatus = iota
+ NoAdditionalInformation
+ Stressed
+ PredictiveFailure
+ NonRecoverableError
+ SupportingEntityInError
+)
+const (
+ UnknownOS OperatingStatus = iota
+ NotAvailableOS
+ Servicing
+ Starting
+ Stopping
+ Stopped
+ Aborted
+ Dormant
+ Completed
+ Migrating
+ Emigrating
+ Immigrating
+ Snapshotting
+ ShuttingDown
+ InTest
+ Transitioning
+ InService
+)
+const (
+ UnknownPS PrimaryStatus = iota
+ OK
+ Degraded
+ ErrorPS
+)
+const (
+ January RunMonth = iota
+ February
+ March
+ April
+ May
+ June
+ July
+ August
+ September
+ October
+ November
+ December
+)
+const (
+ SaturdayNegative RunDayOfWeek = iota - 7
+ FridayNegative
+ ThursdayNegative
+ WednesdayNegative
+ TuesdayNegative
+ MondayNegative
+ SundayNegative
+ ExactDayOfMonth
+ Sunday
+ Monday
+ Tuesday
+ Wednesday
+ Thursday
+ Friday
+ Saturday
+)
+const (
+ UnknownRA RecoveryAction = iota
+ Other
+ DoNotContinue
+ ContinueWithNextJob
+ RerunJob
+ RunRecoveryJob
+)
+const (
+ LocalTime LocalOrUtcTime = iota + 1
+ UTCTime
+)
+const (
+ PowerManagementCapabilitiesUnknown PowerManagementCapabilitiesValues = iota
+ PowerManagementCapabilitiesNotSupported
+ PowerManagementCapabilitiesDisabled
+ PowerManagementCapabilitiesEnabled
+ PowerManagementCapabilitiesPowerSavingModesEnteredAutomatically
+ PowerManagementCapabilitiesPowerStateSettable
+ PowerManagementCapabilitiesPowerCyclingSupported
+ PowerManagementCapabilitiesTimedPowerOnSupported
+)
+const (
+ AvailabilityOther AvailabilityValues = iota + 1
+ AvailabilityUnknown
+ AvailabilityRunningFullPower
+ AvailabilityWarning
+ AvailabilityInTest
+ AvailabilityNotApplicable
+ AvailabilityPowerOff
+ AvailabilityOffLine
+ AvailabilityOffDuty
+ AvailabilityDegraded
+ AvailabilityNotInstalled
+ AvailabilityInstallError
+ AvailabilityPowerSaveUnknown
+ AvailabilityPowerSaveLowPowerMode
+ AvailabilityPowerSaveStandby
+ AvailabilityPowerCycle
+ AvailabilityPowerSaveWarning
+ AvailabilityPaused
+ AvailabilityNotReady
+ AvailabilityNotConfigured
+ AvailabilityQuiesced
+)
+const (
+ StatusInfoOther StatusInfoValues = iota + 1
+ StatusInfoUnknown
+ StatusInfoEnabled
+ StatusInfoDisabled
+ StatusInfoNotApplicable
+)
+const (
+ AdditionalAvailabilityOther AdditionalAvailabilityValues = iota + 1
+ AdditionalAvailabilityUnknown
+ AdditionalAvailabilityRunningFullPower
+ AdditionalAvailabilityWarning
+ AdditionalAvailabilityInTest
+ AdditionalAvailabilityNotApplicable
+ AdditionalAvailabilityPowerOff
+ AdditionalAvailabilityOffLine
+ AdditionalAvailabilityOffDuty
+ AdditionalAvailabilityDegraded
+ AdditionalAvailabilityNotInstalled
+ AdditionalAvailabilityInstallError
+ AdditionalAvailabilityPowerSaveUnknown
+ AdditionalAvailabilityPowerSaveLowPowerMode
+ AdditionalAvailabilityPowerSaveStandby
+ AdditionalAvailabilityPowerCycle
+ AdditionalAvailabilityPowerSaveWarning
+ AdditionalAvailabilityPaused
+ AdditionalAvailabilityNotReady
+ AdditionalAvailabilityNotConfigured
+ AdditionalAvailabilityQuiesced
+)
+
+const (
+ ForceHardDriveBoot BootConfigSettingInstanceID = "Intel(r) AMT: Force Hard-drive Boot"
+ ForceCD_DVDBoot BootConfigSettingInstanceID = "Intel(r) AMT: Force CD/DVD Boot"
+ ForcePXEBoot BootConfigSettingInstanceID = "Intel(r) AMT: Force PXE Boot"
+ ForceOCRUEFIHTTPSBoot BootConfigSettingInstanceID = "Intel(r) AMT: Force OCR UEFI HTTPS Boot"
+ ForceOCRUEFIBootOption1 BootConfigSettingInstanceID = "Intel(r) AMT: Force OCR UEFI Boot Option 1"
+ ForceOCRUEFIBootOption2 BootConfigSettingInstanceID = "Intel(r) AMT: Force OCR UEFI Boot Option 2"
+ ForceOCRUEFIBootOption3 BootConfigSettingInstanceID = "Intel(r) AMT: Force OCR UEFI Boot Option 3"
+ ForceOCRUEFIBootOption4 BootConfigSettingInstanceID = "Intel(r) AMT: Force OCR UEFI Boot Option 4"
+ ForceOCRUEFIBootOption5 BootConfigSettingInstanceID = "Intel(r) AMT: Force OCR UEFI Boot Option 5"
+ ForceOCRUEFIBootOption6 BootConfigSettingInstanceID = "Intel(r) AMT: Force OCR UEFI Boot Option 6"
+ ForceOCRUEFIBootOption7 BootConfigSettingInstanceID = "Intel(r) AMT: Force OCR UEFI Boot Option 7"
+ ForceOCRUEFIBootOption8 BootConfigSettingInstanceID = "Intel(r) AMT: Force OCR UEFI Boot Option 8"
+ ForceOCRUEFIBootOption9 BootConfigSettingInstanceID = "Intel(r) AMT: Force OCR UEFI Boot Option 9"
+ ForceOCRUEFIBootOption10 BootConfigSettingInstanceID = "Intel(r) AMT: Force OCR UEFI Boot Option 10"
+)
+const (
+ RemovalConditions_Unknown RemovalConditions = 0
+ RemovalConditions_NotApplicable RemovalConditions = 2
+ RemovalConditions_RemovableWhenOff RemovalConditions = 3
+ RemovalConditions_RemovableWhenOnOrOff RemovalConditions = 4
+)
+
+const (
+ FailThroughSupportedUnknown FailThroughSupported = iota
+ IsSupported
+ NotSupported
+)
+
+const (
+ OverwritePolicyUnknown OverwritePolicy = 0
+ OverwritePolicyWrapsWhenFull OverwritePolicy = 2
+ OverwritePolicyNeverOverwrites OverwritePolicy = 7
+)
+const (
+ LogStateUnknown LogState = 0
+ LogStateNormal LogState = 2
+ LogStateErasing LogState = 3
+ LogStateNotApplicable LogState = 4
+)
+const (
+ CapabilitiesUnknown CapabilitiesValues = iota
+ CapabilitiesOther
+ CapabilitiesWriteRecordSupported
+ CapabilitiesDeleteRecordSupported
+ CapabilitiesCanMoveBackwardInLog
+ CapabilitiesFreezeLogSupported
+ CapabilitiesClearLogSupported
+ CapabilitiesSupportsAddressingByOrdinalRecordNumber
+ CapabilitiesVariableLengthRecordsSupported
+ CapabilitiesVariableFormatsForRecords
+ CapabilitiesCanFlagRecordsForOverwrite
+)
+const (
+ LastChangeUnknown LastChange = iota
+ LastChangeAdd
+ LastChangeDelete
+ LastChangeModify
+ LastChangeLogCleared
+)
+const (
+ CharacterSetUnknown CharacterSet = iota
+ CharacterSetOther
+ CharacterSetASCII
+ CharacterSetUnicode
+ CharacterSetISO2022
+ CharacterSetISO8859
+ CharacterSetExtendedUNIXCode
+ CharacterSetUTF8
+ CharacterSetUCS2
+ CharacterSetBitmappedData
+ CharacterSetOctetString
+ CharacterSetDefinedByIndividualRecords
+)
+
+const (
+ UpgradeMethodOther UpgradeMethod = iota + 1
+ UpgradeMethodUnknown
+ UpgradeMethodDaughterBoard
+ UpgradeMethodZIFSocket
+ UpgradeMethodReplacementPiggyBack
+ UpgradeMethodNone
+ UpgradeMethodLIFSocket
+ UpgradeMethodSlot1
+ UpgradeMethodSlot2
+ UpgradeMethod370PinSocket
+ UpgradeMethodSlotA
+ UpgradeMethodSlotM
+ UpgradeMethodSocket423
+ UpgradeMethodSocketA
+ UpgradeMethodSocket478
+ UpgradeMethodSocket754
+ UpgradeMethodSocket940
+ UpgradeMethodSocket939
+ UpgradeMethodSocketmPGA604
+ UpgradeMethodSocketLGA771
+ UpgradeMethodSocketLGA775
+ UpgradeMethodSocketS1
+ UpgradeMethodSocketAM2
+ UpgradeMethodSocketF1207
+ UpgradeMethodSocketLGA1366
+ UpgradeMethodSocketG34
+ UpgradeMethodSocketAM3
+ UpgradeMethodSocketC32
+ UpgradeMethodSocketLGA1156
+ UpgradeMethodSocketLGA1567
+ UpgradeMethodSocketPGA988A
+ UpgradeMethodSocketBGA1288
+ UpgradeMethodrPGA988B
+ UpgradeMethodBGA1023
+ UpgradeMethodBGA1224
+ UpgradeMethodLGA1155
+ UpgradeMethodLGA1356
+ UpgradeMethodLGA2011
+ UpgradeMethodSocketFS1
+ UpgradeMethodSocketFS2
+ UpgradeMethodSocketFM1
+ UpgradeMethodSocketFM2
+ UpgradeMethodSocketLGA20113
+ UpgradeMethodSocketLGA13563
+ UpgradeMethodSocketLGA1150
+ UpgradeMethodSocketBGA1168
+ UpgradeMethodSocketBGA1234
+ UpgradeMethodSocketBGA1364
+ UpgradeMethodSocketAM4
+ UpgradeMethodSocketLGA1151
+ UpgradeMethodSocketBGA1356
+ UpgradeMethodSocketBGA1440
+ UpgradeMethodSocketBGA1515
+ UpgradeMethodSocketLGA36471
+ UpgradeMethodSocketSP3
+ UpgradeMethodSocketSP3r2
+ UpgradeMethodSocketLGA2066
+ UpgradeMethodSocketBGA1392
+ UpgradeMethodSocketBGA1510
+ UpgradeMethodSocketBGA1528
+ UpgradeMethodSocketLGA4189
+ UpgradeMethodSocketLGA1200
+ UpgradeMethodSocketLGA4677
+ UpgradeMethodSocketLGA1700
+ UpgradeMethodSocketBGA1744
+ UpgradeMethodSocketBGA1781
+ UpgradeMethodSocketBGA1211
+ UpgradeMethodSocketBGA2422
+ UpgradeMethodSocketLGA1211
+ UpgradeMethodSocketLGA2422
+ UpgradeMethodSocketLGA5773
+ UpgradeMethodSocketBGA5773
+)
+const (
+ CPUStatusUnknown CPUStatus = iota
+ CPUStatusEnabled
+ CPUStatusDisabledByUser
+ CPUStatusDisabledByBIOS
+ CPUStatusIdle
+ CPUStatusOther
+)
+
+const (
+ OperationalStatusUnknown OperationalStatus = iota
+ OperationalStatusOther
+ OperationalStatusOK
+ OperationalStatusDegraded
+ OperationalStatusStressed
+ OperationalStatusPredictiveFailure
+ OperationalStatusError
+ OperationalStatusNonRecoverableError
+ OperationalStatusStarting
+ OperationalStatusStopping
+ OperationalStatusStopped
+ OperationalStatusInService
+ OperationalStatusNoContact
+ OperationalStatusLostCommunication
+ OperationalStatusAborted
+ OperationalStatusDormant
+ OperationalStatusSupportingEntityinError
+ OperationalStatusCompleted
+ OperationalStatusPowerMode
+ OperationalStatusRelocating
+)
+
+const (
+ HealthStateUnknown HealthState = 0
+ HealthStateOK HealthState = 5
+ HealthStateDegradedWarning HealthState = 10
+ HealthStateMinorFailure HealthState = 15
+ HealthStateMajorFailure HealthState = 20
+ HealthStateCriticalFailure HealthState = 25
+ HealthStateNonRecoverableError HealthState = 30
+)
+
+const (
+ EnabledStateUnknown EnabledState = iota
+ EnabledStateOther
+ EnabledStateEnabled
+ EnabledStateDisabled
+ EnabledStateShuttingDown
+ EnabledStateNotApplicable
+ EnabledStateEnabledbutOffline
+ EnabledStateInTest
+ EnabledStateDeferred
+ EnabledStateQuiesce
+ EnabledStateStarting
+)
+
+const (
+ RequestedStateEnabled RequestedState = iota + 2
+ RequestedStateDisabled
+ RequestedStateShutDown
+ RequestedStateNoChange
+ RequestedStateOffline
+ RequestedStateTest
+ RequestedStateDeferred
+ RequestedStateQuiesce
+ RequestedStateReboot
+ RequestedStateReset
+ RequestedStateNotApplicable
+ RequestedStateUnknown RequestedState = 0
+)
+
+const (
+ EnabledDefaultEnabled EnabledDefault = 2
+ EnabledDefaultDisabled EnabledDefault = 3
+ EnabledDefaultNotApplicable EnabledDefault = 5
+ EnabledDefaultEnabledbutOffline EnabledDefault = 6
+ EnabledDefaultNoDefault EnabledDefault = 7
+ EnabledDefaultQuiesce EnabledDefault = 9
+)
diff --git a/pkg/wsman/cim/models/methods.go b/pkg/wsman/cim/models/methods.go
new file mode 100644
index 00000000..a11644ba
--- /dev/null
+++ b/pkg/wsman/cim/models/methods.go
@@ -0,0 +1,27 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+// Package models provides a set of utility types, constants, and functions that are used broadly across amt, cim, and ips packages
+package models
+
+// HasSelector checks the SelectorSet and returns true if the SelectorSet contains a Selector
+func (rp *ReferenceParmetersNoNamespace) HasSelector(name string, value string) bool {
+ for _, selector := range rp.SelectorSet {
+ if selector.Name == name && selector.Value == value {
+ return true
+ }
+ }
+ return false
+}
+
+// GetSelectorValue returns the Value property of a selector found in a SelectorSet based on the selector name
+func (rp *ReferenceParmetersNoNamespace) GetSelectorValue(name string) string {
+ for _, selector := range rp.SelectorSet {
+ if selector.Name == name {
+ return selector.Value
+ }
+ }
+ return ""
+}
diff --git a/pkg/wsman/cim/models/types.go b/pkg/wsman/cim/models/types.go
new file mode 100644
index 00000000..29d4c865
--- /dev/null
+++ b/pkg/wsman/cim/models/types.go
@@ -0,0 +1,516 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package models
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+)
+
+type SettingData struct {
+ XMLName xml.Name `xml:"CIM_SettingData"`
+ ManagedElement
+ InstanceID string `xml:"InstanceID,omitempty"` // MaxLen=256
+}
+
+type ManagedElement struct {
+ XMLName xml.Name `xml:"h:ManagedElement"`
+ Caption string `xml:"h:Caption,omitempty"` // MaxLen=64
+ Description string `xml:"h:Description,omitempty"` // MaxLen=256
+ ElementName string `xml:"h:ElementName,omitempty"` // MaxLen=256
+}
+type Collection struct {
+ XMLName xml.Name `xml:"CIM_Collection"`
+ ManagedElement
+}
+
+type Role struct {
+ XMLName xml.Name `xml:"CIM_Role"`
+ Collection
+ CreationClassName string `xml:"CreationClassName,omitempty"`
+ Name string `xml:"Name,omitempty"`
+ CommonName string `xml:"CommonName,omitempty"`
+ RoleCharacteristics []RoleCharacteristics `xml:"RoleCharacteristics,omitempty"`
+}
+
+type RoleCharacteristics int
+
+type LogicalPort struct {
+ LogicalDevice
+ Speed int `xml:"Speed,omitempty"`
+ MaxSpeed int `xml:"MaxSpeed,omitempty"`
+ RequestedSpeed int `xml:"RequestedSpeed,omitempty"`
+ UsageRestriction UsageRestriction `xml:"UsageRestriction,omitempty"`
+ PortType PortType `xml:"PortType,omitempty"`
+ OtherPortType string `xml:"OtherPortType,omitempty"`
+}
+type UsageRestriction int
+
+type PortType int
+
+type NetworkPort struct {
+ LogicalPort
+ PortNumber int
+ LinkTechnology LinkTechnology `xml:"LinkTechnology,omitempty"`
+ OtherLinkTechnology string `xml:"OtherLinkTechnology,omitempty"`
+ PermanentAddress string `xml:"PermanentAddress,omitempty"`
+ NetworkAddresses []string `xml:"NetworkAddresses,omitempty"`
+ FullDuplex bool `xml:"FullDuplex,omitempty"`
+ AutoSense bool `xml:"AutoSense,omitempty"`
+ SupportedMaximumTransmissionUnit int `xml:"SupportedMaximumTransmissionUnit,omitempty"`
+ ActiveMaximumTransmissionUnit int `xml:"OtherActiveMaximumTransmissionUnitPortType,omitempty"`
+}
+
+type LinkTechnology int
+
+type EthernetPort struct {
+ NetworkPort
+}
+
+type WiFiPort struct {
+ NetworkPort
+}
+
+type Antecedent struct {
+ XMLName xml.Name `xml:"Antecedent,omitempty"`
+ Address string `xml:"Address,omitempty"`
+ ReferenceParameters ReferenceParameters
+}
+
+type Dependent struct {
+ XMLName xml.Name `xml:"Dependent,omitempty"`
+ Address string `xml:"Address,omitempty"`
+ ReferenceParameters ReferenceParameters
+}
+
+type SystemPackage struct {
+ Antecedent Antecedent
+ Dependent Dependent
+ PlatformGUID string `xml:"PlatformGUID,omitempty"`
+}
+
+type PhysicalElement struct {
+ ManagedSystemElement
+ Tag string `xml:"Tag,omitempty"` // MaxLen=256
+ CreationClassName string `xml:"CreationClassName,omitempty"` // MaxLen=256
+ Manufacturer string `xml:"Manufacturer,omitempty"` // MaxLen=256
+ Model string `xml:"Model,omitempty"` // MaxLen=256
+ Sku string `xml:"Sku,omitempty"` // MaxLen=64
+ SerialNumber string `xml:"SerialNumber,omitempty"` // MaxLen=256
+ Version string `xml:"Version,omitempty"` // MaxLen=64
+ PartNumber string `xml:"PartNumber,omitempty"` // MaxLen=256
+ OtherIdentifyingInfo string `xml:"OtherIdentifyingInfo,omitempty"` // MaxLen=256
+ PoweredOn bool `xml:"PoweredOn,omitempty"`
+ ManufactureDate DateTime `xml:"ManufactureDate,omitempty"`
+ VendorEquipmentType string `xml:"VendorEquipmentType,omitempty"` // MaxLen=256
+ UserTracking string `xml:"UserTracking,omitempty"` // MaxLen=256
+ CanBeFRUed bool `xml:"CanBeFRUed,omitempty"`
+}
+
+type PhysicalComponent struct {
+ PhysicalElement
+ RemovalConditions RemovalConditions `xml:"RemovalConditions,omitempty"`
+ Removable bool `xml:"Removable,omitempty"`
+ Replaceable bool `xml:"Replaceable,omitempty"`
+ HotSwappable bool `xml:"HotSwappable,omitempty"`
+}
+type Chip struct {
+ PhysicalComponent
+}
+
+type PhysicalPackage struct {
+ PhysicalElement
+ PackageType PackageType `xml:"PackageType,omitempty"`
+}
+
+/**
+ * Enabled:1 | Disabled:2 | Enabled For Debug:3
+ */
+type Enabled int
+type PhysicalFrame struct {
+ PhysicalPackage
+ VendorCompatibilityStrings []string `xml:"VendorCompatibilityStrings,omitempty"`
+ OtherPackageType string `xml:"OtherPackageType,omitempty"`
+ Weight int `xml:"Weight,omitempty"`
+ Width int `xml:"Width,omitempty"`
+ Depth int `xml:"Depth,omitempty"`
+ Height int `xml:"Height,omitempty"`
+ RemovalConditions RemovalConditions `xml:"RemovalConditions,omitempty"`
+ Removable bool `xml:"Removable,omitempty"`
+ Replaceable bool `xml:"Replaceable,omitempty"`
+ HotSwappable bool `xml:"HotSwappable,omitempty"`
+ CableManagementStrategy string `xml:"CableManagementStrategy,omitempty"`
+ ServicePhilosophy ServicePhilosophy `xml:"ServicePhilosophy,omitempty"`
+ ServiceDescriptions []string `xml:"ServiceDescriptions,omitempty"`
+ LockPresent bool `xml:"LockPresent,omitempty"`
+ AudibleAlarm bool `xml:"AudibleAlarm,omitempty"`
+ VisibleAlarm bool `xml:"VisibleAlarm,omitempty"`
+ SecurityBreach SecurityBreach `xml:"SecurityBreach,omitempty"`
+ BreachDescription string `xml:"BreachDescription,omitempty"`
+ IsLocked bool `xml:"IsLocked,omitempty"`
+}
+
+type Chassis struct {
+ PhysicalFrame
+ ChassisPackageType ChassisPackageType `xml:"ChassisPackageType,omitempty"`
+}
+
+type LogicalElement struct {
+ ManagedSystemElement
+}
+
+type SoftwareElement struct {
+ LogicalElement
+ Version string `xml:"Version,omitempty"`
+ SoftwareElementState SoftwareElementState `xml:"SoftwareElementState,omitempty"`
+ SoftwareElementId string `xml:"SoftwareElementId,omitempty"`
+ TargetOperatingSystem TargetOperatingSystem `xml:"TargetOperatingSystem,omitempty"`
+ OtherTargetOs string `xml:"OtherTargetOs,omitempty"`
+ Manufacturer string `xml:"Manufacturer,omitempty"`
+ BuildNumber string `xml:"BuildNumber,omitempty"`
+ SerialNumber string `xml:"SerialNumber,omitempty"`
+ CodeSet string `xml:"CodeSet,omitempty"`
+ IdentificationCode string `xml:"IdentificationCode,omitempty"`
+ LanguageEdition string `xml:"LanguageEdition,omitempty"`
+}
+type BIOSElement struct {
+ SoftwareElement
+ PrimaryBIOS bool `xml:"PrimaryBIOS,omitempty"`
+ ReleaseDate DateTime
+}
+type BootSettingData struct {
+ SettingData
+ OwningEntity string `xml:"OwningEntity,omitempty"` // MaxLen=256
+}
+
+// SharedCredential represents a shared credential for a device.
+type SharedCredential struct {
+ InstanceID string `xml:"InstanceID,omitempty"`
+ RemoteID string `xml:"RemoteID,omitempty"`
+ Secret string `xml:"Secret,omitempty"`
+ Algorithm string `xml:"Algorithm,omitempty"`
+ Protocol string `xml:"Protocol,omitempty"`
+}
+
+// IEEE8021xSettings represents the IEEE 802.1x settings for a network interface.
+type IEEE8021xSettings struct {
+ XMLName xml.Name `xml:"h:IEEE8021xSettingsInput,omitempty"`
+ H string `xml:"xmlns:q,attr"`
+ ElementName string `xml:"ElementName,omitempty"`
+ InstanceID string `xml:"InstanceID,omitempty"`
+ AuthenticationProtocol AuthenticationProtocol `xml:"AuthenticationProtocol"`
+ RoamingIdentity string `xml:"RoamingIdentity,omitempty"`
+ ServerCertificateName string `xml:"ServerCertificateName,omitempty"`
+ ServerCertificateNameComparison ServerCertificateNameComparison `xml:"ServerCertificateNameComparison,omitempty"`
+ Username string `xml:"Username,omitempty"`
+ Password string `xml:"Password,omitempty"`
+ Domain string `xml:"Domain,omitempty"`
+ ProtectedAccessCredential string `xml:"ProtectedAccessCredential,omitempty"`
+ PACPassword string `xml:"PACPassword,omitempty"`
+ PSK string `xml:"PSK,omitempty"`
+}
+
+type AuthenticationProtocol int
+
+// BootSourceSetting represents the boot source settings for a device.
+type BootSourceSetting struct {
+ SettingData
+ StructuredBootString string `xml:"StructuredBootString,omitempty"`
+ BIOSBootString string `xml:"BIOSBootString,omitempty"`
+ BootString string `xml:"BootString,omitempty"`
+ FailThroughSupported FailThroughSupported `xml:"FailThroughSupported,omitempty"`
+}
+
+type Service struct {
+ EnabledLogicalElement
+ SystemCreationClassName string `xml:"SystemCreationClassName,omitempty"`
+ SystemName string `xml:"SystemName,omitempty"`
+ CreationClassName string `xml:"CreationClassName,omitempty"`
+ PrimaryOwnerName string `xml:"PrimaryOwnerName,omitempty"`
+ PrimaryOwnerContact string `xml:"PrimaryOwnerContact,omitempty"`
+ StartMode string `xml:"StartMode,omitempty"`
+ Started bool `xml:"Started,omitempty"`
+}
+
+type SecurityService struct {
+ Service
+}
+
+type AuthenticationService struct {
+ SecurityService
+}
+type NetworkPortConfigurationService struct {
+ Service
+}
+type CredentialManagementService struct {
+ AuthenticationService
+ // InstanceID is an optional property that may be used to opaquely and uniquely identify an instance of this class within the scope of the instantiating Namespace . . .
+ InstanceID string // MaxLen=256
+}
+
+type EnabledLogicalElement struct {
+ LogicalElement
+ EnabledState EnabledState `xml:"EnabledState,omitempty"`
+ OtherEnabledState string `xml:"OtherEnabledState,omitempty"`
+ RequestedState RequestedState `xml:"RequestedState,omitempty"`
+ EnabledDefault EnabledDefault `xml:"EnabledDefault,omitempty"`
+ TimeOfLastStateChange DateTime
+}
+type LogicalDevice struct {
+ EnabledLogicalElement EnabledLogicalElement
+ SystemCreationClassName string `xml:"SystemCreationClassName,omitempty"`
+ SystemName string `xml:"SystemName,omitempty"`
+ CreationClassName string `xml:"CreationClassName,omitempty"`
+ DeviceId string `xml:"DeviceId,omitempty"`
+ PowerManagementSupported bool `xml:"PowerManagementSupported,omitempty"`
+ PowerManagementCapabilities []PowerManagementCapabilitiesValues `xml:"PowerManagementCapabilities,omitempty"`
+ Availability AvailabilityValues `xml:"Availability,omitempty"`
+ StatusInfo StatusInfoValues `xml:"StatusInfo,omitempty"`
+ LastErrorCode int `xml:"LastErrorCode,omitempty"`
+ ErrorDescription string `xml:"ErrorDescription,omitempty"`
+ ErrorCleared bool `xml:"ErrorCleared,omitempty"`
+ OtherIdentifyingInfo []string `xml:"OtherIdentifyingInfo,omitempty"`
+ PowerOnHours int `xml:"PowerOnHours,omitempty"`
+ TotalPowerOnHours int `xml:"TotalPowerOnHours,omitempty"`
+ IdentifyingDescriptions []string `xml:"IdentifyingDescriptions,omitempty"`
+ AdditionalAvailability []AdditionalAvailabilityValues `xml:"AdditionalAvailability,omitempty"`
+ MaxQuiesceTime int `xml:"MaxQuiesceTime,omitempty"`
+}
+
+type Job struct {
+ LogicalElement
+ InstanceId string `xml:"InstanceId,omitempty"`
+ CommunicationStatus CommunicationStatus `xml:"CommunicationStatus,omitempty"`
+ DetailedStatus DetailedStatus `xml:"DetailedStatus,omitempty"`
+ OperatingStatus OperatingStatus `xml:"OperatingStatus,omitempty"`
+ PrimaryStatus PrimaryStatus `xml:"PrimaryStatus,omitempty"`
+ JobStatus string `xml:"JobStatus,omitempty"`
+ TimeSubmitted DateTime `xml:"TimeSubmitted,omitempty"`
+ ScheduledStartTime DateTime `xml:"ScheduledStartTime,omitempty"`
+ StartTime DateTime `xml:"StartTime,omitempty"`
+ ElapsedTime DateTime `xml:"ElapsedTime,omitempty"`
+ JobRunTimes int `xml:"JobRunTimes,omitempty"`
+ RunMonth RunMonth `xml:"RunMonth,omitempty"`
+ RunDay int `xml:"RunDay,omitempty"`
+ RunDayOfWeek RunDayOfWeek `xml:"RunDayOfWeek,omitempty"`
+ RunStartInterval DateTime `xml:"RunStartInterval,omitempty"`
+ LocalOrUtcTime LocalOrUtcTime `xml:"LocalOrUtcTime,omitempty"`
+ Notify string `xml:"Notify,omitempty"`
+ Owner string `xml:"Owner,omitempty"`
+ Priority int `xml:"Priority,omitempty"`
+ PercentComplete int `xml:"PercentComplete,omitempty"`
+ DeleteOnCompletion bool `xml:"DeleteOnCompletion,omitempty"`
+ ErrorCode int `xml:"ErrorCode,omitempty"`
+ ErrorDescription string `xml:"ErrorDescription,omitempty"`
+ RecoveryAction RecoveryAction `xml:"RecoveryAction,omitempty"`
+ OtherRecoveryAction string `xml:"OtherRecoveryAction,omitempty"`
+}
+type ConcreteJob struct {
+ Job
+ UntilTime DateTime `xml:"UntilTime,omitempty"`
+ JobState ConcreteJobState `xml:"JobState,omitempty"`
+ TimeOfLastStateChange DateTime `xml:"TimeOfLastStateChange,omitempty"`
+ TimeBeforeRemoval DateTime `xml:"TimeBeforeRemoval,omitempty"`
+}
+
+type ConcreteJobState int
+
+type CommunicationStatus int
+
+type DetailedStatus int
+
+type OperatingStatus int
+
+type PrimaryStatus int
+
+type RunMonth int
+
+type RunDayOfWeek int
+
+type RecoveryAction int
+
+type LocalOrUtcTime int
+
+type PowerManagementCapabilitiesValues int
+
+type AvailabilityValues int
+
+type StatusInfoValues int
+
+type AdditionalAvailabilityValues int
+
+type Credential struct {
+ ManagedElement
+ Issued DateTime `xml:"Issued,omitempty"` // The date and time when the credential was issued. Default is current time
+ Expires DateTime `xml:"Expires,omitempty"` // The date and time when the credential expires (and is not appropriate for use for authentication/authorization). Default is '99991231235959.999999+999'
+}
+
+type CredentialContext struct {
+ ElementInContext Credential
+ ElementProvidingContext ManagedElement
+}
+
+type ManagedSystemElement struct {
+ ManagedElement
+ InstallDate DateTime `xml:"InstallDate,omitempty"`
+ Name string `xml:"Name,omitempty"`
+ OperationalStatus OperationalStatus `xml:"OperationalStatus,omitempty"`
+ StatusDescriptions []string `xml:"Items>StatusDescriptions,omitempty"`
+ Status string `xml:"Status,omitempty"`
+ HealthState HealthState `xml:"HealthState,omitempty"`
+}
+
+type DateTime struct {
+ DateTime string `xml:"DateTime,omitempty"`
+}
+
+type ServiceAvailableToElement struct {
+ ServiceProvided ServiceProvider
+ UserOfService UserOfService
+}
+
+type AssociationReference struct {
+ Address string `xml:"Address,omitempty"`
+ ReferenceParameters ReferenceParmetersNoNamespace
+}
+
+type ReferenceParmetersNoNamespace struct {
+ ResourceURI string `xml:"ResourceURI,omitempty"`
+ SelectorSet []SelectorNoNamespace `xml:"SelectorSet>Selector,omitempty"`
+}
+
+type SelectorNoNamespace struct {
+ //XMLName xml.Name `xml:"Selector,omitempty"`
+ Name string `xml:"Name,attr"`
+ Value string `xml:",chardata"`
+}
+
+type ServiceProvider struct {
+ Address string `xml:"Address,omitempty"`
+ ReferenceParameters ReferenceParameters
+}
+
+type UserOfService struct {
+ Address string `xml:"Address,omitempty"`
+ ReferenceParameters ReferenceParameters
+}
+
+type ReferenceParameters struct {
+ XMLName xml.Name `xml:"ReferenceParameters"`
+ H string `xml:"xmlns:c,attr"`
+ ResourceURI string `xml:"c:ResourceURI,omitempty"`
+ SelectorSet SelectorSet `xml:"c:SelectorSet,omitempty"`
+}
+
+type ReferenceParameters_OUTPUT struct {
+ ResourceURI string `xml:"ResourceURI,omitempty"`
+ SelectorSet SelectorSet_OUTPUT `xml:"SelectorSet,omitempty"`
+}
+type SelectorSet_OUTPUT struct {
+ XMLName xml.Name `xml:"SelectorSet,omitempty"`
+ Selector []message.Selector_OUTPUT
+}
+
+type SelectorSet struct {
+ H string `xml:"xmlns:c,attr"`
+ XMLName xml.Name `xml:"c:SelectorSet,omitempty"`
+ Selector []Selector
+}
+
+type Selector struct {
+ H string `xml:"xmlns:c,attr"`
+ XMLName xml.Name `xml:"c:Selector,omitempty"`
+ Name string `xml:"Name,attr"`
+ Value string `xml:",chardata"`
+}
+
+type AssociatedPowerManagementService struct {
+ ServiceAvailableToElement
+ CIMAssociatedPowerManagementService CIMAssociatedPowerManagementServiceItem
+}
+
+type CIMAssociatedPowerManagementServiceItem struct {
+ ServiceAvailableToElement
+ AvailableRequestedPowerStates []string `xml:"AvailableRequestedPowerStates,omitempty"`
+ PowerState string `xml:"PowerState,omitempty"`
+}
+
+type SoftwareIdentity struct {
+ LogicalElement
+ CIMSoftwareIdentity []CIMSoftwareIdentityItem
+}
+
+type CIMSoftwareIdentityItem struct {
+ LogicalElement
+ InstanceID string `xml:"InstanceID,omitempty"`
+ VersionString string `xml:"VersionString,omitempty"`
+ IsEntity bool `xml:"IsEntity,omitempty"`
+}
+
+type Log struct {
+ EnabledLogicalElement
+ MaxNumberOfRecords int `xml:"MaxNumberOfRecords,omitempty"`
+ CurrentNumberOfRecords int `xml:"CurrentNumberOfRecords,omitempty"`
+ OverwritePolicy OverwritePolicy `xml:"OverwritePolicy,omitempty"`
+ LogState LogState `xml:"LogState,omitempty"`
+}
+
+type MessageLog struct {
+ Log
+ CreationClassName string `xml:"CreationClassName,omitempty"`
+ Capabilities []CapabilitiesValues `xml:"Capabilities,omitempty"`
+ CapabilitiesDescriptions []string `xml:"CapabilitiesDescriptions,omitempty"`
+ MaxLogSize int `xml:"MaxLogSize,omitempty"`
+ SizeOfHeader int `xml:"SizeOfHeader,omitempty"`
+ HeaderFormat string `xml:"HeaderFormat,omitempty"`
+ MaxRecordSize int `xml:"MaxRecordSize,omitempty"`
+ SizeOfRecordHeader int `xml:"SizeOfRecordHeader,omitempty"`
+ RecordHeaderFormat string `xml:"RecordHeaderFormat,omitempty"`
+ OtherPolicyDescription string `xml:"OtherPolicyDescription,omitempty"`
+ TimeWhenOutdated DateTime `xml:"TimeWhenOutdated,omitempty"`
+ PercentageNearFull int `xml:"PercentageNearFull,omitempty"`
+ LastChange LastChange `xml:"LastChange,omitempty"`
+ TimeOfLastChange DateTime `xml:"TimeOfLastChange,omitempty"`
+ RecordLastChanged int `xml:"RecordLastChanged,omitempty"`
+ IsFrozen bool `xml:"IsFrozen,omitempty"`
+ CharacterSet CharacterSet `xml:"CharacterSet,omitempty"`
+}
+
+type ServiceAccessPoint struct {
+ EnabledLogicalElement EnabledLogicalElement
+ SystemCreationClassName string `xml:"SystemCreationClassName,omitempty"`
+ SystemName string `xml:"SystemName,omitempty"`
+ CreationClassName string `xml:"CreationClassName,omitempty"`
+}
+
+type OverwritePolicy int
+type LogState int
+type CapabilitiesValues int
+type LastChange int
+type CharacterSet int
+type BootConfigSettingInstanceID string
+type FailThroughSupported int
+type RemovalConditions int
+type PackageType int
+type ServicePhilosophy int
+type SecurityBreach int
+type ChassisPackageType int
+type SoftwareElementState int
+type TargetOperatingSystem int
+
+// ServerCertificateNameComparison represents the ServerCertificateNameComparison type for IEEE8021xProfile.
+type ServerCertificateNameComparison int
+
+// PowerState represents the PowerState type in the PowerManagementService namespace.
+
+type UpgradeMethod int
+type CPUStatus int
+type OperationalStatus int
+type HealthState int
+type EnabledState int
+type RequestedState int
+type EnabledDefault int
diff --git a/pkg/wsman/cim/physical/constants.go b/pkg/wsman/cim/physical/constants.go
new file mode 100644
index 00000000..fc2e1abe
--- /dev/null
+++ b/pkg/wsman/cim/physical/constants.go
@@ -0,0 +1,46 @@
+package physical
+
+const (
+ CIM_PhysicalMemory string = "CIM_PhysicalMemory"
+ CIM_PhysicalPackage string = "CIM_PhysicalPackage"
+)
+
+const (
+ MemoryTypeUnknown MemoryType = iota
+ MemoryTypeOther
+ MemoryTypeDRAM
+ MemoryTypeSynchronous_DRAM
+ MemoryTypeCache_DRAM
+ MemoryTypeEDO
+ MemoryTypeEDRAM
+ MemoryTypeVRAM
+ MemoryTypeSRAM
+ MemoryTypeRAM
+ MemoryTypeROM
+ MemoryTypeFlash
+ MemoryTypeEEPROM
+ MemoryTypeFEPROM
+ MemoryTypeEPROM
+ MemoryTypeCDRAM
+ MemoryType3DRAM
+ MemoryTypeSDRAM
+ MemoryTypeSGRAM
+ MemoryTypeRDRAM
+ MemoryTypeDDR
+ MemoryTypeDDR2
+ MemoryTypeBRAM
+ MemoryTypeFBDIMM
+ MemoryTypeDDR3
+ MemoryTypeFBD2
+ MemoryTypeDDR4
+ MemoryTypeLPDDR
+ MemoryTypeLPDDR2
+ MemoryTypeLPDDR3
+ MemoryTypeLPDDR4
+ MemoryTypeLogicalnonvolatiledevice
+ MemoryTypeHBM
+ MemoryTypeHBM2
+ MemoryTypeDDR5
+ MemoryTypeLPDDR5
+ MemoryTypeHBM3
+)
diff --git a/pkg/wsman/cim/physical/marshal.go b/pkg/wsman/cim/physical/marshal.go
new file mode 100644
index 00000000..caea1538
--- /dev/null
+++ b/pkg/wsman/cim/physical/marshal.go
@@ -0,0 +1,30 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package physical
+
+import (
+ "encoding/json"
+
+ "gopkg.in/yaml.v3"
+)
+
+// JSON marshals the type into JSON format
+func (r *Response) JSON() string {
+ jsonOutput, err := json.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(jsonOutput)
+}
+
+// YAML marshals the type into YAML format
+func (r *Response) YAML() string {
+ yamlOutput, err := yaml.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(yamlOutput)
+}
diff --git a/pkg/wsman/cim/physical/memory.go b/pkg/wsman/cim/physical/memory.go
new file mode 100644
index 00000000..2b274985
--- /dev/null
+++ b/pkg/wsman/cim/physical/memory.go
@@ -0,0 +1,63 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package physical
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+)
+
+// NewPhysicalMemory returns a new instance of the PhysicalMemory struct.
+func NewPhysicalMemoryWithClient(wsmanMessageCreator *message.WSManMessageCreator, client client.WSMan) Memory {
+ return Memory{
+ base: message.NewBaseWithClient(wsmanMessageCreator, CIM_PhysicalMemory, client),
+ client: client,
+ }
+}
+
+// TODO: Figure out how to call GET requiring resourceURIs and Selectors
+// Get retrieves the representation of the instance
+
+// Enumerate returns an enumeration context which is used in a subsequent Pull call
+func (memory Memory) Enumerate() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: memory.base.Enumerate(),
+ },
+ }
+
+ err = memory.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+
+}
+
+// Pull returns the instances of this class. An enumeration context provided by the Enumerate call is used as input.
+func (memory Memory) Pull(enumerationContext string) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: memory.base.Pull(enumerationContext),
+ },
+ }
+ err = memory.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
diff --git a/pkg/wsman/cim/physical/memory_test.go b/pkg/wsman/cim/physical/memory_test.go
new file mode 100644
index 00000000..741d75d8
--- /dev/null
+++ b/pkg/wsman/cim/physical/memory_test.go
@@ -0,0 +1,220 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package physical
+
+import (
+ "encoding/xml"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
+)
+
+func TestPositiveCIMMemory(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "cim/physical/memory",
+ }
+ elementUnderTest := NewPhysicalMemoryWithClient(wsmanMessageCreator, &client)
+
+ t.Run("cim_Memory Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //ENUMERATES
+ {
+ "should create and parse a valid cim_PhysicalMemory Enumerate call",
+ "CIM_PhysicalMemory",
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Enumerate"
+ return elementUnderTest.Enumerate()
+ }, Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "D6020000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create and parse a valid cim_PhysicalMemory Pull call",
+ "CIM_PhysicalMemory",
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Pull"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ MemoryItems: []PhysicalMemory{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_PhysicalMemory", Local: "CIM_PhysicalMemory"},
+ BankLabel: "BANK 0",
+ Capacity: 17179869184,
+ ConfiguredMemoryClockSpeed: 2400,
+ CreationClassName: "CIM_PhysicalMemory",
+ ElementName: "Managed System Memory Chip",
+ FormFactor: 13,
+ IsSpeedInMhz: true,
+ Manufacturer: "859B",
+ MaxMemorySpeed: 2400,
+ MemoryType: 26,
+ PartNumber: "CT16G4SFD824A.M16FE ",
+ SerialNumber: "E0E8D670",
+ Speed: 0,
+ Tag: "9876543210",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_PhysicalMemory", Local: "CIM_PhysicalMemory"},
+ BankLabel: "BANK 2",
+ Capacity: 17179869184,
+ ConfiguredMemoryClockSpeed: 2400,
+ CreationClassName: "CIM_PhysicalMemory",
+ ElementName: "Managed System Memory Chip",
+ FormFactor: 13,
+ IsSpeedInMhz: true,
+ Manufacturer: "859B",
+ MaxMemorySpeed: 2400,
+ MemoryType: 26,
+ PartNumber: "CT16G4SFD824A.M16FE ",
+ SerialNumber: "E0E8D070",
+ Speed: 0,
+ Tag: "9876543210 (#1)",
+ },
+ },
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.NoError(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.Equal(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
+func TestNegativeCIMMemory(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "cim/physical/memory",
+ }
+ elementUnderTest := NewPhysicalMemoryWithClient(wsmanMessageCreator, &client)
+
+ t.Run("cim_Memory Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //ENUMERATES
+ {
+ "should create and parse a valid cim_PhysicalMemory Enumerate call",
+ "CIM_PhysicalMemory",
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Enumerate()
+ }, Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "D6020000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create and parse a valid cim_PhysicalMemory Pull call",
+ "CIM_PhysicalMemory",
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ MemoryItems: []PhysicalMemory{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_PhysicalMemory", Local: "CIM_PhysicalMemory"},
+ BankLabel: "BANK 0",
+ Capacity: 17179869184,
+ ConfiguredMemoryClockSpeed: 2400,
+ CreationClassName: "CIM_PhysicalMemory",
+ ElementName: "Managed System Memory Chip",
+ FormFactor: 13,
+ IsSpeedInMhz: true,
+ Manufacturer: "859B",
+ MaxMemorySpeed: 2400,
+ MemoryType: 26,
+ PartNumber: "CT16G4SFD824A.M16FE ",
+ SerialNumber: "E0E8D670",
+ Speed: 0,
+ Tag: "9876543210",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_PhysicalMemory", Local: "CIM_PhysicalMemory"},
+ BankLabel: "BANK 2",
+ Capacity: 17179869184,
+ ConfiguredMemoryClockSpeed: 2400,
+ CreationClassName: "CIM_PhysicalMemory",
+ ElementName: "Managed System Memory Chip",
+ FormFactor: 13,
+ IsSpeedInMhz: true,
+ Manufacturer: "859B",
+ MaxMemorySpeed: 2400,
+ MemoryType: 26,
+ PartNumber: "CT16G4SFD824A.M16FE ",
+ SerialNumber: "E0E8D070",
+ Speed: 0,
+ Tag: "9876543210 (#1)",
+ },
+ },
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.Error(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.NotEqual(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
diff --git a/pkg/wsman/cim/physical/package.go b/pkg/wsman/cim/physical/package.go
new file mode 100644
index 00000000..924e0ed9
--- /dev/null
+++ b/pkg/wsman/cim/physical/package.go
@@ -0,0 +1,63 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package physical
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+)
+
+// NewPhysicalPackage returns a new instance of the PhysicalPackage struct.
+func NewPhysicalPackageWithClient(wsmanMessageCreator *message.WSManMessageCreator, client client.WSMan) Package {
+ return Package{
+ base: message.NewBaseWithClient(wsmanMessageCreator, CIM_PhysicalPackage, client),
+ client: client,
+ }
+}
+
+// TODO: Figure out how to call GET requiring resourceURIs and Selectors
+// Get retrieves the representation of the instance
+
+// Enumerate returns an enumeration context which is used in a subsequent Pull call
+func (physicalPackage Package) Enumerate() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: physicalPackage.base.Enumerate(),
+ },
+ }
+
+ err = physicalPackage.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+
+}
+
+// Pull returns the instances of this class. An enumeration context provided by the Enumerate call is used as input.
+func (physicalPackage Package) Pull(enumerationContext string) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: physicalPackage.base.Pull(enumerationContext),
+ },
+ }
+ err = physicalPackage.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
diff --git a/pkg/wsman/cim/physical/package_test.go b/pkg/wsman/cim/physical/package_test.go
new file mode 100644
index 00000000..44a9be84
--- /dev/null
+++ b/pkg/wsman/cim/physical/package_test.go
@@ -0,0 +1,187 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package physical
+
+import (
+ "encoding/xml"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/card"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
+)
+
+func TestPositiveCIMPackage(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "cim/physical/package",
+ }
+ elementUnderTest := NewPhysicalPackageWithClient(wsmanMessageCreator, &client)
+
+ t.Run("cim_Package Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //ENUMERATES
+ {
+ "should create a valid cim_PhysicalPackage Enumerate wsman message",
+ CIM_PhysicalPackage,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Enumerate"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "D8020000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid cim_PhysicalPackage Pull wsman message",
+ CIM_PhysicalPackage,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Pull"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "D7020000-0000-0000-0000-000000000000",
+ },
+ PhysicalPackage: []card.PackageResponse{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_Card", Local: "CIM_Card"},
+ CanBeFRUed: true,
+ CreationClassName: "CIM_Card",
+ ElementName: "Managed System Base Board",
+ Manufacturer: "Intel Corporation",
+ Model: "NUC9V7QNB",
+ OperationalStatus: 0,
+ PackageType: 9,
+ SerialNumber: "KNQN0221020W",
+ Tag: "CIM_Card",
+ Version: "K47180-402",
+ },
+ },
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.NoError(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.Equal(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
+func TestNegativeCIMPackage(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "cim/physical/package",
+ }
+ elementUnderTest := NewPhysicalPackageWithClient(wsmanMessageCreator, &client)
+
+ t.Run("cim_Package Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //ENUMERATES
+ {
+ "should create a valid cim_PhysicalPackage Enumerate wsman message",
+ CIM_PhysicalPackage,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "D8020000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create a valid cim_PhysicalPackage Pull wsman message",
+ CIM_PhysicalPackage,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "D7020000-0000-0000-0000-000000000000",
+ },
+ PhysicalPackage: []card.PackageResponse{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_Card", Local: "CIM_Card"},
+ CanBeFRUed: true,
+ CreationClassName: "CIM_Card",
+ ElementName: "Managed System Base Board",
+ Manufacturer: "Intel Corporation",
+ Model: "NUC9V7QNB",
+ OperationalStatus: 0,
+ PackageType: 9,
+ SerialNumber: "KNQN0221020W",
+ Tag: "CIM_Card",
+ Version: "K47180-402",
+ },
+ },
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.Error(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.NotEqual(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
diff --git a/pkg/wsman/cim/physical/types.go b/pkg/wsman/cim/physical/types.go
new file mode 100644
index 00000000..432132e4
--- /dev/null
+++ b/pkg/wsman/cim/physical/types.go
@@ -0,0 +1,70 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package physical
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/card"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/models"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+)
+
+type Memory struct {
+ base message.Base
+ client client.WSMan
+}
+
+type Package struct {
+ base message.Base
+ client client.WSMan
+}
+
+// Response Types
+type (
+ Response struct {
+ *client.Message
+ XMLName xml.Name `xml:"Envelope"`
+ Header message.Header `xml:"Header"`
+ Body Body `xml:"Body"`
+ }
+
+ Body struct {
+ XMLName xml.Name `xml:"Body"`
+ PullResponse PullResponse
+ EnumerateResponse common.EnumerateResponse
+ MemoryResponse PhysicalMemory
+ }
+
+ PullResponse struct {
+ XMLName xml.Name `xml:"PullResponse"`
+ common.EnumerateResponse
+ MemoryItems []PhysicalMemory `xml:"Items>CIM_PhysicalMemory"`
+ PhysicalPackage []card.PackageResponse `xml:"Items>CIM_Card"` // This might need to be fixed if we get more than just CIM_Card back on a Pull call
+ }
+ PhysicalMemory struct {
+ XMLName xml.Name `xml:"CIM_PhysicalMemory"`
+ PartNumber string `xml:"PartNumber"`
+ SerialNumber string `xml:"SerialNumber"`
+ Manufacturer string `xml:"Manufacturer"`
+ ElementName string `xml:"ElementName"`
+ CreationClassName string `xml:"CreationClassName"`
+ Tag string `xml:"Tag"`
+ OperationalStatus models.OperationalStatus `xml:"OperationalStatus"`
+ FormFactor int `xml:"FormFactor,omitempty"`
+ MemoryType MemoryType `xml:"MemoryType,omitempty"`
+ Speed int `xml:"Speed,omitempty"`
+ Capacity int `xml:"Capacity,omitempty"`
+ BankLabel string `xml:"BankLabel,omitempty"`
+ ConfiguredMemoryClockSpeed int `xml:"ConfiguredMemoryClockSpeed,omitempty"`
+ IsSpeedInMhz bool `xml:"IsSpeedInMhz,omitempty"`
+ MaxMemorySpeed int `xml:"MaxMemorySpeed,omitempty"`
+ }
+
+ MemoryType int
+)
diff --git a/pkg/wsman/cim/power/constants.go b/pkg/wsman/cim/power/constants.go
new file mode 100644
index 00000000..30e48e17
--- /dev/null
+++ b/pkg/wsman/cim/power/constants.go
@@ -0,0 +1,58 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package power
+
+const (
+ CIM_PowerManagementService string = "CIM_PowerManagementService"
+ RequestPowerStateChange string = "RequestPowerStateChange"
+)
+
+const (
+ // Power On
+ PowerOn PowerState = 2 // Verified Hardware Power On
+
+ // Sleep - Light
+ SleepLight PowerState = 3 // ?
+
+ // Sleep - Deep
+ SleepDeep PowerState = 4 // ?
+
+ // Power Cycle (Off Soft)
+ PowerCycleOffSoft PowerState = 6 // ?
+
+ // Power Off - Hard
+ PowerOffHard PowerState = 8 // Verfied Hardware Power Off
+
+ // Hibernate
+ Hibernate PowerState = 7 // ?
+
+ // Power Off - Soft
+ PowerOffSoft PowerState = 9 // ?
+
+ // Power Cycle (Off Hard)
+ PowerCycleOffHard PowerState = 5 // Verified Hardware Power Cycle (off then on)
+
+ // Master Bus Reset
+ MasterBusReset PowerState = 10 // Verified Hardware Reboot
+
+ // Diagnostic Interrupt (NMI)
+ DiagnosticInterruptNMI PowerState = 11 // ?
+
+ // Power Off - Soft Graceful
+ PowerOffSoftGraceful PowerState = 12 // ?
+
+ // Power Off - Hard Graceful
+ PowerOffHardGraceful PowerState = 13 // ?
+
+ // Master Bus Reset Graceful
+ MasterBusResetGraceful PowerState = 14 // ?
+
+ // Power Cycle (Off - Soft Graceful)
+ PowerCycleOffSoftGraceful PowerState = 15 // ?
+
+ // Power Cycle (Off - Hard Graceful)
+ PowerCycleOffHardGraceful PowerState = 16 // ?
+)
diff --git a/pkg/wsman/cim/power/managementservice.go b/pkg/wsman/cim/power/managementservice.go
new file mode 100644
index 00000000..5b1b4e80
--- /dev/null
+++ b/pkg/wsman/cim/power/managementservice.go
@@ -0,0 +1,106 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package power
+
+import (
+ "encoding/xml"
+ "fmt"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/methods"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+)
+
+// NewPowerManagementService returns a new instance of the PowerManagementService struct.
+func NewPowerManagementServiceWithClient(wsmanMessageCreator *message.WSManMessageCreator, client client.WSMan) ManagementService {
+ return ManagementService{
+ base: message.NewBaseWithClient(wsmanMessageCreator, CIM_PowerManagementService, client),
+ client: client,
+ }
+}
+
+// RequestPowerStateChange defines the desired power state of the managed element, and when the element should be put into that state.
+func (managementService ManagementService) RequestPowerStateChange(powerState PowerState) (response Response, err error) {
+ header := managementService.base.WSManMessageCreator.CreateHeader(methods.GenerateAction(CIM_PowerManagementService, RequestPowerStateChange), CIM_PowerManagementService, nil, "", "")
+ body := fmt.Sprintf(`%dhttp://schemas.xmlsoap.org/ws/2004/08/addressinghttp://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ComputerSystemCIM_ComputerSystemManagedSystem`, powerState)
+ response = Response{
+ Message: &client.Message{
+ XMLInput: managementService.base.WSManMessageCreator.CreateXML(header, body),
+ },
+ }
+ // send the message to AMT
+ err = managementService.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ // put the xml response into the go struct
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+
+ return
+}
+
+// Get retrieves the representation of the instance
+func (managementService ManagementService) Get() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: managementService.base.Get(nil),
+ },
+ }
+
+ err = managementService.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+
+}
+
+// // Enumerate returns an enumeration context which is used in a subsequent Pull call
+func (managementService ManagementService) Enumerate() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: managementService.base.Enumerate(),
+ },
+ }
+
+ err = managementService.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Pull returns the instances of this class. An enumeration context provided by the Enumerate call is used as input.
+func (managementService ManagementService) Pull(enumerationContext string) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: managementService.base.Pull(enumerationContext),
+ },
+ }
+ err = managementService.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
diff --git a/pkg/wsman/cim/power/managementservice_test.go b/pkg/wsman/cim/power/managementservice_test.go
new file mode 100644
index 00000000..84c62626
--- /dev/null
+++ b/pkg/wsman/cim/power/managementservice_test.go
@@ -0,0 +1,257 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package power
+
+import (
+ "encoding/xml"
+ "testing"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/methods"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
+ "github.com/stretchr/testify/assert"
+)
+
+const (
+ RequestPowerStateChange_BODY = "8http://schemas.xmlsoap.org/ws/2004/08/addressinghttp://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ComputerSystemCIM_ComputerSystemManagedSystem"
+)
+
+func TestPositiveCIMPowerManagementService(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "cim/power/managementservice",
+ }
+ elementUnderTest := NewPowerManagementServiceWithClient(wsmanMessageCreator, &client)
+
+ t.Run("cim_PowerManagementService Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ {
+ "Should issue a valid cim_PowerManagementService RequestPowerStateChange call",
+ CIM_PowerManagementService,
+ methods.GenerateAction(CIM_PowerManagementService, RequestPowerStateChange),
+ RequestPowerStateChange_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "RequestPowerStateChange"
+ var powerState PowerState = PowerOffHard
+ return elementUnderTest.RequestPowerStateChange(powerState)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ RequestPowerStateChangeResponse: PowerActionResponse{
+ ReturnValue: 0,
+ },
+ },
+ },
+ {
+ "Should issue a valid cim_PowerManagementService Get call",
+ CIM_PowerManagementService,
+ wsmantesting.GET,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Get"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GetResponse: PowerManagementService{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_PowerManagementService", Local: "CIM_PowerManagementService"},
+ CreationClassName: "CIM_PowerManagementService",
+ ElementName: "Intel(r) AMT Power Management Service",
+ EnabledState: 5,
+ Name: "Intel(r) AMT Power Management Service",
+ RequestedState: 12,
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "Intel(r) AMT",
+ },
+ },
+ },
+ {
+ "Should issue a valid cim_PowerManagementService Enumerate call",
+ CIM_PowerManagementService,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Enumerate"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "DB020000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ {
+ "Should issue a valid cim_PowerManagementService Pull call",
+ CIM_PowerManagementService,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Pull"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ PowerManagementServiceItems: []PowerManagementService{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_PowerManagementService", Local: "CIM_PowerManagementService"},
+ CreationClassName: "CIM_PowerManagementService",
+ ElementName: "Intel(r) AMT Power Management Service",
+ EnabledState: 5,
+ Name: "Intel(r) AMT Power Management Service",
+ RequestedState: 12,
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "Intel(r) AMT",
+ },
+ },
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.NoError(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.Equal(t, test.expectedResponse, response.Body)
+
+ })
+ }
+ })
+}
+
+func TestNegativeCIMPowerManagementService(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "cim/power/managementservice",
+ }
+ elementUnderTest := NewPowerManagementServiceWithClient(wsmanMessageCreator, &client)
+
+ t.Run("cim_PowerManagementService Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ {
+ "Should issue a valid cim_PowerManagementService RequestPowerStateChange call",
+ CIM_PowerManagementService,
+ methods.GenerateAction(CIM_PowerManagementService, RequestPowerStateChange),
+ RequestPowerStateChange_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ var powerState PowerState = PowerOffHard
+ return elementUnderTest.RequestPowerStateChange(powerState)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ RequestPowerStateChangeResponse: PowerActionResponse{
+ ReturnValue: 0,
+ },
+ },
+ },
+ {
+ "Should issue a valid cim_PowerManagementService Get call",
+ CIM_PowerManagementService,
+ wsmantesting.GET,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ GetResponse: PowerManagementService{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_PowerManagementService", Local: "CIM_PowerManagementService"},
+ CreationClassName: "CIM_PowerManagementService",
+ ElementName: "Intel(r) AMT Power Management Service",
+ EnabledState: 5,
+ Name: "Intel(r) AMT Power Management Service",
+ RequestedState: 12,
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "Intel(r) AMT",
+ },
+ },
+ },
+ {
+ "Should issue a valid cim_PowerManagementService Enumerate call",
+ CIM_PowerManagementService,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "DB020000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ {
+ "Should issue a valid cim_PowerManagementService Pull call",
+ CIM_PowerManagementService,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ PowerManagementServiceItems: []PowerManagementService{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_PowerManagementService", Local: "CIM_PowerManagementService"},
+ CreationClassName: "CIM_PowerManagementService",
+ ElementName: "Intel(r) AMT Power Management Service",
+ EnabledState: 5,
+ Name: "Intel(r) AMT Power Management Service",
+ RequestedState: 12,
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "Intel(r) AMT",
+ },
+ },
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.Error(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.NotEqual(t, test.expectedResponse, response.Body)
+
+ })
+ }
+ })
+}
diff --git a/pkg/wsman/cim/power/marshal.go b/pkg/wsman/cim/power/marshal.go
new file mode 100644
index 00000000..0a771f96
--- /dev/null
+++ b/pkg/wsman/cim/power/marshal.go
@@ -0,0 +1,30 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package power
+
+import (
+ "encoding/json"
+
+ "gopkg.in/yaml.v3"
+)
+
+// JSON marshals the type into JSON format
+func (r *Response) JSON() string {
+ jsonOutput, err := json.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(jsonOutput)
+}
+
+// YAML marshals the type into YAML format
+func (r *Response) YAML() string {
+ yamlOutput, err := yaml.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(yamlOutput)
+}
diff --git a/pkg/wsman/cim/power/types.go b/pkg/wsman/cim/power/types.go
new file mode 100644
index 00000000..2e788859
--- /dev/null
+++ b/pkg/wsman/cim/power/types.go
@@ -0,0 +1,59 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package power
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/models"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+)
+
+type ManagementService struct {
+ base message.Base
+ client client.WSMan
+}
+
+type PowerState int
+
+// Response Types
+type (
+ Response struct {
+ *client.Message
+ XMLName xml.Name `xml:"Envelope"`
+ Header message.Header `xml:"Header"`
+ Body Body `xml:"Body"`
+ }
+ Body struct {
+ XMLName xml.Name `xml:"Body"`
+ RequestPowerStateChangeResponse PowerActionResponse `xml:"RequestPowerStateChange_OUTPUT"`
+ GetResponse PowerManagementService
+ EnumerateResponse common.EnumerateResponse
+ PullResponse PullResponse
+ }
+
+ PullResponse struct {
+ XMLName xml.Name `xml:"PullResponse"`
+ PowerManagementServiceItems []PowerManagementService `xml:"Items>CIM_PowerManagementService"`
+ }
+
+ PowerManagementService struct {
+ XMLName xml.Name `xml:"CIM_PowerManagementService"`
+ CreationClassName string `xml:"CreationClassName,omitempty"`
+ ElementName string `xml:"ElementName,omitempty"`
+ EnabledState models.EnabledState `xml:"EnabledState,omitempty"`
+ Name string `xml:"Name,omitempty"`
+ RequestedState models.RequestedState `xml:"RequestedState,omitempty"`
+ SystemCreationClassName string `xml:"SystemCreationClassName,omitempty"`
+ SystemName string `xml:"SystemName,omitempty"`
+ }
+
+ PowerActionResponse struct {
+ ReturnValue int `xml:"ReturnValue"`
+ }
+)
diff --git a/pkg/wsman/cim/processor/constants.go b/pkg/wsman/cim/processor/constants.go
new file mode 100644
index 00000000..ee032cdb
--- /dev/null
+++ b/pkg/wsman/cim/processor/constants.go
@@ -0,0 +1,167 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package processor
+
+const CIM_Processor string = "CIM_Processor"
+
+const (
+ OperationalStatusUnknown OperationalStatus = iota
+ OperationalStatusOther
+ OperationalStatusOK
+ OperationalStatusDegraded
+ OperationalStatusStressed
+ OperationalStatusPredictiveFailure
+ OperationalStatusError
+ OperationalStatusNonRecoverableError
+ OperationalStatusStarting
+ OperationalStatusStopping
+ OperationalStatusStopped
+ OperationalStatusInService
+ OperationalStatusNoContact
+ OperationalStatusLostCommunication
+ OperationalStatusAborted
+ OperationalStatusDormant
+ OperationalStatusSupportingEntityInError
+ OperationalStatusCompleted
+ OperationalStatusPowerMode
+ OperationalStatusRelocating
+)
+
+const (
+ HealthStateUnknown HealthState = iota
+ HealthStateOK
+ HealthStateDegraded
+ HealthStateWarning
+ HealthStateMinorFailure
+ HealthStateMajorFailure
+ HealthStateCriticalFailure
+ HealthStateNonRecoverableError
+ HealthStateDMTFReserved
+ HealthStateVendorSpecific
+)
+
+const (
+ EnabledStateUnknown EnabledState = iota
+ EnabledStateOther
+ EnabledStateEnabled
+ EnabledStateDisabled
+ EnabledStateShuttingDown
+ EnabledStateNotApplicable
+ EnabledStateEnabledButOffline
+ EnabledStateInTestDeferred
+ EnabledStateQuiesce
+ EnabledStateStarting
+ EnabledStateDMTFReserved
+ EnabledStateVendorReserved
+)
+
+const (
+ RequestedStateUnknown RequestedState = iota
+ RequestedStateEnabled
+ RequestedStateDisabled
+ RequestedStateShutDown
+ RequestedStateNoChange
+ RequestedStateOffline
+ RequestedStateTest
+ RequestedStateDeferred
+ RequestedStateQuiesce
+ RequestedStateReboot
+ RequestedStateReset
+ RequestedStateNotApplicable
+ RequestedStateDMTFReserved
+ RequestedStateVendorReserved
+)
+
+const (
+ UpgradeMethodUnknown UpgradeMethod = iota
+ UpgradeMethodOther
+ UpgradeMethodDaughterBoard
+ UpgradeMethodZIFSocket
+ UpgradeMethodReplacement
+ UpgradeMethodPiggyBack
+ UpgradeMethodNone
+ UpgradeMethodLIFSocket
+ UpgradeMethodSlot1
+ UpgradeMethodSlot2
+ UpgradeMethod370PinSocket
+ UpgradeMethodSlotA
+ UpgradeMethodSlotM
+ UpgradeMethodSocket423
+ UpgradeMethodSocketA
+ UpgradeMethodSocket478
+ UpgradeMethodSocket754
+ UpgradeMethodSocket940
+ UpgradeMethodSocket939
+ UpgradeMethodSocketPGA604
+ UpgradeMethodSocketLGA771
+ UpgradeMethodSocketLGA775
+ UpgradeMethodSocketS1
+ UpgradeMethodSocketAM2
+ UpgradeMethodSocketF
+ UpgradeMethodSocketLGA1366
+ UpgradeMethodSocketG34
+ UpgradeMethodSocketAM3
+ UpgradeMethodSocketC32
+ UpgradeMethodSocketLGA1156
+ UpgradeMethodSocketLGA1567
+ UpgradeMethodSocketPGA988A
+ UpgradeMethodSocketBGA1288
+ UpgradeMethodPGA988B
+ UpgradeMethodBGA1023
+ UpgradeMethodBGA1224
+ UpgradeMethodLGA1155
+ UpgradeMethodLGA1356
+ UpgradeMethodLGA2011
+ UpgradeMethodSocketFS1
+ UpgradeMethodSocketFS2
+ UpgradeMethodSocketFM1
+ UpgradeMethodSocketFM2
+ UpgradeMethodSocketLGA2011
+ UpgradeMethodSocketLGA1356
+ UpgradeMethodSocketLGA1150
+ UpgradeMethodSocketBGA1168
+ UpgradeMethodSocketBGA1234
+ UpgradeMethodSocketBGA1364
+ UpgradeMethodSocketAM4
+ UpgradeMethodSocketLGA1151
+ UpgradeMethodSocketBGA1356
+ UpgradeMethodSocketBGA1440
+ UpgradeMethodSocketBGA1515
+ UpgradeMethodSocketLGA3647
+ UpgradeMethodSocketSP3
+ UpgradeMethodSocketSP3r2
+ UpgradeMethodSocketLGA2066
+ UpgradeMethodSocketBGA1392
+ UpgradeMethodSocketBGA1510
+ UpgradeMethodSocketBGA1528
+ UpgradeMethodSocketLGA4189
+ UpgradeMethodSocketLGA1200
+ UpgradeMethodSocketLGA4677
+ UpgradeMethodSocketLGA1700
+ UpgradeMethodSocketBGA1744
+ UpgradeMethodSocketBGA1781
+ UpgradeMethodSocketBGA1211
+ UpgradeMethodSocketBGA2422
+ UpgradeMethodSocketLGA5773
+ UpgradeMethodSocketBGA5773
+ UpgradeMethodSocketAM5
+ UpgradeMethodSocketSP5
+ UpgradeMethodSocketSP6
+ UpgradeMethodSocketBGA883
+ UpgradeMethodSocketBGA1190
+ UpgradeMethodSocketBGA4129
+ UpgradeMethodSocketLGA4710
+ UpgradeMethodSocketLGA7529
+)
+
+const (
+ CPUStatusUnknown CPUStatus = iota
+ CPUStatusCPUEnabled
+ CPUStatusCPUDisabledByUser
+ CPUStatusCPUDisabledByBIOS
+ CPUStatusCPUIsIdle
+ CPUStatusOther
+)
diff --git a/pkg/wsman/cim/processor/marshal.go b/pkg/wsman/cim/processor/marshal.go
new file mode 100644
index 00000000..ab6c506b
--- /dev/null
+++ b/pkg/wsman/cim/processor/marshal.go
@@ -0,0 +1,30 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package processor
+
+import (
+ "encoding/json"
+
+ "gopkg.in/yaml.v3"
+)
+
+// JSON marshals the type into JSON format
+func (r *Response) JSON() string {
+ jsonOutput, err := json.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(jsonOutput)
+}
+
+// YAML marshals the type into YAML format
+func (r *Response) YAML() string {
+ yamlOutput, err := yaml.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(yamlOutput)
+}
diff --git a/pkg/wsman/cim/processor/processor.go b/pkg/wsman/cim/processor/processor.go
new file mode 100644
index 00000000..9a2c0b6b
--- /dev/null
+++ b/pkg/wsman/cim/processor/processor.go
@@ -0,0 +1,82 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+// Package processor facilitates communication with Intel® AMT devices capabilities and management of the Processor LogicalDevice
+package processor
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+)
+
+// NewProcessor returns a new instance of the Processor struct.
+func NewProcessorWithClient(wsmanMessageCreator *message.WSManMessageCreator, client client.WSMan) Package {
+ return Package{
+ base: message.NewBaseWithClient(wsmanMessageCreator, CIM_Processor, client),
+ client: client,
+ }
+}
+
+// Get retrieves the representation of the instance
+func (processor Package) Get() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: processor.base.Get(nil),
+ },
+ }
+
+ err = processor.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+
+}
+
+// Enumerate returns an enumeration context which is used in a subsequent Pull call
+func (processor Package) Enumerate() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: processor.base.Enumerate(),
+ },
+ }
+
+ err = processor.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+
+}
+
+// Pull returns the instances of this class. An enumeration context provided by the Enumerate call is used as input.
+func (processor Package) Pull(enumerationContext string) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: processor.base.Pull(enumerationContext),
+ },
+ }
+ err = processor.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
diff --git a/pkg/wsman/cim/processor/processor_test.go b/pkg/wsman/cim/processor/processor_test.go
new file mode 100644
index 00000000..745f8a8a
--- /dev/null
+++ b/pkg/wsman/cim/processor/processor_test.go
@@ -0,0 +1,262 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package processor
+
+import (
+ "encoding/xml"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
+)
+
+func TestPositiveCIMProcessor(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "cim/physical/processor",
+ }
+ elementUnderTest := NewProcessorWithClient(wsmanMessageCreator, &client)
+
+ t.Run("cim_Processor Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create and parse a valid cim_Processor Get wsman call",
+ CIM_Processor,
+ wsmantesting.GET,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Get"
+ return elementUnderTest.Get()
+ }, Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PackageResponse: PackageResponse{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_Processor", Local: "CIM_Processor"},
+ CPUStatus: 1,
+ CreationClassName: "CIM_Processor",
+ CurrentClockSpeed: 2400,
+ DeviceID: "CPU 0",
+ ElementName: "Managed System CPU",
+ EnabledState: 2,
+ ExternalBusClockSpeed: 100,
+ Family: 198,
+ HealthState: 0,
+ MaxClockSpeed: 8300,
+ OperationalStatus: 0,
+ OtherFamilyDescription: "",
+ RequestedState: 12,
+ Role: "Central",
+ Stepping: "13",
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "ManagedSystem",
+ UpgradeMethod: 52,
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create and parse a valid cim_Processor Enumerate wsman call",
+ CIM_Processor,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Enumerate"
+ return elementUnderTest.Enumerate()
+ }, Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "D9020000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create and parse a valid cim_Processor Pull wsman call",
+ CIM_Processor,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Pull"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ PackageItems: []PackageResponse{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_Processor", Local: "CIM_Processor"},
+ CPUStatus: 1,
+ CreationClassName: "CIM_Processor",
+ CurrentClockSpeed: 2400,
+ DeviceID: "CPU 0",
+ ElementName: "Managed System CPU",
+ EnabledState: 2,
+ ExternalBusClockSpeed: 100,
+ Family: 198,
+ HealthState: 0,
+ MaxClockSpeed: 8300,
+ OperationalStatus: 0,
+ OtherFamilyDescription: "",
+ RequestedState: 12,
+ Role: "Central",
+ Stepping: "13",
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "ManagedSystem",
+ UpgradeMethod: 52,
+ },
+ },
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.NoError(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.Equal(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
+func TestNegativeCIMProcessor(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "cim/physical/processor",
+ }
+ elementUnderTest := NewProcessorWithClient(wsmanMessageCreator, &client)
+
+ t.Run("cim_Processor Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create and parse a valid cim_Processor Get wsman call",
+ CIM_Processor,
+ wsmantesting.GET,
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Get()
+ }, Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PackageResponse: PackageResponse{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_Processor", Local: "CIM_Processor"},
+ CPUStatus: 1,
+ CreationClassName: "CIM_Processor",
+ CurrentClockSpeed: 2400,
+ DeviceID: "CPU 0",
+ ElementName: "Managed System CPU",
+ EnabledState: 2,
+ ExternalBusClockSpeed: 100,
+ Family: 198,
+ HealthState: 0,
+ MaxClockSpeed: 8300,
+ OperationalStatus: 0,
+ OtherFamilyDescription: "",
+ RequestedState: 12,
+ Role: "Central",
+ Stepping: "13",
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "ManagedSystem",
+ UpgradeMethod: 52,
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create and parse a valid cim_Processor Enumerate wsman call",
+ CIM_Processor,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Enumerate()
+ }, Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "D9020000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create and parse a valid cim_Processor Pull wsman call",
+ CIM_Processor,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ PackageItems: []PackageResponse{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_Processor", Local: "CIM_Processor"},
+ CPUStatus: 1,
+ CreationClassName: "CIM_Processor",
+ CurrentClockSpeed: 2400,
+ DeviceID: "CPU 0",
+ ElementName: "Managed System CPU",
+ EnabledState: 2,
+ ExternalBusClockSpeed: 100,
+ Family: 198,
+ HealthState: 0,
+ MaxClockSpeed: 8300,
+ OperationalStatus: 0,
+ OtherFamilyDescription: "",
+ RequestedState: 12,
+ Role: "Central",
+ Stepping: "13",
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "ManagedSystem",
+ UpgradeMethod: 52,
+ },
+ },
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.Error(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.NotEqual(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
diff --git a/pkg/wsman/cim/processor/types.go b/pkg/wsman/cim/processor/types.go
new file mode 100644
index 00000000..e5e963eb
--- /dev/null
+++ b/pkg/wsman/cim/processor/types.go
@@ -0,0 +1,172 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package processor
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+)
+
+type Package struct {
+ base message.Base
+ client client.WSMan
+}
+
+type (
+ Response struct {
+ *client.Message
+ XMLName xml.Name `xml:"Envelope"`
+ Header message.Header `xml:"Header"`
+ Body Body `xml:"Body"`
+ }
+
+ Body struct {
+ XMLName xml.Name `xml:"Body"`
+ PullResponse PullResponse
+ EnumerateResponse common.EnumerateResponse
+ PackageResponse PackageResponse
+ }
+
+ PullResponse struct {
+ XMLName xml.Name `xml:"PullResponse"`
+ PackageItems []PackageResponse `xml:"Items>CIM_Processor"`
+ }
+
+ PackageResponse struct {
+ XMLName xml.Name `xml:"CIM_Processor"`
+ DeviceID string `xml:"DeviceID,omitempty"` // An address or other identifying information to uniquely name the LogicalDevice.
+ CreationClassName string `xml:"CreationClassName,omitempty"` // CreationClassName indicates the name of the class or the subclass used in the creation of an instance. When used with the other key properties of this class, this property allows all instances of this class and its subclasses to be uniquely identified.
+ SystemName string `xml:"SystemName,omitempty"` // The scoping System's Name.
+ SystemCreationClassName string `xml:"SystemCreationClassName,omitempty"` // The scoping System's CreationClassName.
+ ElementName string `xml:"ElementName,omitempty"` // A user-friendly name for the object. This property allows each instance to define a user-friendly name in addition to its key properties, identity data, and description information. Note that the Name property of ManagedSystemElement is also defined as a user-friendly name. But, it is often subclassed to be a Key. It is not reasonable that the same property can convey both identity and a user-friendly name, without inconsistencies. Where Name exists and is not a Key (such as for instances of LogicalDevice), the same information can be present in both the Name and ElementName properties. Note that if there is an associated instance of CIM_EnabledLogicalElementCapabilities, restrictions on this properties may exist as defined in ElementNameMask and MaxElementNameLen properties defined in that class.
+ OperationalStatus OperationalStatus `xml:"OperationalStatus,omitempty"` // Indicates the current statuses of the element.
+ HealthState HealthState `xml:"HealthState,omitempty"` // Indicates the current health of the element.
+ EnabledState EnabledState `xml:"EnabledState,omitempty"` // EnabledState is an integer enumeration that indicates the enabled and disabled states of an element.
+ RequestedState RequestedState `xml:"RequestedState,omitempty"` // RequestedState is an integer enumeration that indicates the last requested or desired state for the element, irrespective of the mechanism through which it was requested.
+ Role string `xml:"Role,omitempty"` // A free-form string that describes the role of the Processor, for example, "Central Processor" or "Math Processor".
+ Family int `xml:"Family,omitempty"` // The Processor family type. For example, values include "Pentium(R) processor with MMX(TM) technology" (value=14) and "68040" (value=96).
+ OtherFamilyDescription string `xml:"OtherFamilyDescription,omitempty"` // A string that describes the Processor Family type. It is used when the Family property is set to 1 ("Other"). This string should be set to NULL when the Family property is any value other than 1.
+ UpgradeMethod UpgradeMethod `xml:"UpgradeMethod,omitempty"` // CPU socket information that includes data on how this Processor can be upgraded (if upgrades are supported). This property is an integer enumeration.
+ MaxClockSpeed int `xml:"MaxClockSpeed,omitempty"` // The maximum speed (in MHz) of this Processor.
+ CurrentClockSpeed int `xml:"CurrentClockSpeed,omitempty"` // The current speed (in MHz) of this Processor.
+ Stepping string `xml:"Stepping,omitempty"` // Stepping is a free-form string that indicates the revision level of the Processor within the Processor.Family.
+ CPUStatus CPUStatus `xml:"CPUStatus,omitempty"` // The CPUStatus property that indicates the current status of the Processor.
+ ExternalBusClockSpeed int `xml:"ExternalBusClockSpeed,omitempty"` // The speed (in MHz) of the external bus interface (also known as the front side bus).
+ }
+)
+
+// Indicates the current statuses of the element. Various operational statuses are defined. Many of the enumeration's values are self-explanatory. However, a few are not and are described here in more detail:
+//
+// - "Stressed" indicates that the element is functioning, but needs attention. Examples of "Stressed" states are overload, overheated, and so on.
+//
+// - "Predictive Failure" indicates that an element is functioning nominally but predicting a failure in the near future.
+//
+// - "In Service" describes an element being configured, maintained, cleaned, or otherwise administered.
+//
+// - "No Contact" indicates that the monitoring system has knowledge of this element, but has never been able to establish communications with it.
+//
+// - "Lost Communication" indicates that the ManagedSystem Element is known to exist and has been contacted successfully in the past, but is currently unreachable.
+//
+// - "Stopped" and "Aborted" are similar, although the former implies a clean and orderly stop, while the latter implies an abrupt stop where the state and configuration of the element might need to be updated.
+//
+// - "Dormant" indicates that the element is inactive or quiesced.
+//
+// - "Supporting Entity in Error" indicates that this element might be "OK" but that another element, on which it is dependent, is in error. An example is a network service or endpoint that cannot function due to lower-layer networking problems.
+//
+// - "Completed" indicates that the element has completed its operation. This value should be combined with either OK, Error, or Degraded so that a client can tell if the complete operation Completed with OK (passed), Completed with Error (failed), or Completed with Degraded (the operation finished, but it did not complete OK or did not report an error).
+//
+// - "Power Mode" indicates that the element has additional power model information contained in the Associated PowerManagementService association.
+//
+// - "Relocating" indicates the element is being relocated.
+//
+// OperationalStatus replaces the Status property on ManagedSystemElement to provide a consistent approach to enumerations, to address implementation needs for an array property, and to provide a migration path from today's environment to the future. This change was not made earlier because it required the deprecated qualifier. Due to the widespread use of the existing Status property in management applications, it is strongly recommended that providers or instrumentation provide both the Status and OperationalStatus properties. Further, the first value of OperationalStatus should contain the primary status for the element. When instrumented, Status (because it is single-valued) should also provide the primary status of the element.
+//
+// ValueMap={0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, .., 0x8000..}
+//
+// Values={Unknown, Other, OK, Degraded, Stressed, Predictive Failure, Error, Non-Recoverable Error, Starting, Stopping, Stopped, In Service, No Contact, Lost Communication, Aborted, Dormant, Supporting Entity in Error, Completed, Power Mode, Relocating, DMTF Reserved, Vendor Reserved}
+type OperationalStatus int
+
+// Indicates the current health of the element. This attribute expresses the health of this element but not necessarily that of its subcomponents. The possible values are 0 to 30, where 5 means the element is entirely healthy and 30 means the element is completely non-functional. The following continuum is defined:
+//
+// - "Non-recoverable Error" (30) - The element has completely failed, and recovery is not possible. All functionality provided by this element has been lost.
+//
+// - "Critical Failure" (25) - The element is non-functional and recovery might not be possible.
+//
+// - "Major Failure" (20) - The element is failing. It is possible that some or all of the functionality of this component is degraded or not working.
+//
+// - "Minor Failure" (15) - All functionality is available but some might be degraded.
+//
+// - "Degraded/Warning" (10) - The element is in working order and all functionality is provided. However, the element is not working to the best of its abilities. For example, the element might not be operating at optimal performance or it might be reporting recoverable errors.
+//
+// - "OK" (5) - The element is fully functional and is operating within normal operational parameters and without error.
+//
+// - "Unknown" (0) - The implementation cannot report on HealthState at this time.
+//
+// DMTF has reserved the unused portion of the continuum for additional HealthStates in the future.
+//
+// ValueMap={0, 5, 10, 15, 20, 25, 30, .., 32768..65535}
+//
+// Values={Unknown, OK, Degraded/Warning, Minor failure, Major failure, Critical failure, Non-recoverable error, DMTF Reserved, Vendor Specific}
+type HealthState int
+
+// EnabledState is an integer enumeration that indicates the enabled and disabled states of an element. It can also indicate the transitions between these requested states. For example, shutting down (value=4) and starting (value=10) are transient states between enabled and disabled. The following text briefly summarizes the various enabled and disabled states:
+//
+// - Enabled (2) indicates that the element is or could be executing commands, will process any queued commands, and queues new requests.
+//
+// - Disabled (3) indicates that the element will not execute commands and will drop any new requests.
+//
+// - Shutting Down (4) indicates that the element is in the process of going to a Disabled state.
+//
+// - Not Applicable (5) indicates the element does not support being enabled or disabled.
+//
+// - Enabled but Offline (6) indicates that the element might be completing commands, and will drop any new requests.
+//
+// - Test (7) indicates that the element is in a test state.
+//
+// - Deferred (8) indicates that the element might be completing commands, but will queue any new requests.
+//
+// - Quiesce (9) indicates that the element is enabled but in a restricted mode.
+//
+// - Starting (10) indicates that the element is in the process of going to an Enabled state. New requests are queued.
+//
+// ValueMap={0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11..32767, 32768..65535}
+//
+// Values={Unknown, Other, Enabled, Disabled, Shutting Down, Not Applicable, Enabled but Offline, In Test, Deferred, Quiesce, Starting, DMTF Reserved, Vendor Reserved}
+type EnabledState int
+
+// RequestedState is an integer enumeration that indicates the last requested or desired state for the element, irrespective of the mechanism through which it was requested. The actual state of the element is represented by EnabledState. This property is provided to compare the last requested and current enabled or disabled states. Note that when EnabledState is set to 5 ("Not Applicable"), then this property has no meaning. Refer to the EnabledState property description for explanations of the values in the RequestedState enumeration.
+//
+// - "Unknown" (0) indicates the last requested state for the element is unknown.
+//
+// - Note that the value "No Change" (5) has been deprecated in lieu of indicating the last requested state is "Unknown" (0). If the last requested or desired state is unknown, RequestedState should have the value "Unknown" (0), but may have the value "No Change" (5).Offline (6) indicates that the element has been requested to transition to the Enabled but Offline EnabledState.
+//
+// - It should be noted that there are two new values in RequestedState that build on the statuses of EnabledState. These are "Reboot" (10) and "Reset" (11). Reboot refers to doing a "Shut Down" and then moving to an "Enabled" state. Reset indicates that the element is first "Disabled" and then "Enabled". The distinction between requesting "Shut Down" and "Disabled" should also be noted. Shut Down requests an orderly transition to the Disabled state, and might involve removing power, to completely erase any existing state. The Disabled state requests an immediate disabling of the element, such that it will not execute or accept any commands or processing requests.
+//
+// This property is set as the result of a method invocation (such as Start or StopService on CIM_Service), or can be overridden and defined as WRITEable in a subclass. The method approach is considered superior to a WRITEable property, because it allows an explicit invocation of the operation and the return of a result code.
+//
+// If knowledge of the last RequestedState is not supported for the EnabledLogicalElement, the property shall be NULL or have the value 12 "Not Applicable".
+//
+// ValueMap={0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, .., 32768..65535}
+//
+// Values={Unknown, Enabled, Disabled, Shut Down, No Change, Offline, Test, Deferred, Quiesce, Reboot, Reset, Not Applicable, DMTF Reserved, Vendor Reserved}
+type RequestedState int
+
+// CPU socket information that includes data on how this Processor can be upgraded (if upgrades are supported). This property is an integer enumeration.
+//
+// ValueMap={ "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "70", "71", "72" , "73", "74", "75", "76", "77", "78", "79", "80" }
+//
+// Values={ "Other", "Unknown", "Daughter Board", "ZIF Socket", "Replacement/Piggy Back", "None", "LIF Socket", "Slot 1", "Slot 2", "370 Pin Socket", "Slot A", "Slot M", "Socket 423", "Socket A (Socket 462)", "Socket 478", "Socket 754", "Socket 940", "Socket 939", "Socket mPGA604", "Socket LGA771", "Socket LGA775", "Socket S1", "Socket AM2", "Socket F (1207)", "Socket LGA1366", "Socket G34", "Socket AM3", "Socket C32", "Socket LGA1156", "Socket LGA1567", "Socket PGA988A", "Socket BGA1288", "rPGA988B", "BGA1023", "BGA1224", "LGA1155", "LGA1356", "LGA2011", "Socket FS1", "Socket FS2", "Socket FM1", "Socket FM2", "Socket LGA2011-3", "Socket LGA1356-3", "Socket LGA1150", "Socket BGA1168", "Socket BGA1234", "Socket BGA1364", "Socket AM4", "Socket LGA1151", "Socket BGA1356", "Socket BGA1440", "Socket BGA1515", "Socket LGA3647-1", "Socket SP3", "Socket SP3r2", "Socket LGA2066", "Socket BGA1392", "Socket BGA1510", "Socket BGA1528", "Socket LGA4189", "Socket LGA1200", "Socket LGA4677", "Socket LGA1700", "Socket BGA1744", "Socket BGA1781", "Socket BGA1211", "Socket BGA2422", "Socket LGA5773", "Socket BGA5773", "Socket AM5", "Socket SP5", "Socket SP6", "Socket BGA883", "Socket BGA1190", "Socket BGA4129", "Socket LGA4710", "Socket LGA7529" }
+type UpgradeMethod int
+
+// The CPUStatus property that indicates the current status of the Processor. For example, the Processor might be disabled by the user (value=2), or disabled due to a POST error (value=3). Information in this property can be obtained from SMBIOS, the Type 4 structure, and the Status attribute.
+//
+// ValueMap={0, 1, 2, 3, 4, 7}
+//
+// Values={Unknown, CPU Enabled, CPU Disabled by User, CPU Disabled By BIOS (POST Error), CPU Is Idle, Other}
+type CPUStatus int
diff --git a/pkg/wsman/cim/service/availabletoelement.go b/pkg/wsman/cim/service/availabletoelement.go
new file mode 100644
index 00000000..019158fa
--- /dev/null
+++ b/pkg/wsman/cim/service/availabletoelement.go
@@ -0,0 +1,63 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package service
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+)
+
+// NewServiceAvailableToElement returns a new instance of the ServiceAvailableToElement struct.
+func NewServiceAvailableToElementWithClient(wsmanMessageCreator *message.WSManMessageCreator, client client.WSMan) AvailableToElement {
+ return AvailableToElement{
+ base: message.NewBaseWithClient(wsmanMessageCreator, CIM_ServiceAvailableToElement, client),
+ client: client,
+ }
+}
+
+// TODO Figure out how to call GET requiring resourceURIs and Selectors
+// Get retrieves the representation of the instance. No route
+
+// Enumerate returns an enumeration context which is used in a subsequent Pull call
+func (availableToElement AvailableToElement) Enumerate() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: availableToElement.base.Enumerate(),
+ },
+ }
+
+ err = availableToElement.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+
+}
+
+// Pull returns the instances of this class. An enumeration context provided by the Enumerate call is used as input.
+func (availableToElement AvailableToElement) Pull(enumerationContext string) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: availableToElement.base.Pull(enumerationContext),
+ },
+ }
+ err = availableToElement.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
diff --git a/pkg/wsman/cim/service/availabletoelement_test.go b/pkg/wsman/cim/service/availabletoelement_test.go
new file mode 100644
index 00000000..0019a72f
--- /dev/null
+++ b/pkg/wsman/cim/service/availabletoelement_test.go
@@ -0,0 +1,104 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package service
+
+import (
+ "encoding/xml"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
+)
+
+func TestNegativeAvailableToElement(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "cim/service/availabletoelement",
+ }
+ elementUnderTest := NewServiceAvailableToElementWithClient(wsmanMessageCreator, &client)
+
+ t.Run("cim_* Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //ENUMERATES
+ {
+ "should handle error making cim_ServiceAvailableToElement Enumerate call",
+ CIM_ServiceAvailableToElement,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "DD020000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should handle error making cim_ServiceAvailableToElement Pull call",
+ CIM_ServiceAvailableToElement,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ AssociatedPowerManagementService: []CIM_AssociatedPowerManagementService{
+ {
+ AvailableRequestedPowerStates: 10,
+ PowerState: 2,
+ ServiceProvided: ServiceProvided{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/08/addressing", Local: "ServiceProvided"},
+ Address: "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
+ ReferenceParameters: ReferenceParameters{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "ReferenceParameters"},
+ ResourceURI: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_PowerManagementService",
+ SelelctorSet: message.SelectorSet{
+ Selector: message.Selector{
+ Name: "CreationClassName",
+ Value: "CIM_PowerManagementService",
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.Error(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.NotEqual(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
diff --git a/pkg/wsman/cim/service/constants.go b/pkg/wsman/cim/service/constants.go
new file mode 100644
index 00000000..688ce1fd
--- /dev/null
+++ b/pkg/wsman/cim/service/constants.go
@@ -0,0 +1,8 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package service
+
+const CIM_ServiceAvailableToElement string = "CIM_ServiceAvailableToElement"
diff --git a/pkg/wsman/cim/service/marshal.go b/pkg/wsman/cim/service/marshal.go
new file mode 100644
index 00000000..52d049e0
--- /dev/null
+++ b/pkg/wsman/cim/service/marshal.go
@@ -0,0 +1,30 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package service
+
+import (
+ "encoding/json"
+
+ "gopkg.in/yaml.v3"
+)
+
+// JSON marshals the type into JSON format
+func (r *Response) JSON() string {
+ jsonOutput, err := json.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(jsonOutput)
+}
+
+// YAML marshals the type into YAML format
+func (r *Response) YAML() string {
+ yamlOutput, err := yaml.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(yamlOutput)
+}
diff --git a/pkg/wsman/cim/service/types.go b/pkg/wsman/cim/service/types.go
new file mode 100644
index 00000000..843a1162
--- /dev/null
+++ b/pkg/wsman/cim/service/types.go
@@ -0,0 +1,60 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package service
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+)
+
+type AvailableToElement struct {
+ base message.Base
+ client client.WSMan
+}
+
+// Response Types
+type (
+ Response struct {
+ *client.Message
+ XMLName xml.Name `xml:"Envelope"`
+ Header message.Header `xml:"Header"`
+ Body Body `xml:"Body"`
+ }
+ Body struct {
+ XMLName xml.Name `xml:"Body"`
+ PullResponse PullResponse
+ EnumerateResponse common.EnumerateResponse
+ AssociatedPowerManagementService CIM_AssociatedPowerManagementService `xml:"CIM_AssociatedPowerManagementService"`
+ }
+ PullResponse struct {
+ XMLName xml.Name `xml:"PullResponse"`
+ AssociatedPowerManagementService []CIM_AssociatedPowerManagementService `xml:"Items>CIM_AssociatedPowerManagementService"`
+ }
+ CIM_AssociatedPowerManagementService struct {
+ AvailableRequestedPowerStates int `xml:"AvailableReuestedPowerStates,omitempty"`
+ PowerState int `xml:"PowerState,omitempty"`
+ ServiceProvided ServiceProvided
+ UserOfService UserOfService
+ }
+ ServiceProvided struct {
+ XMLName xml.Name `xml:"ServiceProvided,omitempty"`
+ Address string `xml:"Address"`
+ ReferenceParameters ReferenceParameters
+ }
+ UserOfService struct {
+ XMLName xml.Name `xml:"UserOfService,omitempty"`
+ Address string `xml:"Address"`
+ ReferenceParameters ReferenceParameters
+ }
+ ReferenceParameters struct {
+ XMLName xml.Name `xml:"ReferenceParameters,omitempty"`
+ ResourceURI string `xml:"ResourceURI,omitempty"`
+ SelelctorSet message.SelectorSet
+ }
+)
diff --git a/pkg/wsman/cim/software/constants.go b/pkg/wsman/cim/software/constants.go
new file mode 100644
index 00000000..0a492d9a
--- /dev/null
+++ b/pkg/wsman/cim/software/constants.go
@@ -0,0 +1,8 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package software
+
+const CIM_SoftwareIdentity = "CIM_SoftwareIdentity"
diff --git a/pkg/wsman/cim/software/identity.go b/pkg/wsman/cim/software/identity.go
new file mode 100644
index 00000000..1068f8fb
--- /dev/null
+++ b/pkg/wsman/cim/software/identity.go
@@ -0,0 +1,81 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package software
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+)
+
+// NewSoftwareIdentity returns a new instance of the SoftwareIdentity struct.
+func NewSoftwareIdentityWithClient(wsmanMessageCreator *message.WSManMessageCreator, client client.WSMan) Identity {
+ return Identity{
+ base: message.NewBaseWithClient(wsmanMessageCreator, CIM_SoftwareIdentity, client),
+ client: client,
+ }
+}
+
+// Get retrieves the representation of the instance
+func (identity Identity) Get(selector Selector) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: identity.base.Get((*message.Selector)(&selector)),
+ },
+ }
+
+ err = identity.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+
+}
+
+// Enumerate returns an enumeration context which is used in a subsequent Pull call
+func (identity Identity) Enumerate() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: identity.base.Enumerate(),
+ },
+ }
+
+ err = identity.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+
+}
+
+// Pull returns the instances of this class. An enumeration context provided by the Enumerate call is used as input.
+func (identity Identity) Pull(enumerationContext string) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: identity.base.Pull(enumerationContext),
+ },
+ }
+ err = identity.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
diff --git a/pkg/wsman/cim/software/identity_test.go b/pkg/wsman/cim/software/identity_test.go
new file mode 100644
index 00000000..c88b0319
--- /dev/null
+++ b/pkg/wsman/cim/software/identity_test.go
@@ -0,0 +1,342 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package software
+
+import (
+ "encoding/xml"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
+)
+
+func TestPositiveCIMSoftwareIdentity(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "cim/software/identity",
+ }
+ elementUnderTest := NewSoftwareIdentityWithClient(wsmanMessageCreator, &client)
+
+ t.Run("cim_SoftwareIdentity Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ extraHeaders string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create and parse a valid cim_SoftwareIdentity Get call",
+ CIM_SoftwareIdentity,
+ wsmantesting.GET,
+ "AMTApps",
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Get"
+ selector := Selector{
+ Name: "InstanceID",
+ Value: "AMTApps",
+ }
+ return elementUnderTest.Get(selector)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ SoftwareIdentityResponse: SoftwareIdentity{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_SoftwareIdentity", Local: "CIM_SoftwareIdentity"},
+ InstanceID: "AMTApps",
+ IsEntity: true,
+ VersionString: "12.0.67",
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create and parse a valid cim_SoftwareIdentity Enumerate call",
+ CIM_SoftwareIdentity,
+ wsmantesting.ENUMERATE,
+ "",
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Enumerate"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "E2020000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create and parse a valid cim_SoftwareIdentity Pull call",
+ CIM_SoftwareIdentity,
+ wsmantesting.PULL,
+ "",
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Pull"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ SoftwareIdentityItems: []SoftwareIdentity{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_SoftwareIdentity", Local: "CIM_SoftwareIdentity"},
+ InstanceID: "Flash",
+ IsEntity: true,
+ VersionString: "12.0.67",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_SoftwareIdentity", Local: "CIM_SoftwareIdentity"},
+ InstanceID: "Netstack",
+ IsEntity: true,
+ VersionString: "12.0.67",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_SoftwareIdentity", Local: "CIM_SoftwareIdentity"},
+ InstanceID: "AMTApps",
+ IsEntity: true,
+ VersionString: "12.0.67",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_SoftwareIdentity", Local: "CIM_SoftwareIdentity"},
+ InstanceID: "AMT",
+ IsEntity: true,
+ VersionString: "12.0.67",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_SoftwareIdentity", Local: "CIM_SoftwareIdentity"},
+ InstanceID: "Sku",
+ IsEntity: true,
+ VersionString: "16392",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_SoftwareIdentity", Local: "CIM_SoftwareIdentity"},
+ InstanceID: "VendorID",
+ IsEntity: true,
+ VersionString: "8086",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_SoftwareIdentity", Local: "CIM_SoftwareIdentity"},
+ InstanceID: "Build Number",
+ IsEntity: true,
+ VersionString: "1579",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_SoftwareIdentity", Local: "CIM_SoftwareIdentity"},
+ InstanceID: "Recovery Version",
+ IsEntity: true,
+ VersionString: "12.0.67",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_SoftwareIdentity", Local: "CIM_SoftwareIdentity"},
+ InstanceID: "Recovery Build Num",
+ IsEntity: true,
+ VersionString: "1579",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_SoftwareIdentity", Local: "CIM_SoftwareIdentity"},
+ InstanceID: "Legacy Mode",
+ IsEntity: true,
+ VersionString: "False",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_SoftwareIdentity", Local: "CIM_SoftwareIdentity"},
+ InstanceID: "AMT FW Core Version",
+ IsEntity: true,
+ VersionString: "12.0.67",
+ },
+ },
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, test.extraHeaders, test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.NoError(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.Equal(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
+func TestNegativeCIMSoftwareIdentity(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "cim/software/identity",
+ }
+ elementUnderTest := NewSoftwareIdentityWithClient(wsmanMessageCreator, &client)
+
+ t.Run("cim_SoftwareIdentity Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ extraHeaders string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create and parse a valid cim_SoftwareIdentity Get call",
+ CIM_SoftwareIdentity,
+ wsmantesting.GET,
+ "AMTApps",
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ selector := Selector{
+ Name: "InstanceID",
+ Value: "AMTApps",
+ }
+ return elementUnderTest.Get(selector)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ SoftwareIdentityResponse: SoftwareIdentity{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_SoftwareIdentity", Local: "CIM_SoftwareIdentity"},
+ InstanceID: "AMTApps",
+ IsEntity: true,
+ VersionString: "12.0.67",
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create and parse a valid cim_SoftwareIdentity Enumerate call",
+ CIM_SoftwareIdentity,
+ wsmantesting.ENUMERATE,
+ "",
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "E2020000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create and parse a valid cim_SoftwareIdentity Pull call",
+ CIM_SoftwareIdentity,
+ wsmantesting.PULL,
+ "",
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ SoftwareIdentityItems: []SoftwareIdentity{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_SoftwareIdentity", Local: "CIM_SoftwareIdentity"},
+ InstanceID: "Flash",
+ IsEntity: true,
+ VersionString: "12.0.67",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_SoftwareIdentity", Local: "CIM_SoftwareIdentity"},
+ InstanceID: "Netstack",
+ IsEntity: true,
+ VersionString: "12.0.67",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_SoftwareIdentity", Local: "CIM_SoftwareIdentity"},
+ InstanceID: "AMTApps",
+ IsEntity: true,
+ VersionString: "12.0.67",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_SoftwareIdentity", Local: "CIM_SoftwareIdentity"},
+ InstanceID: "AMT",
+ IsEntity: true,
+ VersionString: "12.0.67",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_SoftwareIdentity", Local: "CIM_SoftwareIdentity"},
+ InstanceID: "Sku",
+ IsEntity: true,
+ VersionString: "16392",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_SoftwareIdentity", Local: "CIM_SoftwareIdentity"},
+ InstanceID: "VendorID",
+ IsEntity: true,
+ VersionString: "8086",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_SoftwareIdentity", Local: "CIM_SoftwareIdentity"},
+ InstanceID: "Build Number",
+ IsEntity: true,
+ VersionString: "1579",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_SoftwareIdentity", Local: "CIM_SoftwareIdentity"},
+ InstanceID: "Recovery Version",
+ IsEntity: true,
+ VersionString: "12.0.67",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_SoftwareIdentity", Local: "CIM_SoftwareIdentity"},
+ InstanceID: "Recovery Build Num",
+ IsEntity: true,
+ VersionString: "1579",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_SoftwareIdentity", Local: "CIM_SoftwareIdentity"},
+ InstanceID: "Legacy Mode",
+ IsEntity: true,
+ VersionString: "False",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_SoftwareIdentity", Local: "CIM_SoftwareIdentity"},
+ InstanceID: "AMT FW Core Version",
+ IsEntity: true,
+ VersionString: "12.0.67",
+ },
+ },
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, test.extraHeaders, test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.Error(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.NotEqual(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
diff --git a/pkg/wsman/cim/software/marshal.go b/pkg/wsman/cim/software/marshal.go
new file mode 100644
index 00000000..8769dbc1
--- /dev/null
+++ b/pkg/wsman/cim/software/marshal.go
@@ -0,0 +1,30 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package software
+
+import (
+ "encoding/json"
+
+ "gopkg.in/yaml.v3"
+)
+
+// JSON marshals the type into JSON format
+func (r *Response) JSON() string {
+ jsonOutput, err := json.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(jsonOutput)
+}
+
+// YAML marshals the type into YAML format
+func (r *Response) YAML() string {
+ yamlOutput, err := yaml.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(yamlOutput)
+}
diff --git a/pkg/wsman/cim/software/types.go b/pkg/wsman/cim/software/types.go
new file mode 100644
index 00000000..f8be25b2
--- /dev/null
+++ b/pkg/wsman/cim/software/types.go
@@ -0,0 +1,49 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package software
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+)
+
+type Identity struct {
+ base message.Base
+ client client.WSMan
+}
+
+// Response Types
+type (
+ Response struct {
+ *client.Message
+ XMLName xml.Name `xml:"Envelope"`
+ Header message.Header `xml:"Header"`
+ Body Body `xml:"Body"`
+ }
+ Body struct {
+ XMLName xml.Name `xml:"Body"`
+ PullResponse PullResponse
+ EnumerateResponse common.EnumerateResponse
+ SoftwareIdentityResponse SoftwareIdentity
+ }
+
+ PullResponse struct {
+ XMLName xml.Name `xml:"PullResponse"`
+ SoftwareIdentityItems []SoftwareIdentity `xml:"Items>CIM_SoftwareIdentity"`
+ }
+
+ SoftwareIdentity struct {
+ XMLName xml.Name `xml:"CIM_SoftwareIdentity"`
+ InstanceID string `xml:"InstanceID"`
+ VersionString string `xml:"VersionString"`
+ IsEntity bool `xml:"IsEntity"`
+ }
+
+ Selector message.Selector
+)
diff --git a/pkg/wsman/cim/system/constants.go b/pkg/wsman/cim/system/constants.go
new file mode 100644
index 00000000..87ca6d73
--- /dev/null
+++ b/pkg/wsman/cim/system/constants.go
@@ -0,0 +1,8 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package system
+
+const CIM_SystemPackaging string = "CIM_SystemPackaging"
diff --git a/pkg/wsman/cim/system/marshal.go b/pkg/wsman/cim/system/marshal.go
new file mode 100644
index 00000000..0e35b31b
--- /dev/null
+++ b/pkg/wsman/cim/system/marshal.go
@@ -0,0 +1,30 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package system
+
+import (
+ "encoding/json"
+
+ "gopkg.in/yaml.v3"
+)
+
+// JSON marshals the type into JSON format
+func (r *Response) JSON() string {
+ jsonOutput, err := json.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(jsonOutput)
+}
+
+// YAML marshals the type into YAML format
+func (r *Response) YAML() string {
+ yamlOutput, err := yaml.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(yamlOutput)
+}
diff --git a/pkg/wsman/cim/system/packaging.go b/pkg/wsman/cim/system/packaging.go
new file mode 100644
index 00000000..ce293e99
--- /dev/null
+++ b/pkg/wsman/cim/system/packaging.go
@@ -0,0 +1,62 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package system
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+)
+
+// NewSystemPackaging returns a new instance of the SystemPackaging struct.
+func NewSystemPackageWithClient(wsmanMessageCreator *message.WSManMessageCreator, client client.WSMan) Package {
+ return Package{
+ base: message.NewBaseWithClient(wsmanMessageCreator, CIM_SystemPackaging, client),
+ }
+}
+
+// TODO: Figure out how to call GET requiring resourceURIs and Selectors
+// Get retrieves the representation of the instance. No Route
+
+// Enumerate returns an enumeration context which is used in a subsequent Pull call
+func (packaging Package) Enumerate() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: packaging.base.Enumerate(),
+ },
+ }
+
+ err = packaging.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+
+}
+
+// Pull returns the instances of this class. An enumeration context provided by the Enumerate call is used as input.
+func (packaging Package) Pull(enumerationContext string) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: packaging.base.Pull(enumerationContext),
+ },
+ }
+ err = packaging.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
diff --git a/pkg/wsman/cim/system/packaging_test.go b/pkg/wsman/cim/system/packaging_test.go
new file mode 100644
index 00000000..43706a74
--- /dev/null
+++ b/pkg/wsman/cim/system/packaging_test.go
@@ -0,0 +1,250 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package system
+
+import (
+ "encoding/xml"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
+)
+
+func TestPositiveCIMComputerSystemPackage(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "cim/system/packaging",
+ }
+ elementUnderTest := NewSystemPackageWithClient(wsmanMessageCreator, &client)
+
+ t.Run("cim_ComputerSystemPackage Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //ENUMERATES
+ {
+ "should create and parse a valid cim_SystemPackaging Enumerate call",
+ CIM_SystemPackaging,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Enumerate"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "E3020000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create and parse a valid cim_SystemPackaging Pull call",
+ CIM_SystemPackaging,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Pull"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ SystemPackageItems: []SystemPackage{
+ {
+ Antecedent: Antecedent{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ComputerSystemPackage", Local: "Antecedent"},
+ Address: "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
+ ReferenceParameters: ReferenceParameters{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/08/addressing", Local: "ReferenceParameters"},
+ ResourceURI: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_Chassis",
+ SelectorSet: SelectorSet{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "SelectorSet"},
+ Selector: []Selector{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "CreationClassName",
+ Value: "CIM_Chassis",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "Tag",
+ Value: "CIM_Chassis",
+ },
+ },
+ },
+ },
+ },
+ Dependent: Dependent{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ComputerSystemPackage", Local: "Dependent"},
+ Address: "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
+ ReferenceParameters: ReferenceParameters{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/08/addressing", Local: "ReferenceParameters"},
+ ResourceURI: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ComputerSystem",
+ SelectorSet: SelectorSet{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "SelectorSet"},
+ Selector: []Selector{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "CreationClassName",
+ Value: "CIM_ComputerSystem",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "Name",
+ Value: "ManagedSystem",
+ },
+ },
+ },
+ },
+ },
+ PlatformGUID: "FA4EC1D8F1B1EA11BE6DC6D21730D800",
+ },
+ },
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.NoError(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.Equal(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
+func TestNegativeCIMComputerSystemPackage(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "cim/system/packaging",
+ }
+ elementUnderTest := NewSystemPackageWithClient(wsmanMessageCreator, &client)
+
+ t.Run("cim_ComputerSystemPackage Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //ENUMERATES
+ {
+ "should create and parse a valid cim_SystemPackaging Enumerate call",
+ CIM_SystemPackaging,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "E3020000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create and parse a valid cim_SystemPackaging Pull call",
+ CIM_SystemPackaging,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ SystemPackageItems: []SystemPackage{
+ {
+ Antecedent: Antecedent{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ComputerSystemPackage", Local: "Antecedent"},
+ Address: "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
+ ReferenceParameters: ReferenceParameters{
+ ResourceURI: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_Chassis",
+ SelectorSet: SelectorSet{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "SelectorSet"},
+ Selector: []Selector{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "CreationClassName",
+ Value: "CIM_Chassis",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "Tag",
+ Value: "CIM_Chassis",
+ },
+ },
+ },
+ },
+ },
+ Dependent: Dependent{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ComputerSystemPackage", Local: "Dependent"},
+ Address: "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
+ ReferenceParameters: ReferenceParameters{
+ ResourceURI: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ComputerSystem",
+ SelectorSet: SelectorSet{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "SelectorSet"},
+ Selector: []Selector{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "CreationClassName",
+ Value: "CIM_ComputerSystem",
+ },
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "Selector"},
+ Name: "Name",
+ Value: "ManagedSystem",
+ },
+ },
+ },
+ },
+ },
+ PlatformGUID: "FA4EC1D8F1B1EA11BE6DC6D21730D800",
+ },
+ },
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.Error(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.NotEqual(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
diff --git a/pkg/wsman/cim/system/types.go b/pkg/wsman/cim/system/types.go
new file mode 100644
index 00000000..8fc97028
--- /dev/null
+++ b/pkg/wsman/cim/system/types.go
@@ -0,0 +1,66 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package system
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+)
+
+type Package struct {
+ base message.Base
+}
+
+// Response Types
+type (
+ Response struct {
+ *client.Message
+ XMLName xml.Name `xml:"Envelope"`
+ Header message.Header `xml:"Header"`
+ Body Body `xml:"Body"`
+ }
+ Body struct {
+ XMLName xml.Name `xml:"Body"`
+ EnumerateResponse common.EnumerateResponse
+ PullResponse PullResponse
+ }
+ PullResponse struct {
+ XMLName xml.Name `xml:"PullResponse"`
+ SystemPackageItems []SystemPackage `xml:"Items>CIM_ComputerSystemPackage"`
+ }
+ Antecedent struct {
+ XMLName xml.Name `xml:"Antecedent,omitempty"`
+ Address string `xml:"Address,omitempty"`
+ ReferenceParameters ReferenceParameters
+ }
+ Dependent struct {
+ XMLName xml.Name `xml:"Dependent,omitempty"`
+ Address string `xml:"Address,omitempty"`
+ ReferenceParameters ReferenceParameters
+ }
+ SystemPackage struct {
+ Antecedent Antecedent
+ Dependent Dependent
+ PlatformGUID string `xml:"PlatformGUID,omitempty"`
+ }
+ ReferenceParameters struct {
+ XMLName xml.Name `xml:"ReferenceParameters"`
+ ResourceURI string `xml:"ResourceURI,omitempty"`
+ SelectorSet SelectorSet `xml:"SelectorSet,omitempty"`
+ }
+ SelectorSet struct {
+ XMLName xml.Name `xml:"SelectorSet,omitempty"`
+ Selector []Selector
+ }
+ Selector struct {
+ XMLName xml.Name `xml:"Selector,omitempty"`
+ Name string `xml:"Name,attr"`
+ Value string `xml:",chardata"`
+ }
+)
diff --git a/pkg/wsman/cim/wifi/constants.go b/pkg/wsman/cim/wifi/constants.go
new file mode 100644
index 00000000..42f2d48a
--- /dev/null
+++ b/pkg/wsman/cim/wifi/constants.go
@@ -0,0 +1,74 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package wifi
+
+const (
+ CIM_WiFiEndpoint string = "CIM_WiFiEndpoint"
+ CIM_WiFiEndpointSettings string = "CIM_WiFiEndpointSettings"
+ CIM_WiFiPort string = "CIM_WiFiPort"
+)
+
+const (
+ LinkTechnologyUnknown LinkTechnology = iota
+ LinkTechnologyOther
+ LinkTechnologyEthernet
+ LinkTechnologyIB
+ LinkTechnologyFC
+ LinkTechnologyFDDI
+ LinkTechnologyATM
+ LinkTechnologyTokenRing
+ LinkTechnologyFrameRelay
+ LinkTechnologyInfrared
+ LinkTechnologyBlueTooth
+ LinkTechnologyWirelessLAN
+)
+
+const (
+ AuthenticationMethod_Other AuthenticationMethod = iota + 1
+ AuthenticationMethod_OpenSystem
+ AuthenticationMethod_SharedKey
+ AuthenticationMethod_WPA_PSK
+ AuthenticationMethod_WPA_IEEE8021x
+ AuthenticationMethod_WPA2_PSK
+ AuthenticationMethod_WPA2_IEEE8021x
+ AuthenticationMethod_DMTFReserved
+)
+const (
+ AuthenticationMethod_WPA3_SAE AuthenticationMethod = iota + 32768
+ AuthenticationMethod_WPA3_OWE
+ AuthenticationMethod_VendorReserved
+)
+
+const (
+ BSSType_Unknown BSSType = 0
+ BSSType_Independent BSSType = 2
+ BSSType_Infrastructure BSSType = 3
+)
+
+const (
+ EncryptionMethod_Other EncryptionMethod = iota + 1
+ EncryptionMethod_WEP
+ EncryptionMethod_TKIP
+ EncryptionMethod_CCMP
+ EncryptionMethod_None
+ EncryptionMethod_DMTFReserved
+)
+
+const (
+ CompletedwithNoError ReturnValue = iota
+ NotSupported
+ UnknownorUnspecifiedError
+ CannotcompletewithinTimeoutPeriod
+ Failed
+ InvalidParameter
+ InUse
+)
+const (
+ MethodParametersCheckedJobStarted ReturnValue = iota + 4096
+ InvalidStateTransition
+ UseofTimeoutParameterNotSupported
+ Busy
+)
diff --git a/pkg/wsman/cim/wifi/endpointsettings.go b/pkg/wsman/cim/wifi/endpointsettings.go
new file mode 100644
index 00000000..640af0ef
--- /dev/null
+++ b/pkg/wsman/cim/wifi/endpointsettings.go
@@ -0,0 +1,83 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package wifi
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+)
+
+// NewWiFiEndpointSettings returns a new instance of the WiFiEndpointSettings struct.
+func NewWiFiEndpointSettingsWithClient(wsmanMessageCreator *message.WSManMessageCreator, client client.WSMan) EndpointSettings {
+ return EndpointSettings{
+ base: message.NewBaseWithClient(wsmanMessageCreator, CIM_WiFiEndpointSettings, client),
+ }
+}
+
+// TODO: Figure out how to call GET requiring resourceURIs and Selectors
+// Get retrieves the representation of the instance
+
+// Enumerate returns an enumeration context which is used in a subsequent Pull call
+func (endpointSettings EndpointSettings) Enumerate() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: endpointSettings.base.Enumerate(),
+ },
+ }
+
+ err = endpointSettings.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+
+}
+
+// Pull returns the instances of this class. An enumeration context provided by the Enumerate call is used as input.
+func (endpointSettings EndpointSettings) Pull(enumerationContext string) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: endpointSettings.base.Pull(enumerationContext),
+ },
+ }
+ err = endpointSettings.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
+
+// Delete removes a the specified instance
+func (endpointSettings EndpointSettings) Delete(handle string) (response Response, err error) {
+ selector := message.Selector{Name: "InstanceID", Value: handle}
+ response = Response{
+ Message: &client.Message{
+ XMLInput: endpointSettings.base.Delete(selector),
+ },
+ }
+
+ err = endpointSettings.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
diff --git a/pkg/wsman/cim/wifi/endpointsettings_test.go b/pkg/wsman/cim/wifi/endpointsettings_test.go
new file mode 100644
index 00000000..53dc7705
--- /dev/null
+++ b/pkg/wsman/cim/wifi/endpointsettings_test.go
@@ -0,0 +1,214 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package wifi
+
+import (
+ "encoding/xml"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
+)
+
+func TestPositiveCIMWifiEndpointSettings(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "cim/wifi/endpointsettings",
+ }
+ elementUnderTest := NewWiFiEndpointSettingsWithClient(wsmanMessageCreator, &client)
+
+ t.Run("cim_* Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ extraHeader string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //ENUMERATES
+ {
+ "should create and parse a valid cim_WiFiEndpointSettings Enumerate call",
+ CIM_WiFiEndpointSettings,
+ wsmantesting.ENUMERATE,
+ "",
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Enumerate"
+ return elementUnderTest.Enumerate()
+ }, Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "95040000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create and parse a valid cim_WiFiEndpointSettings Pull call",
+ CIM_WiFiEndpointSettings,
+ wsmantesting.PULL,
+ "",
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Pull"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ EndpointSettingsItems: []WiFiEndpointSettingsResponse{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_WiFiEndpointSettings", Local: "CIM_WiFiEndpointSettings"},
+ AuthenticationMethod: 2,
+ BSSType: 3,
+ ElementName: "Test",
+ EncryptionMethod: 2,
+ InstanceID: "Test",
+ Priority: 1,
+ SSID: "testSSID",
+ },
+ },
+ },
+ },
+ },
+ //DELETE
+ {
+ "should create and parse a valid cim_WiFiEndpointSettings Delete call",
+ CIM_WiFiEndpointSettings,
+ wsmantesting.DELETE,
+ "instanceID123",
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Delete"
+ return elementUnderTest.Delete("instanceID123")
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ RequestStateChange_OUTPUT: common.ReturnValue{
+ ReturnValue: 0,
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, test.extraHeader, test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.NoError(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.Equal(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
+func TestNegativeCIMWifiEndpointSettings(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "cim/wifi/endpointsettings",
+ }
+ elementUnderTest := NewWiFiEndpointSettingsWithClient(wsmanMessageCreator, &client)
+
+ t.Run("cim_* Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ extraHeader string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //ENUMERATES
+ {
+ "should handle error when cim_WiFiEndpointSettings Enumerate call",
+ CIM_WiFiEndpointSettings,
+ wsmantesting.ENUMERATE,
+ "",
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Enumerate()
+ }, Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "95040000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should handle error when cim_WiFiEndpointSettings Pull call",
+ CIM_WiFiEndpointSettings,
+ wsmantesting.PULL,
+ "",
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ EndpointSettingsItems: []WiFiEndpointSettingsResponse{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_WiFiEndpointSettings", Local: "CIM_WiFiEndpointSettings"},
+ AuthenticationMethod: 2,
+ BSSType: 3,
+ ElementName: "Test",
+ EncryptionMethod: 2,
+ InstanceID: "Test",
+ Priority: 1,
+ SSID: "testSSID",
+ },
+ },
+ },
+ },
+ },
+ //DELETE
+ {
+ "should handle error when cim_WiFiEndpointSettings Delete call",
+ CIM_WiFiEndpointSettings,
+ wsmantesting.DELETE,
+ "instanceID123",
+ "",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Delete("instanceID123")
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ RequestStateChange_OUTPUT: common.ReturnValue{
+ ReturnValue: 0,
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, test.extraHeader, test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.Error(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.NotEqual(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
diff --git a/pkg/wsman/cim/wifi/marshal.go b/pkg/wsman/cim/wifi/marshal.go
new file mode 100644
index 00000000..14ab4e18
--- /dev/null
+++ b/pkg/wsman/cim/wifi/marshal.go
@@ -0,0 +1,30 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package wifi
+
+import (
+ "encoding/json"
+
+ "gopkg.in/yaml.v3"
+)
+
+// JSON marshals the type into JSON format
+func (r *Response) JSON() string {
+ jsonOutput, err := json.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(jsonOutput)
+}
+
+// YAML marshals the type into YAML format
+func (r *Response) YAML() string {
+ yamlOutput, err := yaml.Marshal(r.Body)
+ if err != nil {
+ return ""
+ }
+ return string(yamlOutput)
+}
diff --git a/pkg/wsman/cim/wifi/port.go b/pkg/wsman/cim/wifi/port.go
new file mode 100644
index 00000000..2eb1c199
--- /dev/null
+++ b/pkg/wsman/cim/wifi/port.go
@@ -0,0 +1,107 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package wifi
+
+import (
+ "encoding/xml"
+ "errors"
+ "strconv"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/methods"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+)
+
+// NewWiFiPort returns a new instance of the WiFiPort struct.
+func NewWiFiPortWithClient(wsmanMessageCreator *message.WSManMessageCreator, client client.WSMan) Port {
+ return Port{
+ base: message.NewBaseWithClient(wsmanMessageCreator, CIM_WiFiPort, client),
+ client: client,
+ }
+}
+
+// RequestStateChange requests that the state of the element be changed to the value specified in the RequestedState parameter . . .
+func (port Port) RequestStateChange(requestedState int) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: port.base.RequestStateChange(methods.GenerateAction(CIM_WiFiPort, "RequestStateChange"), requestedState),
+ },
+ }
+
+ err = port.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ if response.Body.RequestStateChange_OUTPUT.ReturnValue != 0 {
+ err = errors.New("RequestStateChange failed with return code " + strconv.Itoa(response.Body.RequestStateChange_OUTPUT.ReturnValue))
+ }
+ return
+}
+
+// Get retrieves the representation of the instance
+func (port Port) Get() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: port.base.Get(nil),
+ },
+ }
+
+ err = port.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+
+}
+
+// Enumerate returns an enumeration context which is used in a subsequent Pull call
+func (port Port) Enumerate() (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: port.base.Enumerate(),
+ },
+ }
+
+ err = port.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+
+}
+
+// Pull returns the instances of this class. An enumeration context provided by the Enumerate call is used as input.
+func (port Port) Pull(enumerationContext string) (response Response, err error) {
+ response = Response{
+ Message: &client.Message{
+ XMLInput: port.base.Pull(enumerationContext),
+ },
+ }
+ err = port.base.Execute(response.Message)
+ if err != nil {
+ return
+ }
+ err = xml.Unmarshal([]byte(response.XMLOutput), &response)
+ if err != nil {
+ return
+ }
+ return
+}
diff --git a/pkg/wsman/cim/wifi/port_test.go b/pkg/wsman/cim/wifi/port_test.go
new file mode 100644
index 00000000..154209fe
--- /dev/null
+++ b/pkg/wsman/cim/wifi/port_test.go
@@ -0,0 +1,271 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package wifi
+
+import (
+ "encoding/xml"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/methods"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/wsmantesting"
+)
+
+func TestPositiveCIMWifiPort(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "cim/wifi/port",
+ }
+ elementUnderTest := NewWiFiPortWithClient(wsmanMessageCreator, &client)
+
+ t.Run("cim_* Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create and parse a valid cim_WiFiPort Get call",
+ CIM_WiFiPort,
+ wsmantesting.GET,
+ "", func() (Response, error) {
+ client.CurrentMessage = "Get"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ WiFiPortGetResponse: WiFiPort{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_WiFiPort", Local: "CIM_WiFiPort"},
+ CreationClassName: "CIM_WiFiPort",
+ DeviceID: "WiFi Port 0",
+ ElementName: "WiFi Port 0",
+ EnabledState: 3,
+ HealthState: 5,
+ LinkTechnology: 11,
+ PermanentAddress: "000000000000",
+ PortType: 0,
+ RequestedState: 3,
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "Intel(r) AMT",
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create and parse a valid cim_WiFiPort Enumerate call",
+ CIM_WiFiPort,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Enumerate"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "22000000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create and parse a valid cim_WiFiPort Pull call",
+ CIM_WiFiPort,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Pull"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ WiFiPortItems: []WiFiPort{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_WiFiPort", Local: "CIM_WiFiPort"},
+ CreationClassName: "CIM_WiFiPort",
+ DeviceID: "WiFi Port 0",
+ ElementName: "WiFi Port 0",
+ EnabledState: 3,
+ HealthState: 5,
+ LinkTechnology: 11,
+ PermanentAddress: "000000000000",
+ PortType: 0,
+ RequestedState: 3,
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "Intel(r) AMT",
+ },
+ },
+ },
+ },
+ },
+ {
+ "should create and parse a valid cim_WiFiPort Request State Change call",
+ CIM_WiFiPort,
+ methods.RequestStateChange(CIM_WiFiPort),
+ "3",
+ func() (Response, error) {
+ client.CurrentMessage = "RequestStateChange"
+ return elementUnderTest.RequestStateChange(3)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ RequestStateChange_OUTPUT: common.ReturnValue{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_WiFiPort", Local: "RequestStateChange_OUTPUT"},
+ ReturnValue: 0,
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.NoError(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.Equal(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
+func TestNegativeCIMWifiPort(t *testing.T) {
+ messageID := 0
+ resourceUriBase := "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/"
+ wsmanMessageCreator := message.NewWSManMessageCreator(resourceUriBase)
+ client := wsmantesting.MockClient{
+ PackageUnderTest: "cim/wifi/port",
+ }
+ elementUnderTest := NewWiFiPortWithClient(wsmanMessageCreator, &client)
+
+ t.Run("cim_* Tests", func(t *testing.T) {
+ tests := []struct {
+ name string
+ method string
+ action string
+ body string
+ responseFunc func() (Response, error)
+ expectedResponse interface{}
+ }{
+ //GETS
+ {
+ "should create and parse a valid cim_WiFiPort Get call",
+ CIM_WiFiPort,
+ wsmantesting.GET,
+ "", func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Get()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ WiFiPortGetResponse: WiFiPort{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_WiFiPort", Local: "CIM_WiFiPort"},
+ CreationClassName: "CIM_WiFiPort",
+ DeviceID: "WiFi Port 0",
+ ElementName: "WiFi Port 0",
+ EnabledState: 3,
+ HealthState: 5,
+ LinkTechnology: 11,
+ PermanentAddress: "000000000000",
+ PortType: 0,
+ RequestedState: 3,
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "Intel(r) AMT",
+ },
+ },
+ },
+ //ENUMERATES
+ {
+ "should create and parse a valid cim_WiFiPort Enumerate call",
+ CIM_WiFiPort,
+ wsmantesting.ENUMERATE,
+ wsmantesting.ENUMERATE_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Enumerate()
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ EnumerateResponse: common.EnumerateResponse{
+ EnumerationContext: "22000000-0000-0000-0000-000000000000",
+ },
+ },
+ },
+ //PULLS
+ {
+ "should create and parse a valid cim_WiFiPort Pull call",
+ CIM_WiFiPort,
+ wsmantesting.PULL,
+ wsmantesting.PULL_BODY,
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.Pull(wsmantesting.EnumerationContext)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ PullResponse: PullResponse{
+ XMLName: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "PullResponse"},
+ WiFiPortItems: []WiFiPort{
+ {
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_WiFiPort", Local: "CIM_WiFiPort"},
+ CreationClassName: "CIM_WiFiPort",
+ DeviceID: "WiFi Port 0",
+ ElementName: "WiFi Port 0",
+ EnabledState: 3,
+ HealthState: 5,
+ LinkTechnology: 11,
+ PermanentAddress: "000000000000",
+ PortType: 0,
+ RequestedState: 3,
+ SystemCreationClassName: "CIM_ComputerSystem",
+ SystemName: "Intel(r) AMT",
+ },
+ },
+ },
+ },
+ },
+ {
+ "should create and parse a valid cim_WiFiPort Request State Change call",
+ CIM_WiFiPort,
+ methods.RequestStateChange(CIM_WiFiPort),
+ "3",
+ func() (Response, error) {
+ client.CurrentMessage = "Error"
+ return elementUnderTest.RequestStateChange(3)
+ },
+ Body{
+ XMLName: xml.Name{Space: message.XMLBodySpace, Local: "Body"},
+ RequestStateChange_OUTPUT: common.ReturnValue{
+ XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_WiFiPort", Local: "RequestStateChange_OUTPUT"},
+ ReturnValue: 0,
+ },
+ },
+ },
+ }
+
+ for _, test := range tests {
+ t.Run(test.name, func(t *testing.T) {
+ expectedXMLInput := wsmantesting.ExpectedResponse(messageID, resourceUriBase, test.method, test.action, "", test.body)
+ messageID++
+ response, err := test.responseFunc()
+ assert.Error(t, err)
+ assert.Equal(t, expectedXMLInput, response.XMLInput)
+ assert.NotEqual(t, test.expectedResponse, response.Body)
+ })
+ }
+ })
+}
diff --git a/pkg/wsman/cim/wifi/types.go b/pkg/wsman/cim/wifi/types.go
new file mode 100644
index 00000000..03bf9028
--- /dev/null
+++ b/pkg/wsman/cim/wifi/types.go
@@ -0,0 +1,115 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2023
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+
+package wifi
+
+import (
+ "encoding/xml"
+
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/internal/message"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/models"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/client"
+ "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/common"
+)
+
+type Port struct {
+ base message.Base
+ client client.WSMan
+}
+
+type EndpointSettings struct {
+ base message.Base
+}
+
+// OUTPUT
+// Response Types
+type (
+ Response struct {
+ *client.Message
+ XMLName xml.Name `xml:"Envelope"`
+ Header message.Header `xml:"Header"`
+ Body Body `xml:"Body"`
+ }
+
+ Body struct {
+ XMLName xml.Name `xml:"Body"`
+ WiFiPortGetResponse WiFiPort
+ EnumerateResponse common.EnumerateResponse
+ PullResponse PullResponse
+ RequestStateChange_OUTPUT common.ReturnValue
+ }
+
+ PullResponse struct {
+ XMLName xml.Name `xml:"PullResponse"`
+ EndpointSettingsItems []WiFiEndpointSettingsResponse `xml:"Items>CIM_WiFiEndpointSettings"`
+ WiFiPortItems []WiFiPort `xml:"Items>CIM_WiFiPort"`
+ }
+
+ WiFiEndpointSettingsResponse struct {
+ XMLName xml.Name `xml:"CIM_WiFiEndpointSettings"`
+ AuthenticationMethod AuthenticationMethod
+ BSSType BSSType
+ ElementName string
+ EncryptionMethod EncryptionMethod
+ InstanceID string
+ Priority int
+ SSID string
+ }
+
+ WiFiPort struct {
+ XMLName xml.Name `xml:"CIM_WiFiPort"`
+ LinkTechnology LinkTechnology
+ DeviceID string
+ CreationClassName string
+ SystemName string
+ SystemCreationClassName string
+ ElementName string
+ HealthState models.HealthState
+ EnabledState models.EnabledState
+ RequestedState models.RequestedState
+ PortType int
+ PermanentAddress string
+ }
+)
+
+// INPUT
+// Request Types
+type (
+ WiFiEndpointSettings_INPUT struct {
+ XMLName xml.Name `xml:"CIM_WiFiEndpointSettings"`
+ H string `xml:"xmlns:q,attr"`
+ AuthenticationMethod AuthenticationMethod
+ BSSType BSSType
+ ElementName string
+ EncryptionMethod EncryptionMethod
+ InstanceID string
+ Priority int
+ SSID string
+ }
+ WiFiEndpointSettingsRequest struct {
+ XMLName xml.Name `xml:"h:WiFiEndpointSettingsInput"`
+ H string `xml:"xmlns:q,attr"`
+ // SettingData
+ ElementName string `xml:"q:ElementName,omitempty"`
+ InstanceID string `xml:"q:InstanceID,omitempty"`
+ AuthenticationMethod AuthenticationMethod `xml:"q:AuthenticationMethod,omitempty"`
+ EncryptionMethod EncryptionMethod `xml:"q:EncryptionMethod,omitempty"`
+ SSID string `xml:"q:SSID,omitempty"` // Max Length 32
+ Priority int `xml:"q:Priority,omitempty"`
+ PSKPassPhrase string `xml:"q:PSKPassPhrase,omitempty"` // Min Length 8 Max Length 63
+ BSSType BSSType `xml:"q:BSSType,omitempty"`
+ Keys []string `xml:"q:Keys,omitempty"` // OctetString ArrayType=Indexed Max Length 256
+ KeyIndex int `xml:"q:KeyIndex,omitempty"`
+ PSKValue int `xml:"q:PSKValue,omitempty"` // OctetString
+ }
+)
+
+type (
+ LinkTechnology int
+ AuthenticationMethod int
+ BSSType int
+ EncryptionMethod int
+ ReturnValue int
+)
diff --git a/pkg/wsman/hash.go b/pkg/wsman/client/hash.go
similarity index 87%
rename from pkg/wsman/hash.go
rename to pkg/wsman/client/hash.go
index 6ac4c441..a967b7ca 100644
--- a/pkg/wsman/hash.go
+++ b/pkg/wsman/client/hash.go
@@ -2,7 +2,8 @@
* Copyright (c) Intel Corporation 2023
* SPDX-License-Identifier: Apache-2.0
**********************************************************************/
-package wsman
+
+package client
import (
"crypto/md5"
@@ -10,7 +11,6 @@ import (
"fmt"
"io"
"log"
- "regexp"
"strings"
)
@@ -53,8 +53,9 @@ func (c *authChallenge) hashURI(method, uri string) string {
func (c *authChallenge) response(method, uri, cnonce string) (string, error) {
c.NonceCount++
- if c.Qop == "auth" || c.Qop == "" {
- if c.Qop == "auth" {
+ if strings.Contains(c.Qop, "auth") || c.Qop == "" {
+ nonceData := c.Nonce
+ if strings.Contains(c.Qop, "auth") {
if cnonce != "" {
c.CNonce = cnonce
} else {
@@ -64,14 +65,12 @@ func (c *authChallenge) response(method, uri, cnonce string) (string, error) {
}
c.CNonce = fmt.Sprintf("%x", b)[:16]
}
+ c.Qop = "auth"
+ nonceData = fmt.Sprintf("%s:%08x:%s:%s", nonceData, c.NonceCount, c.CNonce, c.Qop)
}
hashedCredentials := c.hashCredentials()
hashedURI := c.hashURI(method, uri)
- nonceData := c.Nonce
- if c.Qop == "auth" {
- nonceData = fmt.Sprintf("%s:%08x:%s:%s", nonceData, c.NonceCount, c.CNonce, c.Qop)
- }
response := hashWithHash(hashedCredentials, fmt.Sprintf("%s:%s", nonceData, hashedURI))
return response, nil
@@ -81,8 +80,9 @@ func (c *authChallenge) response(method, uri, cnonce string) (string, error) {
}
func (c *authChallenge) authorize(method, uri string) (string, error) {
- if c.Qop != "auth" && c.Qop != "" {
- return "", fmt.Errorf("qop not implemented: %s", c.Qop)
+
+ if !strings.Contains(c.Qop, "auth") && c.Qop != "" {
+ return "", fmt.Errorf("qop not implemented")
}
response, err := c.response(method, uri, "")
if err != nil {
@@ -113,11 +113,11 @@ func (c *authChallenge) authorize(method, uri string) (string, error) {
sb.WriteString(`"`)
}
if c.Qop != "" {
- sb.WriteString(", qop=")
+ sb.WriteString(`, qop="`)
sb.WriteString(c.Qop)
- sb.WriteString(", nc=")
+ sb.WriteString(`", nc="`)
sb.WriteString(fmt.Sprintf("%08x", c.NonceCount))
- sb.WriteString(`, cnonce="`)
+ sb.WriteString(`", cnonce="`)
sb.WriteString(c.CNonce)
sb.WriteString(`"`)
}
@@ -128,14 +128,12 @@ func (c *authChallenge) authorize(method, uri string) (string, error) {
func (c *authChallenge) parseChallenge(input string) error {
const ws = " \n\r\t"
const qs = "\""
- regex := regexp.MustCompile(`([^=,]*)=("[^"]*"|[^,"]*)`)
-
s := strings.Trim(input, ws)
if !strings.HasPrefix(s, "Digest ") {
return fmt.Errorf("challenge is bad, missing digest prefix: %s", input)
}
s = strings.Trim(s[7:], ws)
- sl := regex.FindAllString(s, -1)
+ sl := strings.Split(s, "\",")
c.Algorithm = "MD5"
var r []string
for _, elem := range sl {
@@ -160,12 +158,6 @@ func (c *authChallenge) parseChallenge(input string) error {
c.Algorithm = value
case "qop":
c.Qop = value
- for _, qop := range strings.Split(value, ",") {
- qop = strings.TrimSpace(qop)
- if qop == "auth" {
- c.Qop = "auth"
- }
- }
default:
return fmt.Errorf("challenge is bad, unexpected token: %s", sl)
}
diff --git a/pkg/wsman/hash_test.go b/pkg/wsman/client/hash_test.go
similarity index 51%
rename from pkg/wsman/hash_test.go
rename to pkg/wsman/client/hash_test.go
index e028fca1..5af5d0c7 100644
--- a/pkg/wsman/hash_test.go
+++ b/pkg/wsman/client/hash_test.go
@@ -2,7 +2,8 @@
* Copyright (c) Intel Corporation 2023
* SPDX-License-Identifier: Apache-2.0
**********************************************************************/
-package wsman
+
+package client
import (
"testing"
@@ -70,48 +71,72 @@ func TestAuthChallenge_HashURI(t *testing.T) {
}
}
-func TestAuthChallenge_parseChallenge(t *testing.T) {
+func TestResponse(t *testing.T) {
c := &authChallenge{}
+ testCases := []struct {
+ method string
+ uri string
+ cnonce string
+ expected string
+ }{
+ {"POST", "/path", "1b2311bfa21bfd81", "b9c5d3509b8a70d95a6204668265e6f9"},
+ }
+ for _, tc := range testCases {
+ actual, _ := c.response(tc.method, tc.uri, tc.cnonce)
+ assert.Equal(t, tc.expected, actual)
+ }
+}
+
+func TestResponse_Qop(t *testing.T) {
+ c := &authChallenge{}
testCases := []struct {
- description string
- input string
- expectQOP string
+ method string
+ uri string
+ cnonce string
+ expected string
}{
- {
- description: "expect qop of auth for multiple options if auth is one of them",
- input: `Digest realm="Digest:CA8E24F8F3E8EFBD8322A0BC846BDE7D", nonce="EzyJAVIHAAAAAAAA2hsF/jk27ByMWRKu",stale="false",qop="auth,auth-int, auth"`,
- expectQOP: "auth",
- },
- {
- description: "expect qop of auth for multiple options in any order",
- input: `Digest realm="Digest:CA8E24F8F3E8EFBD8322A0BC846BDE7D", nonce="EzyJAVIHAAAAAAAA2hsF/jk27ByMWRKu",stale="false",qop="auth-int,auth"`,
- expectQOP: "auth",
- },
- {
- description: "expect qop of auth for single option",
- input: `Digest realm="Digest:81D0A72A91B91FC7B08CED6F26DC0D49", nonce="kGuhOSX9AAAAAAAAjlLGwSwRfxiBgr2z",stale="false",qop="auth"`,
- expectQOP: "auth",
- },
- {
- description: "expect qop of auth and ignore unkown options",
- input: `Digest realm="Digest:81D0A72A91B91FC7B08CED6F26DC0D49", nonce="kGuhOSX9AAAAAAAAjlLGwSwRfxiBgr2z",stale="false",qop="auth,not-valid"`,
- expectQOP: "auth",
- },
- {
- description: "expect qop equal to the original if auth not an option",
- input: `Digest realm="Digest:CA8E24F8F3E8EFBD8322A0BC846BDE7D", nonce="EzyJAVIHAAAAAAAA2hsF/jk27ByMWRKu",stale="false",qop="auth-conf,auth-int"`,
- expectQOP: "auth-conf,auth-int",
- },
+ {"POST", "/path", "1b2311bfa21bfd81", "c6b417c8da94a1d3649b4f6894c78379"},
}
for _, tc := range testCases {
- t.Run(tc.description, func(t *testing.T) {
- err := c.parseChallenge(tc.input)
- assert.Nil(t, err)
- assert.Equal(t, tc.expectQOP, c.Qop)
- })
+ c.Qop = "auth,auth-int, auth"
+ actual, _ := c.response(tc.method, tc.uri, tc.cnonce)
+ assert.Equal(t, tc.expected, actual)
+ }
+}
+func TestAuthorize(t *testing.T) {
+ c := &authChallenge{}
+ testCases := []struct {
+ method string
+ uri string
+ expected string
+ }{
+ {"POST", "/path", "Digest username=\"\", realm=\"\", nonce=\"\", uri=\"/path\", response=\"b9c5d3509b8a70d95a6204668265e6f9\""},
+ }
+
+ for _, tc := range testCases {
+ actual, _ := c.authorize(tc.method, tc.uri)
+ assert.Equal(t, tc.expected, actual)
+ }
+}
+
+func TestAuthorize_Full(t *testing.T) {
+ c := &authChallenge{}
+ testCases := []struct {
+ method string
+ uri string
+ expected string
+ }{
+ {"POST", "/path", "Digest username=\"admin\", realm=\"test\", nonce=\"00000001\", uri=\"/path\", response=\"99d726faaaa4e8874b3fd0f425053f5a\""},
}
+ for _, tc := range testCases {
+ c.Username = "admin"
+ c.Realm = "test"
+ c.Nonce = "00000001"
+ actual, _ := c.authorize(tc.method, tc.uri)
+ assert.Equal(t, tc.expected, actual)
+ }
}
diff --git a/pkg/wsman/client/relay.go b/pkg/wsman/client/relay.go
new file mode 100644
index 00000000..11731627
--- /dev/null
+++ b/pkg/wsman/client/relay.go
@@ -0,0 +1,177 @@
+/*********************************************************************
+ * Copyright (c) Intel Corporation 2024
+ * SPDX-License-Identifier: Apache-2.0
+ **********************************************************************/
+package client
+
+import (
+ "bufio"
+ "bytes"
+ "crypto/tls"
+ "errors"
+ "io"
+ "net/http"
+ "net/http/httputil"
+ "net/url"
+ "strconv"
+ "strings"
+ "sync"
+ "time"
+
+ "github.com/gorilla/websocket"
+)
+
+// WsTransport is an implementation of http.Transport which uses websocket relay
+type WsTransport struct {
+ wsurl string
+ protocol int
+ host string
+ username string
+ password string
+ port int
+ tls bool
+ tls1only bool
+ token string
+ conn *websocket.Conn
+ tlsconfig *tls.Config
+ buf_mutex sync.Mutex
+ messages []byte
+}
+
+// NewTransport creates a new Websocket RoundTripper.
+func NewWsTransport(wsurl string, protocol int, host, username, password string, port int, tls, tls1only bool, token string, tlsconfig *tls.Config) *WsTransport {
+ t := &WsTransport{
+ wsurl: wsurl,
+ protocol: protocol,
+ host: host,
+ username: username,
+ password: password,
+ port: port,
+ tls: tls,
+ tls1only: tls1only,
+ token: token,
+ tlsconfig: tlsconfig,
+ buf_mutex: sync.Mutex{},
+ }
+ return t
+}
+
+func (t *WsTransport) timedReadMessage(ms int) (b []byte) {
+ timer := time.NewTimer(time.Duration(ms) * time.Millisecond)
+ <-timer.C
+ t.buf_mutex.Lock()
+ b = append(b, t.messages...)
+ t.messages = []byte{}
+ t.buf_mutex.Unlock()
+ return b
+}
+
+func (t *WsTransport) buildUrl() string {
+ // Use net/url to construct the URL
+ u, _ := url.Parse(t.wsurl)
+ // Prepare query parameters
+ q := u.Query()
+ q.Set("p", strconv.Itoa(t.protocol))
+ q.Set("host", t.host)
+ q.Set("user", t.username)
+ q.Set("pass", t.password)
+ q.Set("port", strconv.Itoa(t.port))
+ q.Set("tls", strconv.FormatBool(t.tls))
+ q.Set("tls1only", strconv.FormatBool(t.tls1only))
+ // Set query string to URL
+ u.RawQuery = q.Encode()
+ return u.String()
+}
+
+func (t *WsTransport) connectWebsocket() (conn *websocket.Conn, err error) {
+ url := t.buildUrl()
+ // Attempt to establish websocket connection
+ var hdr = http.Header{}
+ if t.token != "" {
+ hdr.Set("Sec-Websocket-Protocol", t.token)
+ }
+ wsdialer := websocket.Dialer{}
+ wsdialer.TLSClientConfig = t.tlsconfig
+ conn, _, err = wsdialer.Dial(url, hdr)
+ if err != nil {
+ return nil, err
+ } else {
+ t.conn = conn
+ go func() {
+ for {
+ //Trying to read.
+ _, p, err := t.conn.ReadMessage()
+ if err != nil {
+ return
+ }
+ t.buf_mutex.Lock()
+ t.messages = append(t.messages, p...)
+ t.buf_mutex.Unlock()
+ }
+ }()
+ }
+ return conn, err
+}
+
+func (t *WsTransport) disconnectWebsocket() {
+ if t.conn != nil {
+ _ = t.conn.Close()
+ t.conn = nil
+ }
+}
+
+// RoundTrip makes a low level text exchange over websocket. This is supposed to be used by high level round tripper
+func (t *WsTransport) RoundTrip(r *http.Request) (resp *http.Response, err error) {
+ // Sanity check
+ if t.wsurl == "" || t.protocol == 0 || t.host == "" || t.username == "" || t.password == "" || t.port == 0 {
+ return nil, errors.New("invalid transport data")
+ }
+ // Check if we had already established websocket for this transport object, if not create
+ if t.conn == nil || t.conn.UnderlyingConn() == nil {
+ _, err := t.connectWebsocket()
+ if err != nil {
+ return nil, err
+ }
+ }
+ // t.conn should be established
+ // be careful when working with request Body.. make a copy
+ buf, _ := io.ReadAll(r.Body)
+ bd1 := io.NopCloser(bytes.NewBuffer(buf))
+ bd2 := io.NopCloser(bytes.NewBuffer(buf))
+ l, _ := io.Copy(io.Discard, bd1)
+ r.Body = bd2
+ r.Header.Add("Content-Length", strconv.FormatInt(l, 10))
+
+ bytes_to_send, _ := httputil.DumpRequest(r, true)
+ // write and ignore error status, proper error handling is at read go routine
+ _ = t.conn.WriteMessage(websocket.TextMessage, bytes_to_send)
+
+ b := t.timedReadMessage(100)
+ bf := []byte{}
+ bf = append(bf, b[:]...)
+ // this is to check if we finished reading the whole body, otherwise read again
+ // this will try to read data 10 times with 300 ms delay (3 seconds) if previous read yields empty data
+ max_count := 10
+ count := 0
+ for {
+ b = t.timedReadMessage(300)
+ // how many zero read
+ if len(b) == 0 {
+ count = count + 1
+ if count >= max_count {
+ break
+ }
+ }
+ bf = append(bf, b[:]...)
+ if strings.Index(string(bf), "") > 0 {
+ break
+ }
+ if strings.Index(string(bf), "