config: strip quotes from http redirect addr (#818)

This commit is contained in:
Caleb Doxsey 2020-06-01 08:51:56 -06:00 committed by GitHub
parent 44784e98fe
commit 12e373249b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View file

@ -581,6 +581,9 @@ func (o *Options) Validate() error {
} }
} }
// strip quotes from redirect address (#811)
o.HTTPRedirectAddr = strings.Trim(o.HTTPRedirectAddr, `"'`)
RedirectAndAutocertServer.update(o) RedirectAndAutocertServer.update(o)
err = AutocertManager.update(o) err = AutocertManager.update(o)

View file

@ -13,6 +13,7 @@ import (
"github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts" "github.com/google/go-cmp/cmp/cmpopts"
"github.com/spf13/viper" "github.com/spf13/viper"
"github.com/stretchr/testify/assert"
) )
var cmpOptIgnoreUnexported = cmpopts.IgnoreUnexported(Options{}) var cmpOptIgnoreUnexported = cmpopts.IgnoreUnexported(Options{})
@ -467,6 +468,14 @@ func TestOptions_sourceHostnames(t *testing.T) {
} }
} }
func TestHTTPRedirectAddressStripQuotes(t *testing.T) {
o := NewDefaultOptions()
o.InsecureServer = true
o.HTTPRedirectAddr = `":80"`
assert.NoError(t, o.Validate())
assert.Equal(t, ":80", o.HTTPRedirectAddr)
}
func TestCompareByteSliceSlice(t *testing.T) { func TestCompareByteSliceSlice(t *testing.T) {
type Bytes = [][]byte type Bytes = [][]byte