nuclei/v2/pkg/operators/matchers/validate_test.go
Mzack9999 3838d06aeb
Adding prototype for unexpected fields validation in matchers (#2171)
* Adding unexpected fields validation

* using expected fields

* adding missing expected field

* using reflect
2022-06-30 16:50:54 +05:30

19 lines
408 B
Go

package matchers
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestValidate(t *testing.T) {
m := &Matcher{matcherType: DSLMatcher, DSL: []string{"anything"}}
err := m.Validate()
require.Nil(t, err, "Could not validate correct template")
m = &Matcher{matcherType: DSLMatcher, Part: "test"}
err = m.Validate()
require.NotNil(t, err, "Invalid template was correctly validated")
}