forked from TrueCloudLab/lego
Export PreCheckDNS so library users can manage the DNS check in tests
This commit is contained in:
parent
aa216e0399
commit
2818a41068
2 changed files with 6 additions and 4 deletions
|
@ -17,7 +17,9 @@ import (
|
||||||
type preCheckDNSFunc func(fqdn, value string) (bool, error)
|
type preCheckDNSFunc func(fqdn, value string) (bool, error)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
preCheckDNS preCheckDNSFunc = checkDNSPropagation
|
// PreCheckDNS checks DNS propagation before notifying ACME that
|
||||||
|
// the DNS challenge is ready.
|
||||||
|
PreCheckDNS preCheckDNSFunc = checkDNSPropagation
|
||||||
fqdnToZone = map[string]string{}
|
fqdnToZone = map[string]string{}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -84,7 +86,7 @@ func (s *dnsChallenge) Solve(chlng challenge, domain string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
err = WaitFor(timeout, interval, func() (bool, error) {
|
err = WaitFor(timeout, interval, func() (bool, error) {
|
||||||
return preCheckDNS(fqdn, value)
|
return PreCheckDNS(fqdn, value)
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -86,7 +86,7 @@ var checkAuthoritativeNssTestsErr = []struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDNSValidServerResponse(t *testing.T) {
|
func TestDNSValidServerResponse(t *testing.T) {
|
||||||
preCheckDNS = func(fqdn, value string) (bool, error) {
|
PreCheckDNS = func(fqdn, value string) (bool, error) {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
privKey, _ := rsa.GenerateKey(rand.Reader, 512)
|
privKey, _ := rsa.GenerateKey(rand.Reader, 512)
|
||||||
|
@ -114,7 +114,7 @@ func TestDNSValidServerResponse(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPreCheckDNS(t *testing.T) {
|
func TestPreCheckDNS(t *testing.T) {
|
||||||
ok, err := preCheckDNS("acme-staging.api.letsencrypt.org", "fe01=")
|
ok, err := PreCheckDNS("acme-staging.api.letsencrypt.org", "fe01=")
|
||||||
if err != nil || !ok {
|
if err != nil || !ok {
|
||||||
t.Errorf("preCheckDNS failed for acme-staging.api.letsencrypt.org")
|
t.Errorf("preCheckDNS failed for acme-staging.api.letsencrypt.org")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue