Merge pull request #2504 from jrthrawny/proxy-protocol-timeout-for-passthrough-pr

Add Timeout For TLS Passthrough
This commit is contained in:
k8s-ci-robot 2018-06-03 22:54:53 -07:00 committed by GitHub
commit fa9823634c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 46 additions and 1 deletions

View file

@ -19,6 +19,7 @@ package template
import (
"reflect"
"testing"
"time"
"github.com/kylelemons/godebug/pretty"
@ -32,6 +33,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",