diff --git a/runner/options.go b/runner/options.go index f636b9d1..31813e4d 100644 --- a/runner/options.go +++ b/runner/options.go @@ -871,7 +871,7 @@ func (options *Options) ValidateOptions() error { options.OutputCDN = "true" } - if !stringsutil.EqualFoldAny(options.Protocol, string(httpxcommon.UNKNOWN), string(httpxcommon.HTTP11)) { + if !stringsutil.EqualFoldAny(options.Protocol, string(httpxcommon.UNKNOWN), string(httpxcommon.HTTP11), string(httpxcommon.HTTP2), string(httpxcommon.HTTP3)) { return fmt.Errorf("invalid protocol: %s", options.Protocol) } diff --git a/runner/options_test.go b/runner/options_test.go new file mode 100644 index 00000000..79165f6e --- /dev/null +++ b/runner/options_test.go @@ -0,0 +1,33 @@ + +func TestValidateOptions_Protocol(t *testing.T) { + tests := []struct { + protocol string + wantErr bool + }{ + {"", false}, + {"unknown", false}, + {"UNKNOWN", false}, + {"http11", false}, + {"HTTP11", false}, + {"http2", false}, + {"HTTP2", false}, + {"http3", false}, + {"HTTP3", false}, + {"http10", true}, + {"invalid", true}, + } + + for _, tc := range tests { + t.Run(tc.protocol, func(t *testing.T) { + opts := &Options{ + Protocol: tc.protocol, + } + err := opts.ValidateOptions() + if tc.wantErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +}