Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
projectdiscovery
GitHub Repository: projectdiscovery/nuclei
Path: blob/dev/pkg/protocols/common/expressions/variables_test.go
2072 views
1
package expressions
2
3
import (
4
"errors"
5
"testing"
6
7
"github.com/stretchr/testify/require"
8
)
9
10
func TestUnresolvedVariablesCheck(t *testing.T) {
11
tests := []struct {
12
data string
13
err error
14
}{
15
{"{{test}}", errors.New("unresolved variables found: test")},
16
{"{{test}}/{{another}}", errors.New("unresolved variables found: test,another")},
17
{"test", nil},
18
{"%7b%7btest%7d%7d", errors.New("unresolved variables found: test")},
19
{"%7B%7Bfirst%2Asecond%7D%7D", errors.New("unresolved variables found: first%2Asecond")},
20
{"{{7*7}}", nil},
21
{"{{'a'+'b'}}", nil},
22
{"{{'a'}}", nil},
23
}
24
for _, test := range tests {
25
err := ContainsUnresolvedVariables(test.data)
26
require.Equal(t, test.err, err, "could not get unresolved variables")
27
}
28
}
29
30