-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e41f8e5
commit ab1fa7d
Showing
1 changed file
with
45 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package model | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestWithEngine(t *testing.T) { | ||
queryModder := WithEngine(EngineNameElastAlert) | ||
query := queryModder("query", "schemaPrefix") | ||
assert.Equal(t, query, `query AND schemaPrefixdetection.engine:"elastalert"`) | ||
|
||
queryModder = WithEngine(EngineNameStrelka) | ||
query = queryModder("query", "schemaPrefix") | ||
assert.Equal(t, query, `query AND schemaPrefixdetection.engine:"strelka"`) | ||
|
||
queryModder = WithEngine(EngineNameSuricata) | ||
query = queryModder("query", "schemaPrefix") | ||
assert.Equal(t, query, `query AND schemaPrefixdetection.engine:"suricata"`) | ||
|
||
queryModder = WithEngine(EngineName("unknown")) | ||
query = queryModder("query", "schemaPrefix") | ||
assert.Equal(t, query, `query AND schemaPrefixdetection.engine:"unknown"`) | ||
} | ||
|
||
func TestWithEnabled(t *testing.T) { | ||
queryModder := WithEnabled(true) | ||
query := queryModder("query", "schemaPrefix") | ||
assert.Equal(t, query, `query AND schemaPrefixdetection.isEnabled:"true"`) | ||
|
||
queryModder = WithEnabled(false) | ||
query = queryModder("query", "schemaPrefix") | ||
assert.Equal(t, query, `query AND schemaPrefixdetection.isEnabled:"false"`) | ||
} | ||
|
||
func TestWithCommunity(t *testing.T) { | ||
queryModder := WithCommunity(true) | ||
query := queryModder("query", "schemaPrefix") | ||
assert.Equal(t, query, `query AND schemaPrefixdetection.isCommunity:"true"`) | ||
|
||
queryModder = WithCommunity(false) | ||
query = queryModder("query", "schemaPrefix") | ||
assert.Equal(t, query, `query AND schemaPrefixdetection.isCommunity:"false"`) | ||
} |