From 463f4dd8c83d75b9f3659a0d24ab805aa557db18 Mon Sep 17 00:00:00 2001 From: Mzack9999 Date: Tue, 3 Jan 2023 08:24:33 +0100 Subject: [PATCH] removing unused code in integration tests --- v2/cmd/integration-test/dns.go | 25 ------------------------- v2/cmd/integration-test/http.go | 24 +++--------------------- v2/cmd/integration-test/network.go | 5 ----- v2/cmd/integration-test/template-dir.go | 6 +----- 4 files changed, 4 insertions(+), 56 deletions(-) diff --git a/v2/cmd/integration-test/dns.go b/v2/cmd/integration-test/dns.go index 1a5d2423..0353884e 100644 --- a/v2/cmd/integration-test/dns.go +++ b/v2/cmd/integration-test/dns.go @@ -16,15 +16,10 @@ 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) } @@ -32,15 +27,10 @@ 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) } @@ -48,15 +38,10 @@ 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) } @@ -64,15 +49,10 @@ 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) } @@ -80,14 +60,9 @@ 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) } diff --git a/v2/cmd/integration-test/http.go b/v2/cmd/integration-test/http.go index 23771095..d4fc3a46 100644 --- a/v2/cmd/integration-test/http.go +++ b/v2/cmd/integration-test/http.go @@ -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") @@ -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) } @@ -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") }) @@ -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) } @@ -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 { @@ -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() @@ -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) } @@ -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")) }) @@ -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) } diff --git a/v2/cmd/integration-test/network.go b/v2/cmd/integration-test/network.go index 936c82c9..37ce8c39 100644 --- a/v2/cmd/integration-test/network.go +++ b/v2/cmd/integration-test/network.go @@ -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() @@ -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) } diff --git a/v2/cmd/integration-test/template-dir.go b/v2/cmd/integration-test/template-dir.go index 2b897960..025fbb29 100644 --- a/v2/cmd/integration-test/template-dir.go +++ b/v2/cmd/integration-test/template-dir.go @@ -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) }