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. <marco@zitadel.com>
(cherry picked from commit a8bbac37d9)
This commit is contained in:
Stefan Benz
2025-10-14 18:24:09 +02:00
committed by Livio Spring
parent f506fedcfe
commit 99d3d955b9
21 changed files with 2100 additions and 731 deletions

View File

@@ -17,8 +17,10 @@ import (
"google.golang.org/protobuf/types/known/timestamppb"
"github.com/zitadel/zitadel/internal/integration"
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"
project_v2beta "github.com/zitadel/zitadel/pkg/grpc/project/v2beta"
saml_pb "github.com/zitadel/zitadel/pkg/grpc/saml/v2"
"github.com/zitadel/zitadel/pkg/grpc/session/v2"
)
@@ -609,7 +611,7 @@ func TestServer_CreateResponse_Permission(t *testing.T) {
dep: func(ctx context.Context, t *testing.T) *saml_pb.CreateResponseRequest {
projectID, _, sp := createSAMLApplication(ctx, t, idpMetadata, saml.HTTPRedirectBinding, 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 createSessionAndSmlRequestForCallback(ctx, t, sp, Instance.Users[integration.UserTypeLogin].ID, acsRedirect, user.GetUserId(), saml.HTTPRedirectBinding)
@@ -693,6 +695,26 @@ func createSAMLApplication(ctx context.Context, t *testing.T, idpMetadata *saml.
return project.GetId(), rootURL, sp
}
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)