Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f20b7802b1 |
@@ -63,7 +63,7 @@ func TestCNAMEThatCannotBeFollowedKeepsPrevious(t *testing.T) {
|
|||||||
)
|
)
|
||||||
|
|
||||||
current := hostnameState(map[string]map[string][]string{
|
current := hostnameState(map[string]map[string][]string{
|
||||||
nsA: {"CNAME": {"target.example.invalid."}},
|
nsA: cnameTo("target.example.invalid."),
|
||||||
})
|
})
|
||||||
prev := &state.HostnameState{CNAMEAddresses: []string{oldIP}}
|
prev := &state.HostnameState{CNAMEAddresses: []string{oldIP}}
|
||||||
|
|
||||||
@@ -123,8 +123,8 @@ func TestCNAMEAddressesOfEveryTarget(t *testing.T) {
|
|||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
found := followLive(t, map[string]map[string][]string{
|
found := followLive(t, map[string]map[string][]string{
|
||||||
nsA: {"CNAME": {"one.one.one.one."}},
|
nsA: cnameTo("one.one.one.one."),
|
||||||
nsB: {"CNAME": {"dns.google."}},
|
nsB: cnameTo("dns.google."),
|
||||||
})
|
})
|
||||||
|
|
||||||
for _, ip := range []string{"1.1.1.1", "8.8.8.8"} {
|
for _, ip := range []string{"1.1.1.1", "8.8.8.8"} {
|
||||||
@@ -141,7 +141,7 @@ func TestCNAMEChainEndingInNoAddressSavesEmptyList(t *testing.T) {
|
|||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
found := followLive(t, map[string]map[string][]string{
|
found := followLive(t, map[string]map[string][]string{
|
||||||
nsA: {"CNAME": {"this-surely-does-not-exist-xyz.google.com."}},
|
nsA: cnameTo("this-surely-does-not-exist-xyz.google.com."),
|
||||||
})
|
})
|
||||||
|
|
||||||
if found == nil || len(found) != 0 {
|
if found == nil || len(found) != 0 {
|
||||||
@@ -160,7 +160,7 @@ func TestCNAMEBesideAnAddressNotFollowed(t *testing.T) {
|
|||||||
|
|
||||||
current := hostnameState(map[string]map[string][]string{
|
current := hostnameState(map[string]map[string][]string{
|
||||||
nsA: {"A": {ip1}},
|
nsA: {"A": {ip1}},
|
||||||
nsB: {"CNAME": {"target.example.org."}},
|
nsB: cnameTo("target.example.org."),
|
||||||
})
|
})
|
||||||
|
|
||||||
w.ResolveCNAMEAddresses(t.Context(), host, current, nil)
|
w.ResolveCNAMEAddresses(t.Context(), host, current, nil)
|
||||||
@@ -194,12 +194,18 @@ func TestCNAMEWhoseNameserversAllFailedKeepsPrevious(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cnameTo builds the records of a nameserver that answered with a CNAME
|
||||||
|
// to target and no address.
|
||||||
|
func cnameTo(target string) map[string][]string {
|
||||||
|
return map[string][]string{"CNAME": {target}}
|
||||||
|
}
|
||||||
|
|
||||||
// cnameState builds the state a check leaves behind for a name whose
|
// cnameState builds the state a check leaves behind for a name whose
|
||||||
// nameserver answered with a CNAME and no address, when following the
|
// nameserver answered with a CNAME and no address, when following the
|
||||||
// CNAME found these addresses, which may be none.
|
// CNAME found these addresses, which may be none.
|
||||||
func cnameState(addresses ...string) *state.HostnameState {
|
func cnameState(addresses ...string) *state.HostnameState {
|
||||||
hs := hostnameState(map[string]map[string][]string{
|
hs := hostnameState(map[string]map[string][]string{
|
||||||
nsA: {"CNAME": {"target.example.org."}},
|
nsA: cnameTo("target.example.org."),
|
||||||
})
|
})
|
||||||
|
|
||||||
hs.CNAMEAddresses = append([]string{}, addresses...)
|
hs.CNAMEAddresses = append([]string{}, addresses...)
|
||||||
|
|||||||
Reference in New Issue
Block a user