mirror of
https://github.com/go-acme/lego.git
synced 2024-12-26 11:18:00 +02:00
Fix validateFunc tests
This commit is contained in:
parent
09ff568758
commit
3a3baf1597
@ -130,15 +130,15 @@ func TestValidate(t *testing.T) {
|
||||
}{
|
||||
{"POST-unexpected", []string{"weird"}, "unexpected"},
|
||||
{"POST-valid", []string{"valid"}, ""},
|
||||
{"POST-invalid", []string{"invalid"}, "not validate"},
|
||||
{"POST-invalid", []string{"invalid"}, "Error Detail"},
|
||||
{"GET-unexpected", []string{"pending", "weird"}, "unexpected"},
|
||||
{"GET-valid", []string{"pending", "valid"}, ""},
|
||||
{"GET-invalid", []string{"pending", "invalid"}, "not validate"},
|
||||
{"GET-invalid", []string{"pending", "invalid"}, "Error Detail"},
|
||||
}
|
||||
|
||||
for _, tst := range tsts {
|
||||
statuses = tst.statuses
|
||||
if err := validate(j, ts.URL, challenge{Type: "http-01", Token: "token"}); err == nil && tst.want != "" {
|
||||
if err := validate(j, "example.com", ts.URL, challenge{Type: "http-01", Token: "token"}); err == nil && tst.want != "" {
|
||||
t.Errorf("[%s] validate: got error %v, want something with %q", tst.name, err, tst.want)
|
||||
} else if err != nil && !strings.Contains(err.Error(), tst.want) {
|
||||
t.Errorf("[%s] validate: got error %v, want something with %q", tst.name, err, tst.want)
|
||||
@ -161,7 +161,7 @@ func writeJSONResponse(w http.ResponseWriter, body interface{}) {
|
||||
}
|
||||
|
||||
// stubValidate is like validate, except it does nothing.
|
||||
func stubValidate(j *jws, uri string, chlng challenge) error {
|
||||
func stubValidate(j *jws, domain, uri string, chlng challenge) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ func TestHTTPChallenge(t *testing.T) {
|
||||
privKey, _ := generatePrivateKey(rsakey, 512)
|
||||
j := &jws{privKey: privKey.(*rsa.PrivateKey)}
|
||||
clientChallenge := challenge{Type: "http-01", Token: "http1"}
|
||||
mockValidate := func(_ *jws, _ string, chlng challenge) error {
|
||||
mockValidate := func(_ *jws, _, _ string, chlng challenge) error {
|
||||
uri := "http://localhost:23457/.well-known/acme-challenge/" + chlng.Token
|
||||
resp, err := http.Get(uri)
|
||||
if err != nil {
|
||||
|
@ -14,7 +14,7 @@ func TestTLSSNIChallenge(t *testing.T) {
|
||||
privKey, _ := generatePrivateKey(rsakey, 512)
|
||||
j := &jws{privKey: privKey.(*rsa.PrivateKey)}
|
||||
clientChallenge := challenge{Type: "tls-sni-01", Token: "tlssni1"}
|
||||
mockValidate := func(_ *jws, _ string, chlng challenge) error {
|
||||
mockValidate := func(_ *jws, _, _ string, chlng challenge) error {
|
||||
conn, err := tls.Dial("tcp", "localhost:23457", &tls.Config{
|
||||
InsecureSkipVerify: true,
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user