diff --git a/runner/run.go b/runner/run.go index 1d266607..68914f0b 100644 --- a/runner/run.go +++ b/runner/run.go @@ -360,7 +360,7 @@ func getRequestFromTest(testInput test.Input) *ftwhttp.Request { // If we use raw or encoded request, then we don't use other fields if raw != nil { - req = ftwhttp.NewRawRequest(raw, !*testInput.NoAutocompleteHeaders) + req = ftwhttp.NewRawRequest(raw, !*testInput.AutocompleteHeaders) } else { rline := &ftwhttp.RequestLine{ Method: testInput.GetMethod(), @@ -371,7 +371,7 @@ func getRequestFromTest(testInput test.Input) *ftwhttp.Request { data := testInput.ParseData() // create a new request req = ftwhttp.NewRequest(rline, testInput.Headers, - data, !*testInput.NoAutocompleteHeaders) + data, !*testInput.AutocompleteHeaders) } return req diff --git a/runner/run_input_override_test.go b/runner/run_input_override_test.go index 12238386..d3a856c0 100644 --- a/runner/run_input_override_test.go +++ b/runner/run_input_override_test.go @@ -28,7 +28,7 @@ var configTemplate = ` testoverride: input: {{ with .StopMagic }}stop_magic: {{ . }}{{ end }} - {{ with .NoAutocompleteHeaders }}no_autocomplete_headers: {{ . }}{{ end }} + {{ with .AutocompleteHeaders }}no_autocomplete_headers: {{ . }}{{ end }} {{ with .BrokenConfig }}this_does_not_exist: "test"{{ end }} {{ with .Port }}port: {{ . }}{{ end }} {{ with .DestAddr }}dest_addr: {{ . }}{{ end }} @@ -95,8 +95,8 @@ var overrideConfigMap = map[string]interface{}{ "TestApplyInputOverrideStopMagic": map[string]interface{}{ "StopMagic": "true", }, - "TestApplyInputOverrideNoAutocompleteHeaders": map[string]interface{}{ - "NoAutocompleteHeaders": "true", + "TestApplyInputOverrideAutocompleteHeaders": map[string]interface{}{ + "AutocompleteHeaders": "true", }, } @@ -301,18 +301,18 @@ func (s *inputOverrideTestSuite) TestApplyInputOverrideStopMagic() { s.Equal(overrideStopMagic, *testInput.StopMagic, "`StopMagic` should have been overridden") } -func (s *inputOverrideTestSuite) TestApplyInputOverrideNoAutocompleteHeaders() { - noAutocompleteHeadersBool, err := getOverrideConfigValue("NoAutocompleteHeaders") +func (s *inputOverrideTestSuite) TestApplyInputOverrideAutocompleteHeaders() { + autocompleteHeadersBool, err := getOverrideConfigValue("AutocompleteHeaders") s.NoError(err, "cannot get override value") - overrideNoAutocompleteHeaders, err := strconv.ParseBool(noAutocompleteHeadersBool) - s.NoError(err, "Failed to parse `NoAutocompleteHeaders` override value") + overrideAutocompleteHeaders, err := strconv.ParseBool(autocompleteHeadersBool) + s.NoError(err, "Failed to parse `AutocompleteHeaders` override value") testInput := test.Input{ - NoAutocompleteHeaders: func() *bool { b := false; return &b }(), + AutocompleteHeaders: func() *bool { b := false; return &b }(), } test.ApplyInputOverrides(&s.cfg.TestOverride.Overrides, &testInput) s.NoError(err, "Failed to apply input overrides") // nolint - s.Equal(overrideNoAutocompleteHeaders, *testInput.NoAutocompleteHeaders, "`NoAutocompleteHeaders` should have been overridden") + s.Equal(overrideAutocompleteHeaders, *testInput.AutocompleteHeaders, "`AutocompleteHeaders` should have been overridden") } func (s *inputOverrideTestSuite) TestApplyInputOverrideEncodedRequest() { diff --git a/test/data_test.go b/test/data_test.go index 45e1699d..0fa76eaa 100644 --- a/test/data_test.go +++ b/test/data_test.go @@ -35,7 +35,7 @@ uri: "/" input := Input{} err := yaml.Unmarshal([]byte(yamlString), &input) s.NoError(err) - s.True(*input.NoAutocompleteHeaders) + s.True(*input.AutocompleteHeaders) } func (s *dataTestSuite) TestGetPartialDataFromYAML() { @@ -57,7 +57,7 @@ uri: "/" err := yaml.Unmarshal([]byte(yamlString), &input) s.NoError(err) s.Empty(*input.Version) - s.False(*input.NoAutocompleteHeaders) + s.False(*input.AutocompleteHeaders) } func (s *dataTestSuite) TestDataTemplateFromYAML() { @@ -83,5 +83,5 @@ uri: "/" data = input.ParseData() s.Equal([]byte(repeatTestSprig), data) - s.True(*input.NoAutocompleteHeaders) + s.True(*input.AutocompleteHeaders) } diff --git a/test/defaults_test.go b/test/defaults_test.go index 583cb135..71c3c401 100644 --- a/test/defaults_test.go +++ b/test/defaults_test.go @@ -21,10 +21,10 @@ func getTestInputDefaults() *Input { data := "My Data" inputDefaults := Input{ - Headers: make(ftwhttp.Header), - Data: &data, - SaveCookie: func() *bool { b := false; return &b }(), - NoAutocompleteHeaders: func() *bool { b := false; return &b }(), + Headers: make(ftwhttp.Header), + Data: &data, + SaveCookie: func() *bool { b := false; return &b }(), + AutocompleteHeaders: func() *bool { b := false; return &b }(), } return &inputDefaults } @@ -38,17 +38,17 @@ func getTestExampleInput() *Input { version := "HTTP/1.1" inputTest := Input{ - DestAddr: &destaddr, - Port: &port, - Protocol: &protocol, - URI: &uri, - Version: &version, - Headers: make(ftwhttp.Header), - Method: &method, - Data: nil, - EncodedRequest: "TXkgRGF0YQo=", - SaveCookie: func() *bool { b := false; return &b }(), - NoAutocompleteHeaders: func() *bool { b := false; return &b }(), + DestAddr: &destaddr, + Port: &port, + Protocol: &protocol, + URI: &uri, + Version: &version, + Headers: make(ftwhttp.Header), + Method: &method, + Data: nil, + EncodedRequest: "TXkgRGF0YQo=", + SaveCookie: func() *bool { b := false; return &b }(), + AutocompleteHeaders: func() *bool { b := false; return &b }(), } return &inputTest @@ -75,8 +75,8 @@ Keep-Alive: 300 Proxy-Connection: keep-alive User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727) `, - SaveCookie: func() *bool { b := false; return &b }(), - NoAutocompleteHeaders: func() *bool { b := true; return &b }(), + SaveCookie: func() *bool { b := false; return &b }(), + AutocompleteHeaders: func() *bool { b := true; return &b }(), } return &inputTest @@ -128,7 +128,7 @@ func (s *defaultsTestSuite) TestDefaultGetters() { func (s *defaultsTestSuite) TestRaw() { raw := getRawInput() - s.True(*raw.NoAutocompleteHeaders) + s.True(*raw.AutocompleteHeaders) request, _ := raw.GetRawRequest() s.NotEqual(2, bytes.Index(request, []byte("Acunetix"))) diff --git a/test/types.go b/test/types.go index 051fe59b..275463ec 100644 --- a/test/types.go +++ b/test/types.go @@ -17,11 +17,11 @@ type Input struct { Method *string `yaml:"method,omitempty"` Data *string `yaml:"data,omitempty"` SaveCookie *bool `yaml:"save_cookie,omitempty"` - // Deprecated: replaced with NoAutocompleteHeaders - StopMagic *bool `yaml:"stop_magic"` - NoAutocompleteHeaders *bool `yaml:"no_autocomplete_headers"` - EncodedRequest string `yaml:"encoded_request,omitempty"` - RAWRequest string `yaml:"raw_request,omitempty"` + // Deprecated: replaced with AutocompleteHeaders + StopMagic *bool `yaml:"stop_magic"` + AutocompleteHeaders *bool `yaml:"no_autocomplete_headers"` + EncodedRequest string `yaml:"encoded_request,omitempty"` + RAWRequest string `yaml:"raw_request,omitempty"` } // Overrides represents the overridden inputs that have to be applied to tests @@ -35,9 +35,9 @@ type Overrides struct { Method *string `yaml:"method,omitempty" koanf:"method,omitempty"` Data *string `yaml:"data,omitempty" koanf:"data,omitempty"` SaveCookie *bool `yaml:"save_cookie,omitempty" koanf:"save_cookie,omitempty"` - // Deprecated: replaced with NoAutocompleteHeaders + // Deprecated: replaced with AutocompleteHeaders StopMagic *bool `yaml:"stop_magic" koanf:"stop_magic,omitempty"` - NoAutocompleteHeaders *bool `yaml:"no_autocomplete_headers" koanf:"no_autocomplete_headers,omitempty"` + AutocompleteHeaders *bool `yaml:"no_autocomplete_headers" koanf:"no_autocomplete_headers,omitempty"` EncodedRequest *string `yaml:"encoded_request,omitempty" koanf:"encoded_request,omitempty"` RAWRequest *string `yaml:"raw_request,omitempty" koanf:"raw_request,omitempty"` OverrideEmptyHostHeader *bool `yaml:"override_empty_host_header,omitempty" koanf:"override_empty_host_header,omitempty"` @@ -84,7 +84,7 @@ func ApplyInputOverrides(overrides *Overrides, input *Input) { applySimpleOverrides(overrides, input) applyDestAddrOverride(overrides, input) applyHeadersOverride(overrides, input) - postProcessNoAutocompleteHeaders(overrides.NoAutocompleteHeaders, overrides.StopMagic, input) + postProcessAutocompleteHeaders(overrides.AutocompleteHeaders, overrides.StopMagic, input) } func applyDestAddrOverride(overrides *Overrides, input *Input) { @@ -165,19 +165,19 @@ func postLoadStage(stage *Stage) { } func postLoadInput(input *Input) { - postProcessNoAutocompleteHeaders(input.NoAutocompleteHeaders, input.StopMagic, input) + postProcessAutocompleteHeaders(input.AutocompleteHeaders, input.StopMagic, input) } -func postProcessNoAutocompleteHeaders(noAutocompleteHeaders *bool, stopMagic *bool, input *Input) { - noAutocompleteHeadersMissing := noAutocompleteHeaders == nil +func postProcessAutocompleteHeaders(autocompleteHeaders *bool, stopMagic *bool, input *Input) { + autocompleteHeadersMissing := autocompleteHeaders == nil stopMagicMissing := stopMagic == nil finalValue := false - if noAutocompleteHeadersMissing && !stopMagicMissing { + if autocompleteHeadersMissing && !stopMagicMissing { finalValue = *stopMagic - } else if !noAutocompleteHeadersMissing { - finalValue = *noAutocompleteHeaders + } else if !autocompleteHeadersMissing { + finalValue = *autocompleteHeaders } - input.NoAutocompleteHeaders = &finalValue + input.AutocompleteHeaders = &finalValue input.StopMagic = &finalValue } diff --git a/test/types_test.go b/test/types_test.go index 0d4d614b..f9af4be6 100644 --- a/test/types_test.go +++ b/test/types_test.go @@ -14,7 +14,7 @@ func TestTypesTestSuite(t *testing.T) { suite.Run(t, new(typesTestSuite)) } -var noAutocompleteHeadersDefaultYaml = `--- +var autocompleteHeadersDefaultYaml = `--- meta: author: "tester" enabled: true @@ -64,7 +64,7 @@ tests: status: [200] ` -var noAutocompleteHeadersFalseYaml = `--- +var autocompleteHeadersFalseYaml = `--- meta: author: "tester" enabled: true @@ -117,7 +117,7 @@ tests: status: [200] ` -var noAutocompleteHeadersTrueYaml = `--- +var autocompleteHeadersTrueYaml = `--- meta: author: "tester" enabled: true @@ -170,82 +170,82 @@ tests: status: [200] ` -func (s *typesTestSuite) TestNoAutocompleteHeadersDefault_StopMagicDefault() { - test, err := GetTestFromYaml([]byte(noAutocompleteHeadersDefaultYaml)) +func (s *typesTestSuite) TestAutocompleteHeadersDefault_StopMagicDefault() { + test, err := GetTestFromYaml([]byte(autocompleteHeadersDefaultYaml)) s.NoError(err, "Parsing YAML shouldn't fail") input := test.Tests[0].Stages[0].Stage.Input - s.False(*input.NoAutocompleteHeaders) + s.False(*input.AutocompleteHeaders) s.False(*input.StopMagic) } -func (s *typesTestSuite) TestNoAutocompleteHeadersDefault_StopMagicTrue() { - test, err := GetTestFromYaml([]byte(noAutocompleteHeadersDefaultYaml)) +func (s *typesTestSuite) TestAutocompleteHeadersDefault_StopMagicTrue() { + test, err := GetTestFromYaml([]byte(autocompleteHeadersDefaultYaml)) s.NoError(err, "Parsing YAML shouldn't fail") input := test.Tests[1].Stages[0].Stage.Input - s.True(*input.NoAutocompleteHeaders) + s.True(*input.AutocompleteHeaders) s.True(*input.StopMagic) } -func (s *typesTestSuite) TestNoAutocompleteHeadersDefault_StopMagicFalse() { - test, err := GetTestFromYaml([]byte(noAutocompleteHeadersDefaultYaml)) +func (s *typesTestSuite) TestAutocompleteHeadersDefault_StopMagicFalse() { + test, err := GetTestFromYaml([]byte(autocompleteHeadersDefaultYaml)) s.NoError(err, "Parsing YAML shouldn't fail") input := test.Tests[2].Stages[0].Stage.Input - s.False(*input.NoAutocompleteHeaders) + s.False(*input.AutocompleteHeaders) s.False(*input.StopMagic) } -func (s *typesTestSuite) TestNoAutocompleteHeadersFalse_StopMagicDefault() { - test, err := GetTestFromYaml([]byte(noAutocompleteHeadersFalseYaml)) +func (s *typesTestSuite) TestAutocompleteHeadersFalse_StopMagicDefault() { + test, err := GetTestFromYaml([]byte(autocompleteHeadersFalseYaml)) s.NoError(err, "Parsing YAML shouldn't fail") input := test.Tests[0].Stages[0].Stage.Input - s.False(*input.NoAutocompleteHeaders) + s.False(*input.AutocompleteHeaders) s.False(*input.StopMagic) } -func (s *typesTestSuite) TestNoAutocompleteHeadersFalse_StopMagicTrue() { - test, err := GetTestFromYaml([]byte(noAutocompleteHeadersFalseYaml)) +func (s *typesTestSuite) TestAutocompleteHeadersFalse_StopMagicTrue() { + test, err := GetTestFromYaml([]byte(autocompleteHeadersFalseYaml)) s.NoError(err, "Parsing YAML shouldn't fail") input := test.Tests[1].Stages[0].Stage.Input - s.False(*input.NoAutocompleteHeaders) + s.False(*input.AutocompleteHeaders) s.False(*input.StopMagic) } -func (s *typesTestSuite) TestNoAutocompleteHeadersFalse_StopMagicFalse() { - test, err := GetTestFromYaml([]byte(noAutocompleteHeadersFalseYaml)) +func (s *typesTestSuite) TestAutocompleteHeadersFalse_StopMagicFalse() { + test, err := GetTestFromYaml([]byte(autocompleteHeadersFalseYaml)) s.NoError(err, "Parsing YAML shouldn't fail") input := test.Tests[2].Stages[0].Stage.Input - s.False(*input.NoAutocompleteHeaders) + s.False(*input.AutocompleteHeaders) s.False(*input.StopMagic) } -func (s *typesTestSuite) TestNoAutocompleteHeadersTrue_StopMagicDefault() { - test, err := GetTestFromYaml([]byte(noAutocompleteHeadersTrueYaml)) +func (s *typesTestSuite) TestAutocompleteHeadersTrue_StopMagicDefault() { + test, err := GetTestFromYaml([]byte(autocompleteHeadersTrueYaml)) s.NoError(err, "Parsing YAML shouldn't fail") input := test.Tests[0].Stages[0].Stage.Input - s.True(*input.NoAutocompleteHeaders) + s.True(*input.AutocompleteHeaders) s.True(*input.StopMagic) } -func (s *typesTestSuite) TestNoAutocompleteHeadersTrue_StopMagicTrue() { - test, err := GetTestFromYaml([]byte(noAutocompleteHeadersTrueYaml)) +func (s *typesTestSuite) TestAutocompleteHeadersTrue_StopMagicTrue() { + test, err := GetTestFromYaml([]byte(autocompleteHeadersTrueYaml)) s.NoError(err, "Parsing YAML shouldn't fail") input := test.Tests[1].Stages[0].Stage.Input - s.True(*input.NoAutocompleteHeaders) + s.True(*input.AutocompleteHeaders) s.True(*input.StopMagic) } -func (s *typesTestSuite) TestNoAutocompleteHeadersTrue_StopMagicFalse() { - test, err := GetTestFromYaml([]byte(noAutocompleteHeadersTrueYaml)) +func (s *typesTestSuite) TestAutocompleteHeadersTrue_StopMagicFalse() { + test, err := GetTestFromYaml([]byte(autocompleteHeadersTrueYaml)) s.NoError(err, "Parsing YAML shouldn't fail") input := test.Tests[2].Stages[0].Stage.Input - s.True(*input.NoAutocompleteHeaders) + s.True(*input.AutocompleteHeaders) s.True(*input.StopMagic) }