Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: completed 8021x credential context typing #322

Merged
merged 1 commit into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/wsman/amt/ieee8021x/credentialcontext_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestJson(t *testing.T) {
CredentialContextGetResponse: CredentialContextResponse{},
},
}
expectedResult := "{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"ProfileGetAndPutResponse\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"ElementName\":\"\",\"InstanceID\":\"\",\"Enabled\":false,\"ActiveInS0\":false,\"AuthenticationProtocol\":0,\"RoamingIdentity\":\"\",\"ServerCertificateName\":\"\",\"ServerCertificateNameComparison\":0,\"Username\":\"\",\"Password\":\"\",\"Domain\":\"\",\"ProtectedAccessCredential\":null,\"PACPassword\":\"\",\"ClientCertificate\":\"\",\"ServerCertificateIssue\":\"\",\"PxeTimeout\":0},\"CredentialContextGetResponse\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"}},\"EnumerateResponse\":{\"EnumerationContext\":\"\"},\"PullResponse\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"ProfileItems\":null,\"CredentialContextItems\":null}}"
expectedResult := "{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"ProfileGetAndPutResponse\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"ElementName\":\"\",\"InstanceID\":\"\",\"Enabled\":false,\"ActiveInS0\":false,\"AuthenticationProtocol\":0,\"RoamingIdentity\":\"\",\"ServerCertificateName\":\"\",\"ServerCertificateNameComparison\":0,\"Username\":\"\",\"Password\":\"\",\"Domain\":\"\",\"ProtectedAccessCredential\":null,\"PACPassword\":\"\",\"ClientCertificate\":\"\",\"ServerCertificateIssue\":\"\",\"PxeTimeout\":0},\"CredentialContextGetResponse\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"ElementInContext\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"Address\":\"\",\"ReferenceParameters\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"ResourceURI\":\"\",\"SelectorSet\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"Selectors\":null}}},\"ElementProvidingContext\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"Address\":\"\",\"ReferenceParameters\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"ResourceURI\":\"\",\"SelectorSet\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"Selectors\":null}}}},\"EnumerateResponse\":{\"EnumerationContext\":\"\"},\"PullResponse\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"ProfileItems\":null,\"CredentialContextItems\":null}}"
result := response.JSON()
assert.Equal(t, expectedResult, result)
}
Expand All @@ -33,7 +33,7 @@ func TestYaml(t *testing.T) {
CredentialContextGetResponse: CredentialContextResponse{},
},
}
expectedResult := "xmlname:\n space: \"\"\n local: \"\"\nprofilegetandputresponse:\n xmlname:\n space: \"\"\n local: \"\"\n elementname: \"\"\n instanceid: \"\"\n enabled: false\n activeins0: false\n authenticationprotocol: 0\n roamingidentity: \"\"\n servercertificatename: \"\"\n servercertificatenamecomparison: 0\n username: \"\"\n password: \"\"\n domain: \"\"\n protectedaccesscredential: []\n pacpassword: \"\"\n clientcertificate: \"\"\n servercertificateissue: \"\"\n pxetimeout: 0\ncredentialcontextgetresponse:\n xmlname:\n space: \"\"\n local: \"\"\nenumerateresponse:\n enumerationcontext: \"\"\npullresponse:\n xmlname:\n space: \"\"\n local: \"\"\n profileitems: []\n credentialcontextitems: []\n"
expectedResult := "xmlname:\n space: \"\"\n local: \"\"\nprofilegetandputresponse:\n xmlname:\n space: \"\"\n local: \"\"\n elementname: \"\"\n instanceid: \"\"\n enabled: false\n activeins0: false\n authenticationprotocol: 0\n roamingidentity: \"\"\n servercertificatename: \"\"\n servercertificatenamecomparison: 0\n username: \"\"\n password: \"\"\n domain: \"\"\n protectedaccesscredential: []\n pacpassword: \"\"\n clientcertificate: \"\"\n servercertificateissue: \"\"\n pxetimeout: 0\ncredentialcontextgetresponse:\n xmlname:\n space: \"\"\n local: \"\"\n elementincontext:\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 elementprovidingcontext:\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: []\nenumerateresponse:\n enumerationcontext: \"\"\npullresponse:\n xmlname:\n space: \"\"\n local: \"\"\n profileitems: []\n credentialcontextitems: []\n"
result := response.YAML()
assert.Equal(t, expectedResult, result)
}
Expand Down
29 changes: 27 additions & 2 deletions pkg/wsman/amt/ieee8021x/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,34 @@ type (
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.
}

SelectorResponse struct {
XMLName xml.Name `xml:"Selector,omitempty"`
Name string `xml:"Name,attr"`
Text string `xml:",chardata"`
}
SelectorSetResponse struct {
XMLName xml.Name `xml:"SelectorSet,omitempty"`
Selectors []SelectorResponse `xml:"Selector,omitempty"`
}
ReferenceParametersResponse struct {
XMLName xml.Name `xml:"ReferenceParameters,omitempty"`
ResourceURI string `xml:"ResourceURI,omitempty"`
SelectorSet SelectorSetResponse `xml:"SelectorSet,omitempty"`
}
ElementInContextResponse struct {
XMLName xml.Name `xml:"ElementInContext"`
Address string `xml:"Address,omitempty"`
ReferenceParameters ReferenceParametersResponse `xml:"ReferenceParameters,omitempty"`
}
ElementProvidingContextResponse struct {
XMLName xml.Name `xml:"ElementProvidingContext"`
Address string `xml:"Address,omitempty"`
ReferenceParameters ReferenceParametersResponse `xml:"ReferenceParameters,omitempty"`
}
CredentialContextResponse struct {
XMLName xml.Name `xml:"AMT_8021XCredentialContext"`
XMLName xml.Name `xml:"AMT_8021xCredentialContext"`
ElementInContext ElementInContextResponse `xml:"ElementInContext"`
ElementProvidingContext ElementProvidingContextResponse `xml:"ElementProvidingContext"`
}
)

