diff options
author | 2017-01-12 11:57:00 -0500 | |
---|---|---|
committer | 2017-01-12 11:57:00 -0500 | |
commit | b6a2a5aeaa0811199c6206eb87893eaa2298ae95 (patch) | |
tree | c5ee7862ac0d7f37534d689bd8a8605f7219de4a /test/kubernetes_test.go | |
parent | 2e366459c523653147a54763b8b9234dbcbf0aa4 (diff) | |
download | coredns-b6a2a5aeaa0811199c6206eb87893eaa2298ae95.tar.gz coredns-b6a2a5aeaa0811199c6206eb87893eaa2298ae95.tar.zst coredns-b6a2a5aeaa0811199c6206eb87893eaa2298ae95.zip |
Pod insecure2 (#479)
* return servfail for pod rqsts when pods disabled
* Add integration test for disabled pod mode
Diffstat (limited to 'test/kubernetes_test.go')
-rw-r--r-- | test/kubernetes_test.go | 67 |
1 files changed, 45 insertions, 22 deletions
diff --git a/test/kubernetes_test.go b/test/kubernetes_test.go index 49d3834d8..824f8eadc 100644 --- a/test/kubernetes_test.go +++ b/test/kubernetes_test.go @@ -196,14 +196,7 @@ var dnsTestCases = []test.Case{ }, { Qname: "10-20-0-101.test-1.pod.cluster.local.", Qtype: dns.TypeA, - Rcode: dns.RcodeSuccess, - Answer: []dns.RR{ - test.A("10-20-0-101.test-1.pod.cluster.local. 0 IN A 10.20.0.101"), - }, - }, - { - Qname: "10-20-0-101.test-X.pod.cluster.local.", Qtype: dns.TypeA, - Rcode: dns.RcodeNameError, + Rcode: dns.RcodeServerFailure, Answer: []dns.RR{}, }, { @@ -227,6 +220,21 @@ var dnsTestCases = []test.Case{ }, } +var dnsTestCasesPodsInsecure = []test.Case{ + { + Qname: "10-20-0-101.test-1.pod.cluster.local.", Qtype: dns.TypeA, + Rcode: dns.RcodeSuccess, + Answer: []dns.RR{ + test.A("10-20-0-101.test-1.pod.cluster.local. 0 IN A 10.20.0.101"), + }, + }, + { + Qname: "10-20-0-101.test-X.pod.cluster.local.", Qtype: dns.TypeA, + Rcode: dns.RcodeNameError, + Answer: []dns.RR{}, + }, +} + func createTestServer(t *testing.T, corefile string) (*caddy.Instance, string) { server, err := CoreDNSServer(corefile) if err != nil { @@ -241,19 +249,7 @@ func createTestServer(t *testing.T, corefile string) (*caddy.Instance, string) { return server, udp } -func TestKubernetesIntegration(t *testing.T) { - t.Parallel() - corefile := - `.:0 { - kubernetes cluster.local 0.0.10.in-addr.arpa { - endpoint http://localhost:8080 - #endpoint https://kubernetes/ - #tls admin.pem admin-key.pem ca.pem - #tls k8s_auth/client2.crt k8s_auth/client2.key k8s_auth/ca2.crt - namespaces test-1 - pods insecure - } -` +func doIntegrationTests(t *testing.T, corefile string, testCases []test.Case) { server, udp := createTestServer(t, corefile) defer server.Stop() @@ -261,7 +257,7 @@ func TestKubernetesIntegration(t *testing.T) { // test environment. time.Sleep(5 * time.Second) - for _, tc := range dnsTestCases { + for _, tc := range testCases { dnsClient := new(dns.Client) dnsMessage := new(dns.Msg) @@ -285,3 +281,30 @@ func TestKubernetesIntegration(t *testing.T) { //TODO: Check the actual RR values } } + +func TestKubernetesIntegration(t *testing.T) { + corefile := + `.:0 { + kubernetes cluster.local 0.0.10.in-addr.arpa { + endpoint http://localhost:8080 + #endpoint https://kubernetes/ + #tls admin.pem admin-key.pem ca.pem + #tls k8s_auth/client2.crt k8s_auth/client2.key k8s_auth/ca2.crt + namespaces test-1 + pods disabled + } +` + doIntegrationTests(t, corefile, dnsTestCases) +} + +func TestKubernetesIntegrationPodsInsecure(t *testing.T) { + corefile := + `.:0 { + kubernetes cluster.local 0.0.10.in-addr.arpa { + endpoint http://localhost:8080 + namespaces test-1 + pods insecure + } +` + doIntegrationTests(t, corefile, dnsTestCasesPodsInsecure) +} |