nuclei/v2/pkg/protocols/common/expressions/variables_test.go
Mzack9999 a4cdba0691
Improving literals detection in expression engine (#2148)
* Improving literals detection in expression engine

* fixing lint errors

* re-add accidentally deleted test
2022-06-13 13:55:06 +05:30

28 lines
655 B
Go

package expressions
import (
"errors"
"testing"
"github.com/stretchr/testify/require"
)
func TestUnresolvedVariablesCheck(t *testing.T) {
tests := []struct {
data string
err error
}{
{"{{test}}", errors.New("unresolved variables found: test")},
{"{{test}}/{{another}}", errors.New("unresolved variables found: test,another")},
{"test", nil},
{"%7b%7btest%7d%7d", errors.New("unresolved variables found: test")},
{"{{7*7}}", nil},
{"{{'a'+'b'}}", nil},
{"{{'a'}}", nil},
}
for _, test := range tests {
err := ContainsUnresolvedVariables(test.data)
require.Equal(t, test.err, err, "could not get unresolved variables")
}
}