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/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
|
"path"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/xenolf/lego/challenge/dns01"
|
"github.com/xenolf/lego/challenge/dns01"
|
||||||
|
@ -158,7 +159,8 @@ func (d *DNSProvider) doPost(uri string, msg interface{}) error {
|
||||||
return err
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"path"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
@ -104,6 +105,7 @@ func TestNewDNSProvider_Present(t *testing.T) {
|
||||||
mode string
|
mode string
|
||||||
username string
|
username string
|
||||||
password string
|
password string
|
||||||
|
pathPrefix string
|
||||||
handler http.HandlerFunc
|
handler http.HandlerFunc
|
||||||
expectedError string
|
expectedError string
|
||||||
}{
|
}{
|
||||||
|
@ -111,6 +113,11 @@ func TestNewDNSProvider_Present(t *testing.T) {
|
||||||
desc: "success",
|
desc: "success",
|
||||||
handler: successHandler,
|
handler: successHandler,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
desc: "success with path prefix",
|
||||||
|
handler: successHandler,
|
||||||
|
pathPrefix: "/api/acme/",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
desc: "error",
|
desc: "error",
|
||||||
handler: http.NotFound,
|
handler: http.NotFound,
|
||||||
|
@ -150,11 +157,11 @@ func TestNewDNSProvider_Present(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
mux := http.NewServeMux()
|
mux := http.NewServeMux()
|
||||||
mux.HandleFunc("/present", test.handler)
|
mux.HandleFunc(path.Join("/", test.pathPrefix, "present"), test.handler)
|
||||||
server := httptest.NewServer(mux)
|
server := httptest.NewServer(mux)
|
||||||
|
|
||||||
config := NewDefaultConfig()
|
config := NewDefaultConfig()
|
||||||
config.Endpoint = mustParse(server.URL)
|
config.Endpoint = mustParse(server.URL + test.pathPrefix)
|
||||||
config.Mode = test.mode
|
config.Mode = test.mode
|
||||||
config.Username = test.username
|
config.Username = test.username
|
||||||
config.Password = test.password
|
config.Password = test.password
|
||||||
|
|
Loading…
Reference in a new issue