diff --git a/controllers/nginx/pkg/template/configmap_test.go b/controllers/nginx/pkg/template/configmap_test.go index 0bbdc4cf4..1016cf0fa 100644 --- a/controllers/nginx/pkg/template/configmap_test.go +++ b/controllers/nginx/pkg/template/configmap_test.go @@ -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) + } } diff --git a/controllers/nginx/test/data/config.json b/controllers/nginx/test/data/config.json index 938a97fb6..4aaa2dd11 100644 --- a/controllers/nginx/test/data/config.json +++ b/controllers/nginx/test/data/config.json @@ -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,