mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-06 17:22:28 +00:00
chore: use integration package for name generation (#10591)
# Which Problems Are Solved
Integration test failed sometimes with `organization already
exists`-errors.
# How the Problems Are Solved
Use a consistent function to generate name used for organization
creation.
# Additional Changes
Correct a eventual consistent test for username around organization
domain changes with eventual consistent loop.
# Additional Context
None
---------
Co-authored-by: Livio Spring <livio.a@gmail.com>
(cherry picked from commit 5721b63bcb)
This commit is contained in:
committed by
Livio Spring
parent
678f9ad448
commit
d0d8e904c4
@@ -106,7 +106,7 @@ func TestServer_ListOrganizations(t *testing.T) {
|
||||
func(ctx context.Context, request *org.ListOrganizationsRequest) ([]orgAttr, error) {
|
||||
count := 3
|
||||
orgs := make([]orgAttr, count)
|
||||
prefix := fmt.Sprintf("ListOrgs-%s", gofakeit.AppName())
|
||||
prefix := integration.OrganizationName()
|
||||
for i := 0; i < count; i++ {
|
||||
name := prefix + strconv.Itoa(i)
|
||||
orgs[i] = createOrganization(ctx, name)
|
||||
@@ -275,8 +275,7 @@ func TestServer_ListOrganizations(t *testing.T) {
|
||||
&org.ListOrganizationsRequest{},
|
||||
func(ctx context.Context, request *org.ListOrganizationsRequest) ([]orgAttr, error) {
|
||||
orgs := make([]orgAttr, 1)
|
||||
name := fmt.Sprintf("ListOrgs-%s", gofakeit.AppName())
|
||||
orgs[0] = createOrganization(ctx, name)
|
||||
orgs[0] = createOrganization(ctx, integration.OrganizationName())
|
||||
domain := gofakeit.DomainName()
|
||||
_, err := Instance.Client.Mgmt.AddOrgDomain(integration.SetOrgID(ctx, orgs[0].ID), &management.AddOrgDomainRequest{
|
||||
Domain: domain,
|
||||
@@ -311,7 +310,7 @@ func TestServer_ListOrganizations(t *testing.T) {
|
||||
Queries: []*org.SearchQuery{},
|
||||
},
|
||||
func(ctx context.Context, request *org.ListOrganizationsRequest) ([]orgAttr, error) {
|
||||
name := gofakeit.Name()
|
||||
name := integration.OrganizationName()
|
||||
orgResp := createOrganization(ctx, name)
|
||||
deactivateOrgResp := Instance.DeactivateOrganization(ctx, orgResp.ID)
|
||||
request.Queries = []*org.SearchQuery{
|
||||
|
||||
@@ -1132,29 +1132,31 @@ func TestServer_AddOrganizationDomain_ClaimDomain(t *testing.T) {
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
// check both users: the first one must be untouched, the second one must be updated
|
||||
users, err := Instance.Client.UserV2.ListUsers(CTX, &user.ListUsersRequest{
|
||||
Queries: []*user.SearchQuery{
|
||||
{
|
||||
Query: &user.SearchQuery_InUserIdsQuery{
|
||||
InUserIdsQuery: &user.InUserIDQuery{UserIds: []string{ownUser.GetUserId(), otherUser.GetUserId()}},
|
||||
require.EventuallyWithT(t, func(collect *assert.CollectT) {
|
||||
// check both users: the first one must be untouched, the second one must be updated
|
||||
users, err := Instance.Client.UserV2.ListUsers(CTX, &user.ListUsersRequest{
|
||||
Queries: []*user.SearchQuery{
|
||||
{
|
||||
Query: &user.SearchQuery_InUserIdsQuery{
|
||||
InUserIdsQuery: &user.InUserIDQuery{UserIds: []string{ownUser.GetUserId(), otherUser.GetUserId()}},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.Len(t, users.GetResult(), 2)
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.Len(t, users.GetResult(), 2)
|
||||
|
||||
for _, u := range users.GetResult() {
|
||||
if u.GetUserId() == ownUser.GetUserId() {
|
||||
assert.Equal(t, username, u.GetPreferredLoginName())
|
||||
continue
|
||||
for _, u := range users.GetResult() {
|
||||
if u.GetUserId() == ownUser.GetUserId() {
|
||||
assert.Equal(collect, username, u.GetPreferredLoginName())
|
||||
continue
|
||||
}
|
||||
if u.GetUserId() == otherUser.GetUserId() {
|
||||
assert.NotEqual(collect, otherUsername, u.GetPreferredLoginName())
|
||||
assert.Contains(collect, u.GetPreferredLoginName(), "@temporary.")
|
||||
}
|
||||
}
|
||||
if u.GetUserId() == otherUser.GetUserId() {
|
||||
assert.NotEqual(t, otherUsername, u.GetPreferredLoginName())
|
||||
assert.Contains(t, u.GetPreferredLoginName(), "@temporary.")
|
||||
}
|
||||
}
|
||||
}, 5*time.Second, time.Second, "user not updated in time")
|
||||
}
|
||||
|
||||
func TestServer_ListOrganizationDomains(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user