Skip to content

Commit

Permalink
fix: dns check to use lowercase and update fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
yashmehrotra authored and moshloop committed Nov 27, 2024
1 parent afa4abb commit 4319c92
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
3 changes: 3 additions & 0 deletions checks/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/flanksource/canary-checker/api/external"
v1 "github.com/flanksource/canary-checker/api/v1"
"github.com/flanksource/canary-checker/pkg"
"github.com/samber/lo"
"golang.org/x/net/context"
)

Expand Down Expand Up @@ -213,6 +214,8 @@ func checkResult(got []string, check v1.DNSCheck) (result bool, message string)
}

if len(check.ExactReply) != 0 {
got = lo.Map(got, func(s string, _ int) string { return strings.ToLower(s) })
expected = lo.Map(expected, func(s string, _ int) string { return strings.ToLower(s) })
sort.Strings(got)
sort.Strings(expected)
if !reflect.DeepEqual(got, expected) {
Expand Down
21 changes: 12 additions & 9 deletions fixtures/minimal/dns_pass.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,16 @@ spec:
querytype: "MX"
minrecords: 1
exactreply:
- "aspmx.l.google.com. 1"
- "alt1.aspmx.l.google.com. 5"
- "alt2.aspmx.l.google.com. 5"
- "aspmx3.googlemail.com. 10"
- "aspmx2.googlemail.com. 10"
- aspmx.l.google.com. 1
- aspmx.l.google.com. 1
- alt1.aspmx.l.google.com. 5
- alt2.aspmx.l.google.com. 5
- alt2.aspmx.l.google.com. 5
- alt1.aspmx.l.google.com. 5
- aspmx2.googlemail.com. 10
- aspmx3.googlemail.com. 10
- aspmx3.googlemail.com. 10
- aspmx2.googlemail.com. 10
timeout: 100
thresholdMillis: 1000
- server: 8.8.8.8
Expand All @@ -61,10 +66,8 @@ spec:
querytype: "NS"
minrecords: 1
exactreply:
- "ns-91.awsdns-11.com."
- "ns-908.awsdns-49.net."
- "ns-1450.awsdns-53.org."
- "ns-1896.awsdns-45.co.uk."
- "gina.ns.cloudflare.com."
- "walt.ns.cloudflare.com."
timeout: 100
thresholdMillis: 1000
# - server: 8.8.8.8
Expand Down

0 comments on commit 4319c92

Please sign in to comment.