2021-02-04 01:09:29 +05:30
|
|
|
package templates
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/types"
|
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestMatchTemplateWithTags(t *testing.T) {
|
2021-02-04 14:58:34 +05:30
|
|
|
err := matchTemplateWithTags("php,linux,symfony", &types.Options{Tags: []string{"php"}})
|
2021-02-04 01:09:29 +05:30
|
|
|
require.Nil(t, err, "could not get php tag from input slice")
|
|
|
|
|
|
2021-02-04 14:58:34 +05:30
|
|
|
err = matchTemplateWithTags("lang:php,os:linux,cms:symfony", &types.Options{Tags: []string{"cms:symfony"}})
|
2021-02-04 01:09:29 +05:30
|
|
|
require.Nil(t, err, "could not get php tag from input key value")
|
|
|
|
|
|
2021-02-04 14:58:34 +05:30
|
|
|
err = matchTemplateWithTags("lang:php,os:linux,symfony", &types.Options{Tags: []string{"cms:symfony"}})
|
|
|
|
|
require.NotNil(t, err, "could get key value tag from input key value")
|
2021-02-04 01:09:29 +05:30
|
|
|
|
2021-02-04 14:58:34 +05:30
|
|
|
err = matchTemplateWithTags("lang:php,os:linux,cms:jira", &types.Options{Tags: []string{"cms:symfony"}})
|
2021-02-04 01:09:29 +05:30
|
|
|
require.NotNil(t, err, "could get key value tag from input key value")
|
2021-02-04 14:58:34 +05:30
|
|
|
|
|
|
|
|
t.Run("space", func(t *testing.T) {
|
|
|
|
|
err = matchTemplateWithTags("lang:php, os:linux, cms:symfony", &types.Options{Tags: []string{"cms:symfony"}})
|
|
|
|
|
require.Nil(t, err, "could get key value tag from input key value with space")
|
|
|
|
|
})
|
2021-02-04 01:09:29 +05:30
|
|
|
}
|