Add nginx tests
This commit is contained in:
parent
793672d9b0
commit
dbd368adf2
2 changed files with 21 additions and 2 deletions
|
@ -20,6 +20,8 @@ import (
|
|||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/kylelemons/godebug/pretty"
|
||||
|
||||
"k8s.io/ingress/controllers/nginx/pkg/config"
|
||||
"k8s.io/ingress/core/pkg/net/dns"
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
|
@ -35,7 +37,7 @@ func TestFilterErrors(t *testing.T) {
|
|||
func TestMergeConfigMapToStruct(t *testing.T) {
|
||||
conf := &api.ConfigMap{
|
||||
Data: map[string]string{
|
||||
"custom-http-errors": "300,400",
|
||||
"custom-http-errors": "300,400,demo",
|
||||
"proxy-read-timeout": "1",
|
||||
"proxy-send-timeout": "2",
|
||||
"skip-access-log-urls": "/log,/demo,/test",
|
||||
|
@ -64,4 +66,22 @@ func TestMergeConfigMapToStruct(t *testing.T) {
|
|||
if !reflect.DeepEqual(def, to) {
|
||||
t.Errorf("expected %v but retuned %v", def, to)
|
||||
}
|
||||
|
||||
def = config.NewDefault()
|
||||
to = ReadConfig(&api.ConfigMap{})
|
||||
if !reflect.DeepEqual(def, to) {
|
||||
t.Errorf("expected %v but retuned %v", def, to)
|
||||
}
|
||||
|
||||
def = config.NewDefault()
|
||||
def.WhitelistSourceRange = []string{"1.1.1.1/32"}
|
||||
to = ReadConfig(&api.ConfigMap{
|
||||
Data: map[string]string{
|
||||
"whitelist-source-range": "1.1.1.1/32",
|
||||
},
|
||||
})
|
||||
|
||||
if diff := pretty.Compare(to, def); diff != "" {
|
||||
t.Errorf("unexpected diff: (-got +want)\n%s", diff)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
"proxy-connect-timeout": 5,
|
||||
"proxy-read-timeout": 60,
|
||||
"proxy-send-timeout": 60,
|
||||
"resolver": "",
|
||||
"skip-access-log-urls": ["~*health-check", "~*info"],
|
||||
"ssl-redirect": true,
|
||||
"upstream-fail-timeout": 0,
|
||||
|
|
Loading…
Reference in a new issue