2019-03-11 16:56:48 +00:00
|
|
|
package resolver
|
2018-12-06 21:50:17 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
2019-07-30 19:19:32 +00:00
|
|
|
"github.com/go-acme/lego/v3/acme"
|
|
|
|
"github.com/go-acme/lego/v3/challenge"
|
2018-12-06 21:50:17 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type preSolverMock struct {
|
|
|
|
preSolve map[string]error
|
|
|
|
solve map[string]error
|
|
|
|
cleanUp map[string]error
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *preSolverMock) PreSolve(authorization acme.Authorization) error {
|
|
|
|
return s.preSolve[authorization.Identifier.Value]
|
|
|
|
}
|
|
|
|
func (s *preSolverMock) Solve(authorization acme.Authorization) error {
|
|
|
|
return s.solve[authorization.Identifier.Value]
|
|
|
|
}
|
|
|
|
func (s *preSolverMock) CleanUp(authorization acme.Authorization) error {
|
|
|
|
return s.cleanUp[authorization.Identifier.Value]
|
|
|
|
}
|
|
|
|
|
|
|
|
func createStubAuthorizationHTTP01(domain, status string) acme.Authorization {
|
|
|
|
return acme.Authorization{
|
|
|
|
Status: status,
|
|
|
|
Expires: time.Now(),
|
|
|
|
Identifier: acme.Identifier{
|
|
|
|
Type: challenge.HTTP01.String(),
|
|
|
|
Value: domain,
|
|
|
|
},
|
|
|
|
Challenges: []acme.Challenge{
|
|
|
|
{
|
|
|
|
Type: challenge.HTTP01.String(),
|
|
|
|
Validated: time.Now(),
|
|
|
|
Error: nil,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|