nuclei/v2/pkg/operators/matchers/match_test.go

31 lines
770 B
Go
Raw Normal View History

2020-04-04 00:32:03 +05:30
package matchers
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestANDCondition(t *testing.T) {
m := &Matcher{condition: ANDCondition, Words: []string{"a", "b"}}
2020-12-24 20:47:41 +05:30
matched := m.MatchWords("a b")
2020-04-04 00:32:03 +05:30
require.True(t, matched, "Could not match valid AND condition")
2020-12-24 20:47:41 +05:30
matched = m.MatchWords("b")
2020-04-04 00:32:03 +05:30
require.False(t, matched, "Could match invalid AND condition")
}
func TestORCondition(t *testing.T) {
m := &Matcher{condition: ORCondition, Words: []string{"a", "b"}}
2020-12-24 20:47:41 +05:30
matched := m.MatchWords("a b")
2020-04-04 00:32:03 +05:30
require.True(t, matched, "Could not match valid OR condition")
2020-12-24 20:47:41 +05:30
matched = m.MatchWords("b")
2020-04-04 00:32:03 +05:30
require.True(t, matched, "Could not match valid OR condition")
2020-12-24 20:47:41 +05:30
matched = m.MatchWords("c")
2020-04-04 00:32:03 +05:30
require.False(t, matched, "Could match invalid OR condition")
}