Merge pull request #260 from cristiangraz/export-pre-check-dns

Export PreCheckDNS so library users can manage the DNS check in tests
This commit is contained in:
xenolf 2016-08-12 19:02:52 +02:00 committed by GitHub
commit 68f2512ba1
2 changed files with 6 additions and 4 deletions

View file

@ -17,7 +17,9 @@ import (
type preCheckDNSFunc func(fqdn, value string) (bool, error)
var (
preCheckDNS preCheckDNSFunc = checkDNSPropagation
// PreCheckDNS checks DNS propagation before notifying ACME that
// the DNS challenge is ready.
PreCheckDNS preCheckDNSFunc = checkDNSPropagation
fqdnToZone = map[string]string{}
)
@ -84,7 +86,7 @@ func (s *dnsChallenge) Solve(chlng challenge, domain string) error {
}
err = WaitFor(timeout, interval, func() (bool, error) {
return preCheckDNS(fqdn, value)
return PreCheckDNS(fqdn, value)
})
if err != nil {
return err

View file

@ -86,7 +86,7 @@ var checkAuthoritativeNssTestsErr = []struct {
}
func TestDNSValidServerResponse(t *testing.T) {
preCheckDNS = func(fqdn, value string) (bool, error) {
PreCheckDNS = func(fqdn, value string) (bool, error) {
return true, nil
}
privKey, _ := rsa.GenerateKey(rand.Reader, 512)
@ -114,7 +114,7 @@ func TestDNSValidServerResponse(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 {
t.Errorf("preCheckDNS failed for acme-staging.api.letsencrypt.org")
}