fix: custom absolute endpoints

This commit is contained in:
Livio Amstutz 2020-02-21 10:04:50 +01:00
parent 30d8dec409
commit 660519a19f
4 changed files with 41 additions and 16 deletions

View file

@ -6,7 +6,7 @@ import (
"github.com/caos/oidc/pkg/op"
)
func TestEndpoint_Relative(t *testing.T) {
func TestEndpoint_Path(t *testing.T) {
tests := []struct {
name string
e op.Endpoint
@ -14,12 +14,17 @@ func TestEndpoint_Relative(t *testing.T) {
}{
{
"without starting /",
op.Endpoint("test"),
op.NewEndpoint("test"),
"/test",
},
{
"with starting /",
op.Endpoint("/test"),
op.NewEndpoint("/test"),
"/test",
},
{
"with url",
op.NewEndpointWithURL("/test", "http://test.com/test"),
"/test",
},
}
@ -44,28 +49,34 @@ func TestEndpoint_Absolute(t *testing.T) {
}{
{
"no /",
op.Endpoint("test"),
op.NewEndpoint("test"),
args{"https://host"},
"https://host/test",
},
{
"endpoint without /",
op.Endpoint("test"),
op.NewEndpoint("test"),
args{"https://host/"},
"https://host/test",
},
{
"host without /",
op.Endpoint("/test"),
op.NewEndpoint("/test"),
args{"https://host"},
"https://host/test",
},
{
"both /",
op.Endpoint("/test"),
op.NewEndpoint("/test"),
args{"https://host/"},
"https://host/test",
},
{
"with url",
op.NewEndpointWithURL("test", "https://test.com/test"),
args{"https://host"},
"https://test.com/test",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {