mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-18 00:05:27 +00:00
29 lines
1.1 KiB
Go
29 lines
1.1 KiB
Go
package expressions
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestEvaluate(t *testing.T) {
|
|
items := []struct {
|
|
input string
|
|
expected string
|
|
extra map[string]interface{}
|
|
}{
|
|
{input: "{{hex_encode('PING')}}", expected: "50494e47", extra: map[string]interface{}{}},
|
|
{input: "test", expected: "test", extra: map[string]interface{}{}},
|
|
{input: "{{hex_encode(Item)}}", expected: "50494e47", extra: map[string]interface{}{"Item": "PING"}},
|
|
{input: "{{hex_encode(Item)}}\r\n", expected: "50494e47\r\n", extra: map[string]interface{}{"Item": "PING"}},
|
|
{input: "{{someTestData}}{{hex_encode('PING')}}", expected: "{{someTestData}}50494e47", extra: map[string]interface{}{}},
|
|
{input: `_IWP_JSON_PREFIX_{{base64("{\"iwp_action\":\"add_site\",\"params\":{\"username\":\"\"}}")}}`, expected: "_IWP_JSON_PREFIX_eyJpd3BfYWN0aW9uIjoiYWRkX3NpdGUiLCJwYXJhbXMiOnsidXNlcm5hbWUiOiIifX0=", extra: map[string]interface{}{}},
|
|
}
|
|
for _, item := range items {
|
|
value, err := Evaluate(item.input, item.extra)
|
|
require.Nil(t, err, "could not evaluate helper")
|
|
|
|
require.Equal(t, item.expected, value, "could not get correct expression")
|
|
}
|
|
}
|