chore: add oidc idp for acceptance tests

This commit is contained in:
Stefan Benz
2025-03-27 09:50:06 +01:00
parent 56a2316973
commit e5604edff8
7 changed files with 348 additions and 37 deletions

View File

@@ -87,28 +87,18 @@ FHHEZ+dR4eMaJp6PhNm8hu2O
}()
func hello(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello, %s!", samlsp.AttributeFromContext(r.Context(), "displayName"))
fmt.Fprintf(w, "Hello, %s!", samlsp.AttributeFromContext(r.Context(), "UserName"))
}
func main() {
apiURL := os.Getenv("API_URL")
patFile := os.Getenv("PAT_FILE")
pat := readPAT(os.Getenv("PAT_FILE"))
domain := os.Getenv("API_DOMAIN")
loginURL := os.Getenv("LOGIN_URL")
idpURL := os.Getenv("IDP_URL")
host := os.Getenv("HOST")
port := os.Getenv("PORT")
f, err := os.Open(patFile)
if err != nil {
panic(err)
}
pat, err := io.ReadAll(f)
if err != nil {
panic(err)
}
patStr := strings.Trim(string(pat), "\n")
idpMetadataURL, err := url.Parse(idpURL)
if err != nil {
panic(err)
@@ -151,7 +141,7 @@ func main() {
if err != nil {
panic(err)
}
if err := createZitadelResources(apiURL, patStr, domain, metadata, loginURL); err != nil {
if err := createZitadelResources(apiURL, pat, domain, metadata, loginURL); err != nil {
panic(err)
}
@@ -167,6 +157,18 @@ func main() {
}
}
func readPAT(path string) string {
f, err := os.Open(path)
if err != nil {
panic(err)
}
pat, err := io.ReadAll(f)
if err != nil {
panic(err)
}
return strings.Trim(string(pat), "\n")
}
func createZitadelResources(apiURL, pat, domain string, metadata []byte, loginURL string) error {
projectID, err := CreateProject(apiURL, pat, domain)
if err != nil {