mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-17 21:35:26 +00:00
* use parsed options while signing * update project layout to v3 * fix .gitignore * remove example template * misc updates * bump tlsx version * hide template sig warning with env * js: retain value while using log * fix nil pointer derefernce * misc doc update --------- Co-authored-by: sandeep <8293321+ehsandeep@users.noreply.github.com>
32 lines
894 B
Go
32 lines
894 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")
|
|
|
|
m = &Matcher{matcherType: XPathMatcher, XPath: []string{"//q[@id=\"foo\"]"}}
|
|
|
|
err = m.Validate()
|
|
require.Nil(t, err, "Could not validate correct XPath template")
|
|
|
|
m = &Matcher{matcherType: XPathMatcher, Status: []int{123}}
|
|
err = m.Validate()
|
|
require.NotNil(t, err, "Invalid XPath template was correctly validated")
|
|
|
|
m = &Matcher{matcherType: XPathMatcher, XPath: []string{"//a[@a==1]"}}
|
|
err = m.Validate()
|
|
require.NotNil(t, err, "Invalid XPath query was correctly validated")
|
|
}
|