Integration tests should use a helper func to infer Supervisor's downstream issuer URL

This commit is contained in:
Joshua Casey
2024-07-23 14:43:38 -05:00
committed by Ryan Richard
parent afec420ce6
commit 0f9352db3b
6 changed files with 21 additions and 25 deletions

View File

@@ -5,6 +5,7 @@ package testlib
import (
"encoding/base64"
"net/url"
"os"
"sort"
"strings"
@@ -83,6 +84,20 @@ type TestOIDCUpstream struct {
ExpectedGroups []string `json:"expectedGroups"`
}
// InferTheIssuerURL infers the downstream issuer URL from the callback associated with the upstream test client registration.
func (upstream *TestOIDCUpstream) InferTheIssuerURL(t *testing.T) (*url.URL, string) {
t.Helper()
issuerURL, err := url.Parse(upstream.CallbackURL)
require.NoError(t, err)
require.True(t, strings.HasSuffix(issuerURL.Path, "/callback"))
issuerURL.Path = strings.TrimSuffix(issuerURL.Path, "/callback")
issuerAsString := issuerURL.String()
t.Logf("testing with downstream issuer URL %s", issuerAsString)
return issuerURL, issuerAsString
}
type TestLDAPUpstream struct {
Host string `json:"host"`
Domain string `json:"domain"`