mirror of https://github.com/daffainfo/nuclei.git
41 lines
1.3 KiB
Go
41 lines
1.3 KiB
Go
package loader
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestLoadTemplates(t *testing.T) {
|
|
store, err := New(&Config{
|
|
Templates: []string{"cves/CVE-2021-21315.yaml"},
|
|
})
|
|
require.Nil(t, err, "could not load templates")
|
|
require.Equal(t, []string{"cves/CVE-2021-21315.yaml"}, store.finalTemplates, "could not get correct templates")
|
|
|
|
templatesDirectory := "/test"
|
|
t.Run("blank", func(t *testing.T) {
|
|
store, err := New(&Config{
|
|
TemplatesDirectory: templatesDirectory,
|
|
})
|
|
require.Nil(t, err, "could not load templates")
|
|
require.Equal(t, []string{templatesDirectory}, store.finalTemplates, "could not get correct templates")
|
|
})
|
|
t.Run("only-tags", func(t *testing.T) {
|
|
store, err := New(&Config{
|
|
Tags: []string{"cves"},
|
|
TemplatesDirectory: templatesDirectory,
|
|
})
|
|
require.Nil(t, err, "could not load templates")
|
|
require.Equal(t, []string{templatesDirectory}, store.finalTemplates, "could not get correct templates")
|
|
})
|
|
t.Run("tags-with-path", func(t *testing.T) {
|
|
store, err := New(&Config{
|
|
Tags: []string{"cves"},
|
|
TemplatesDirectory: templatesDirectory,
|
|
})
|
|
require.Nil(t, err, "could not load templates")
|
|
require.Equal(t, []string{templatesDirectory}, store.finalTemplates, "could not get correct templates")
|
|
})
|
|
}
|