Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing unused code in integration tests #3134

Merged
merged 1 commit into from
Jan 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions v2/cmd/integration-test/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,78 +16,53 @@ type dnsBasic struct{}

// Execute executes a test case and returns an error if occurred
func (h *dnsBasic) Execute(filePath string) error {
var routerErr error

results, err := testutils.RunNucleiTemplateAndGetResults(filePath, "one.one.one.one", debug)
if err != nil {
return err
}
if routerErr != nil {
return routerErr
}
return expectResultsCount(results, 1)
}

type dnsPtr struct{}

// Execute executes a test case and returns an error if occurred
func (h *dnsPtr) Execute(filePath string) error {
var routerErr error

results, err := testutils.RunNucleiTemplateAndGetResults(filePath, "1.1.1.1", debug)
if err != nil {
return err
}
if routerErr != nil {
return routerErr
}
return expectResultsCount(results, 1)
}

type dnsCAA struct{}

// Execute executes a test case and returns an error if occurred
func (h *dnsCAA) Execute(filePath string) error {
var routerErr error

results, err := testutils.RunNucleiTemplateAndGetResults(filePath, "google.com", debug)
if err != nil {
return err
}
if routerErr != nil {
return routerErr
}
return expectResultsCount(results, 1)
}

type dnsTLSA struct{}

// Execute executes a test case and returns an error if occurred
func (h *dnsTLSA) Execute(filePath string) error {
var routerErr error

results, err := testutils.RunNucleiTemplateAndGetResults(filePath, "scanme.sh", debug)
if err != nil {
return err
}
if routerErr != nil {
return routerErr
}
return expectResultsCount(results, 0)
}

type dnsVariables struct{}

// Execute executes a test case and returns an error if occurred
func (h *dnsVariables) Execute(filePath string) error {
var routerErr error

results, err := testutils.RunNucleiTemplateAndGetResults(filePath, "one.one.one.one", debug)
if err != nil {
return err
}
if routerErr != nil {
return routerErr
}
return expectResultsCount(results, 1)
}
24 changes: 3 additions & 21 deletions v2/cmd/integration-test/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,6 @@ type httpRawGetQuery struct{}
// Execute executes a test case and returns an error if occurred
func (h *httpRawGetQuery) Execute(filePath string) error {
router := httprouter.New()
var routerErr error

router.GET("/", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
if strings.EqualFold(r.URL.Query().Get("test"), "nuclei") {
fmt.Fprintf(w, "Test is test raw-get-query-matcher text")
Expand All @@ -474,9 +472,6 @@ func (h *httpRawGetQuery) Execute(filePath string) error {
if err != nil {
return err
}
if routerErr != nil {
return routerErr
}

return expectResultsCount(results, 1)
}
Expand All @@ -486,8 +481,6 @@ type httpRawGet struct{}
// Execute executes a test case and returns an error if occurred
func (h *httpRawGet) Execute(filePath string) error {
router := httprouter.New()
var routerErr error

router.GET("/", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
fmt.Fprintf(w, "Test is test raw-get-matcher text")
})
Expand All @@ -498,9 +491,6 @@ func (h *httpRawGet) Execute(filePath string) error {
if err != nil {
return err
}
if routerErr != nil {
return routerErr
}

return expectResultsCount(results, 1)
}
Expand Down Expand Up @@ -613,6 +603,7 @@ func (h *httpRawCookieReuse) Execute(filePath string) error {
return expectResultsCount(results, 1)
}

// TODO: excluded due to parsing errors with console
// type httpRawUnsafeRequest struct{
// Execute executes a test case and returns an error if occurred
// func (h *httpRawUnsafeRequest) Execute(filePath string) error {
Expand Down Expand Up @@ -640,13 +631,12 @@ type httpRequestCondition struct{}
// Execute executes a test case and returns an error if occurred
func (h *httpRequestCondition) Execute(filePath string) error {
router := httprouter.New()
var routerErr error

router.GET("/200", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
w.WriteHeader(200)
w.WriteHeader(http.StatusOK)
})
router.GET("/400", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
w.WriteHeader(400)
w.WriteHeader(http.StatusBadRequest)
})
ts := httptest.NewServer(router)
defer ts.Close()
Expand All @@ -655,9 +645,6 @@ func (h *httpRequestCondition) Execute(filePath string) error {
if err != nil {
return err
}
if routerErr != nil {
return routerErr
}

return expectResultsCount(results, 1)
}
Expand All @@ -667,8 +654,6 @@ type httpRequestSelContained struct{}
// Execute executes a test case and returns an error if occurred
func (h *httpRequestSelContained) Execute(filePath string) error {
router := httprouter.New()
var routerErr error

router.GET("/", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
_, _ = w.Write([]byte("This is self-contained response"))
})
Expand All @@ -685,9 +670,6 @@ func (h *httpRequestSelContained) Execute(filePath string) error {
if err != nil {
return err
}
if routerErr != nil {
return routerErr
}

return expectResultsCount(results, 1)
}
Expand Down
5 changes: 0 additions & 5 deletions v2/cmd/integration-test/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ type networkRequestSelContained struct{}

// Execute executes a test case and returns an error if occurred
func (h *networkRequestSelContained) Execute(filePath string) error {
var routerErr error

ts := testutils.NewTCPServer(nil, defaultStaticPort, func(conn net.Conn) {
defer conn.Close()

Expand All @@ -111,9 +109,6 @@ func (h *networkRequestSelContained) Execute(filePath string) error {
if err != nil {
return err
}
if routerErr != nil {
return routerErr
}

return expectResultsCount(results, 1)
}
Expand Down
6 changes: 1 addition & 5 deletions v2/cmd/integration-test/template-dir.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,10 @@ type templateDirWithTargetTest struct{}
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)
}