Skip to content

Commit

Permalink
Add tests for _dnslink.example.com resolving.
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@gmail.com>
  • Loading branch information
Kubuxu committed Jan 11, 2016
1 parent 847cf97 commit ade1982
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions namesys/dns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ func newMockDNS() *mockDNS {
"ipfs.example.com": []string{
"dnslink=/ipfs/QmY3hE8xgFCjGcz6PHgnvJz5HZi1BaKRfPkn1ghZUcYMjD",
},
"_dnslink.dipfs.example.com": []string{
"dnslink=/ipfs/QmY3hE8xgFCjGcz6PHgnvJz5HZi1BaKRfPkn1ghZUcYMjD",
},
"dns1.example.com": []string{
"dnslink=/ipns/ipfs.example.com",
},
Expand All @@ -83,9 +86,21 @@ func newMockDNS() *mockDNS {
"loop2.example.com": []string{
"dnslink=/ipns/loop1.example.com",
},
"_dnslink.dloop1.example.com": []string{
"dnslink=/ipns/loop2.example.com",
},
"_dnslink.dloop2.example.com": []string{
"dnslink=/ipns/loop1.example.com",
},
"bad.example.com": []string{
"dnslink=",
},
"double.example.com": []string{
"dnslink=/ipfs/QmY3hE8xgFCjGcz6PHgnvJz5HZi1BaKRfPkn1ghZUcYMjD",
},
"_dnslink.double.example.com": []string{
"dnslink=/ipfs/QmY3hE8xgFCjGcz6PHgnvJz5HZi1BaKRfPkn1ghZUcYMjD",
},
},
}
}
Expand All @@ -95,6 +110,7 @@ func TestDNSResolution(t *testing.T) {
r := &DNSResolver{lookupTXT: mock.lookupTXT}
testResolution(t, r, "multihash.example.com", DefaultDepthLimit, "/ipfs/QmY3hE8xgFCjGcz6PHgnvJz5HZi1BaKRfPkn1ghZUcYMjD", nil)
testResolution(t, r, "ipfs.example.com", DefaultDepthLimit, "/ipfs/QmY3hE8xgFCjGcz6PHgnvJz5HZi1BaKRfPkn1ghZUcYMjD", nil)
testResolution(t, r, "dipfs.example.com", DefaultDepthLimit, "/ipfs/QmY3hE8xgFCjGcz6PHgnvJz5HZi1BaKRfPkn1ghZUcYMjD", nil)
testResolution(t, r, "dns1.example.com", DefaultDepthLimit, "/ipfs/QmY3hE8xgFCjGcz6PHgnvJz5HZi1BaKRfPkn1ghZUcYMjD", nil)
testResolution(t, r, "dns1.example.com", 1, "/ipns/ipfs.example.com", ErrResolveRecursion)
testResolution(t, r, "dns2.example.com", DefaultDepthLimit, "/ipfs/QmY3hE8xgFCjGcz6PHgnvJz5HZi1BaKRfPkn1ghZUcYMjD", nil)
Expand All @@ -108,5 +124,12 @@ func TestDNSResolution(t *testing.T) {
testResolution(t, r, "loop1.example.com", 2, "/ipns/loop1.example.com", ErrResolveRecursion)
testResolution(t, r, "loop1.example.com", 3, "/ipns/loop2.example.com", ErrResolveRecursion)
testResolution(t, r, "loop1.example.com", DefaultDepthLimit, "/ipns/loop1.example.com", ErrResolveRecursion)
testResolution(t, r, "dloop1.example.com", 1, "/ipns/loop2.example.com", ErrResolveRecursion)
testResolution(t, r, "dloop1.example.com", 2, "/ipns/loop1.example.com", ErrResolveRecursion)
testResolution(t, r, "dloop1.example.com", 3, "/ipns/loop2.example.com", ErrResolveRecursion)
testResolution(t, r, "dloop1.example.com", DefaultDepthLimit, "/ipns/loop1.example.com", ErrResolveRecursion)
testResolution(t, r, "bad.example.com", DefaultDepthLimit, "", ErrResolveFailed)
// _dnslink and . pointing to the same path is good, if they were pointing to different ones behavior would be undefined.
testResolution(t, r, "double.example.com", DefaultDepthLimit, "/ipfs/QmY3hE8xgFCjGcz6PHgnvJz5HZi1BaKRfPkn1ghZUcYMjD", nil)

}

0 comments on commit ade1982

Please sign in to comment.