chore: fix some eventual consistent integration testing (#10752)

# Which Problems Are Solved

Flakiness in integration tests because of eventual consistentcy.

# How the Problems Are Solved

Split tests related to feature flags and other eventual consistent
resources.

# Additional Changes

None

# Additional Context

None

Co-authored-by: Marco A. <[email protected]>
This commit is contained in:
Stefan Benz
2025-10-14 18:24:09 +02:00
committed by GitHub
co-authored by Marco A.
parent 15bcd46709
commit a8bbac37d9
21 changed files with 2100 additions and 731 deletions
@@ -17,9 +17,11 @@ import (
"github.com/zitadel/zitadel/internal/integration"
"github.com/zitadel/zitadel/pkg/grpc/app"
filter "github.com/zitadel/zitadel/pkg/grpc/filter/v2beta"
mgmt "github.com/zitadel/zitadel/pkg/grpc/management"
"github.com/zitadel/zitadel/pkg/grpc/object/v2"
oidc_pb "github.com/zitadel/zitadel/pkg/grpc/oidc/v2"
project_v2beta "github.com/zitadel/zitadel/pkg/grpc/project/v2beta"
"github.com/zitadel/zitadel/pkg/grpc/session/v2"
)
@@ -624,7 +626,7 @@ func TestServer_CreateCallback_Permission(t *testing.T) {
projectID, clientID := createOIDCApplication(ctx, t, false, true)
orgResp := Instance.CreateOrganization(ctx, integration.OrganizationName(), integration.Email())
Instance.CreateProjectGrant(ctx, t, projectID, orgResp.GetOrganizationId())
createProjectGrant(ctx, t, projectID, orgResp.GetOrganizationId())
user := Instance.CreateHumanUserVerified(ctx, orgResp.GetOrganizationId(), integration.Email(), integration.Phone())
return createSessionAndAuthRequestForCallback(ctx, t, clientID, Instance.Users.Get(integration.UserTypeLogin).ID, user.GetUserId())
@@ -939,6 +941,26 @@ func createOIDCApplication(ctx context.Context, t *testing.T, projectRoleCheck,
return project.GetId(), clientV2.GetClientId()
}
func createProjectGrant(ctx context.Context, t *testing.T, projectID, grantedOrgID string) {
Instance.CreateProjectGrant(ctx, t, projectID, grantedOrgID)
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(ctx, time.Minute)
require.EventuallyWithT(t, func(collect *assert.CollectT) {
resp, err := Instance.Client.Projectv2Beta.ListProjectGrants(ctx, &project_v2beta.ListProjectGrantsRequest{
Filters: []*project_v2beta.ProjectGrantSearchFilter{
{Filter: &project_v2beta.ProjectGrantSearchFilter_InProjectIdsFilter{InProjectIdsFilter: &filter.InIDsFilter{
Ids: []string{projectID},
}}},
{Filter: &project_v2beta.ProjectGrantSearchFilter_ProjectGrantResourceOwnerFilter{ProjectGrantResourceOwnerFilter: &filter.IDFilter{
Id: grantedOrgID,
}}},
},
})
assert.NoError(collect, err)
assert.Len(collect, resp.GetProjectGrants(), 1)
}, retryDuration, tick)
}
func createProjectUserGrant(ctx context.Context, t *testing.T, orgID, projectID, userID string) {
resp := Instance.CreateAuthorizationProject(t, ctx, projectID, userID)