Skip to content

Commit b6607af

Browse files
committed
test: update unit tests for ,chardata XML unmarshalling change
1 parent f46b53f commit b6607af

File tree

7 files changed

+110
-60
lines changed

7 files changed

+110
-60
lines changed

pkg/wsman/amt/tls/credentialcontext.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ func (credentialContext CredentialContext) Create(certHandle string) (response R
132132
if err != nil {
133133
return
134134
}
135+
135136
// put the xml response into the go struct
136137
err = xml.Unmarshal([]byte(response.XMLOutput), &response)
137138
if err != nil {

pkg/wsman/amt/tls/credentialcontext_test.go

Lines changed: 89 additions & 49 deletions
Large diffs are not rendered by default.

pkg/wsman/amt/tls/types.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package tls
77

88
import (
99
"encoding/xml"
10+
"strings"
1011

1112
"github.com/device-management-toolkit/go-wsman-messages/v2/internal/message"
1213
"github.com/device-management-toolkit/go-wsman-messages/v2/pkg/wsman/client"
@@ -102,6 +103,18 @@ type (
102103
}
103104
)
104105

106+
// UnmarshalXML trims insignificant whitespace in SelectorResponse.Text while decoding.
107+
func (s *SelectorResponse) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
108+
type Alias SelectorResponse
109+
var aux Alias
110+
if err := d.DecodeElement(&aux, &start); err != nil {
111+
return err
112+
}
113+
aux.Text = strings.TrimSpace(aux.Text)
114+
*s = SelectorResponse(aux)
115+
return nil
116+
}
117+
105118
type (
106119
SettingDataRequest struct {
107120
XMLName xml.Name `xml:"h:AMT_TLSSettingData"`

pkg/wsman/ips/http/service_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func TestPositiveIPS_HTTPProxyService(t *testing.T) {
7878
XMLName: xml.Name{Space: fmt.Sprintf("%s%s", message.IPSSchema, IPSHTTPProxyService), Local: "ProxyAccessPoint"},
7979
Address: "http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous",
8080
ReferenceParameters: models.ReferenceParameters_OUTPUT{
81-
ResourceURI: "\n http://intel.com/wbem/wscim/1/ips-schema/1/IPS_HTTPProxyAccessPoint",
81+
ResourceURI: "http://intel.com/wbem/wscim/1/ips-schema/1/IPS_HTTPProxyAccessPoint",
8282
SelectorSet: models.SelectorSet_OUTPUT{
8383
XMLName: xml.Name{Space: "http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd", Local: "SelectorSet"},
8484
Selector: []message.Selector_OUTPUT{

pkg/wsman/wsmantesting/responses/amt/tls/credentialcontext/create.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<a:Envelope
3-
xmlns:a="http://www.w3.org/2003/05/soap-envelope"
2+
<a:Envelope xmlns:a="http://www.w3.org/2003/05/soap-envelope"
43
xmlns:b="http://schemas.xmlsoap.org/ws/2004/08/addressing"
54
xmlns:c="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd"
65
xmlns:d="http://schemas.xmlsoap.org/ws/2005/02/trust"

pkg/wsman/wsmantesting/responses/amt/tls/credentialcontext/pull.xml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,18 @@
1515
<h:ElementInContext>
1616
<b:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</b:Address>
1717
<b:ReferenceParameters>
18-
<c:ResourceURI>
19-
http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyCertificate</c:ResourceURI>
18+
<c:ResourceURI>http://intel.com/wbem/wscim/1/amt-schema/1/AMT_PublicKeyCertificate</c:ResourceURI>
2019
<c:SelectorSet>
21-
<c:Selector Name= "InstanceID">Intel(r) AMT Certificate: Handle: 3</c:Selector>
20+
<c:Selector Name="InstanceID">Intel(r) AMT Certificate: Handle: 3</c:Selector>
2221
</c:SelectorSet>
2322
</b:ReferenceParameters>
2423
</h:ElementInContext>
2524
<h:ElementProvidingContext>
2625
<b:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</b:Address>
2726
<b:ReferenceParameters>
28-
<c:ResourceURI>
29-
http://intel.com/wbem/wscim/1/amt-schema/1/AMT_TLSProtocolEndpointCollection</c:ResourceURI>
27+
<c:ResourceURI>http://intel.com/wbem/wscim/1/amt-schema/1/AMT_TLSProtocolEndpointCollection</c:ResourceURI>
3028
<c:SelectorSet>
31-
<c:Selector Name= "ElementName">TLSProtocolEndpoint Instances Collection</c:Selector>
29+
<c:Selector Name="ElementName">TLSProtocolEndpoint Instances Collection</c:Selector>
3230
</c:SelectorSet>
3331
</b:ReferenceParameters>
3432
</h:ElementProvidingContext>

pkg/wsman/wsmantesting/responses/ips/http/addproxyaccesspoint.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
<g:ProxyAccessPoint>
2121
<b:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</b:Address>
2222
<b:ReferenceParameters>
23-
<c:ResourceURI>
24-
http://intel.com/wbem/wscim/1/ips-schema/1/IPS_HTTPProxyAccessPoint</c:ResourceURI>
23+
<c:ResourceURI>http://intel.com/wbem/wscim/1/ips-schema/1/IPS_HTTPProxyAccessPoint</c:ResourceURI>
2524
<c:SelectorSet>
2625
<c:Selector Name="CreationClassName">IPS_HTTPProxyAccessPoint</c:Selector>
2726
<c:Selector Name="Name">Intel(r) ME:HTTP Proxy Access Point 3</c:Selector>

0 commit comments

Comments
 (0)