Merge pull request #1742 from projectdiscovery/1706-test-for-template-install/update

integration test for template update/install
dev
Sandeep Singh 2022-03-22 15:51:38 +05:30 committed by GitHub
commit 49f70377fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 0 deletions

View File

@ -29,6 +29,7 @@ var (
"whois": whoisTestCases,
"ssl": sslTestcases,
"templatesPath": templatesPathTestCases,
"templatesDir": templatesDirTestCases,
}
)

View File

@ -0,0 +1,34 @@
package main
import (
"os"
"github.com/projectdiscovery/nuclei/v2/pkg/testutils"
)
func getTemplatesDir() string {
temp := os.TempDir()
return temp
}
var templatesDirTestCases = map[string]testutils.TestCase{
"dns/cname-fingerprint.yaml": &templateDirWithTargetTest{},
}
type templateDirWithTargetTest struct{}
// Execute executes a test case and returns an error if occurred
func (h *templateDirWithTargetTest) Execute(filePath string) error {
defer os.RemoveAll(getTemplatesDir())
var routerErr error
results, err := testutils.RunNucleiTemplateAndGetResults(filePath, "8x8exch02.8x8.com", debug, "-ud", getTemplatesDir())
if err != nil {
return err
}
if routerErr != nil {
return routerErr
}
return expectResultsCount(results, 1)
}