Path: blob/dev/cmd/integration-test/offline-http.go
2070 views
package main12import (3"fmt"45"github.com/projectdiscovery/nuclei/v3/pkg/testutils"6)78var offlineHttpTestcases = []TestCaseInfo{9{Path: "protocols/offlinehttp/rfc-req-resp.yaml", TestCase: &RfcRequestResponse{}},10{Path: "protocols/offlinehttp/offline-allowed-paths.yaml", TestCase: &RequestResponseWithAllowedPaths{}},11{Path: "protocols/offlinehttp/offline-raw.yaml", TestCase: &RawRequestResponse{}},12}1314type RfcRequestResponse struct{}1516// Execute executes a test case and returns an error if occurred17func (h *RfcRequestResponse) Execute(filePath string) error {18results, err := testutils.RunNucleiTemplateAndGetResults(filePath, "protocols/offlinehttp/data/", debug, "-passive")19if err != nil {20return err21}2223return expectResultsCount(results, 1)24}2526type RequestResponseWithAllowedPaths struct{}2728// Execute executes a test case and returns an error if occurred29func (h *RequestResponseWithAllowedPaths) Execute(filePath string) error {30results, err := testutils.RunNucleiTemplateAndGetResults(filePath, "protocols/offlinehttp/data/", debug, "-passive")31if err != nil {32return err33}3435return expectResultsCount(results, 1)36}3738type RawRequestResponse struct{}3940// Execute executes a test case and returns an error if occurred41func (h *RawRequestResponse) Execute(filePath string) error {42_, err := testutils.RunNucleiTemplateAndGetResults(filePath, "protocols/offlinehttp/data/", debug, "-passive")43if err == nil {44return fmt.Errorf("incorrect result: no error (actual) vs error expected")45}46return nil47}484950