Merge sidnxfr_test.go into xfr_test.go

* Export tests in xfr_test.go
* Rename tests to be `go test -run` friendly
* Hide behind 'net' build tag
This commit is contained in:
Andrew Tunnell-Jones 2015-08-23 07:07:27 +00:00
parent b1bc8d70f4
commit fe0937fa24
2 changed files with 72 additions and 81 deletions

View File

@ -1,78 +0,0 @@
// +build SIDN
// These tests run against servers maintained by SIDN labs, see:
// https://workbench.sidnlabs.nl/
//
// Tests will only be run if the SIDN build tag is provided to `go test`.
// Specific configurations can be tested by providing a regex to `go test`.
//
// Eg:
// go test -tags SIDN -run "AXFR_.*_MD5"
// go test -tags SIDN -run "AXFR_NSD4_.*"
//
package dns
import (
"testing"
"time"
)
func TestAXFR_NSD3_NONE(t *testing.T) { testAXFR(t, "nsd", "") }
func TestAXFR_NSD3_MD5(t *testing.T) { testAXFR(t, "nsd", HmacMD5) }
func TestAXFR_NSD3_SHA1(t *testing.T) { testAXFR(t, "nsd", HmacSHA1) }
func TestAXFR_NSD3_SHA256(t *testing.T) { testAXFR(t, "nsd", HmacSHA256) }
func TestAXFR_NSD4_NONE(t *testing.T) { testAXFR(t, "nsd4", "") }
func TestAXFR_NSD4_MD5(t *testing.T) { testAXFR(t, "nsd4", HmacMD5) }
func TestAXFR_NSD4_SHA1(t *testing.T) { testAXFR(t, "nsd4", HmacSHA1) }
func TestAXFR_NSD4_SHA256(t *testing.T) { testAXFR(t, "nsd4", HmacSHA256) }
func TestAXFR_BIND9_NONE(t *testing.T) { testAXFR(t, "bind9", "") }
func TestAXFR_BIND9_MD5(t *testing.T) { testAXFR(t, "bind9", HmacMD5) }
func TestAXFR_BIND9_SHA1(t *testing.T) { testAXFR(t, "bind9", HmacSHA1) }
func TestAXFR_BIND9_SHA256(t *testing.T) { testAXFR(t, "bind9", HmacSHA256) }
func TestAXFR_KNOT_NONE(t *testing.T) { testAXFR(t, "knot", "") }
func TestAXFR_KNOT_MD5(t *testing.T) { testAXFR(t, "knot", HmacMD5) }
func TestAXFR_KNOT_SHA1(t *testing.T) { testAXFR(t, "knot", HmacSHA1) }
func TestAXFR_KNOT_SHA256(t *testing.T) { testAXFR(t, "knot", HmacSHA256) }
func TestAXFR_POWERDNS_NONE(t *testing.T) { testAXFR(t, "powerdns", "") }
func TestAXFR_POWERDNS_MD5(t *testing.T) { testAXFR(t, "powerdns", HmacMD5) }
func TestAXFR_POWERDNS_SHA1(t *testing.T) { testAXFR(t, "powerdns", HmacSHA1) }
func TestAXFR_POWERDNS_SHA256(t *testing.T) { testAXFR(t, "powerdns", HmacSHA256) }
func TestAXFR_YADIFA_NONE(t *testing.T) { testAXFR(t, "yadifa", "") }
func TestAXFR_YADIFA_MD5(t *testing.T) { testAXFR(t, "yadifa", HmacMD5) }
func TestAXFR_YADIFA_SHA1(t *testing.T) { testAXFR(t, "yadifa", HmacSHA1) }
func TestAXFR_YADIFA_SHA256(t *testing.T) { testAXFR(t, "yadifa", HmacSHA256) }
func testAXFR(t *testing.T, host, alg string) {
x := new(Transfer)
x.TsigSecret = map[string]string{
"wb_md5.": "Wu/utSasZUkoeCNku152Zw==",
"wb_sha1_longkey.": "uhMpEhPq/RAD9Bt4mqhfmi+7ZdKmjLQb/lcrqYPXR4s/nnbsqw==",
"wb_sha256.": "npfrIJjt/MJOjGJoBNZtsjftKMhkSpIYMv2RzRZt1f8=",
}
keyname := map[string]string{
HmacMD5: "wb_md5.",
HmacSHA1: "wb_sha1_longkey.",
HmacSHA256: "wb_sha256.",
}[alg]
m := new(Msg)
m.SetAxfr("types.wb.sidnlabs.nl.")
if keyname != "" {
m.SetTsig(keyname, alg, 300, time.Now().Unix())
}
c, err := x.In(m, host+".sidnlabs.nl:53")
if err != nil {
t.Fatal(err)
}
for e := range c {
if e.Error != nil {
t.Fatal(e.Error)
}
}
}

View File

