mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-18 03:45:27 +00:00
* utils update * use test tempdir * skip custom tm tests on macos --------- Co-authored-by: Tarun Koyalwar <tarun@projectdiscovery.io>
34 lines
1.0 KiB
Go
34 lines
1.0 KiB
Go
package customtemplates
|
|
|
|
import (
|
|
"context"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/projectdiscovery/gologger"
|
|
"github.com/projectdiscovery/nuclei/v3/pkg/catalog/config"
|
|
"github.com/projectdiscovery/nuclei/v3/pkg/testutils"
|
|
osutils "github.com/projectdiscovery/utils/os"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestDownloadCustomTemplatesFromGitHub(t *testing.T) {
|
|
if osutils.IsOSX() {
|
|
t.Skip("skipping on macos due to unknown failure (works locally)")
|
|
}
|
|
|
|
gologger.DefaultLogger.SetWriter(&testutils.NoopWriter{})
|
|
|
|
templatesDirectory := t.TempDir()
|
|
config.DefaultConfig.SetTemplatesDir(templatesDirectory)
|
|
|
|
options := testutils.DefaultOptions
|
|
options.GitHubTemplateRepo = []string{"projectdiscovery/nuclei-templates-test"}
|
|
|
|
ctm, err := NewCustomTemplatesManager(options)
|
|
require.Nil(t, err, "could not create custom templates manager")
|
|
|
|
ctm.Download(context.Background())
|
|
require.DirExists(t, filepath.Join(templatesDirectory, "github", "projectdiscovery", "nuclei-templates-test"), "cloned directory does not exists")
|
|
}
|