Dogan Can Bakir 1d0fbc0b62
restructure repo dir (#4293)
* restructure repo dir

* fix path in test
2023-10-30 21:00:51 +05:30

36 lines
1.2 KiB
Go

package customtemplates
import (
"context"
"os"
"path/filepath"
"testing"
"github.com/projectdiscovery/gologger"
"github.com/projectdiscovery/nuclei/v3/pkg/catalog/config"
"github.com/projectdiscovery/nuclei/v3/pkg/testutils"
"github.com/stretchr/testify/require"
)
func TestDownloadCustomTemplatesFromGitHub(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)
config.DefaultConfig.SetTemplatesDir(templatesDirectory)
options := testutils.DefaultOptions
options.GitHubTemplateRepo = []string{"projectdiscovery/nuclei-templates", "ehsandeep/nuclei-templates"}
options.GitHubToken = os.Getenv("GITHUB_TOKEN")
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"), "cloned directory does not exists")
require.DirExists(t, filepath.Join(templatesDirectory, "github", "ehsandeep", "nuclei-templates"), "cloned directory does not exists")
}