Configurable Proxy Protocol header timeout for TLS passthrough

This commit is contained in:
Jason Roberts 2018-06-03 20:10:41 -05:00
parent c8fec068d9
commit d637a9b978
5 changed files with 46 additions and 1 deletions

View file

@ -18,6 +18,7 @@ package template
import (
"testing"
"time"
"github.com/kylelemons/godebug/pretty"
@ -31,6 +32,22 @@ func TestFilterErrors(t *testing.T) {
}
}
func TestProxytTimeoutParsing(t *testing.T) {
testCases := map[string]struct {
input string
expect time.Duration // duration in seconds
}{
"valid duration": {"35s", time.Duration(35) * time.Second},
"invalid duration": {"3zxs", time.Duration(5) * time.Second},
}
for n, tc := range testCases {
cfg := ReadConfig(map[string]string{"proxy-protocol-header-timeout": tc.input})
if cfg.ProxyProtocolHeaderTimeout.Seconds() != tc.expect.Seconds() {
t.Errorf("Testing %v. Expected %v seconds but got %v seconds", n, tc.expect, cfg.ProxyProtocolHeaderTimeout)
}
}
}
func TestMergeConfigMapToStruct(t *testing.T) {
conf := map[string]string{
"custom-http-errors": "300,400,demo",