git » dnss » commit b5631ea

tests: Make tests more hermetic

author Alberto Bertogli
2021-06-12 13:05:25 UTC
committer Alberto Bertogli
2021-06-12 14:20:53 UTC
parent 556fddc41f6809862f772ba6d911cf57a501b346

tests: Make tests more hermetic

The dnss-against-dnss test today is dependent on external server
behaviour, which can affect tests with truncation and long messages.

This patch makes the tests more hermetic by using minidns when possible.

tests/external.sh +1 -1
tests/minidns.go +5 -0
tests/testzones +19 -0

diff --git a/tests/external.sh b/tests/external.sh
index 99114cb..2d21def 100755
--- a/tests/external.sh
+++ b/tests/external.sh
@@ -119,7 +119,7 @@ minidns
 wait_until_ready tcp 1953
 
 echo "## Launching HTTPS server"
-dnss -enable_https_to_dns \
+dnss -enable_https_to_dns -dns_upstream "localhost:1953" \
 	-insecure_http_server -https_server_addr "localhost:1999"
 HTTP_PID=$PID
 mv .dnss.log .dnss.http.log
diff --git a/tests/minidns.go b/tests/minidns.go
index 9c3aeb4..2a6b80a 100644
--- a/tests/minidns.go
+++ b/tests/minidns.go
@@ -279,6 +279,11 @@ func (m *miniDNS) loadZones(f *os.File) {
 				Pref: 10,
 				MX:   dnsmessage.MustNewName(value),
 			}
+		case "ns":
+			qType = dnsmessage.TypeNS
+			body = &dnsmessage.NSResource{
+				NS: dnsmessage.MustNewName(value),
+			}
 		case "txt":
 			qType = dnsmessage.TypeTXT
 			body = &dnsmessage.TXTResource{
diff --git a/tests/testzones b/tests/testzones
index f8b9479..35b9828 100644
--- a/tests/testzones
+++ b/tests/testzones
@@ -1,3 +1,22 @@
 # Zones for minidns to use in the tests.
 upstream A    127.0.0.1
 upstream AAAA ::1
+
+example.com A    1.2.3.4
+example.com AAAA 1001:2002:3003::4004
+
+com.ar NS a.dns.ar.
+com.ar NS b.dns.ar.
+com.ar NS c.dns.ar.
+com.ar NS e.dns.ar.
+com.ar NS f.dns.ar.
+
+google.com TXT aaaaaaaaaaaaaaaaaaaaaaaaa=bbbbbbbbbbbbbbbb
+google.com TXT cccccccc=dddddddddddddddddddddddddddddddddddd
+google.com TXT eeeeeeeeeeeeeeeeeee=ffffffffffffffffffffffffffffffffffffffffffff
+google.com TXT gggggggggggggggggggggggg=hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
+google.com TXT iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
+google.com TXT jjjjjjjj=kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
+google.com TXT llllllllllllllllllllllll=mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
+google.com TXT nn=oooooooooooooooooooooooooooooooooooooooo
+google.com TXT pppppppppppppppppppppppppppp=qqqqqqqqqqqqqqqqqqqqqqqqqqqqqq