mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-03 16:59:22 +02:00
config: allow specifying auto codec type in all-in-one mode (#2846)
* config: allow specifying auto codec type in all-in-one mode * fix test * fix test
This commit is contained in:
parent
0ee6a72c02
commit
6b949a5c2e
4 changed files with 23 additions and 10 deletions
|
@ -15,6 +15,7 @@ type CodecType string
|
|||
|
||||
// CodecTypes
|
||||
const (
|
||||
CodecTypeUnset CodecType = ""
|
||||
CodecTypeAuto CodecType = "auto"
|
||||
CodecTypeHTTP1 CodecType = "http1"
|
||||
CodecTypeHTTP2 CodecType = "http2"
|
||||
|
|
17
config/codec_type_test.go
Normal file
17
config/codec_type_test.go
Normal file
|
@ -0,0 +1,17 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestOptions_GetCodecType(t *testing.T) {
|
||||
options := NewDefaultOptions()
|
||||
assert.Equal(t, CodecTypeHTTP1, options.GetCodecType())
|
||||
options.Services = "proxy"
|
||||
assert.Equal(t, CodecTypeAuto, options.GetCodecType())
|
||||
options.Services = "all"
|
||||
options.CodecType = CodecTypeAuto
|
||||
assert.Equal(t, CodecTypeAuto, options.GetCodecType())
|
||||
}
|
|
@ -312,7 +312,6 @@ var defaultOptions = Options{
|
|||
Services: "all",
|
||||
CookieHTTPOnly: true,
|
||||
CookieSecure: true,
|
||||
CodecType: CodecTypeAuto,
|
||||
CookieExpire: 14 * time.Hour,
|
||||
CookieName: "_pomerium",
|
||||
DefaultUpstreamTimeout: 30 * time.Second,
|
||||
|
@ -1034,8 +1033,11 @@ func (o *Options) GetQPS() float64 {
|
|||
|
||||
// GetCodecType gets a codec type.
|
||||
func (o *Options) GetCodecType() CodecType {
|
||||
if IsAll(o.Services) && o.CodecType == CodecTypeAuto {
|
||||
return CodecTypeHTTP1
|
||||
if o.CodecType == CodecTypeUnset {
|
||||
if IsAll(o.Services) {
|
||||
return CodecTypeHTTP1
|
||||
}
|
||||
return CodecTypeAuto
|
||||
}
|
||||
return o.CodecType
|
||||
}
|
||||
|
|
|
@ -313,7 +313,6 @@ func TestOptionsFromViper(t *testing.T) {
|
|||
EnvoyAdminAccessLogPath: os.DevNull,
|
||||
EnvoyAdminProfilePath: os.DevNull,
|
||||
EnvoyAdminAddress: "127.0.0.1:9901",
|
||||
CodecType: CodecTypeAuto,
|
||||
},
|
||||
false,
|
||||
},
|
||||
|
@ -335,7 +334,6 @@ func TestOptionsFromViper(t *testing.T) {
|
|||
EnvoyAdminAccessLogPath: os.DevNull,
|
||||
EnvoyAdminProfilePath: os.DevNull,
|
||||
EnvoyAdminAddress: "127.0.0.1:9901",
|
||||
CodecType: CodecTypeAuto,
|
||||
},
|
||||
false,
|
||||
},
|
||||
|
@ -693,8 +691,3 @@ func mustParseWeightedURLs(t *testing.T, urls ...string) []WeightedURL {
|
|||
require.NoError(t, err)
|
||||
return wu
|
||||
}
|
||||
|
||||
func TestDefaults(t *testing.T) {
|
||||
o := NewDefaultOptions()
|
||||
assert.Equal(t, CodecTypeAuto, o.CodecType)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue