forked from elastic/beats
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[filebeat] Add preserve_original_event option to o365audit input (ela…
…stic#26273) (elastic#26288) * Add preserve_original_event option to o365audit input * Use String method from MapStr * Add test (cherry picked from commit 08eaadb) Co-authored-by: Marc Guasch <marc-gr@users.noreply.github.com>
- Loading branch information
1 parent
3961465
commit 4564e02
Showing
5 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
// or more contributor license agreements. Licensed under the Elastic License; | ||
// you may not use this file except in compliance with the Elastic License. | ||
|
||
package o365audit | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/elastic/beats/v7/libbeat/common" | ||
) | ||
|
||
func TestPreserveOriginalEvent(t *testing.T) { | ||
env := apiEnvironment{ | ||
Config: APIConfig{PreserveOriginalEvent: false}, | ||
} | ||
|
||
doc := common.MapStr{ | ||
"field1": "val1", | ||
} | ||
|
||
event := env.toBeatEvent(doc) | ||
|
||
v, err := event.GetValue("event.original") | ||
require.EqualError(t, err, "key not found") | ||
assert.Nil(t, v) | ||
|
||
env.Config.PreserveOriginalEvent = true | ||
|
||
event = env.toBeatEvent(doc) | ||
|
||
v, err = event.GetValue("event.original") | ||
require.NoError(t, err) | ||
assert.JSONEq(t, `{"field1":"val1"}`, v.(string)) | ||
} |