eventmanager: fix params copy

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino 2023-08-12 19:03:47 +02:00
parent f03fdd1155
commit 6395fa0b67
No known key found for this signature in database
GPG key ID: 935D2952DEC4EECF
2 changed files with 11 additions and 0 deletions

View file

@ -584,6 +584,13 @@ func (p *EventParams) getACopy() *EventParams {
}
params.IDPCustomFields = &fields
}
if len(params.Metadata) > 0 {
metadata := make(map[string]string)
for k, v := range p.Metadata {
metadata[k] = v
}
params.Metadata = metadata
}
return &params
}

View file

@ -2056,6 +2056,10 @@ func TestEventParamsCopy(t *testing.T) {
assert.Equal(t, params.IDPCustomFields, paramsCopy.IDPCustomFields)
(*paramsCopy.IDPCustomFields)["field1"] = "val2"
assert.NotEqual(t, params.IDPCustomFields, paramsCopy.IDPCustomFields)
params.Metadata = map[string]string{"key": "value"}
paramsCopy = params.getACopy()
params.Metadata["key1"] = "value1"
require.Equal(t, map[string]string{"key": "value"}, paramsCopy.Metadata)
}
func TestEventParamsStatusFromError(t *testing.T) {