Path: blob/dev/cmd/integration-test/profile-loader.go
2070 views
package main12import (3"fmt"45"github.com/projectdiscovery/nuclei/v3/pkg/testutils"6"github.com/projectdiscovery/utils/errkit"7)89var profileLoaderTestcases = []TestCaseInfo{10{Path: "profile-loader/load-with-filename", TestCase: &profileLoaderByRelFile{}},11{Path: "profile-loader/load-with-id", TestCase: &profileLoaderById{}},12{Path: "profile-loader/basic.yml", TestCase: &customProfileLoader{}},13}1415type profileLoaderByRelFile struct{}1617func (h *profileLoaderByRelFile) Execute(testName string) error {18results, err := testutils.RunNucleiWithArgsAndGetResults(debug, "-tl", "-tp", "cloud.yml")19if err != nil {20return errkit.Wrap(err, "failed to load template with id")21}22if len(results) <= 10 {23return fmt.Errorf("incorrect result: expected more results than %d, got %v", 10, len(results))24}25return nil26}2728type profileLoaderById struct{}2930func (h *profileLoaderById) Execute(testName string) error {31results, err := testutils.RunNucleiWithArgsAndGetResults(debug, "-tl", "-tp", "cloud")32if err != nil {33return errkit.Wrap(err, "failed to load template with id")34}35if len(results) <= 10 {36return fmt.Errorf("incorrect result: expected more results than %d, got %v", 10, len(results))37}38return nil39}4041// this profile with load kevs42type customProfileLoader struct{}4344func (h *customProfileLoader) Execute(filepath string) error {45results, err := testutils.RunNucleiWithArgsAndGetResults(debug, "-tl", "-tp", filepath)46if err != nil {47return errkit.Wrap(err, "failed to load template with id")48}49if len(results) < 1 {50return fmt.Errorf("incorrect result: expected more results than %d, got %v", 1, len(results))51}52return nil53}545556