@@ -26,6 +26,8 @@ import (
2626 "time"
2727
2828 "github.com/stretchr/testify/assert"
29+
30+ "github.com/elastic/beats/v7/libbeat/common"
2931)
3032
3133const allXML = `
@@ -79,9 +81,10 @@ const allXML = `
7981func TestXML (t * testing.T ) {
8082 allXMLTimeCreated , _ := time .Parse (time .RFC3339Nano , "2016-01-28T20:33:27.990735300Z" )
8183
82- var tests = []struct {
83- xml string
84- event Event
84+ tests := []struct {
85+ xml string
86+ event Event
87+ mapstr common.MapStr
8588 }{
8689 {
8790 xml : allXML ,
@@ -150,6 +153,14 @@ func TestXML(t *testing.T) {
150153 },
151154 },
152155 },
156+ mapstr : common.MapStr {
157+ "event_id" : "0" ,
158+ "time_created" : time.Time {},
159+ "user_data" : common.MapStr {
160+ "Id" : "{00000000-0000-0000-0000-000000000000}" ,
161+ "xml_name" : "Operation_ClientFailure" ,
162+ },
163+ },
153164 },
154165 }
155166
@@ -160,6 +171,9 @@ func TestXML(t *testing.T) {
160171 continue
161172 }
162173 assert .Equal (t , test .event , event )
174+ if test .mapstr != nil {
175+ assert .Equal (t , test .mapstr , event .Fields ())
176+ }
163177
164178 if testing .Verbose () {
165179 json , err := json .MarshalIndent (event , "" , " " )
@@ -174,7 +188,7 @@ func TestXML(t *testing.T) {
174188// Tests that control characters other than CR and LF are escaped
175189// when the event is decoded.
176190func TestInvalidXML (t * testing.T ) {
177- evXML := strings .Replace (allXML , "%1" , "\t 
\n \x1b " , - 1 )
191+ evXML := strings .ReplaceAll (allXML , "%1" , "\t 
\n \x1b " )
178192 ev , err := UnmarshalXML ([]byte (evXML ))
179193 assert .Equal (t , nil , err )
180194 assert .Equal (t , "Creating WSMan shell on server with ResourceUri: \t \r \n \\ u001b" , ev .Message )
0 commit comments