diff --git a/backend/v3/storage/database/events_testing/events_test.go b/backend/v3/storage/database/events_testing/events_test.go index e1bc903bea..8b9986e292 100644 --- a/backend/v3/storage/database/events_testing/events_test.go +++ b/backend/v3/storage/database/events_testing/events_test.go @@ -14,6 +14,7 @@ import ( "github.com/zitadel/zitadel/backend/v3/storage/database" "github.com/zitadel/zitadel/backend/v3/storage/database/dialect/postgres" "github.com/zitadel/zitadel/internal/integration" + "github.com/zitadel/zitadel/pkg/grpc/admin" v2beta_org "github.com/zitadel/zitadel/pkg/grpc/org/v2beta" "github.com/zitadel/zitadel/pkg/grpc/system" ) @@ -26,6 +27,7 @@ var ( Instance *integration.Instance SystemClient system.SystemServiceClient OrgClient v2beta_org.OrganizationServiceClient + AdminClient admin.AdminServiceClient ) var pool database.Pool @@ -40,6 +42,7 @@ func TestMain(m *testing.M) { CTX = Instance.WithAuthorization(ctx, integration.UserTypeIAMOwner) SystemClient = integration.SystemClient() OrgClient = Instance.Client.OrgV2beta + AdminClient = Instance.Client.Admin var err error dbConfig, err := pgxpool.ParseConfig(ConnString) diff --git a/backend/v3/storage/database/events_testing/idp_provider_test.go b/backend/v3/storage/database/events_testing/idp_provider_test.go new file mode 100644 index 0000000000..660e873ee0 --- /dev/null +++ b/backend/v3/storage/database/events_testing/idp_provider_test.go @@ -0,0 +1,64 @@ +//go:build integration + +package events_test + +import ( + "fmt" + "testing" + + "github.com/brianvoe/gofakeit/v6" + "github.com/stretchr/testify/require" + + "github.com/zitadel/zitadel/pkg/grpc/admin" + "github.com/zitadel/zitadel/pkg/grpc/idp" + v2beta_org "github.com/zitadel/zitadel/pkg/grpc/org/v2beta" +) + +func TestServer_TestIDProviderReduces(t *testing.T) { + // instanceID := Instance.ID() + + t.Run("test org add reduces", func(t *testing.T) { + // beforeCreate := time.Now() + orgName := gofakeit.Name() + + // create org + _, err := OrgClient.CreateOrganization(CTX, &v2beta_org.CreateOrganizationRequest{ + Name: orgName, + }) + require.NoError(t, err) + // afterCreate := time.Now() + + addOCID, err := AdminClient.AddOIDCIDP(CTX, &admin.AddOIDCIDPRequest{ + Name: gofakeit.Name(), + StylingType: idp.IDPStylingType_STYLING_TYPE_GOOGLE, + ClientId: "clientID", + ClientSecret: "clientSecret", + Issuer: "issuer", + Scopes: []string{"scope"}, + DisplayNameMapping: idp.OIDCMappingField_OIDC_MAPPING_FIELD_EMAIL, + UsernameMapping: idp.OIDCMappingField_OIDC_MAPPING_FIELD_EMAIL, + AutoRegister: true, + }) + fmt.Printf("@@ >>>>>>>>>>>>>>>>>>>>>>>>>>>> addOCID = %+v\n", addOCID) + fmt.Printf("@@ >>>>>>>>>>>>>>>>>>>>>>>>>>>> err = %+v\n", err) + + // idpRepo := repository.IDProviderRepository(pool) + + // retryDuration, tick := integration.WaitForAndTickWithMaxDuration(CTX, time.Minute) + // assert.EventuallyWithT(t, func(tt *assert.CollectT) { + // organization, err := idpRepo.Get(CTX, + // idpRepo.NameCondition(orgName), + // instanceID, + // ) + // require.NoError(tt, err) + + // // event org.added + // assert.NotNil(t, organization.ID) + // assert.Equal(t, orgName, organization.Name) + // assert.NotNil(t, organization.InstanceID) + // assert.Equal(t, domain.OrgStateActive.String(), organization.State) + // assert.WithinRange(t, organization.CreatedAt, beforeCreate, afterCreate) + // assert.WithinRange(t, organization.UpdatedAt, beforeCreate, afterCreate) + // }, retryDuration, tick) + }) +} diff --git a/backend/v3/storage/database/events_testing/instance_test.go b/backend/v3/storage/database/events_testing/instance_test.go index 576e65e020..fb8c82c344 100644 --- a/backend/v3/storage/database/events_testing/instance_test.go +++ b/backend/v3/storage/database/events_testing/instance_test.go @@ -10,6 +10,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/zitadel/zitadel/backend/v3/storage/database" "github.com/zitadel/zitadel/backend/v3/storage/database/repository" "github.com/zitadel/zitadel/internal/integration" "github.com/zitadel/zitadel/pkg/grpc/system" @@ -131,7 +132,8 @@ func TestServer_TestInstanceReduces(t *testing.T) { ) // event instance.removed assert.Nil(t, instance) - require.Equal(t, repository.ErrResourceDoesNotExist, err) + // require.Equal(t, repository.ErrResourceDoesNotExist, err) + require.ErrorIs(t, &database.NoRowFoundError{}, err) }, retryDuration, tick) }) } diff --git a/backend/v3/storage/database/events_testing/organization_test.go b/backend/v3/storage/database/events_testing/organization_test.go index 54c07e8ab1..d2bcc00db2 100644 --- a/backend/v3/storage/database/events_testing/organization_test.go +++ b/backend/v3/storage/database/events_testing/organization_test.go @@ -11,6 +11,7 @@ import ( "github.com/stretchr/testify/require" "github.com/zitadel/zitadel/backend/v3/domain" + "github.com/zitadel/zitadel/backend/v3/storage/database" "github.com/zitadel/zitadel/backend/v3/storage/database/repository" "github.com/zitadel/zitadel/internal/integration" v2beta_org "github.com/zitadel/zitadel/pkg/grpc/org/v2beta" @@ -208,7 +209,7 @@ func TestServer_TestOrganizationReduces(t *testing.T) { orgRepo.NameCondition(orgName), instanceID, ) - require.Equal(t, repository.ErrResourceDoesNotExist, err) + require.ErrorIs(t, &database.NoRowFoundError{}, err) // event org.remove assert.Nil(t, organization)