Skip to content

Commit

Permalink
added unittests
Browse files Browse the repository at this point in the history
  • Loading branch information
nbys committed Jan 17, 2022
1 parent c103535 commit 1c4d990
Show file tree
Hide file tree
Showing 2 changed files with 332 additions and 28 deletions.
17 changes: 4 additions & 13 deletions app/acme/dns_challenge.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,9 @@ var (
acmeV2Enpoint = "https://acme-v02.api.letsencrypt.org/directory"
)

// Acmer is an interface for ACME client
type acmer interface {
Register(context.Context, *acme.Account, func(string) bool) (*acme.Account, error)
GetAuthorization(context.Context, string) (*acme.Authorization, error)
GetChallenge(context.Context, string) (*acme.Challenge, error)
DNS01ChallengeRecord(string) (string, error)
Accept(context.Context, *acme.Challenge) (*acme.Challenge, error)
WaitAuthorization(context.Context, string) (*acme.Authorization, error)
AuthorizeOrder(ctx context.Context, id []acme.AuthzID, opt ...acme.OrderOption) (*acme.Order, error)
CreateOrderCert(ctx context.Context, url string, csr []byte, bundle bool) (der [][]byte, certURL string, err error)
}

// DNSChallenge represents an ACME DNS challenge
type DNSChallenge struct {
client acmer
client *acme.Client
accountKey *rsa.PrivateKey
provider dnsprovider.Provider
nameservers []string
Expand Down Expand Up @@ -226,7 +214,10 @@ func (d *DNSChallenge) prepareOrder(domains []string) (*acme.Order, []dnsprovide
if err != nil {
return nil, nil, err
}

// according to ACME spec, authorization objects are created in the "pending" state
if authz.Status != acme.StatusPending {
log.Printf("[ERROR] DNS-01 challenge for %v is not pending, with status %s", authz.Identifier.Value, authz.Status)
continue
}

Expand Down

0 comments on commit 1c4d990

Please sign in to comment.