2025-01-09 12:46:36 +01:00
|
|
|
//go:build integration
|
|
|
|
|
|
|
|
package integration_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"os"
|
2025-01-29 15:23:56 +01:00
|
|
|
"regexp"
|
2025-01-09 12:46:36 +01:00
|
|
|
"testing"
|
|
|
|
"time"
|
2025-01-17 16:16:26 +01:00
|
|
|
|
2025-01-30 16:43:13 +01:00
|
|
|
"github.com/brianvoe/gofakeit/v6"
|
|
|
|
|
2025-01-17 16:16:26 +01:00
|
|
|
"github.com/zitadel/zitadel/internal/integration"
|
2025-01-30 16:43:13 +01:00
|
|
|
"github.com/zitadel/zitadel/pkg/grpc/org/v2"
|
2025-01-09 12:46:36 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2025-01-30 16:43:13 +01:00
|
|
|
Instance *integration.Instance
|
|
|
|
SecondaryOrganization *org.AddOrganizationResponse
|
|
|
|
CTX context.Context
|
2025-01-29 15:23:56 +01:00
|
|
|
|
|
|
|
// remove comments in the json, as the default golang json unmarshaler cannot handle them
|
|
|
|
// some test files (e.g. bulk, patch) are much easier to maintain with comments
|
|
|
|
removeCommentsRegex = regexp.MustCompile("(?s)//.*?\n|/\\*.*?\\*/")
|
2025-01-09 12:46:36 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestMain(m *testing.M) {
|
|
|
|
os.Exit(func() int {
|
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Minute)
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
Instance = integration.NewInstance(ctx)
|
|
|
|
|
|
|
|
CTX = Instance.WithAuthorization(ctx, integration.UserTypeOrgOwner)
|
2025-01-30 16:43:13 +01:00
|
|
|
|
|
|
|
iamOwnerCtx := Instance.WithAuthorization(CTX, integration.UserTypeIAMOwner)
|
|
|
|
SecondaryOrganization = Instance.CreateOrganization(iamOwnerCtx, gofakeit.Name(), gofakeit.Email())
|
|
|
|
|
2025-01-09 12:46:36 +01:00
|
|
|
return m.Run()
|
|
|
|
}())
|
|
|
|
}
|
2025-01-29 15:23:56 +01:00
|
|
|
|
|
|
|
func removeComments(json []byte) []byte {
|
|
|
|
return removeCommentsRegex.ReplaceAll(json, nil)
|
|
|
|
}
|