Skip to content

Commit

Permalink
Tests for the options
Browse files Browse the repository at this point in the history
  • Loading branch information
coreyogburn committed May 31, 2024
1 parent e41f8e5 commit ab1fa7d
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions model/detection_options_test.go
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"`)
}

0 comments on commit ab1fa7d

Please sign in to comment.