mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-22 02:55:26 +00:00
35 lines
1.2 KiB
Go
35 lines
1.2 KiB
Go
package runner
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/projectdiscovery/gologger"
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/catalog/config"
|
|
"github.com/projectdiscovery/nuclei/v2/pkg/testutils"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestDownloadCustomTemplates(t *testing.T) {
|
|
gologger.DefaultLogger.SetWriter(&testutils.NoopWriter{})
|
|
|
|
templatesDirectory, err := os.MkdirTemp("", "template-custom-*")
|
|
require.Nil(t, err, "could not create temp directory")
|
|
defer os.RemoveAll(templatesDirectory)
|
|
|
|
options := testutils.DefaultOptions
|
|
options.GithubTemplateRepo = []string{"projectdiscovery/nuclei-templates", "ehsandeep/nuclei-templates"}
|
|
r := &Runner{templatesConfig: &config.Config{TemplatesDirectory: templatesDirectory}, options: options}
|
|
|
|
r.customTemplates = r.parseCustomTemplates()
|
|
|
|
for _, ct := range r.customTemplates {
|
|
ct.Download(r.templatesConfig.TemplatesDirectory, context.Background())
|
|
}
|
|
|
|
require.DirExists(t, filepath.Join(templatesDirectory, "github", "nuclei-templates"), "cloned directory does not exists")
|
|
require.DirExists(t, filepath.Join(templatesDirectory, "github", "nuclei-templates-ehsandeep"), "cloned directory does not exists")
|
|
}
|