@ -1,3 +1,5 @@
// +build net
package dns
import (
@ -16,7 +18,8 @@ func getIP(s string) string {
// flaky, need to setup local server and test from
// that.
func testClientAXFR(t *testing.T) {
func TestAXFR_Miek(t *testing.T) {
// This test runs against a server maintained by Miek
if testing.Short() {
return
}
@ -43,7 +46,8 @@ func testClientAXFR(t *testing.T) {
}
// fails.
func testClientAXFRMultipleEnvelopes(t *testing.T) {
func TestAXFR_NLNL_MultipleEnvelopes(t *testing.T) {
// This test runs against a server maintained by NLnet Labs
if testing.Short() {
return
}
@ -65,7 +69,8 @@ func testClientAXFRMultipleEnvelopes(t *testing.T) {
}
}
func testClientTsigAXFR(t *testing.T) {
func TestAXFR_Miek_Tsig(t *testing.T) {
// This test runs against a server maintained by Miek
if testing.Short() {
return
}
@ -90,3 +95,67 @@ func testClientTsigAXFR(t *testing.T) {
}
}
}
func TestAXFR_SIDN_NSD3_NONE(t *testing.T) { testAXFRSIDN(t, "nsd", "") }
func TestAXFR_SIDN_NSD3_MD5(t *testing.T) { testAXFRSIDN(t, "nsd", HmacMD5) }
func TestAXFR_SIDN_NSD3_SHA1(t *testing.T) { testAXFRSIDN(t, "nsd", HmacSHA1) }
func TestAXFR_SIDN_NSD3_SHA256(t *testing.T) { testAXFRSIDN(t, "nsd", HmacSHA256) }
func TestAXFR_SIDN_NSD4_NONE(t *testing.T) { testAXFRSIDN(t, "nsd4", "") }
func TestAXFR_SIDN_NSD4_MD5(t *testing.T) { testAXFRSIDN(t, "nsd4", HmacMD5) }
func TestAXFR_SIDN_NSD4_SHA1(t *testing.T) { testAXFRSIDN(t, "nsd4", HmacSHA1) }
func TestAXFR_SIDN_NSD4_SHA256(t *testing.T) { testAXFRSIDN(t, "nsd4", HmacSHA256) }
func TestAXFR_SIDN_BIND9_NONE(t *testing.T) { testAXFRSIDN(t, "bind9", "") }
func TestAXFR_SIDN_BIND9_MD5(t *testing.T) { testAXFRSIDN(t, "bind9", HmacMD5) }
func TestAXFR_SIDN_BIND9_SHA1(t *testing.T) { testAXFRSIDN(t, "bind9", HmacSHA1) }
func TestAXFR_SIDN_BIND9_SHA256(t *testing.T) { testAXFRSIDN(t, "bind9", HmacSHA256) }
func TestAXFR_SIDN_KNOT_NONE(t *testing.T) { testAXFRSIDN(t, "knot", "") }
func TestAXFR_SIDN_KNOT_MD5(t *testing.T) { testAXFRSIDN(t, "knot", HmacMD5) }
func TestAXFR_SIDN_KNOT_SHA1(t *testing.T) { testAXFRSIDN(t, "knot", HmacSHA1) }
func TestAXFR_SIDN_KNOT_SHA256(t *testing.T) { testAXFRSIDN(t, "knot", HmacSHA256) }
func TestAXFR_SIDN_POWERDNS_NONE(t *testing.T) { testAXFRSIDN(t, "powerdns", "") }
func TestAXFR_SIDN_POWERDNS_MD5(t *testing.T) { testAXFRSIDN(t, "powerdns", HmacMD5) }
func TestAXFR_SIDN_POWERDNS_SHA1(t *testing.T) { testAXFRSIDN(t, "powerdns", HmacSHA1) }
func TestAXFR_SIDN_POWERDNS_SHA256(t *testing.T) { testAXFRSIDN(t, "powerdns", HmacSHA256) }
func TestAXFR_SIDN_YADIFA_NONE(t *testing.T) { testAXFRSIDN(t, "yadifa", "") }
func TestAXFR_SIDN_YADIFA_MD5(t *testing.T) { testAXFRSIDN(t, "yadifa", HmacMD5) }
func TestAXFR_SIDN_YADIFA_SHA1(t *testing.T) { testAXFRSIDN(t, "yadifa", HmacSHA1) }
func TestAXFR_SIDN_YADIFA_SHA256(t *testing.T) { testAXFRSIDN(t, "yadifa", HmacSHA256) }
func testAXFRSIDN(t *testing.T, host, alg string) {
// This tests run against a server maintained by SIDN labs, see:
// https://workbench.sidnlabs.nl/
if testing.Short() {
return
}
x := new(Transfer)
x.TsigSecret = map[string]string{
"wb_md5.": "Wu/utSasZUkoeCNku152Zw==",
"wb_sha1_longkey.": "uhMpEhPq/RAD9Bt4mqhfmi+7ZdKmjLQb/lcrqYPXR4s/nnbsqw==",
"wb_sha256.": "npfrIJjt/MJOjGJoBNZtsjftKMhkSpIYMv2RzRZt1f8=",
}
keyname := map[string]string{
HmacMD5: "wb_md5.",
HmacSHA1: "wb_sha1_longkey.",
HmacSHA256: "wb_sha256.",
}[alg]
m := new(Msg)
m.SetAxfr("types.wb.sidnlabs.nl.")
if keyname != "" {
m.SetTsig(keyname, alg, 300, time.Now().Unix())
}
c, err := x.In(m, host+".sidnlabs.nl:53")
if err != nil {
t.Fatal(err)
}
for e := range c {
if e.Error != nil {
t.Fatal(e.Error)
}
}
}