forked from TrueCloudLab/lego
fix: endpoint with path. (#781)
This commit is contained in:
parent
3019d10801
commit
f05aa4c241
2 changed files with 12 additions and 3 deletions
|
@ -10,6 +10,7 @@ import (
|
|||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"path"
|
||||
"time"
|
||||
|
||||
"github.com/xenolf/lego/challenge/dns01"
|
||||
|
@ -158,7 +159,8 @@ func (d *DNSProvider) doPost(uri string, msg interface{}) error {
|
|||
return err
|
||||
}
|
||||
|
||||
endpoint, err := d.config.Endpoint.Parse(uri)
|
||||
newURI := path.Join(d.config.Endpoint.EscapedPath(), uri)
|
||||
endpoint, err := d.config.Endpoint.Parse(newURI)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
"path"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
@ -104,6 +105,7 @@ func TestNewDNSProvider_Present(t *testing.T) {
|
|||
mode string
|
||||
username string
|
||||
password string
|
||||
pathPrefix string
|
||||
handler http.HandlerFunc
|
||||
expectedError string
|
||||
}{
|
||||
|
@ -111,6 +113,11 @@ func TestNewDNSProvider_Present(t *testing.T) {
|
|||
desc: "success",
|
||||
handler: successHandler,
|
||||
},
|
||||
{
|
||||
desc: "success with path prefix",
|
||||
handler: successHandler,
|
||||
pathPrefix: "/api/acme/",
|
||||
},
|
||||
{
|
||||
desc: "error",
|
||||
handler: http.NotFound,
|
||||
|
@ -150,11 +157,11 @@ func TestNewDNSProvider_Present(t *testing.T) {
|
|||
t.Parallel()
|
||||
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc("/present", test.handler)
|
||||
mux.HandleFunc(path.Join("/", test.pathPrefix, "present"), test.handler)
|
||||
server := httptest.NewServer(mux)
|
||||
|
||||
config := NewDefaultConfig()
|
||||
config.Endpoint = mustParse(server.URL)
|
||||
config.Endpoint = mustParse(server.URL + test.pathPrefix)
|
||||
config.Mode = test.mode
|
||||
config.Username = test.username
|
||||
config.Password = test.password
|
||||
|
|
Loading…
Reference in a new issue