From b9627714600dc0f818c6061152d65a4b30ea78cd Mon Sep 17 00:00:00 2001 From: Rick B Date: Wed, 22 May 2024 16:58:27 -0700 Subject: [PATCH] feat: support get certs api Co-authored-by: madhavilosetty-intel --- pkg/wsman/amt/publickey/certificate.go | 17 ++++++++++++++ pkg/wsman/amt/publickey/certificate_test.go | 4 ++-- pkg/wsman/amt/publickey/types.go | 26 +++++++++++++++++++++ pkg/wsman/amt/publicprivate/keypair.go | 12 ++++++++++ pkg/wsman/amt/publicprivate/keypair_test.go | 4 ++-- pkg/wsman/amt/publicprivate/types.go | 17 ++++++++++---- pkg/wsman/cim/credential/context_test.go | 8 +++---- pkg/wsman/cim/credential/types.go | 14 +++-------- 8 files changed, 79 insertions(+), 23 deletions(-) diff --git a/pkg/wsman/amt/publickey/certificate.go b/pkg/wsman/amt/publickey/certificate.go index b0fe20fb..4a18b711 100644 --- a/pkg/wsman/amt/publickey/certificate.go +++ b/pkg/wsman/amt/publickey/certificate.go @@ -75,6 +75,7 @@ func (certificate Certificate) Enumerate() (response Response, err error) { // 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) { + var refinedOutput []RefinedPublicKeyCertificateResponse response = Response{ Message: &client.Message{ XMLInput: certificate.base.Pull(enumerationContext), @@ -91,6 +92,22 @@ func (certificate Certificate) Pull(enumerationContext string) (response Respons return } + for _, item := range response.Body.PullResponse.PublicKeyCertificateItems { + output := RefinedPublicKeyCertificateResponse{ + InstanceID: item.InstanceID, + X509Certificate: item.X509Certificate, + ElementName: item.ElementName, + TrustedRootCertificate: item.TrustedRootCertificate, + Issuer: item.Issuer, + Subject: item.Subject, + ReadOnlyCertificate: item.ReadOnlyCertificate, + } + + refinedOutput = append(refinedOutput, output) + } + + response.Body.RefinedPullResponse.PublicKeyCertificateItems = refinedOutput + return } diff --git a/pkg/wsman/amt/publickey/certificate_test.go b/pkg/wsman/amt/publickey/certificate_test.go index b9617fa3..93030fd8 100644 --- a/pkg/wsman/amt/publickey/certificate_test.go +++ b/pkg/wsman/amt/publickey/certificate_test.go @@ -26,7 +26,7 @@ func TestJson(t *testing.T) { AddCertificate_OUTPUT: AddCertificate_OUTPUT{}, }, } - expectedResult := "{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"AddTrustedRootCertificate_OUTPUT\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"CreatedCertificate\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"Address\":\"\",\"ReferenceParameters\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"ResourceURI\":\"\",\"SelectorSet\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"Selectors\":null}}},\"ReturnValue\":0},\"AddCertificate_OUTPUT\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"CreatedCertificate\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"Address\":\"\",\"ReferenceParameters\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"ResourceURI\":\"\",\"SelectorSet\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"Selectors\":null}}},\"ReturnValue\":0},\"AddKey_OUTPUT\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"CreatedKey\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"Address\":\"\",\"ReferenceParameters\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"ResourceURI\":\"\",\"SelectorSet\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"Selectors\":null}}},\"ReturnValue\":0},\"GenerateKeyPair_OUTPUT\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"KeyPair\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"Address\":\"\",\"ReferenceParameters\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"ResourceURI\":\"\",\"SelectorSet\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"Selectors\":null}}},\"ReturnValue\":0},\"GeneratePKCS10RequestEx_OUTPUT\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"SignedCertificateRequest\":\"\",\"ReturnValue\":0},\"KeyManagementGetResponse\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"CreationClassName\":\"\",\"ElementName\":\"\",\"EnabledDefault\":0,\"EnabledState\":0,\"Name\":\"\",\"OperationalStatus\":null,\"RequestedState\":0,\"SystemCreationClassName\":\"\",\"SystemName\":\"\"},\"PublicKeyCertificateGetAndPutResponse\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"ElementName\":\"\",\"InstanceID\":\"\",\"X509Certificate\":\"\",\"TrustedRootCertificate\":false,\"Issuer\":\"\",\"Subject\":\"\",\"ReadOnlyCertificate\":false},\"EnumerateResponse\":{\"EnumerationContext\":\"\"},\"PullResponse\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"KeyManagementItems\":null,\"PublicKeyCertificateItems\":null}}" + expectedResult := "{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"AddTrustedRootCertificate_OUTPUT\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"CreatedCertificate\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"Address\":\"\",\"ReferenceParameters\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"ResourceURI\":\"\",\"SelectorSet\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"Selectors\":null}}},\"ReturnValue\":0},\"AddCertificate_OUTPUT\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"CreatedCertificate\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"Address\":\"\",\"ReferenceParameters\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"ResourceURI\":\"\",\"SelectorSet\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"Selectors\":null}}},\"ReturnValue\":0},\"AddKey_OUTPUT\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"CreatedKey\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"Address\":\"\",\"ReferenceParameters\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"ResourceURI\":\"\",\"SelectorSet\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"Selectors\":null}}},\"ReturnValue\":0},\"GenerateKeyPair_OUTPUT\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"KeyPair\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"Address\":\"\",\"ReferenceParameters\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"ResourceURI\":\"\",\"SelectorSet\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"Selectors\":null}}},\"ReturnValue\":0},\"GeneratePKCS10RequestEx_OUTPUT\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"SignedCertificateRequest\":\"\",\"ReturnValue\":0},\"KeyManagementGetResponse\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"CreationClassName\":\"\",\"ElementName\":\"\",\"EnabledDefault\":0,\"EnabledState\":0,\"Name\":\"\",\"OperationalStatus\":null,\"RequestedState\":0,\"SystemCreationClassName\":\"\",\"SystemName\":\"\"},\"PublicKeyCertificateGetAndPutResponse\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"ElementName\":\"\",\"InstanceID\":\"\",\"X509Certificate\":\"\",\"TrustedRootCertificate\":false,\"Issuer\":\"\",\"Subject\":\"\",\"ReadOnlyCertificate\":false},\"EnumerateResponse\":{\"EnumerationContext\":\"\"},\"PullResponse\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"KeyManagementItems\":null,\"PublicKeyCertificateItems\":null},\"RefinedPullResponse\":{}}" result := response.JSON() assert.Equal(t, expectedResult, result) } @@ -37,7 +37,7 @@ func TestYaml(t *testing.T) { AddCertificate_OUTPUT: AddCertificate_OUTPUT{}, }, } - expectedResult := "xmlname:\n space: \"\"\n local: \"\"\naddtrustedrootcertificate_output:\n xmlname:\n space: \"\"\n local: \"\"\n createdcertificate:\n xmlname:\n space: \"\"\n local: \"\"\n address: \"\"\n referenceparameters:\n xmlname:\n space: \"\"\n local: \"\"\n resourceuri: \"\"\n selectorset:\n xmlname:\n space: \"\"\n local: \"\"\n selectors: []\n returnvalue: 0\naddcertificate_output:\n xmlname:\n space: \"\"\n local: \"\"\n createdcertificate:\n xmlname:\n space: \"\"\n local: \"\"\n address: \"\"\n referenceparameters:\n xmlname:\n space: \"\"\n local: \"\"\n resourceuri: \"\"\n selectorset:\n xmlname:\n space: \"\"\n local: \"\"\n selectors: []\n returnvalue: 0\naddkey_output:\n xmlname:\n space: \"\"\n local: \"\"\n createdkey:\n xmlname:\n space: \"\"\n local: \"\"\n address: \"\"\n referenceparameters:\n xmlname:\n space: \"\"\n local: \"\"\n resourceuri: \"\"\n selectorset:\n xmlname:\n space: \"\"\n local: \"\"\n selectors: []\n returnvalue: 0\ngeneratekeypair_output:\n xmlname:\n space: \"\"\n local: \"\"\n keypair:\n xmlname:\n space: \"\"\n local: \"\"\n address: \"\"\n referenceparameters:\n xmlname:\n space: \"\"\n local: \"\"\n resourceuri: \"\"\n selectorset:\n xmlname:\n space: \"\"\n local: \"\"\n selectors: []\n returnvalue: 0\ngeneratepkcs10requestex_output:\n xmlname:\n space: \"\"\n local: \"\"\n signedcertificaterequest: \"\"\n returnvalue: 0\nkeymanagementgetresponse:\n xmlname:\n space: \"\"\n local: \"\"\n creationclassname: \"\"\n elementname: \"\"\n enableddefault: 0\n enabledstate: 0\n name: \"\"\n operationalstatus: []\n requestedstate: 0\n systemcreationclassname: \"\"\n systemname: \"\"\npublickeycertificategetandputresponse:\n xmlname:\n space: \"\"\n local: \"\"\n elementname: \"\"\n instanceid: \"\"\n x509certificate: \"\"\n trustedrootcertificate: false\n issuer: \"\"\n subject: \"\"\n readonlycertificate: false\nenumerateresponse:\n enumerationcontext: \"\"\npullresponse:\n xmlname:\n space: \"\"\n local: \"\"\n keymanagementitems: []\n publickeycertificateitems: []\n" + expectedResult := "xmlname:\n space: \"\"\n local: \"\"\naddtrustedrootcertificate_output:\n xmlname:\n space: \"\"\n local: \"\"\n createdcertificate:\n xmlname:\n space: \"\"\n local: \"\"\n address: \"\"\n referenceparameters:\n xmlname:\n space: \"\"\n local: \"\"\n resourceuri: \"\"\n selectorset:\n xmlname:\n space: \"\"\n local: \"\"\n selectors: []\n returnvalue: 0\naddcertificate_output:\n xmlname:\n space: \"\"\n local: \"\"\n createdcertificate:\n xmlname:\n space: \"\"\n local: \"\"\n address: \"\"\n referenceparameters:\n xmlname:\n space: \"\"\n local: \"\"\n resourceuri: \"\"\n selectorset:\n xmlname:\n space: \"\"\n local: \"\"\n selectors: []\n returnvalue: 0\naddkey_output:\n xmlname:\n space: \"\"\n local: \"\"\n createdkey:\n xmlname:\n space: \"\"\n local: \"\"\n address: \"\"\n referenceparameters:\n xmlname:\n space: \"\"\n local: \"\"\n resourceuri: \"\"\n selectorset:\n xmlname:\n space: \"\"\n local: \"\"\n selectors: []\n returnvalue: 0\ngeneratekeypair_output:\n xmlname:\n space: \"\"\n local: \"\"\n keypair:\n xmlname:\n space: \"\"\n local: \"\"\n address: \"\"\n referenceparameters:\n xmlname:\n space: \"\"\n local: \"\"\n resourceuri: \"\"\n selectorset:\n xmlname:\n space: \"\"\n local: \"\"\n selectors: []\n returnvalue: 0\ngeneratepkcs10requestex_output:\n xmlname:\n space: \"\"\n local: \"\"\n signedcertificaterequest: \"\"\n returnvalue: 0\nkeymanagementgetresponse:\n xmlname:\n space: \"\"\n local: \"\"\n creationclassname: \"\"\n elementname: \"\"\n enableddefault: 0\n enabledstate: 0\n name: \"\"\n operationalstatus: []\n requestedstate: 0\n systemcreationclassname: \"\"\n systemname: \"\"\npublickeycertificategetandputresponse:\n xmlname:\n space: \"\"\n local: \"\"\n elementname: \"\"\n instanceid: \"\"\n x509certificate: \"\"\n trustedrootcertificate: false\n issuer: \"\"\n subject: \"\"\n readonlycertificate: false\nenumerateresponse:\n enumerationcontext: \"\"\npullresponse:\n xmlname:\n space: \"\"\n local: \"\"\n keymanagementitems: []\n publickeycertificateitems: []\nrefinedpullresponse:\n keymanagementitems: []\n publickeycertificateitems: []\n" result := response.YAML() assert.Equal(t, expectedResult, result) } diff --git a/pkg/wsman/amt/publickey/types.go b/pkg/wsman/amt/publickey/types.go index 6d6c6ec7..f1c14b24 100644 --- a/pkg/wsman/amt/publickey/types.go +++ b/pkg/wsman/amt/publickey/types.go @@ -41,6 +41,11 @@ type ( PublicKeyCertificateGetAndPutResponse PublicKeyCertificateResponse `xml:"AMT_PublicKeyCertificate,omitempty"` EnumerateResponse common.EnumerateResponse PullResponse PullResponse + RefinedPullResponse RefinedPullResponse + } + RefinedPullResponse struct { + KeyManagementItems []RefinedKeyManagementResponse `json:"KeyManagementItems,omitempty"` + PublicKeyCertificateItems []RefinedPublicKeyCertificateResponse `json:"PublicKeyCertificateItems,omitempty"` } PullResponse struct { XMLName xml.Name `xml:"PullResponse,omitempty"` @@ -59,6 +64,17 @@ type ( SystemCreationClassName string `xml:"SystemCreationClassName,omitempty"` // The CreationClassName of the scoping System. SystemName string `xml:"SystemName,omitempty"` // The Name of the scoping System. } + RefinedKeyManagementResponse struct { + CreationClassName string + ElementName string + EnabledDefault EnabledDefault + EnabledState EnabledState + Name string + RequestedState RequestedState + SystemCreationClassName string + SystemName string + } + PublicKeyCertificateResponse struct { XMLName xml.Name `xml:"AMT_PublicKeyCertificate,omitempty"` ElementName string `xml:"ElementName,omitempty"` // A user-friendly name for the object . . . @@ -69,6 +85,16 @@ type ( 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. } + + RefinedPublicKeyCertificateResponse struct { + 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"` diff --git a/pkg/wsman/amt/publicprivate/keypair.go b/pkg/wsman/amt/publicprivate/keypair.go index 7c8408b6..7174657f 100644 --- a/pkg/wsman/amt/publicprivate/keypair.go +++ b/pkg/wsman/amt/publicprivate/keypair.go @@ -70,6 +70,7 @@ func (keyPair KeyPair) Enumerate() (response Response, err error) { // 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) { + var refinedOutput []RefinedPublicPrivateKeyPair response = Response{ Message: &client.Message{ XMLInput: keyPair.base.Pull(enumerationContext), @@ -85,6 +86,17 @@ func (keyPair KeyPair) Pull(enumerationContext string) (response Response, err e if err != nil { return } + for _, item := range response.Body.PullResponse.PublicPrivateKeyPairItems { + output := RefinedPublicPrivateKeyPair{ + InstanceID: item.InstanceID, + ElementName: item.ElementName, + DERKey: item.DERKey, + } + + refinedOutput = append(refinedOutput, output) + } + + response.Body.RefinedPullResponse.PublicPrivateKeyPairItems = refinedOutput return } diff --git a/pkg/wsman/amt/publicprivate/keypair_test.go b/pkg/wsman/amt/publicprivate/keypair_test.go index a13cc2cd..e3fd4559 100644 --- a/pkg/wsman/amt/publicprivate/keypair_test.go +++ b/pkg/wsman/amt/publicprivate/keypair_test.go @@ -23,7 +23,7 @@ func TestJson(t *testing.T) { GetResponse: PublicPrivateKeyPair{}, }, } - expectedResult := "{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"GetResponse\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"ElementName\":\"\",\"InstanceID\":\"\",\"DERKey\":\"\"},\"EnumerateResponse\":{\"EnumerationContext\":\"\"},\"PullResponse\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"PublicPrivateKeyPairItems\":null}}" + expectedResult := "{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"GetResponse\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"ElementName\":\"\",\"InstanceID\":\"\",\"DERKey\":\"\"},\"EnumerateResponse\":{\"EnumerationContext\":\"\"},\"PullResponse\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"PublicPrivateKeyPairItems\":null},\"RefinedPullResponse\":{\"PublicPrivateKeyPairItems\":null}}" result := response.JSON() assert.Equal(t, expectedResult, result) } @@ -34,7 +34,7 @@ func TestYaml(t *testing.T) { GetResponse: PublicPrivateKeyPair{}, }, } - expectedResult := "xmlname:\n space: \"\"\n local: \"\"\ngetresponse:\n xmlname:\n space: \"\"\n local: \"\"\n elementname: \"\"\n instanceid: \"\"\n derkey: \"\"\nenumerateresponse:\n enumerationcontext: \"\"\npullresponse:\n xmlname:\n space: \"\"\n local: \"\"\n publicprivatekeypairitems: []\n" + expectedResult := "xmlname:\n space: \"\"\n local: \"\"\ngetresponse:\n xmlname:\n space: \"\"\n local: \"\"\n elementname: \"\"\n instanceid: \"\"\n derkey: \"\"\nenumerateresponse:\n enumerationcontext: \"\"\npullresponse:\n xmlname:\n space: \"\"\n local: \"\"\n publicprivatekeypairitems: []\nrefinedpullresponse:\n publicprivatekeypairitems: []\n" result := response.YAML() assert.Equal(t, expectedResult, result) } diff --git a/pkg/wsman/amt/publicprivate/types.go b/pkg/wsman/amt/publicprivate/types.go index f56c61a2..c3f4db2d 100644 --- a/pkg/wsman/amt/publicprivate/types.go +++ b/pkg/wsman/amt/publicprivate/types.go @@ -28,16 +28,20 @@ type ( } Body struct { - XMLName xml.Name `xml:"Body"` - GetResponse PublicPrivateKeyPair - EnumerateResponse common.EnumerateResponse - PullResponse PullResponse + XMLName xml.Name `xml:"Body"` + GetResponse PublicPrivateKeyPair + EnumerateResponse common.EnumerateResponse + PullResponse PullResponse + RefinedPullResponse RefinedPullResponse } PullResponse struct { XMLName xml.Name `xml:"PullResponse"` PublicPrivateKeyPairItems []PublicPrivateKeyPair `xml:"Items>AMT_PublicPrivateKeyPair"` } + RefinedPullResponse struct { + PublicPrivateKeyPairItems []RefinedPublicPrivateKeyPair + } PublicPrivateKeyPair struct { XMLName xml.Name `xml:"AMT_PublicPrivateKeyPair"` @@ -46,5 +50,10 @@ type ( 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] } + RefinedPublicPrivateKeyPair struct { + 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/cim/credential/context_test.go b/pkg/wsman/cim/credential/context_test.go index 9aa6912c..fdff5b97 100644 --- a/pkg/wsman/cim/credential/context_test.go +++ b/pkg/wsman/cim/credential/context_test.go @@ -129,8 +129,8 @@ func TestPositiveCIMCredentialContext(t *testing.T) { }, }, }, - []CredentialContextTLS(nil), - []CredentialContext8021x(nil), + []CredentialContext(nil), + []CredentialContext(nil), }, EndOfSequence: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "EndOfSequence"}, }, @@ -235,8 +235,8 @@ func TestNegativeCIMCredentialContext(t *testing.T) { }, }, }, - []CredentialContextTLS(nil), - []CredentialContext8021x(nil), + []CredentialContext(nil), + []CredentialContext(nil), }, EndOfSequence: xml.Name{Space: "http://schemas.xmlsoap.org/ws/2004/09/enumeration", Local: "EndOfSequence"}, }, diff --git a/pkg/wsman/cim/credential/types.go b/pkg/wsman/cim/credential/types.go index b08da4ef..8f0d4972 100644 --- a/pkg/wsman/cim/credential/types.go +++ b/pkg/wsman/cim/credential/types.go @@ -40,20 +40,12 @@ type ( } Items struct { - CredentialContext []CredentialContext `xml:"CIM_CredentialContext"` - CredentialContextTLS []CredentialContextTLS `xml:"AMT_TLSCredentialContext"` - CredentialContext8021x []CredentialContext8021x `xml:"IPS_8021xCredentialContext"` + CredentialContext []CredentialContext `xml:"CIM_CredentialContext"` + CredentialContextTLS []CredentialContext `xml:"AMT_TLSCredentialContext"` + CredentialContext8021x []CredentialContext `xml:"IPS_8021xCredentialContext"` } 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. } - CredentialContextTLS 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. - } - CredentialContext8021x 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. - } )