all: add UpstreamConfig.VerifyDomain

So the self-check process is only done for ControlD upstream, and can be
distinguished between .com and .dev resolvers.
This commit is contained in:
Cuong Manh Le
2023-05-26 21:33:24 +07:00
committed by Cuong Manh Le
parent 54e63ccf9b
commit 8fda856e24
4 changed files with 76 additions and 9 deletions
+33
View File
@@ -190,6 +190,39 @@ func TestUpstreamConfig_Init(t *testing.T) {
}
}
func TestUpstreamConfig_VerifyDomain(t *testing.T) {
tests := []struct {
name string
uc *UpstreamConfig
verifyDomain string
}{
{
controlDComDomain,
&UpstreamConfig{Endpoint: "https://freedns.controld.com/p2"},
controldVerifiedDomain[controlDComDomain],
},
{
controlDDevDomain,
&UpstreamConfig{Endpoint: "https://freedns.controld.dev/p2"},
controldVerifiedDomain[controlDDevDomain],
},
{
"non-ControlD upstream",
&UpstreamConfig{Endpoint: "https://dns.google/dns-query"},
"",
},
}
for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
if got := tc.uc.VerifyDomain(); got != tc.verifyDomain {
t.Errorf("unexpected verify domain, want: %q, got: %q", tc.verifyDomain, got)
}
})
}
}
func ptrBool(b bool) *bool {
return &b
}