chore: move gofakeit integration testing calls (#10684)

# Which Problems Are Solved

Flakiness and conflicts in value from gofakeit.

# How the Problems Are Solved

Move Gofakeit calls to the integration package, to guarantee proper
usage and values for integration testing.

# Additional Changes

None

# Additional Context

None
This commit is contained in:
Stefan Benz
2025-09-10 09:00:31 +03:00
committed by GitHub
parent b9b9baf67f
commit 492f1826ee
71 changed files with 1083 additions and 980 deletions
@@ -13,7 +13,6 @@ import (
"text/template"
"time"
"github.com/brianvoe/gofakeit/v6"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/text/language"
@@ -173,7 +172,7 @@ func withUsername(fixture []byte, username string) []byte {
}
func TestCreateUser(t *testing.T) {
minimalUsername := gofakeit.Username()
minimalUsername := integration.Username()
tests := []struct {
name string
body []byte
@@ -278,21 +277,21 @@ func TestCreateUser(t *testing.T) {
},
{
name: "not authenticated",
body: withUsername(minimalUserJson, gofakeit.Username()),
body: withUsername(minimalUserJson, integration.Username()),
ctx: context.Background(),
wantErr: true,
errorStatus: http.StatusUnauthorized,
},
{
name: "no permissions",
body: withUsername(minimalUserJson, gofakeit.Username()),
body: withUsername(minimalUserJson, integration.Username()),
ctx: Instance.WithAuthorization(CTX, integration.UserTypeNoPermission),
wantErr: true,
errorStatus: http.StatusNotFound,
},
{
name: "another org",
body: withUsername(minimalUserJson, gofakeit.Username()),
body: withUsername(minimalUserJson, integration.Username()),
orgID: SecondaryOrganization.OrganizationId,
wantErr: true,
errorStatus: http.StatusNotFound,
@@ -356,7 +355,7 @@ func TestCreateUser(t *testing.T) {
}
func TestCreateUser_duplicate(t *testing.T) {
parsedMinimalUserJson := withUsername(minimalUserJson, gofakeit.Username())
parsedMinimalUserJson := withUsername(minimalUserJson, integration.Username())
createdUser, err := Instance.Client.SCIM.Users.Create(CTX, Instance.DefaultOrg.Id, parsedMinimalUserJson)
require.NoError(t, err)
@@ -370,7 +369,7 @@ func TestCreateUser_duplicate(t *testing.T) {
}
func TestCreateUser_metadata(t *testing.T) {
username := gofakeit.Username()
username := integration.Username()
createdUser, err := Instance.Client.SCIM.Users.Create(CTX, Instance.DefaultOrg.Id, withUsername(fullUserJson, username))
require.NoError(t, err)
@@ -408,7 +407,7 @@ func TestCreateUser_scopedExternalID(t *testing.T) {
require.NoError(t, err)
ctx := integration.WithAuthorizationToken(CTX, callingUserPat)
setProvisioningDomain(t, callingUserId, "fooBar")
createdUser, err := Instance.Client.SCIM.Users.Create(ctx, Instance.DefaultOrg.Id, withUsername(fullUserJson, gofakeit.Username()))
createdUser, err := Instance.Client.SCIM.Users.Create(ctx, Instance.DefaultOrg.Id, withUsername(fullUserJson, integration.Username()))
require.NoError(t, err)
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(ctx, time.Minute)
require.EventuallyWithT(t, func(tt *assert.CollectT) {