chore: fix flakiness in gofakeit usage with additional random string (#10385)

# Which Problems Are Solved

Flakiness in integration tests regarding gofakeit functions, which
provided the same names on 2 different occasions.

# How the Problems Are Solved

Attach a random string to the provided names, so that they are not
dependent on the gofakeit code.

# Additional Changes

None

# Additional Context

None

---------

Co-authored-by: Marco A. <marco@zitadel.com>
This commit is contained in:
Stefan Benz
2025-08-07 15:27:01 +02:00
committed by GitHub
parent a96f4708cb
commit 6e8aa9a7d1
31 changed files with 700 additions and 665 deletions

View File

@@ -13,12 +13,13 @@ import (
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"github.com/zitadel/zitadel/internal/integration"
app "github.com/zitadel/zitadel/pkg/grpc/app/v2beta"
org "github.com/zitadel/zitadel/pkg/grpc/org/v2beta"
)
func TestCreateApplication(t *testing.T) {
p := instance.CreateProject(IAMOwnerCtx, t, instance.DefaultOrg.GetId(), gofakeit.Name(), false, false)
p := instance.CreateProject(IAMOwnerCtx, t, instance.DefaultOrg.GetId(), integration.ProjectName(), false, false)
t.Parallel()
@@ -202,7 +203,7 @@ func TestCreateApplication_WithDifferentPermissions(t *testing.T) {
inputCtx: LoginUserCtx,
creationRequest: &app.CreateApplicationRequest{
ProjectId: p.GetId(),
Name: gofakeit.Name(),
Name: integration.ApplicationName(),
CreationRequestType: &app.CreateApplicationRequest_ApiRequest{
ApiRequest: &app.CreateAPIApplicationRequest{
AuthMethodType: app.APIAuthMethodType_API_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT,
@@ -271,7 +272,7 @@ func TestCreateApplication_WithDifferentPermissions(t *testing.T) {
inputCtx: OrgOwnerCtx,
creationRequest: &app.CreateApplicationRequest{
ProjectId: p.GetId(),
Name: gofakeit.Name(),
Name: integration.ApplicationName(),
CreationRequestType: &app.CreateApplicationRequest_ApiRequest{
ApiRequest: &app.CreateAPIApplicationRequest{
AuthMethodType: app.APIAuthMethodType_API_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT,
@@ -340,7 +341,7 @@ func TestCreateApplication_WithDifferentPermissions(t *testing.T) {
inputCtx: projectOwnerCtx,
creationRequest: &app.CreateApplicationRequest{
ProjectId: p.GetId(),
Name: gofakeit.Name(),
Name: integration.ApplicationName(),
CreationRequestType: &app.CreateApplicationRequest_ApiRequest{
ApiRequest: &app.CreateAPIApplicationRequest{
AuthMethodType: app.APIAuthMethodType_API_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT,
@@ -421,10 +422,10 @@ func TestCreateApplication_WithDifferentPermissions(t *testing.T) {
}
func TestUpdateApplication(t *testing.T) {
orgNotInCtx := instance.CreateOrganization(IAMOwnerCtx, gofakeit.Name(), gofakeit.Email())
orgNotInCtx := instance.CreateOrganization(IAMOwnerCtx, integration.ProjectName(), gofakeit.Email())
pNotInCtx := instance.CreateProject(IAMOwnerCtx, t, orgNotInCtx.GetOrganizationId(), gofakeit.AppName(), false, false)
p := instance.CreateProject(IAMOwnerCtx, t, instance.DefaultOrg.GetId(), gofakeit.Name(), false, false)
p := instance.CreateProject(IAMOwnerCtx, t, instance.DefaultOrg.GetId(), integration.ProjectName(), false, false)
baseURI := "http://example.com"
@@ -855,7 +856,7 @@ func TestUpdateApplication_WithDifferentPermissions(t *testing.T) {
}
func TestDeleteApplication(t *testing.T) {
p := instance.CreateProject(IAMOwnerCtx, t, instance.DefaultOrg.GetId(), gofakeit.Name(), false, false)
p := instance.CreateProject(IAMOwnerCtx, t, instance.DefaultOrg.GetId(), integration.ProjectName(), false, false)
reqForAppNameCreation := &app.CreateApplicationRequest_ApiRequest{
ApiRequest: &app.CreateAPIApplicationRequest{AuthMethodType: app.APIAuthMethodType_API_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT},
@@ -975,7 +976,7 @@ func TestDeleteApplication_WithDifferentPermissions(t *testing.T) {
}
func TestDeactivateApplication(t *testing.T) {
p := instance.CreateProject(IAMOwnerCtx, t, instance.DefaultOrg.GetId(), gofakeit.Name(), false, false)
p := instance.CreateProject(IAMOwnerCtx, t, instance.DefaultOrg.GetId(), integration.ProjectName(), false, false)
reqForAppNameCreation := &app.CreateApplicationRequest_ApiRequest{
ApiRequest: &app.CreateAPIApplicationRequest{AuthMethodType: app.APIAuthMethodType_API_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT},
@@ -1096,7 +1097,7 @@ func TestDeactivateApplication_WithDifferentPermissions(t *testing.T) {
}
func TestReactivateApplication(t *testing.T) {
p := instance.CreateProject(IAMOwnerCtx, t, instance.DefaultOrg.GetId(), gofakeit.Name(), false, false)
p := instance.CreateProject(IAMOwnerCtx, t, instance.DefaultOrg.GetId(), integration.ProjectName(), false, false)
reqForAppNameCreation := &app.CreateApplicationRequest_ApiRequest{
ApiRequest: &app.CreateAPIApplicationRequest{AuthMethodType: app.APIAuthMethodType_API_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT},
@@ -1229,7 +1230,7 @@ func TestReactivateApplication_WithDifferentPermissions(t *testing.T) {
}
func TestRegenerateClientSecret(t *testing.T) {
p := instance.CreateProject(IAMOwnerCtx, t, instance.DefaultOrg.GetId(), gofakeit.Name(), false, false)
p := instance.CreateProject(IAMOwnerCtx, t, instance.DefaultOrg.GetId(), integration.ProjectName(), false, false)
reqForApiAppCreation := &app.CreateApplicationRequest_ApiRequest{
ApiRequest: &app.CreateAPIApplicationRequest{AuthMethodType: app.APIAuthMethodType_API_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT},

View File

@@ -23,7 +23,7 @@ import (
func TestGetApplication(t *testing.T) {
p, projectOwnerCtx := getProjectAndProjectContext(t, instance, IAMOwnerCtx)
apiAppName := gofakeit.AppName()
apiAppName := integration.ApplicationName()
createdApiApp, errAPIAppCreation := instance.Client.AppV2Beta.CreateApplication(IAMOwnerCtx, &app.CreateApplicationRequest{
ProjectId: p.GetId(),
Name: apiAppName,
@@ -35,7 +35,7 @@ func TestGetApplication(t *testing.T) {
})
require.Nil(t, errAPIAppCreation)
samlAppName := gofakeit.AppName()
samlAppName := integration.ApplicationName()
createdSAMLApp, errSAMLAppCreation := instance.Client.AppV2Beta.CreateApplication(IAMOwnerCtx, &app.CreateApplicationRequest{
ProjectId: p.GetId(),
Name: samlAppName,
@@ -48,7 +48,7 @@ func TestGetApplication(t *testing.T) {
})
require.Nil(t, errSAMLAppCreation)
oidcAppName := gofakeit.AppName()
oidcAppName := integration.ApplicationName()
createdOIDCApp, errOIDCAppCreation := instance.Client.AppV2Beta.CreateApplication(IAMOwnerCtx, &app.CreateApplicationRequest{
ProjectId: p.GetId(),
Name: oidcAppName,
@@ -464,7 +464,7 @@ func TestListApplications_WithPermissionV2(t *testing.T) {
p, projectOwnerCtx := getProjectAndProjectContext(t, instancePermissionV2, iamOwnerCtx)
_, otherProjectOwnerCtx := getProjectAndProjectContext(t, instancePermissionV2, iamOwnerCtx)
appName1, appName2, appName3 := gofakeit.AppName(), gofakeit.AppName(), gofakeit.AppName()
appName1, appName2, appName3 := integration.ApplicationName(), integration.ApplicationName(), integration.ApplicationName()
reqForAPIAppCreation := &app.CreateApplicationRequest_ApiRequest{
ApiRequest: &app.CreateAPIApplicationRequest{AuthMethodType: app.APIAuthMethodType_API_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT},
}

View File

@@ -52,7 +52,7 @@ func TestMain(m *testing.M) {
}
func getProjectAndProjectContext(t *testing.T, inst *integration.Instance, ctx context.Context) (*project_v2beta.CreateProjectResponse, context.Context) {
project := inst.CreateProject(ctx, t, inst.DefaultOrg.GetId(), gofakeit.Name(), false, false)
project := inst.CreateProject(ctx, t, inst.DefaultOrg.GetId(), integration.ProjectName(), false, false)
userResp := inst.CreateMachineUser(ctx)
patResp := inst.CreatePersonalAccessToken(ctx, userResp.GetUserId())
inst.CreateProjectMembership(t, ctx, project.GetId(), userResp.GetUserId())
@@ -83,7 +83,7 @@ func samlMetadataGen(entityID string) []byte {
func createSAMLAppWithName(t *testing.T, baseURI, projectID string) ([]byte, *app.CreateApplicationResponse, string) {
samlMetas := samlMetadataGen(gofakeit.URL())
appName := gofakeit.AppName()
appName := integration.ApplicationName()
appForSAMLConfigChange, appSAMLConfigChangeErr := instance.Client.AppV2Beta.CreateApplication(IAMOwnerCtx, &app.CreateApplicationRequest{
ProjectId: projectID,
@@ -114,7 +114,7 @@ func createSAMLApp(t *testing.T, baseURI, projectID string) ([]byte, *app.Create
}
func createOIDCAppWithName(t *testing.T, baseURI, projectID string) (*app.CreateApplicationResponse, string) {
appName := gofakeit.AppName()
appName := integration.ApplicationName()
appForOIDCConfigChange, appOIDCConfigChangeErr := instance.Client.AppV2Beta.CreateApplication(IAMOwnerCtx, &app.CreateApplicationRequest{
ProjectId: projectID,
@@ -152,7 +152,7 @@ func createOIDCApp(t *testing.T, baseURI, projctID string) *app.CreateApplicatio
}
func createAPIAppWithName(t *testing.T, ctx context.Context, inst *integration.Instance, projectID string) (*app.CreateApplicationResponse, string) {
appName := gofakeit.AppName()
appName := integration.ApplicationName()
reqForAPIAppCreation := &app.CreateApplicationRequest_ApiRequest{
ApiRequest: &app.CreateAPIApplicationRequest{AuthMethodType: app.APIAuthMethodType_API_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT},