Added unit tests
This commit is contained in:
parent
fc5153af3e
commit
d4dc133e20
1 changed files with 63 additions and 0 deletions
63
dns_test.go
Normal file
63
dns_test.go
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
package headscale
|
||||||
|
|
||||||
|
import (
|
||||||
|
"gopkg.in/check.v1"
|
||||||
|
"inet.af/netaddr"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (s *Suite) TestMagicDNSRootDomains100(c *check.C) {
|
||||||
|
prefix := netaddr.MustParseIPPrefix("100.64.0.0/10")
|
||||||
|
domains, err := generateMagicDNSRootDomains(prefix, "headscale.net")
|
||||||
|
c.Assert(err, check.IsNil)
|
||||||
|
|
||||||
|
found := false
|
||||||
|
for _, domain := range *domains {
|
||||||
|
if domain == "64.100.in-addr.arpa." {
|
||||||
|
found = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
c.Assert(found, check.Equals, true)
|
||||||
|
|
||||||
|
found = false
|
||||||
|
for _, domain := range *domains {
|
||||||
|
if domain == "100.100.in-addr.arpa." {
|
||||||
|
found = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
c.Assert(found, check.Equals, true)
|
||||||
|
|
||||||
|
found = false
|
||||||
|
for _, domain := range *domains {
|
||||||
|
if domain == "127.100.in-addr.arpa." {
|
||||||
|
found = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
c.Assert(found, check.Equals, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Suite) TestMagicDNSRootDomains172(c *check.C) {
|
||||||
|
prefix := netaddr.MustParseIPPrefix("172.16.0.0/16")
|
||||||
|
domains, err := generateMagicDNSRootDomains(prefix, "headscale.net")
|
||||||
|
c.Assert(err, check.IsNil)
|
||||||
|
|
||||||
|
found := false
|
||||||
|
for _, domain := range *domains {
|
||||||
|
if domain == "0.16.172.in-addr.arpa." {
|
||||||
|
found = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
c.Assert(found, check.Equals, true)
|
||||||
|
|
||||||
|
found = false
|
||||||
|
for _, domain := range *domains {
|
||||||
|
if domain == "255.16.172.in-addr.arpa." {
|
||||||
|
found = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
c.Assert(found, check.Equals, true)
|
||||||
|
}
|
Loading…
Reference in a new issue