Expand Down
4 changes: 2 additions & 2 deletions pkg/wsman/ips/ieee8021x/credentialcontext_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestJson(t *testing.T) {
PullResponse: PullResponse{},
},
}
expectedResult := "{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"PullResponse\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"IEEE8021xSettingsItems\":null},\"EnumerateResponse\":{\"EnumerationContext\":\"\"},\"IEEE8021xSettingsResponse\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"ElementName\":\"\",\"InstanceID\":\"\",\"Enabled\":0,\"AvailableInS0\":false,\"PxeTimeout\":0},\"SetCertificatesResponse\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"ReturnValue\":0}}"
expectedResult := "{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"PullResponse\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"IEEE8021xSettingsItems\":null,\"CredentialContextItems\":null},\"EnumerateResponse\":{\"EnumerationContext\":\"\"},\"IEEE8021xSettingsResponse\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"ElementName\":\"\",\"InstanceID\":\"\",\"Enabled\":0,\"AvailableInS0\":false,\"PxeTimeout\":0},\"SetCertificatesResponse\":{\"XMLName\":{\"Space\":\"\",\"Local\":\"\"},\"ReturnValue\":0}}"
result := response.JSON()
assert.Equal(t, expectedResult, result)
}
Expand All @@ -33,7 +33,7 @@ func TestYaml(t *testing.T) {
PullResponse: PullResponse{},
},
}
expectedResult := "xmlname:\n space: \"\"\n local: \"\"\npullresponse:\n xmlname:\n space: \"\"\n local: \"\"\n ieee8021xsettingsitems: []\nenumerateresponse:\n enumerationcontext: \"\"\nieee8021xsettingsresponse:\n xmlname:\n space: \"\"\n local: \"\"\n elementname: \"\"\n instanceid: \"\"\n enabled: 0\n availableins0: false\n pxetimeout: 0\nsetcertificatesresponse:\n xmlname:\n space: \"\"\n local: \"\"\n returnvalue: 0\n"
expectedResult := "xmlname:\n space: \"\"\n local: \"\"\npullresponse:\n xmlname:\n space: \"\"\n local: \"\"\n ieee8021xsettingsitems: []\n credentialcontextitems: []\nenumerateresponse:\n enumerationcontext: \"\"\nieee8021xsettingsresponse:\n xmlname:\n space: \"\"\n local: \"\"\n elementname: \"\"\n instanceid: \"\"\n enabled: 0\n availableins0: false\n pxetimeout: 0\nsetcertificatesresponse:\n xmlname:\n space: \"\"\n local: \"\"\n returnvalue: 0\n"
result := response.YAML()
assert.Equal(t, expectedResult, result)
}
Expand Down
30 changes: 30 additions & 0 deletions pkg/wsman/ips/ieee8021x/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,36 @@ type (
PullResponse struct {
XMLName xml.Name `xml:"PullResponse"`
IEEE8021xSettingsItems []IEEE8021xSettingsResponse `xml:"Items>IPS_IEEE8021xSettings"`
CredentialContextItems []CredentialContextResponse `xml:"Items>IPS_8021xCredentialContext"`
}
CredentialContextResponse struct {
XMLName xml.Name `xml:"IPS_8021xCredentialContext"`
ElementInContext ElementInContextResponse `xml:"ElementInContext"`
ElementProvidingContext ElementProvidingContextResponse `xml:"ElementProvidingContext"`
}
SelectorResponse struct {
XMLName xml.Name `xml:"Selector,omitempty"`
Name string `xml:"Name,attr"`
Text string `xml:",chardata"`
}
SelectorSetResponse struct {
XMLName xml.Name `xml:"SelectorSet,omitempty"`
Selectors []SelectorResponse `xml:"Selector,omitempty"`
}
ReferenceParametersResponse struct {
XMLName xml.Name `xml:"ReferenceParameters,omitempty"`
ResourceURI string `xml:"ResourceURI,omitempty"`
SelectorSet SelectorSetResponse `xml:"SelectorSet,omitempty"`
}
ElementInContextResponse struct {
XMLName xml.Name `xml:"ElementInContext"`
Address string `xml:"Address,omitempty"`
ReferenceParameters ReferenceParametersResponse `xml:"ReferenceParameters,omitempty"`
}
ElementProvidingContextResponse struct {
XMLName xml.Name `xml:"ElementProvidingContext"`
Address string `xml:"Address,omitempty"`
ReferenceParameters ReferenceParametersResponse `xml:"ReferenceParameters,omitempty"`
}
SetCertificates_OUTPUT struct {
XMLName xml.Name `xml:"SetCertificates_OUTPUT"`
Expand Down
Loading