refactor: relational identity provider table and projection (#11739)

This commit is contained in:
Silvan
2026-03-05 09:43:14 +00:00
committed by GitHub
parent b33c811a01
commit 90faf440f4
9 changed files with 1465 additions and 2522 deletions
+27 -46
View File
@@ -40,7 +40,7 @@ const (
type IDPAutoLinkingField uint8 type IDPAutoLinkingField uint8
const ( const (
IDPAutoLinkingFieldUserName IDPAutoLinkingField = iota + 1 IDPAutoLinkingFieldUsername IDPAutoLinkingField = iota + 1
IDPAutoLinkingFieldEmail IDPAutoLinkingFieldEmail
) )
@@ -64,12 +64,10 @@ type IdentityProvider struct {
// Type represents the type of and idp. It is a pointer because it can be nil during the migration of the events // Type represents the type of and idp. It is a pointer because it can be nil during the migration of the events
Type *IDPType `json:"type,omitempty" db:"type"` Type *IDPType `json:"type,omitempty" db:"type"`
AllowCreation bool `json:"allowCreation,omitempty" db:"allow_creation"` AllowCreation bool `json:"allowCreation,omitempty" db:"allow_creation"`
AutoRegister bool `json:"autoRegister,omitempty" db:"auto_register"`
AllowAutoCreation bool `json:"allowAutoCreation,omitempty" db:"allow_auto_creation"` AllowAutoCreation bool `json:"allowAutoCreation,omitempty" db:"allow_auto_creation"`
AllowAutoUpdate bool `json:"allowAutoUpdate,omitempty" db:"allow_auto_update"` AllowAutoUpdate bool `json:"allowAutoUpdate,omitempty" db:"allow_auto_update"`
AllowLinking bool `json:"allowLinking,omitempty" db:"allow_linking"` AllowLinking bool `json:"allowLinking,omitempty" db:"allow_linking"`
AutoLinkingField *IDPAutoLinkingField `json:"autoLinkingField,omitempty" db:"auto_linking_field"` AutoLinkingField *IDPAutoLinkingField `json:"autoLinkingField,omitempty" db:"auto_linking_field"`
StylingType *int16 `json:"stylingType,omitempty" db:"styling_type"`
Payload json.RawMessage `json:"payload,omitempty" db:"payload"` Payload json.RawMessage `json:"payload,omitempty" db:"payload"`
CreatedAt time.Time `json:"createdAt,omitzero" db:"created_at"` CreatedAt time.Time `json:"createdAt,omitzero" db:"created_at"`
UpdatedAt time.Time `json:"updatedAt,omitzero" db:"updated_at"` UpdatedAt time.Time `json:"updatedAt,omitzero" db:"updated_at"`
@@ -191,16 +189,16 @@ type IDPGitlab struct {
Gitlab Gitlab
} }
type GitlabSelfHosting struct { type GitlabSelfHosted struct {
Issuer string `json:"issuer"` Issuer string `json:"issuer"`
ClientID string `json:"clientId,omitempty"` ClientID string `json:"clientId,omitempty"`
ClientSecret *crypto.CryptoValue `json:"clientSecret,omitempty"` ClientSecret *crypto.CryptoValue `json:"clientSecret,omitempty"`
Scopes []string `json:"scopes,omitempty"` Scopes []string `json:"scopes,omitempty"`
} }
type IDPGitlabSelfHosting struct { type IDPGitlabSelfHosted struct {
*IdentityProvider *IdentityProvider
GitlabSelfHosting GitlabSelfHosted
} }
type LDAP struct { type LDAP struct {
@@ -269,13 +267,6 @@ type IDPSAML struct {
SAML SAML
} }
// IDPIdentifierCondition is used to help specify a single identity_provider,
// it will either be used as the identity_provider ID or identity_provider name,
// as identity_provider can be identified either using (instanceID + OrganizationID + ID) OR (instanceID + OrganizationID + name)
type IDPIdentifierCondition interface {
database.Condition
}
type idProviderColumns interface { type idProviderColumns interface {
InstanceIDColumn() database.Column InstanceIDColumn() database.Column
OrgIDColumn() database.Column OrgIDColumn() database.Column
@@ -284,12 +275,10 @@ type idProviderColumns interface {
NameColumn() database.Column NameColumn() database.Column
TypeColumn() database.Column TypeColumn() database.Column
AllowCreationColumn() database.Column AllowCreationColumn() database.Column
AutoRegisterColumn() database.Column
AllowAutoCreationColumn() database.Column AllowAutoCreationColumn() database.Column
AllowAutoUpdateColumn() database.Column AllowAutoUpdateColumn() database.Column
AllowLinkingColumn() database.Column AllowLinkingColumn() database.Column
AllowAutoLinkingColumn() database.Column AutoLinkingFieldColumn() database.Column
StylingTypeColumn() database.Column
PayloadColumn() database.Column PayloadColumn() database.Column
CreatedAtColumn() database.Column CreatedAtColumn() database.Column
UpdatedAtColumn() database.Column UpdatedAtColumn() database.Column
@@ -300,32 +289,24 @@ type idProviderConditions interface {
PrimaryKeyCondition(instanceID, idpID string) database.Condition PrimaryKeyCondition(instanceID, idpID string) database.Condition
InstanceIDCondition(id string) database.Condition InstanceIDCondition(id string) database.Condition
OrgIDCondition(id *string) database.Condition OrgIDCondition(id *string) database.Condition
IDCondition(id string) IDPIdentifierCondition IDCondition(id string) database.Condition
StateCondition(state IDPState) database.Condition StateCondition(state IDPState) database.Condition
NameCondition(name string) IDPIdentifierCondition NameCondition(op database.TextOperation, name string) database.Condition
TypeCondition(typee IDPType) database.Condition TypeCondition(typee IDPType) database.Condition
AutoRegisterCondition(allow bool) database.Condition
AllowCreationCondition(allow bool) database.Condition
AllowAutoCreationCondition(allow bool) database.Condition
AllowAutoUpdateCondition(allow bool) database.Condition
AllowLinkingCondition(allow bool) database.Condition
AllowAutoLinkingCondition(linkingType IDPAutoLinkingField) database.Condition
StylingTypeCondition(style int16) database.Condition
PayloadCondition(payload string) database.Condition
} }
type idProviderChanges interface { type idProviderChanges interface {
SetName(name string) database.Change SetName(name string) database.Change
SetState(state IDPState) database.Change SetState(state IDPState) database.Change
SetAllowCreation(allow bool) database.Change SetAllowCreation(allow bool) database.Change
SetAutoRegister(allow bool) database.Change
SetAllowAutoCreation(allow bool) database.Change SetAllowAutoCreation(allow bool) database.Change
SetAllowAutoUpdate(allow bool) database.Change SetAllowAutoUpdate(allow bool) database.Change
SetAllowLinking(allow bool) database.Change SetAllowLinking(allow bool) database.Change
SetAutoAllowLinking(allow bool) database.Change SetAutoLinkingField(field *IDPAutoLinkingField) database.Change
SetStylingType(stylingType int16) database.Change
SetPayload(payload string) database.Change SetPayload(payload string) database.Change
SetUpdatedAt(createdAt *time.Time) database.Change SetUpdatedAt(updatedAt *time.Time) database.Change
// SetType is used for migrating generic idps to specific types.
SetType(typee IDPType) database.Change
} }
type IDProviderRepository interface { type IDProviderRepository interface {
@@ -335,25 +316,25 @@ type IDProviderRepository interface {
idProviderConditions idProviderConditions
idProviderChanges idProviderChanges
Get(ctx context.Context, client database.QueryExecutor, id IDPIdentifierCondition, instanceID string, orgID *string) (*IdentityProvider, error) Get(ctx context.Context, client database.QueryExecutor, opts ...database.QueryOption) (*IdentityProvider, error)
List(ctx context.Context, client database.QueryExecutor, conditions ...database.Condition) ([]*IdentityProvider, error) List(ctx context.Context, client database.QueryExecutor, opts ...database.QueryOption) ([]*IdentityProvider, error)
Create(ctx context.Context, client database.QueryExecutor, idp *IdentityProvider) error Create(ctx context.Context, client database.QueryExecutor, idp *IdentityProvider) error
Update(ctx context.Context, client database.QueryExecutor, id IDPIdentifierCondition, instanceID string, orgID *string, changes ...database.Change) (int64, error) Update(ctx context.Context, client database.QueryExecutor, condition database.Condition, changes ...database.Change) (int64, error)
Delete(ctx context.Context, client database.QueryExecutor, id IDPIdentifierCondition, instanceID string, orgID *string) (int64, error) Delete(ctx context.Context, client database.QueryExecutor, condition database.Condition) (int64, error)
GetOIDC(ctx context.Context, client database.QueryExecutor, id IDPIdentifierCondition, instanceID string, orgID *string) (*IDPOIDC, error) GetOIDC(ctx context.Context, client database.QueryExecutor, opts ...database.QueryOption) (*IDPOIDC, error)
GetJWT(ctx context.Context, client database.QueryExecutor, id IDPIdentifierCondition, instanceID string, orgID *string) (*IDPJWT, error) GetJWT(ctx context.Context, client database.QueryExecutor, opts ...database.QueryOption) (*IDPJWT, error)
GetOAuth(ctx context.Context, client database.QueryExecutor, id IDPIdentifierCondition, instanceID string, orgID *string) (*IDPOAuth, error) GetOAuth(ctx context.Context, client database.QueryExecutor, opts ...database.QueryOption) (*IDPOAuth, error)
GetAzureAD(ctx context.Context, client database.QueryExecutor, id IDPIdentifierCondition, instanceID string, orgID *string) (*IDPAzureAD, error) GetAzureAD(ctx context.Context, client database.QueryExecutor, opts ...database.QueryOption) (*IDPAzureAD, error)
GetGoogle(ctx context.Context, client database.QueryExecutor, id IDPIdentifierCondition, instanceID string, orgID *string) (*IDPGoogle, error) GetGoogle(ctx context.Context, client database.QueryExecutor, opts ...database.QueryOption) (*IDPGoogle, error)
GetGithub(ctx context.Context, client database.QueryExecutor, id IDPIdentifierCondition, instanceID string, orgID *string) (*IDPGithub, error) GetGithub(ctx context.Context, client database.QueryExecutor, opts ...database.QueryOption) (*IDPGithub, error)
GetGithubEnterprise(ctx context.Context, client database.QueryExecutor, id IDPIdentifierCondition, instanceID string, orgID *string) (*IDPGithubEnterprise, error) GetGithubEnterprise(ctx context.Context, client database.QueryExecutor, opts ...database.QueryOption) (*IDPGithubEnterprise, error)
GetGitlab(ctx context.Context, client database.QueryExecutor, id IDPIdentifierCondition, instanceID string, orgID *string) (*IDPGitlab, error) GetGitlab(ctx context.Context, client database.QueryExecutor, opts ...database.QueryOption) (*IDPGitlab, error)
GetGitlabSelfHosting(ctx context.Context, client database.QueryExecutor, id IDPIdentifierCondition, instanceID string, orgID *string) (*IDPGitlabSelfHosting, error) GetGitlabSelfHosted(ctx context.Context, client database.QueryExecutor, opts ...database.QueryOption) (*IDPGitlabSelfHosted, error)
GetLDAP(ctx context.Context, client database.QueryExecutor, id IDPIdentifierCondition, instanceID string, orgID *string) (*IDPLDAP, error) GetLDAP(ctx context.Context, client database.QueryExecutor, opts ...database.QueryOption) (*IDPLDAP, error)
GetApple(ctx context.Context, client database.QueryExecutor, id IDPIdentifierCondition, instanceID string, orgID *string) (*IDPApple, error) GetApple(ctx context.Context, client database.QueryExecutor, opts ...database.QueryOption) (*IDPApple, error)
GetSAML(ctx context.Context, client database.QueryExecutor, id IDPIdentifierCondition, instanceID string, orgID *string) (*IDPSAML, error) GetSAML(ctx context.Context, client database.QueryExecutor, opts ...database.QueryOption) (*IDPSAML, error)
} }
@@ -25,15 +25,15 @@ func (i IDPAutoLinkingField) String() string {
// Re-run the stringer command to generate them again. // Re-run the stringer command to generate them again.
func _IDPAutoLinkingFieldNoOp() { func _IDPAutoLinkingFieldNoOp() {
var x [1]struct{} var x [1]struct{}
_ = x[IDPAutoLinkingFieldUserName-(1)] _ = x[IDPAutoLinkingFieldUsername-(1)]
_ = x[IDPAutoLinkingFieldEmail-(2)] _ = x[IDPAutoLinkingFieldEmail-(2)]
} }
var _IDPAutoLinkingFieldValues = []IDPAutoLinkingField{IDPAutoLinkingFieldUserName, IDPAutoLinkingFieldEmail} var _IDPAutoLinkingFieldValues = []IDPAutoLinkingField{IDPAutoLinkingFieldUsername, IDPAutoLinkingFieldEmail}
var _IDPAutoLinkingFieldNameToValueMap = map[string]IDPAutoLinkingField{ var _IDPAutoLinkingFieldNameToValueMap = map[string]IDPAutoLinkingField{
_IDPAutoLinkingFieldName[0:8]: IDPAutoLinkingFieldUserName, _IDPAutoLinkingFieldName[0:8]: IDPAutoLinkingFieldUsername,
_IDPAutoLinkingFieldLowerName[0:8]: IDPAutoLinkingFieldUserName, _IDPAutoLinkingFieldLowerName[0:8]: IDPAutoLinkingFieldUsername,
_IDPAutoLinkingFieldName[8:13]: IDPAutoLinkingFieldEmail, _IDPAutoLinkingFieldName[8:13]: IDPAutoLinkingFieldEmail,
_IDPAutoLinkingFieldLowerName[8:13]: IDPAutoLinkingFieldEmail, _IDPAutoLinkingFieldLowerName[8:13]: IDPAutoLinkingFieldEmail,
} }
@@ -10,13 +10,11 @@ CREATE TABLE zitadel.identity_providers (
, state zitadel.idp_state NOT NULL DEFAULT 'active' , state zitadel.idp_state NOT NULL DEFAULT 'active'
, name TEXT NOT NULL CHECK (name <> '') , name TEXT NOT NULL CHECK (name <> '')
, type SMALLINT DEFAULT NULL , type SMALLINT DEFAULT NULL
, auto_register BOOLEAN NOT NULL DEFAULT TRUE
, allow_creation BOOLEAN NOT NULL DEFAULT TRUE , allow_creation BOOLEAN NOT NULL DEFAULT TRUE
, allow_auto_creation BOOLEAN NOT NULL DEFAULT TRUE , allow_auto_creation BOOLEAN NOT NULL DEFAULT TRUE
, allow_auto_update BOOLEAN NOT NULL DEFAULT TRUE , allow_auto_update BOOLEAN NOT NULL DEFAULT TRUE
, allow_linking BOOLEAN NOT NULL DEFAULT TRUE , allow_linking BOOLEAN NOT NULL DEFAULT TRUE
, auto_linking_field SMALLINT DEFAULT NULL , auto_linking_field SMALLINT DEFAULT NULL
, styling_type SMALLINT
, payload JSONB , payload JSONB
, created_at TIMESTAMPTZ NOT NULL DEFAULT now() , created_at TIMESTAMPTZ NOT NULL DEFAULT now()
@@ -25,8 +23,8 @@ CREATE TABLE zitadel.identity_providers (
, PRIMARY KEY (instance_id, id) , PRIMARY KEY (instance_id, id)
, CONSTRAINT identity_providers_id_unique UNIQUE NULLS NOT DISTINCT (instance_id, org_id, id) , CONSTRAINT identity_providers_id_unique UNIQUE NULLS NOT DISTINCT (instance_id, org_id, id)
, CONSTRAINT identity_providers_name_unique UNIQUE NULLS NOT DISTINCT (instance_id, org_id, name) , CONSTRAINT identity_providers_name_unique UNIQUE NULLS NOT DISTINCT (instance_id, org_id, name)
, FOREIGN KEY (instance_id) REFERENCES zitadel.instances(id) , FOREIGN KEY (instance_id) REFERENCES zitadel.instances(id) ON DELETE CASCADE
, FOREIGN KEY (instance_id, org_id) REFERENCES zitadel.organizations(instance_id, id) , FOREIGN KEY (instance_id, org_id) REFERENCES zitadel.organizations(instance_id, id) ON DELETE CASCADE
); );
-- CREATE INDEX idx_identity_providers_org_id ON identity_providers(instance_id, org_id) WHERE org_id IS NOT NULL; -- CREATE INDEX idx_identity_providers_org_id ON identity_providers(instance_id, org_id) WHERE org_id IS NOT NULL;
@@ -145,7 +145,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
name := gofakeit.Name() name := gofakeit.Name()
before := time.Now() before := time.Now()
addOIDC, err := AdminClient.AddOIDCIDP(IAMCTX, defaultOIDCIDReq(name, true)) addOIDC, err := AdminClient.AddOIDCIDP(IAMCTX, defaultOIDCIDPReq(name, true))
after := time.Now() after := time.Now()
require.NoError(t, err) require.NoError(t, err)
@@ -153,11 +153,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
idp, err := idpRepo.Get(IAMCTX, pool, idp, err := idpRepo.Get(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.NameCondition(database.TextOperationEqual, name))))
idpRepo.NameCondition(name),
instanceID,
nil,
)
require.NoError(t, err) require.NoError(t, err)
// event iam.idp.config.added // event iam.idp.config.added
@@ -166,12 +162,10 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
assert.Equal(t, addOIDC.IdpId, idp.ID) assert.Equal(t, addOIDC.IdpId, idp.ID)
assert.Equal(t, domain.IDPStateActive, idp.State) assert.Equal(t, domain.IDPStateActive, idp.State)
assert.Equal(t, name, idp.Name) assert.Equal(t, name, idp.Name)
assert.Equal(t, true, idp.AutoRegister)
assert.Equal(t, true, idp.AllowCreation) assert.Equal(t, true, idp.AllowCreation)
assert.Equal(t, false, idp.AllowAutoUpdate) assert.Equal(t, false, idp.AllowAutoUpdate)
assert.Equal(t, true, idp.AllowLinking) assert.Equal(t, true, idp.AllowLinking)
assert.Nil(t, idp.AutoLinkingField) assert.Nil(t, idp.AutoLinkingField)
assert.Equal(t, int16(idp_grpc.IDPStylingType_STYLING_TYPE_GOOGLE), *idp.StylingType)
assert.WithinRange(t, idp.UpdatedAt, before, after) assert.WithinRange(t, idp.UpdatedAt, before, after)
assert.WithinRange(t, idp.CreatedAt, before, after) assert.WithinRange(t, idp.CreatedAt, before, after)
}, retryDuration, tick) }, retryDuration, tick)
@@ -180,7 +174,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
t.Run("test instance idp update reduces", func(t *testing.T) { t.Run("test instance idp update reduces", func(t *testing.T) {
name := gofakeit.Name() name := gofakeit.Name()
addOIDC, err := AdminClient.AddOIDCIDP(IAMCTX, defaultOIDCIDReq(name, true)) addOIDC, err := AdminClient.AddOIDCIDP(IAMCTX, defaultOIDCIDPReq(name, true))
require.NoError(t, err) require.NoError(t, err)
name = "new_" + name name = "new_" + name
@@ -199,18 +193,12 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
idp, err := idpRepo.Get(IAMCTX, pool, idp, err := idpRepo.Get(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.NameCondition(database.TextOperationEqual, name))))
idpRepo.NameCondition(name),
instanceID,
nil,
)
require.NoError(t, err) require.NoError(t, err)
// event iam.idp.config.changed // event iam.idp.config.changed
assert.Equal(t, addOIDC.IdpId, idp.ID) assert.Equal(t, addOIDC.IdpId, idp.ID)
assert.Equal(t, name, idp.Name) assert.Equal(t, name, idp.Name)
assert.Equal(t, false, idp.AutoRegister)
assert.Equal(t, int16(idp_grpc.IDPStylingType_STYLING_TYPE_UNSPECIFIED), *idp.StylingType)
assert.WithinRange(t, idp.UpdatedAt, before, after) assert.WithinRange(t, idp.UpdatedAt, before, after)
}, retryDuration, tick) }, retryDuration, tick)
}) })
@@ -218,7 +206,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
t.Run("test instance idp deactivate reduces", func(t *testing.T) { t.Run("test instance idp deactivate reduces", func(t *testing.T) {
name := gofakeit.Name() name := gofakeit.Name()
addOIDC, err := AdminClient.AddOIDCIDP(IAMCTX, defaultOIDCIDReq(name, true)) addOIDC, err := AdminClient.AddOIDCIDP(IAMCTX, defaultOIDCIDPReq(name, true))
require.NoError(t, err) require.NoError(t, err)
// deactivate idp // deactivate idp
@@ -233,11 +221,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
idp, err := idpRepo.Get(IAMCTX, pool, idp, err := idpRepo.Get(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.IDCondition(addOIDC.IdpId))))
idpRepo.IDCondition(addOIDC.IdpId),
instanceID,
nil,
)
require.NoError(t, err) require.NoError(t, err)
// event iam.idp.config.deactivated // event iam.idp.config.deactivated
@@ -250,7 +234,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
t.Run("test instance idp config reactivate reduces", func(t *testing.T) { t.Run("test instance idp config reactivate reduces", func(t *testing.T) {
name := gofakeit.Name() name := gofakeit.Name()
addOIDC, err := AdminClient.AddOIDCIDP(IAMCTX, defaultOIDCIDReq(name, true)) addOIDC, err := AdminClient.AddOIDCIDP(IAMCTX, defaultOIDCIDPReq(name, true))
require.NoError(t, err) require.NoError(t, err)
idpRepo := repository.IDProviderRepository() idpRepo := repository.IDProviderRepository()
@@ -263,11 +247,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
// wait for idp to be deactivated // wait for idp to be deactivated
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
idp, err := idpRepo.Get(IAMCTX, pool, idp, err := idpRepo.Get(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.IDCondition(addOIDC.IdpId))))
idpRepo.IDCondition(addOIDC.IdpId),
instanceID,
nil,
)
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, addOIDC.IdpId, idp.ID) assert.Equal(t, addOIDC.IdpId, idp.ID)
@@ -284,11 +264,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
idp, err := idpRepo.Get(IAMCTX, pool, idp, err := idpRepo.Get(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.IDCondition(addOIDC.IdpId))))
idpRepo.IDCondition(addOIDC.IdpId),
instanceID,
nil,
)
require.NoError(t, err) require.NoError(t, err)
// event iam.idp.config.reactivated // event iam.idp.config.reactivated
@@ -302,10 +278,16 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
name := gofakeit.Name() name := gofakeit.Name()
// add idp // add idp
addOIDC, err := AdminClient.AddOIDCIDP(IAMCTX, defaultOIDCIDReq(name, true)) addOIDC, err := AdminClient.AddOIDCIDP(IAMCTX, defaultOIDCIDPReq(name, true))
require.NoError(t, err) require.NoError(t, err)
idpRepo := repository.IDProviderRepository() idpRepo := repository.IDProviderRepository()
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) {
_, err := idpRepo.Get(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.IDCondition(addOIDC.IdpId))))
require.NoError(t, err)
}, retryDuration, tick)
// remove idp // remove idp
_, err = AdminClient.RemoveIDP(IAMCTX, &admin.RemoveIDPRequest{ _, err = AdminClient.RemoveIDP(IAMCTX, &admin.RemoveIDPRequest{
@@ -313,13 +295,9 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
}) })
require.NoError(t, err) require.NoError(t, err)
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
_, err := idpRepo.Get(IAMCTX, pool, _, err := idpRepo.Get(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.IDCondition(addOIDC.IdpId))))
idpRepo.IDCondition(addOIDC.IdpId),
instanceID,
nil,
)
// event iam.idp.config.remove // event iam.idp.config.remove
require.ErrorIs(t, &database.NoRowFoundError{}, err) require.ErrorIs(t, &database.NoRowFoundError{}, err)
@@ -330,18 +308,14 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
name := gofakeit.Name() name := gofakeit.Name()
// add oidc // add oidc
addOIDC, err := AdminClient.AddOIDCIDP(IAMCTX, defaultOIDCIDReq(name, false)) addOIDC, err := AdminClient.AddOIDCIDP(IAMCTX, defaultOIDCIDPReq(name, false))
require.NoError(t, err) require.NoError(t, err)
idpRepo := repository.IDProviderRepository() idpRepo := repository.IDProviderRepository()
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
oidc, err := idpRepo.GetOIDC(IAMCTX, pool, oidc, err := idpRepo.GetOIDC(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.IDCondition(addOIDC.IdpId))))
idpRepo.IDCondition(addOIDC.IdpId),
instanceID,
nil,
)
require.NoError(t, err) require.NoError(t, err)
// event org.idp.oidc.config.added // event org.idp.oidc.config.added
@@ -356,8 +330,6 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
assert.Equal(t, "issuer", oidc.Issuer) assert.Equal(t, "issuer", oidc.Issuer)
assert.Equal(t, "clientID", oidc.ClientID) assert.Equal(t, "clientID", oidc.ClientID)
assert.Equal(t, []string{"scope"}, oidc.Scopes) assert.Equal(t, []string{"scope"}, oidc.Scopes)
assert.Equal(t, int16(idp_grpc.IDPStylingType_STYLING_TYPE_GOOGLE), *oidc.StylingType)
assert.Equal(t, false, oidc.AutoRegister)
assert.Equal(t, domain.OIDCMappingField(idp.OIDCMappingField_OIDC_MAPPING_FIELD_EMAIL), oidc.IDPDisplayNameMapping) assert.Equal(t, domain.OIDCMappingField(idp.OIDCMappingField_OIDC_MAPPING_FIELD_EMAIL), oidc.IDPDisplayNameMapping)
assert.Equal(t, domain.OIDCMappingField(idp.OIDCMappingField_OIDC_MAPPING_FIELD_EMAIL), oidc.UserNameMapping) assert.Equal(t, domain.OIDCMappingField(idp.OIDCMappingField_OIDC_MAPPING_FIELD_EMAIL), oidc.UserNameMapping)
}, retryDuration, tick) }, retryDuration, tick)
@@ -367,16 +339,16 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
name := gofakeit.Name() name := gofakeit.Name()
// add oidc // add oidc
addOIDC, err := AdminClient.AddOIDCIDP(IAMCTX, defaultOIDCIDReq(name, true)) addOIDC, err := AdminClient.AddOIDCIDP(IAMCTX, defaultOIDCIDPReq(name, true))
require.NoError(t, err) require.NoError(t, err)
idpRepo := repository.IDProviderRepository() idpRepo := repository.IDProviderRepository()
// check original values for OCID // ensure oidc is added before updating
var oidc *domain.IDPOIDC var oidc *domain.IDPOIDC
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
oidc, err = idpRepo.GetOIDC(IAMCTX, pool, idpRepo.IDCondition(addOIDC.IdpId), instanceID, nil) oidc, err = idpRepo.GetOIDC(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.IDCondition(addOIDC.IdpId))))
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, addOIDC.IdpId, oidc.ID) assert.Equal(t, addOIDC.IdpId, oidc.ID)
}, retryDuration, tick) }, retryDuration, tick)
@@ -396,14 +368,9 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
updateOIDC, err := idpRepo.GetOIDC(IAMCTX, pool, updateOIDC, err := idpRepo.GetOIDC(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.IDCondition(addOIDC.IdpId))))
idpRepo.IDCondition(addOIDC.IdpId),
instanceID,
nil,
)
require.NoError(t, err) require.NoError(t, err)
// event org.idp.oidc.config.changed
// idp // idp
assert.Equal(t, instanceID, oidc.InstanceID) assert.Equal(t, instanceID, oidc.InstanceID)
assert.Nil(t, oidc.OrgID) assert.Nil(t, oidc.OrgID)
@@ -444,11 +411,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
jwt, err := idpRepo.GetJWT(IAMCTX, pool, jwt, err := idpRepo.GetJWT(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.IDCondition(addJWT.IdpId))))
idpRepo.IDCondition(addJWT.IdpId),
instanceID,
nil,
)
require.NoError(t, err) require.NoError(t, err)
// event iam.idp.jwt.config.added // event iam.idp.jwt.config.added
@@ -458,7 +421,6 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
assert.Equal(t, name, jwt.Name) assert.Equal(t, name, jwt.Name)
assert.Equal(t, addJWT.IdpId, jwt.ID) assert.Equal(t, addJWT.IdpId, jwt.ID)
assert.Equal(t, domain.IDPTypeJWT, domain.IDPType(*jwt.Type)) assert.Equal(t, domain.IDPTypeJWT, domain.IDPType(*jwt.Type))
assert.Equal(t, int16(idp_grpc.IDPStylingType_STYLING_TYPE_GOOGLE), *jwt.StylingType)
// jwt // jwt
assert.Equal(t, "jwtEndpoint", jwt.JWTEndpoint) assert.Equal(t, "jwtEndpoint", jwt.JWTEndpoint)
@@ -498,11 +460,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
updateJWT, err := idpRepo.GetJWT(IAMCTX, pool, updateJWT, err := idpRepo.GetJWT(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.IDCondition(addJWT.IdpId))))
idpRepo.IDCondition(addJWT.IdpId),
instanceID,
nil,
)
require.NoError(t, err) require.NoError(t, err)
// event iam.idp.jwt.config.changed // event iam.idp.jwt.config.changed
@@ -551,7 +509,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
var oauth *domain.IDPOAuth var oauth *domain.IDPOAuth
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
oauth, err = idpRepo.GetOAuth(IAMCTX, pool, idpRepo.IDCondition(addOAuth.Id), instanceID, nil) oauth, err = idpRepo.GetOAuth(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.IDCondition(addOAuth.Id))))
require.NoError(t, err) require.NoError(t, err)
// event instance.idp.oauth.added // event instance.idp.oauth.added
@@ -610,7 +568,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
var oauth *domain.IDPOAuth var oauth *domain.IDPOAuth
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
oauth, err = idpRepo.GetOAuth(IAMCTX, pool, idpRepo.IDCondition(addOAuth.Id), instanceID, nil) oauth, err = idpRepo.GetOAuth(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.IDCondition(addOAuth.Id))))
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, addOAuth.Id, oauth.ID) assert.Equal(t, addOAuth.Id, oauth.ID)
}, retryDuration, tick) }, retryDuration, tick)
@@ -641,11 +599,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
updateOauth, err := idpRepo.GetOAuth(IAMCTX, pool, updateOauth, err := idpRepo.GetOAuth(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.IDCondition(addOAuth.Id))))
idpRepo.IDCondition(addOAuth.Id),
instanceID,
nil,
)
require.NoError(t, err) require.NoError(t, err)
// event instance.idp.oauth.changed // event instance.idp.oauth.changed
@@ -658,7 +612,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
assert.Equal(t, true, updateOauth.AllowLinking) assert.Equal(t, true, updateOauth.AllowLinking)
assert.Equal(t, true, updateOauth.AllowCreation) assert.Equal(t, true, updateOauth.AllowCreation)
assert.Equal(t, true, updateOauth.AllowAutoUpdate) assert.Equal(t, true, updateOauth.AllowAutoUpdate)
assert.Equal(t, domain.IDPAutoLinkingFieldUserName, domain.IDPAutoLinkingField(*updateOauth.AutoLinkingField)) assert.Equal(t, domain.IDPAutoLinkingFieldUsername, domain.IDPAutoLinkingField(*updateOauth.AutoLinkingField))
assert.Equal(t, true, updateOauth.UsePKCE) assert.Equal(t, true, updateOauth.UsePKCE)
assert.WithinRange(t, updateOauth.UpdatedAt, before, after) assert.WithinRange(t, updateOauth.UpdatedAt, before, after)
@@ -701,7 +655,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
// check values for oidc // check values for oidc
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
oidc, err := idpRepo.GetOIDC(IAMCTX, pool, idpRepo.IDCondition(addOIDC.Id), instanceID, nil) oidc, err := idpRepo.GetOIDC(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.IDCondition(addOIDC.Id))))
require.NoError(t, err) require.NoError(t, err)
// event instance.idp.oidc added // event instance.idp.oidc added
@@ -729,7 +683,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
}, retryDuration, tick) }, retryDuration, tick)
}) })
t.Run("test instanceidp oidc changed reduces", func(t *testing.T) { t.Run("test instance idp oidc changed reduces", func(t *testing.T) {
name := gofakeit.Name() name := gofakeit.Name()
addOIDC, err := AdminClient.AddGenericOIDCProvider(IAMCTX, &admin.AddGenericOIDCProviderRequest{ addOIDC, err := AdminClient.AddGenericOIDCProvider(IAMCTX, &admin.AddGenericOIDCProviderRequest{
@@ -756,7 +710,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
var oidc *domain.IDPOIDC var oidc *domain.IDPOIDC
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
oidc, err = idpRepo.GetOIDC(IAMCTX, pool, idpRepo.IDCondition(addOIDC.Id), instanceID, nil) oidc, err = idpRepo.GetOIDC(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.IDCondition(addOIDC.Id))))
require.NoError(t, err) require.NoError(t, err)
}, retryDuration, tick) }, retryDuration, tick)
@@ -784,11 +738,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
updateOIDC, err := idpRepo.GetOIDC(IAMCTX, pool, updateOIDC, err := idpRepo.GetOIDC(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.IDCondition(addOIDC.Id))))
idpRepo.IDCondition(addOIDC.Id),
instanceID,
nil,
)
require.NoError(t, err) require.NoError(t, err)
// event instance.idp.oidc.changed // event instance.idp.oidc.changed
@@ -801,7 +751,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
assert.Equal(t, true, updateOIDC.AllowLinking) assert.Equal(t, true, updateOIDC.AllowLinking)
assert.Equal(t, true, updateOIDC.AllowCreation) assert.Equal(t, true, updateOIDC.AllowCreation)
assert.Equal(t, true, updateOIDC.AllowAutoUpdate) assert.Equal(t, true, updateOIDC.AllowAutoUpdate)
assert.Equal(t, domain.IDPAutoLinkingFieldUserName, domain.IDPAutoLinkingField(*updateOIDC.AutoLinkingField)) assert.Equal(t, domain.IDPAutoLinkingFieldUsername, domain.IDPAutoLinkingField(*updateOIDC.AutoLinkingField))
assert.WithinRange(t, updateOIDC.UpdatedAt, before, after) assert.WithinRange(t, updateOIDC.UpdatedAt, before, after)
// oidc // oidc
@@ -841,7 +791,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
var oidc *domain.IDPOIDC var oidc *domain.IDPOIDC
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
oidc, err = idpRepo.GetOIDC(IAMCTX, pool, idpRepo.IDCondition(addOIDC.Id), instanceID, nil) oidc, err = idpRepo.GetOIDC(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.IDCondition(addOIDC.Id))))
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, domain.IDPTypeOIDC, domain.IDPType(*oidc.Type)) assert.Equal(t, domain.IDPTypeOIDC, domain.IDPType(*oidc.Type))
}, retryDuration, tick) }, retryDuration, tick)
@@ -876,7 +826,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
azure, err := idpRepo.GetAzureAD(IAMCTX, pool, idpRepo.IDCondition(addOIDC.Id), instanceID, nil) azure, err := idpRepo.GetAzureAD(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.IDCondition(addOIDC.Id))))
require.NoError(t, err) require.NoError(t, err)
// event instance.idp.oidc.migrated.azure // event instance.idp.oidc.migrated.azure
@@ -890,7 +840,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
assert.Equal(t, true, azure.AllowLinking) assert.Equal(t, true, azure.AllowLinking)
assert.Equal(t, true, azure.AllowCreation) assert.Equal(t, true, azure.AllowCreation)
assert.Equal(t, true, azure.AllowAutoUpdate) assert.Equal(t, true, azure.AllowAutoUpdate)
assert.Equal(t, domain.IDPAutoLinkingFieldUserName, domain.IDPAutoLinkingField(*azure.AutoLinkingField)) assert.Equal(t, domain.IDPAutoLinkingFieldUsername, domain.IDPAutoLinkingField(*azure.AutoLinkingField))
assert.WithinRange(t, azure.UpdatedAt, before, after) assert.WithinRange(t, azure.UpdatedAt, before, after)
// oidc // oidc
@@ -929,7 +879,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
var oidc *domain.IDPOIDC var oidc *domain.IDPOIDC
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
oidc, err = idpRepo.GetOIDC(IAMCTX, pool, idpRepo.IDCondition(addOIDC.Id), instanceID, nil) oidc, err = idpRepo.GetOIDC(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.IDCondition(addOIDC.Id))))
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, domain.IDPTypeOIDC, domain.IDPType(*oidc.Type)) assert.Equal(t, domain.IDPTypeOIDC, domain.IDPType(*oidc.Type))
}, retryDuration, tick) }, retryDuration, tick)
@@ -958,7 +908,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
google, err := idpRepo.GetGoogle(IAMCTX, pool, idpRepo.IDCondition(addOIDC.Id), instanceID, nil) google, err := idpRepo.GetGoogle(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.IDCondition(addOIDC.Id))))
require.NoError(t, err) require.NoError(t, err)
// event instance.idp.oidc.migrated.google // event instance.idp.oidc.migrated.google
@@ -972,7 +922,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
assert.Equal(t, true, google.AllowLinking) assert.Equal(t, true, google.AllowLinking)
assert.Equal(t, true, google.AllowCreation) assert.Equal(t, true, google.AllowCreation)
assert.Equal(t, true, google.AllowAutoUpdate) assert.Equal(t, true, google.AllowAutoUpdate)
assert.Equal(t, domain.IDPAutoLinkingFieldUserName, domain.IDPAutoLinkingField(*google.AutoLinkingField)) assert.Equal(t, domain.IDPAutoLinkingFieldUsername, domain.IDPAutoLinkingField(*google.AutoLinkingField))
assert.WithinRange(t, google.UpdatedAt, before, after) assert.WithinRange(t, google.UpdatedAt, before, after)
// oidc // oidc
@@ -1009,7 +959,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
// check values for jwt // check values for jwt
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
jwt, err := idpRepo.GetJWT(IAMCTX, pool, idpRepo.IDCondition(addJWT.Id), instanceID, nil) jwt, err := idpRepo.GetJWT(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.IDCondition(addJWT.Id))))
require.NoError(t, err) require.NoError(t, err)
// event instance.idp.jwt.added // event instance.idp.jwt.added
@@ -1080,7 +1030,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
// check values for jwt // check values for jwt
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
jwt, err := idpRepo.GetJWT(IAMCTX, pool, idpRepo.IDCondition(addJWT.Id), instanceID, nil) jwt, err := idpRepo.GetJWT(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.IDCondition(addJWT.Id))))
require.NoError(t, err) require.NoError(t, err)
// event instance.idp.jwt.added // event instance.idp.jwt.added
@@ -1093,7 +1043,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
assert.Equal(t, true, jwt.AllowLinking) assert.Equal(t, true, jwt.AllowLinking)
assert.Equal(t, true, jwt.AllowCreation) assert.Equal(t, true, jwt.AllowCreation)
assert.Equal(t, true, jwt.AllowAutoUpdate) assert.Equal(t, true, jwt.AllowAutoUpdate)
assert.Equal(t, domain.IDPAutoLinkingFieldUserName, domain.IDPAutoLinkingField(*jwt.AutoLinkingField)) assert.Equal(t, domain.IDPAutoLinkingFieldUsername, domain.IDPAutoLinkingField(*jwt.AutoLinkingField))
assert.WithinRange(t, jwt.UpdatedAt, before, after) assert.WithinRange(t, jwt.UpdatedAt, before, after)
// jwt // jwt
@@ -1136,7 +1086,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
// check values for azure // check values for azure
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
azure, err := idpRepo.GetAzureAD(IAMCTX, pool, idpRepo.IDCondition(addAzure.Id), instanceID, nil) azure, err := idpRepo.GetAzureAD(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.IDCondition(addAzure.Id))))
require.NoError(t, err) require.NoError(t, err)
// event instance.idp.azure.added // event instance.idp.azure.added
@@ -1149,7 +1099,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
assert.Equal(t, true, azure.AllowLinking) assert.Equal(t, true, azure.AllowLinking)
assert.Equal(t, true, azure.AllowCreation) assert.Equal(t, true, azure.AllowCreation)
assert.Equal(t, true, azure.AllowAutoUpdate) assert.Equal(t, true, azure.AllowAutoUpdate)
assert.Equal(t, domain.IDPAutoLinkingFieldUserName, domain.IDPAutoLinkingField(*azure.AutoLinkingField)) assert.Equal(t, domain.IDPAutoLinkingFieldUsername, domain.IDPAutoLinkingField(*azure.AutoLinkingField))
assert.WithinRange(t, azure.UpdatedAt, before, after) assert.WithinRange(t, azure.UpdatedAt, before, after)
// azure // azure
@@ -1191,7 +1141,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
var azure *domain.IDPAzureAD var azure *domain.IDPAzureAD
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
azure, err = idpRepo.GetAzureAD(IAMCTX, pool, idpRepo.IDCondition(addAzure.Id), instanceID, nil) azure, err = idpRepo.GetAzureAD(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.IDCondition(addAzure.Id))))
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, addAzure.Id, azure.ID) assert.Equal(t, addAzure.Id, azure.ID)
}, retryDuration, tick) }, retryDuration, tick)
@@ -1225,7 +1175,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
// check values for azure // check values for azure
retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
updateAzure, err := idpRepo.GetAzureAD(IAMCTX, pool, idpRepo.IDCondition(addAzure.Id), instanceID, nil) updateAzure, err := idpRepo.GetAzureAD(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.IDCondition(addAzure.Id))))
require.NoError(t, err) require.NoError(t, err)
// event instance.idp.azure.changed // event instance.idp.azure.changed
@@ -1276,7 +1226,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
// check values for github // check values for github
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
github, err := idpRepo.GetGithub(IAMCTX, pool, idpRepo.IDCondition(addGithub.Id), instanceID, nil) github, err := idpRepo.GetGithub(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.IDCondition(addGithub.Id))))
require.NoError(t, err) require.NoError(t, err)
// event instance.idp.github.added // event instance.idp.github.added
@@ -1289,7 +1239,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
assert.Equal(t, false, github.AllowLinking) assert.Equal(t, false, github.AllowLinking)
assert.Equal(t, false, github.AllowCreation) assert.Equal(t, false, github.AllowCreation)
assert.Equal(t, false, github.AllowAutoUpdate) assert.Equal(t, false, github.AllowAutoUpdate)
assert.Equal(t, domain.IDPAutoLinkingFieldUserName, domain.IDPAutoLinkingField(*github.AutoLinkingField)) assert.Equal(t, domain.IDPAutoLinkingFieldUsername, domain.IDPAutoLinkingField(*github.AutoLinkingField))
assert.WithinRange(t, github.UpdatedAt, before, after) assert.WithinRange(t, github.UpdatedAt, before, after)
assert.Equal(t, "clientId", github.ClientID) assert.Equal(t, "clientId", github.ClientID)
@@ -1322,7 +1272,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
var github *domain.IDPGithub var github *domain.IDPGithub
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
github, err = idpRepo.GetGithub(IAMCTX, pool, idpRepo.IDCondition(addGithub.Id), instanceID, nil) github, err = idpRepo.GetGithub(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.IDCondition(addGithub.Id))))
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, addGithub.Id, github.ID) assert.Equal(t, addGithub.Id, github.ID)
}, retryDuration, tick) }, retryDuration, tick)
@@ -1350,7 +1300,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
// check values for azure // check values for azure
retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
updateGithub, err := idpRepo.GetGithub(IAMCTX, pool, idpRepo.IDCondition(addGithub.Id), instanceID, nil) updateGithub, err := idpRepo.GetGithub(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.IDCondition(addGithub.Id))))
require.NoError(t, err) require.NoError(t, err)
// event instance.idp.github.changed // event instance.idp.github.changed
@@ -1363,7 +1313,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
assert.Equal(t, true, updateGithub.AllowLinking) assert.Equal(t, true, updateGithub.AllowLinking)
assert.Equal(t, true, updateGithub.AllowCreation) assert.Equal(t, true, updateGithub.AllowCreation)
assert.Equal(t, true, updateGithub.AllowAutoUpdate) assert.Equal(t, true, updateGithub.AllowAutoUpdate)
assert.Equal(t, domain.IDPAutoLinkingFieldUserName, domain.IDPAutoLinkingField(*updateGithub.AutoLinkingField)) assert.Equal(t, domain.IDPAutoLinkingFieldUsername, domain.IDPAutoLinkingField(*updateGithub.AutoLinkingField))
assert.WithinRange(t, updateGithub.UpdatedAt, before, after) assert.WithinRange(t, updateGithub.UpdatedAt, before, after)
// github // github
@@ -1402,7 +1352,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
// check values for github enterprise // check values for github enterprise
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
githubEnterprise, err := idpRepo.GetGithubEnterprise(IAMCTX, pool, idpRepo.IDCondition(addGithubEnterprise.Id), instanceID, nil) githubEnterprise, err := idpRepo.GetGithubEnterprise(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.IDCondition(addGithubEnterprise.Id))))
require.NoError(t, err) require.NoError(t, err)
// event instance.idp.github_enterprise.added // event instance.idp.github_enterprise.added
@@ -1456,7 +1406,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
var githubEnterprise *domain.IDPGithubEnterprise var githubEnterprise *domain.IDPGithubEnterprise
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
githubEnterprise, err = idpRepo.GetGithubEnterprise(IAMCTX, pool, idpRepo.IDCondition(addGithubEnterprise.Id), instanceID, nil) githubEnterprise, err = idpRepo.GetGithubEnterprise(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.IDCondition(addGithubEnterprise.Id))))
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, addGithubEnterprise.Id, githubEnterprise.ID) assert.Equal(t, addGithubEnterprise.Id, githubEnterprise.ID)
}, retryDuration, tick) }, retryDuration, tick)
@@ -1487,7 +1437,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
// check values for azure // check values for azure
retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
updateGithubEnterprise, err := idpRepo.GetGithubEnterprise(IAMCTX, pool, idpRepo.IDCondition(addGithubEnterprise.Id), instanceID, nil) updateGithubEnterprise, err := idpRepo.GetGithubEnterprise(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.IDCondition(addGithubEnterprise.Id))))
require.NoError(t, err) require.NoError(t, err)
// event instance.idp.github_enterprise.changed // event instance.idp.github_enterprise.changed
@@ -1539,7 +1489,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
// check values for gitlab // check values for gitlab
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
gitlab, err := idpRepo.GetGitlab(IAMCTX, pool, idpRepo.IDCondition(addGithub.Id), instanceID, nil) gitlab, err := idpRepo.GetGitlab(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.IDCondition(addGithub.Id))))
require.NoError(t, err) require.NoError(t, err)
// event instance.idp.gitlab.added // event instance.idp.gitlab.added
@@ -1587,7 +1537,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
var githlab *domain.IDPGitlab var githlab *domain.IDPGitlab
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
githlab, err = idpRepo.GetGitlab(IAMCTX, pool, idpRepo.IDCondition(addGitlab.Id), instanceID, nil) githlab, err = idpRepo.GetGitlab(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.IDCondition(addGitlab.Id))))
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, addGitlab.Id, githlab.ID) assert.Equal(t, addGitlab.Id, githlab.ID)
}, retryDuration, tick) }, retryDuration, tick)
@@ -1615,7 +1565,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
// check values for gitlab // check values for gitlab
retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
updateGitlab, err := idpRepo.GetGitlab(IAMCTX, pool, idpRepo.IDCondition(addGitlab.Id), instanceID, nil) updateGitlab, err := idpRepo.GetGitlab(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.IDCondition(addGitlab.Id))))
require.NoError(t, err) require.NoError(t, err)
// event instance.idp.gitlab.changed // event instance.idp.gitlab.changed
@@ -1627,7 +1577,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
assert.Equal(t, true, updateGitlab.AllowLinking) assert.Equal(t, true, updateGitlab.AllowLinking)
assert.Equal(t, true, updateGitlab.AllowCreation) assert.Equal(t, true, updateGitlab.AllowCreation)
assert.Equal(t, true, updateGitlab.AllowAutoUpdate) assert.Equal(t, true, updateGitlab.AllowAutoUpdate)
assert.Equal(t, domain.IDPAutoLinkingFieldUserName, domain.IDPAutoLinkingField(*updateGitlab.AutoLinkingField)) assert.Equal(t, domain.IDPAutoLinkingFieldUsername, domain.IDPAutoLinkingField(*updateGitlab.AutoLinkingField))
assert.WithinRange(t, updateGitlab.UpdatedAt, before, after) assert.WithinRange(t, updateGitlab.UpdatedAt, before, after)
// gitlab // gitlab
@@ -1665,7 +1615,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
// check values for gitlab self hosted // check values for gitlab self hosted
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
gitlabSelfHosted, err := idpRepo.GetGitlabSelfHosting(IAMCTX, pool, idpRepo.IDCondition(addGitlabSelfHosted.Id), instanceID, nil) gitlabSelfHosted, err := idpRepo.GetGitlabSelfHosted(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.IDCondition(addGitlabSelfHosted.Id))))
require.NoError(t, err) require.NoError(t, err)
// event instance.idp.gitlab_self_hosted.added // event instance.idp.gitlab_self_hosted.added
@@ -1712,10 +1662,10 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
idpRepo := repository.IDProviderRepository() idpRepo := repository.IDProviderRepository()
var githlabSelfHosted *domain.IDPGitlabSelfHosting var githlabSelfHosted *domain.IDPGitlabSelfHosted
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
githlabSelfHosted, err = idpRepo.GetGitlabSelfHosting(IAMCTX, pool, idpRepo.IDCondition(addGitlabSelfHosted.Id), instanceID, nil) githlabSelfHosted, err = idpRepo.GetGitlabSelfHosted(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.IDCondition(addGitlabSelfHosted.Id))))
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, addGitlabSelfHosted.Id, githlabSelfHosted.ID) assert.Equal(t, addGitlabSelfHosted.Id, githlabSelfHosted.ID)
}, retryDuration, tick) }, retryDuration, tick)
@@ -1744,7 +1694,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
// check values for gitlab self hosted // check values for gitlab self hosted
retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
updateGitlabSelfHosted, err := idpRepo.GetGitlabSelfHosting(IAMCTX, pool, idpRepo.IDCondition(addGitlabSelfHosted.Id), instanceID, nil) updateGitlabSelfHosted, err := idpRepo.GetGitlabSelfHosted(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.IDCondition(addGitlabSelfHosted.Id))))
require.NoError(t, err) require.NoError(t, err)
// event instance.idp.gitlab_self_hosted.changed // event instance.idp.gitlab_self_hosted.changed
@@ -1757,7 +1707,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
assert.Equal(t, true, updateGitlabSelfHosted.AllowLinking) assert.Equal(t, true, updateGitlabSelfHosted.AllowLinking)
assert.Equal(t, true, updateGitlabSelfHosted.AllowCreation) assert.Equal(t, true, updateGitlabSelfHosted.AllowCreation)
assert.Equal(t, true, updateGitlabSelfHosted.AllowAutoUpdate) assert.Equal(t, true, updateGitlabSelfHosted.AllowAutoUpdate)
assert.Equal(t, domain.IDPAutoLinkingFieldUserName, domain.IDPAutoLinkingField(*updateGitlabSelfHosted.AutoLinkingField)) assert.Equal(t, domain.IDPAutoLinkingFieldUsername, domain.IDPAutoLinkingField(*updateGitlabSelfHosted.AutoLinkingField))
assert.WithinRange(t, updateGitlabSelfHosted.UpdatedAt, before, after) assert.WithinRange(t, updateGitlabSelfHosted.UpdatedAt, before, after)
// gitlab self hosted // gitlab self hosted
@@ -1794,7 +1744,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
// check values for google // check values for google
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
google, err := idpRepo.GetGoogle(IAMCTX, pool, idpRepo.IDCondition(addGoogle.Id), instanceID, nil) google, err := idpRepo.GetGoogle(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.IDCondition(addGoogle.Id))))
require.NoError(t, err) require.NoError(t, err)
// event instance.idp.google.added // event instance.idp.google.added
@@ -1842,7 +1792,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
var google *domain.IDPGoogle var google *domain.IDPGoogle
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
google, err = idpRepo.GetGoogle(IAMCTX, pool, idpRepo.IDCondition(addGoogle.Id), instanceID, nil) google, err = idpRepo.GetGoogle(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.IDCondition(addGoogle.Id))))
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, addGoogle.Id, google.ID) assert.Equal(t, addGoogle.Id, google.ID)
}, retryDuration, tick) }, retryDuration, tick)
@@ -1870,7 +1820,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
// check values for google // check values for google
retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
updateGoogle, err := idpRepo.GetGoogle(IAMCTX, pool, idpRepo.IDCondition(addGoogle.Id), instanceID, nil) updateGoogle, err := idpRepo.GetGoogle(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.IDCondition(addGoogle.Id))))
require.NoError(t, err) require.NoError(t, err)
// event instance.idp.google.changed // event instance.idp.google.changed
@@ -1883,7 +1833,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
assert.Equal(t, true, updateGoogle.AllowLinking) assert.Equal(t, true, updateGoogle.AllowLinking)
assert.Equal(t, true, updateGoogle.AllowCreation) assert.Equal(t, true, updateGoogle.AllowCreation)
assert.Equal(t, true, updateGoogle.AllowAutoUpdate) assert.Equal(t, true, updateGoogle.AllowAutoUpdate)
assert.Equal(t, domain.IDPAutoLinkingFieldUserName, domain.IDPAutoLinkingField(*updateGoogle.AutoLinkingField)) assert.Equal(t, domain.IDPAutoLinkingFieldUsername, domain.IDPAutoLinkingField(*updateGoogle.AutoLinkingField))
assert.WithinRange(t, updateGoogle.UpdatedAt, before, after) assert.WithinRange(t, updateGoogle.UpdatedAt, before, after)
// google // google
@@ -1906,7 +1856,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
ldap, err := idpRepo.GetLDAP(IAMCTX, pool, idpRepo.IDCondition(addLdap.Id), instanceID, nil) ldap, err := idpRepo.GetLDAP(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.IDCondition(addLdap.Id))))
require.NoError(t, err) require.NoError(t, err)
// event instance.idp.ldap.v2.added // event instance.idp.ldap.v2.added
@@ -1961,7 +1911,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
var ldap *domain.IDPLDAP var ldap *domain.IDPLDAP
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
ldap, err = idpRepo.GetLDAP(IAMCTX, pool, idpRepo.IDCondition(addLdap.Id), instanceID, nil) ldap, err = idpRepo.GetLDAP(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.IDCondition(addLdap.Id))))
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, addLdap.Id, ldap.ID) assert.Equal(t, addLdap.Id, ldap.ID)
}, retryDuration, tick) }, retryDuration, tick)
@@ -2010,7 +1960,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
// check values for ldap // check values for ldap
retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
updateLdap, err := idpRepo.GetLDAP(IAMCTX, pool, idpRepo.IDCondition(addLdap.Id), instanceID, nil) updateLdap, err := idpRepo.GetLDAP(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.IDCondition(addLdap.Id))))
require.NoError(t, err) require.NoError(t, err)
// event instance.idp.ldap.v2.changed // event instance.idp.ldap.v2.changed
@@ -2023,7 +1973,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
assert.Equal(t, true, updateLdap.AllowLinking) assert.Equal(t, true, updateLdap.AllowLinking)
assert.Equal(t, true, updateLdap.AllowCreation) assert.Equal(t, true, updateLdap.AllowCreation)
assert.Equal(t, true, updateLdap.AllowAutoUpdate) assert.Equal(t, true, updateLdap.AllowAutoUpdate)
assert.Equal(t, domain.IDPAutoLinkingFieldUserName, domain.IDPAutoLinkingField(*updateLdap.AutoLinkingField)) assert.Equal(t, domain.IDPAutoLinkingFieldUsername, domain.IDPAutoLinkingField(*updateLdap.AutoLinkingField))
assert.WithinRange(t, updateLdap.UpdatedAt, before, after) assert.WithinRange(t, updateLdap.UpdatedAt, before, after)
// ldap // ldap
@@ -2079,7 +2029,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
apple, err := idpRepo.GetApple(IAMCTX, pool, idpRepo.IDCondition(addApple.Id), instanceID, nil) apple, err := idpRepo.GetApple(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.IDCondition(addApple.Id))))
require.NoError(t, err) require.NoError(t, err)
// event instance.idp.apple.added // event instance.idp.apple.added
@@ -2131,7 +2081,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
var apple *domain.IDPApple var apple *domain.IDPApple
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
apple, err = idpRepo.GetApple(IAMCTX, pool, idpRepo.IDCondition(addApple.Id), instanceID, nil) apple, err = idpRepo.GetApple(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.IDCondition(addApple.Id))))
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, addApple.Id, apple.ID) assert.Equal(t, addApple.Id, apple.ID)
}, retryDuration, tick) }, retryDuration, tick)
@@ -2161,7 +2111,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
// check values for apple // check values for apple
retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
updateApple, err := idpRepo.GetApple(IAMCTX, pool, idpRepo.IDCondition(addApple.Id), instanceID, nil) updateApple, err := idpRepo.GetApple(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.IDCondition(addApple.Id))))
require.NoError(t, err) require.NoError(t, err)
// event nstance.idp.apple.changed // event nstance.idp.apple.changed
@@ -2174,7 +2124,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
assert.Equal(t, true, updateApple.AllowLinking) assert.Equal(t, true, updateApple.AllowLinking)
assert.Equal(t, true, updateApple.AllowCreation) assert.Equal(t, true, updateApple.AllowCreation)
assert.Equal(t, true, updateApple.AllowAutoUpdate) assert.Equal(t, true, updateApple.AllowAutoUpdate)
assert.Equal(t, domain.IDPAutoLinkingFieldUserName, domain.IDPAutoLinkingField(*updateApple.AutoLinkingField)) assert.Equal(t, domain.IDPAutoLinkingFieldUsername, domain.IDPAutoLinkingField(*updateApple.AutoLinkingField))
assert.WithinRange(t, updateApple.UpdatedAt, before, after) assert.WithinRange(t, updateApple.UpdatedAt, before, after)
// apple // apple
@@ -2200,7 +2150,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
saml, err := idpRepo.GetSAML(IAMCTX, pool, idpRepo.IDCondition(addSAML.Id), instanceID, nil) saml, err := idpRepo.GetSAML(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.IDCondition(addSAML.Id))))
require.NoError(t, err) require.NoError(t, err)
// event instance.idp.saml.added // event instance.idp.saml.added
@@ -2243,7 +2193,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
var saml *domain.IDPSAML var saml *domain.IDPSAML
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
saml, err = idpRepo.GetSAML(IAMCTX, pool, idpRepo.IDCondition(addSAML.Id), instanceID, nil) saml, err = idpRepo.GetSAML(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.IDCondition(addSAML.Id))))
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, addSAML.Id, saml.ID) assert.Equal(t, addSAML.Id, saml.ID)
}, retryDuration, tick) }, retryDuration, tick)
@@ -2278,7 +2228,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
// check values for apple // check values for apple
retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
updateSAML, err := idpRepo.GetSAML(IAMCTX, pool, idpRepo.IDCondition(addSAML.Id), instanceID, nil) updateSAML, err := idpRepo.GetSAML(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.IDCondition(addSAML.Id))))
require.NoError(t, err) require.NoError(t, err)
// event instance.idp.saml.changed // event instance.idp.saml.changed
@@ -2291,7 +2241,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
assert.Equal(t, true, updateSAML.AllowLinking) assert.Equal(t, true, updateSAML.AllowLinking)
assert.Equal(t, true, updateSAML.AllowCreation) assert.Equal(t, true, updateSAML.AllowCreation)
assert.Equal(t, true, updateSAML.AllowAutoUpdate) assert.Equal(t, true, updateSAML.AllowAutoUpdate)
assert.Equal(t, domain.IDPAutoLinkingFieldUserName, domain.IDPAutoLinkingField(*updateSAML.AutoLinkingField)) assert.Equal(t, domain.IDPAutoLinkingFieldUsername, domain.IDPAutoLinkingField(*updateSAML.AutoLinkingField))
assert.WithinRange(t, updateSAML.UpdatedAt, before, after) assert.WithinRange(t, updateSAML.UpdatedAt, before, after)
// saml // saml
@@ -2312,7 +2262,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
name := gofakeit.Name() name := gofakeit.Name()
// add idp // add idp
addOIDC, err := AdminClient.AddOIDCIDP(IAMCTX, defaultOIDCIDReq(name, true)) addOIDC, err := AdminClient.AddOIDCIDP(IAMCTX, defaultOIDCIDPReq(name, true))
require.NoError(t, err) require.NoError(t, err)
idpRepo := repository.IDProviderRepository() idpRepo := repository.IDProviderRepository()
@@ -2320,11 +2270,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
// check idp exists // check idp exists
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
_, err := idpRepo.Get(IAMCTX, pool, _, err := idpRepo.Get(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.IDCondition(addOIDC.IdpId))))
idpRepo.IDCondition(addOIDC.IdpId),
instanceID,
nil,
)
require.NoError(t, err) require.NoError(t, err)
}, retryDuration, tick) }, retryDuration, tick)
@@ -2337,11 +2283,7 @@ func TestServer_TestIDProviderInstanceReduces(t *testing.T) {
// check idp is removed // check idp is removed
retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
_, err := idpRepo.Get(IAMCTX, pool, _, err := idpRepo.Get(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.IDCondition(addOIDC.IdpId))))
idpRepo.IDCondition(addOIDC.IdpId),
instanceID,
nil,
)
require.ErrorIs(t, &database.NoRowFoundError{}, err) require.ErrorIs(t, &database.NoRowFoundError{}, err)
}, retryDuration, tick) }, retryDuration, tick)
}) })
@@ -2369,7 +2311,7 @@ func defaultInstanceSAMLRequest(name string, federatedLogoutEnable *bool) *admin
} }
} }
func defaultOIDCIDReq(name string, autoRegister bool) *admin.AddOIDCIDPRequest { func defaultOIDCIDPReq(name string, autoRegister bool) *admin.AddOIDCIDPRequest {
return &admin.AddOIDCIDPRequest{ return &admin.AddOIDCIDPRequest{
Name: name, Name: name,
StylingType: idp_grpc.IDPStylingType_STYLING_TYPE_GOOGLE, StylingType: idp_grpc.IDPStylingType_STYLING_TYPE_GOOGLE,
@@ -25,7 +25,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
instanceID := Instance.ID() instanceID := Instance.ID()
orgID := Instance.DefaultOrg.Id orgID := Instance.DefaultOrg.Id
t.Run("test instance idp add reduces", func(t *testing.T) { t.Run("test org idp add reduces", func(t *testing.T) {
name := gofakeit.Name() name := gofakeit.Name()
before := time.Now() before := time.Now()
@@ -47,11 +47,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
idp, err := idpRepo.Get(IAMCTX, pool, idp, err := idpRepo.Get(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.NameCondition(database.TextOperationEqual, name))))
idpRepo.NameCondition(name),
instanceID,
&orgID,
)
require.NoError(t, err) require.NoError(t, err)
// event org.idp.config.added // event org.idp.config.added
@@ -60,18 +56,16 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
assert.Equal(t, addOIDC.IdpId, idp.ID) assert.Equal(t, addOIDC.IdpId, idp.ID)
assert.Equal(t, domain.IDPStateActive, idp.State) assert.Equal(t, domain.IDPStateActive, idp.State)
assert.Equal(t, name, idp.Name) assert.Equal(t, name, idp.Name)
assert.Equal(t, true, idp.AutoRegister)
assert.Equal(t, true, idp.AllowCreation) assert.Equal(t, true, idp.AllowCreation)
assert.Equal(t, false, idp.AllowAutoUpdate) assert.Equal(t, false, idp.AllowAutoUpdate)
assert.Equal(t, true, idp.AllowLinking) assert.Equal(t, true, idp.AllowLinking)
assert.Nil(t, idp.AutoLinkingField) assert.Nil(t, idp.AutoLinkingField)
assert.Equal(t, int16(idp_grpc.IDPStylingType_STYLING_TYPE_GOOGLE), *idp.StylingType)
assert.WithinRange(t, idp.UpdatedAt, before, after) assert.WithinRange(t, idp.UpdatedAt, before, after)
assert.WithinRange(t, idp.CreatedAt, before, after) assert.WithinRange(t, idp.CreatedAt, before, after)
}, retryDuration, tick) }, retryDuration, tick)
}) })
// t.Run("test instance idp update reduces", func(t *testing.T) { // t.Run("test org idp update reduces", func(t *testing.T) {
// name := gofakeit.Name() // name := gofakeit.Name()
// addOIDC, err := MgmtClient.AddOrgOIDCIDP(IAMCTX, &management.AddOrgOIDCIDPRequest{ // addOIDC, err := MgmtClient.AddOrgOIDCIDP(IAMCTX, &management.AddOrgOIDCIDPRequest{
@@ -119,7 +113,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
// }, retryDuration, tick) // }, retryDuration, tick)
// }) // })
t.Run("test instance idp deactivate reduces", func(t *testing.T) { t.Run("test org idp deactivate reduces", func(t *testing.T) {
name := gofakeit.Name() name := gofakeit.Name()
addOIDC, err := MgmtClient.AddOrgOIDCIDP(IAMCTX, &management.AddOrgOIDCIDPRequest{ addOIDC, err := MgmtClient.AddOrgOIDCIDP(IAMCTX, &management.AddOrgOIDCIDPRequest{
@@ -147,11 +141,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
idp, err := idpRepo.Get(IAMCTX, pool, idp, err := idpRepo.Get(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.IDCondition(addOIDC.IdpId))))
idpRepo.IDCondition(addOIDC.IdpId),
instanceID,
&orgID,
)
require.NoError(t, err) require.NoError(t, err)
// event org.idp.config.deactivated // event org.idp.config.deactivated
@@ -161,7 +151,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
}, retryDuration, tick) }, retryDuration, tick)
}) })
t.Run("test instance idp reactivate reduces", func(t *testing.T) { t.Run("test org idp reactivate reduces", func(t *testing.T) {
name := gofakeit.Name() name := gofakeit.Name()
addOIDC, err := MgmtClient.AddOrgOIDCIDP(IAMCTX, &management.AddOrgOIDCIDPRequest{ addOIDC, err := MgmtClient.AddOrgOIDCIDP(IAMCTX, &management.AddOrgOIDCIDPRequest{
@@ -187,11 +177,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
// wait for idp to be deactivated // wait for idp to be deactivated
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
idp, err := idpRepo.Get(IAMCTX, pool, idp, err := idpRepo.Get(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.IDCondition(addOIDC.IdpId))))
idpRepo.IDCondition(addOIDC.IdpId),
instanceID,
&orgID,
)
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, addOIDC.IdpId, idp.ID) assert.Equal(t, addOIDC.IdpId, idp.ID)
@@ -208,11 +194,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
idp, err := idpRepo.Get(IAMCTX, pool, idp, err := idpRepo.Get(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.IDCondition(addOIDC.IdpId))))
idpRepo.IDCondition(addOIDC.IdpId),
instanceID,
&orgID,
)
require.NoError(t, err) require.NoError(t, err)
// event org.idp.config.reactivated // event org.idp.config.reactivated
@@ -222,7 +204,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
}, retryDuration, tick) }, retryDuration, tick)
}) })
t.Run("test instance idp remove reduces", func(t *testing.T) { t.Run("test org idp remove reduces", func(t *testing.T) {
name := gofakeit.Name() name := gofakeit.Name()
// add idp // add idp
@@ -241,26 +223,31 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
idpRepo := repository.IDProviderRepository() idpRepo := repository.IDProviderRepository()
// wait until idp is added
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) {
_, err := idpRepo.Get(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.IDCondition(addOIDC.IdpId))))
// event org.idp.config.remove
require.NoError(t, err)
}, retryDuration, tick)
// remove idp // remove idp
_, err = MgmtClient.RemoveOrgIDP(IAMCTX, &management.RemoveOrgIDPRequest{ _, err = MgmtClient.RemoveOrgIDP(IAMCTX, &management.RemoveOrgIDPRequest{
IdpId: addOIDC.IdpId, IdpId: addOIDC.IdpId,
}) })
require.NoError(t, err) require.NoError(t, err)
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
_, err := idpRepo.Get(IAMCTX, pool, _, err := idpRepo.Get(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.IDCondition(addOIDC.IdpId))))
idpRepo.IDCondition(addOIDC.IdpId),
instanceID,
&orgID,
)
// event org.idp.config.remove // event org.idp.config.remove
require.ErrorIs(t, &database.NoRowFoundError{}, err) require.ErrorIs(t, &database.NoRowFoundError{}, err)
}, retryDuration, tick) }, retryDuration, tick)
}) })
t.Run("test instance idp oidc added reduces", func(t *testing.T) { t.Run("test org idp oidc added reduces", func(t *testing.T) {
name := gofakeit.Name() name := gofakeit.Name()
// add oidc // add oidc
@@ -281,11 +268,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
oidc, err := idpRepo.GetOIDC(IAMCTX, pool, oidc, err := idpRepo.GetOIDC(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.IDCondition(addOIDC.IdpId))))
idpRepo.IDCondition(addOIDC.IdpId),
instanceID,
&orgID,
)
require.NoError(t, err) require.NoError(t, err)
// event org.idp.oidc.config.added // event org.idp.oidc.config.added
@@ -300,14 +283,12 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
assert.Equal(t, "issuer", oidc.Issuer) assert.Equal(t, "issuer", oidc.Issuer)
assert.Equal(t, "clientID", oidc.ClientID) assert.Equal(t, "clientID", oidc.ClientID)
assert.Equal(t, []string{"scope"}, oidc.Scopes) assert.Equal(t, []string{"scope"}, oidc.Scopes)
assert.Equal(t, int16(idp_grpc.IDPStylingType_STYLING_TYPE_GOOGLE), *oidc.StylingType)
assert.Equal(t, false, oidc.AutoRegister)
assert.Equal(t, domain.OIDCMappingField(idp.OIDCMappingField_OIDC_MAPPING_FIELD_EMAIL), oidc.IDPDisplayNameMapping) assert.Equal(t, domain.OIDCMappingField(idp.OIDCMappingField_OIDC_MAPPING_FIELD_EMAIL), oidc.IDPDisplayNameMapping)
assert.Equal(t, domain.OIDCMappingField(idp.OIDCMappingField_OIDC_MAPPING_FIELD_EMAIL), oidc.UserNameMapping) assert.Equal(t, domain.OIDCMappingField(idp.OIDCMappingField_OIDC_MAPPING_FIELD_EMAIL), oidc.UserNameMapping)
}, retryDuration, tick) }, retryDuration, tick)
}) })
t.Run("test instance idp oidc changed reduces", func(t *testing.T) { t.Run("test org idp oidc changed reduces", func(t *testing.T) {
name := gofakeit.Name() name := gofakeit.Name()
// add oidc // add oidc
@@ -330,7 +311,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
var oidc *domain.IDPOIDC var oidc *domain.IDPOIDC
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
oidc, err = idpRepo.GetOIDC(IAMCTX, pool, idpRepo.IDCondition(addOIDC.IdpId), instanceID, &orgID) oidc, err = idpRepo.GetOIDC(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.IDCondition(addOIDC.IdpId))))
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, addOIDC.IdpId, oidc.ID) assert.Equal(t, addOIDC.IdpId, oidc.ID)
}, retryDuration, tick) }, retryDuration, tick)
@@ -350,11 +331,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
updateOIDC, err := idpRepo.GetOIDC(IAMCTX, pool, updateOIDC, err := idpRepo.GetOIDC(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.IDCondition(addOIDC.IdpId))))
idpRepo.IDCondition(addOIDC.IdpId),
instanceID,
&orgID,
)
require.NoError(t, err) require.NoError(t, err)
// event org.idp.oidc.config.changed // event org.idp.oidc.config.changed
@@ -379,7 +356,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
}, retryDuration, tick) }, retryDuration, tick)
}) })
t.Run("test instance idp jwt added reduces", func(t *testing.T) { t.Run("test org idp jwt added reduces", func(t *testing.T) {
name := gofakeit.Name() name := gofakeit.Name()
// add jwt // add jwt
@@ -398,11 +375,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
jwt, err := idpRepo.GetJWT(IAMCTX, pool, jwt, err := idpRepo.GetJWT(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.IDCondition(addJWT.IdpId))))
idpRepo.IDCondition(addJWT.IdpId),
instanceID,
&orgID,
)
require.NoError(t, err) require.NoError(t, err)
// event org.idp.jwt.config.added // event org.idp.jwt.config.added
@@ -412,7 +385,6 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
assert.Equal(t, name, jwt.Name) assert.Equal(t, name, jwt.Name)
assert.Equal(t, addJWT.IdpId, jwt.ID) assert.Equal(t, addJWT.IdpId, jwt.ID)
assert.Equal(t, domain.IDPTypeJWT, domain.IDPType(*jwt.Type)) assert.Equal(t, domain.IDPTypeJWT, domain.IDPType(*jwt.Type))
assert.Equal(t, int16(idp_grpc.IDPStylingType_STYLING_TYPE_GOOGLE), *jwt.StylingType)
// jwt // jwt
assert.Equal(t, "jwtEndpoint", jwt.JWTEndpoint) assert.Equal(t, "jwtEndpoint", jwt.JWTEndpoint)
@@ -422,7 +394,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
}, retryDuration, tick) }, retryDuration, tick)
}) })
t.Run("test instance idp jwt changed reduces", func(t *testing.T) { t.Run("test org idp jwt changed reduces", func(t *testing.T) {
name := gofakeit.Name() name := gofakeit.Name()
// add jwt // add jwt
@@ -452,11 +424,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
updateJWT, err := idpRepo.GetJWT(IAMCTX, pool, updateJWT, err := idpRepo.GetJWT(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.IDCondition(addJWT.IdpId))))
idpRepo.IDCondition(addJWT.IdpId),
instanceID,
&orgID,
)
require.NoError(t, err) require.NoError(t, err)
// event org.idp.jwt.config.changed // event org.idp.jwt.config.changed
@@ -506,7 +474,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
var oauth *domain.IDPOAuth var oauth *domain.IDPOAuth
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
oauth, err = idpRepo.GetOAuth(IAMCTX, pool, idpRepo.IDCondition(addOAuth.Id), instanceID, &orgID) oauth, err = idpRepo.GetOAuth(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.IDCondition(addOAuth.Id))))
require.NoError(t, err) require.NoError(t, err)
// event org.idp.oauth.added // event org.idp.oauth.added
@@ -519,7 +487,9 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
assert.Equal(t, false, oauth.AllowLinking) assert.Equal(t, false, oauth.AllowLinking)
assert.Equal(t, false, oauth.AllowCreation) assert.Equal(t, false, oauth.AllowCreation)
assert.Equal(t, false, oauth.AllowAutoUpdate) assert.Equal(t, false, oauth.AllowAutoUpdate)
assert.Equal(t, domain.IDPAutoLinkingFieldEmail, domain.IDPAutoLinkingField(*oauth.AutoLinkingField)) if assert.NotNil(t, oauth.AutoLinkingField) {
assert.Equal(t, domain.IDPAutoLinkingFieldEmail, domain.IDPAutoLinkingField(*oauth.AutoLinkingField))
}
assert.WithinRange(t, oauth.CreatedAt, before, after) assert.WithinRange(t, oauth.CreatedAt, before, after)
assert.WithinRange(t, oauth.UpdatedAt, before, after) assert.WithinRange(t, oauth.UpdatedAt, before, after)
@@ -565,7 +535,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
var oauth *domain.IDPOAuth var oauth *domain.IDPOAuth
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
oauth, err = idpRepo.GetOAuth(IAMCTX, pool, idpRepo.IDCondition(addOAuth.Id), instanceID, &orgID) oauth, err = idpRepo.GetOAuth(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.IDCondition(addOAuth.Id))))
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, addOAuth.Id, oauth.ID) assert.Equal(t, addOAuth.Id, oauth.ID)
}, retryDuration, tick) }, retryDuration, tick)
@@ -596,11 +566,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
updateOauth, err := idpRepo.GetOAuth(IAMCTX, pool, updateOauth, err := idpRepo.GetOAuth(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.IDCondition(addOAuth.Id))))
idpRepo.IDCondition(addOAuth.Id),
instanceID,
&orgID,
)
require.NoError(t, err) require.NoError(t, err)
// event org.idp.oauth.changed // event org.idp.oauth.changed
@@ -613,7 +579,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
assert.Equal(t, true, updateOauth.AllowLinking) assert.Equal(t, true, updateOauth.AllowLinking)
assert.Equal(t, true, updateOauth.AllowCreation) assert.Equal(t, true, updateOauth.AllowCreation)
assert.Equal(t, true, updateOauth.AllowAutoUpdate) assert.Equal(t, true, updateOauth.AllowAutoUpdate)
assert.Equal(t, domain.IDPAutoLinkingFieldUserName, domain.IDPAutoLinkingField(*updateOauth.AutoLinkingField)) assert.Equal(t, domain.IDPAutoLinkingFieldUsername, domain.IDPAutoLinkingField(*updateOauth.AutoLinkingField))
assert.Equal(t, true, updateOauth.UsePKCE) assert.Equal(t, true, updateOauth.UsePKCE)
assert.WithinRange(t, updateOauth.UpdatedAt, before, after) assert.WithinRange(t, updateOauth.UpdatedAt, before, after)
@@ -656,7 +622,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
// check values for oidc // check values for oidc
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
oidc, err := idpRepo.GetOIDC(IAMCTX, pool, idpRepo.IDCondition(addOIDC.Id), instanceID, &orgID) oidc, err := idpRepo.GetOIDC(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.IDCondition(addOIDC.Id))))
require.NoError(t, err) require.NoError(t, err)
// event org.idp.oidc added // event org.idp.oidc added
@@ -711,7 +677,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
var oidc *domain.IDPOIDC var oidc *domain.IDPOIDC
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
oidc, err = idpRepo.GetOIDC(IAMCTX, pool, idpRepo.IDCondition(addOIDC.Id), instanceID, &orgID) oidc, err = idpRepo.GetOIDC(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.IDCondition(addOIDC.Id))))
require.NoError(t, err) require.NoError(t, err)
}, retryDuration, tick) }, retryDuration, tick)
@@ -739,11 +705,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
updateOIDC, err := idpRepo.GetOIDC(IAMCTX, pool, updateOIDC, err := idpRepo.GetOIDC(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.IDCondition(addOIDC.Id))))
idpRepo.IDCondition(addOIDC.Id),
instanceID,
&orgID,
)
require.NoError(t, err) require.NoError(t, err)
// event org.idp.oidc.changed // event org.idp.oidc.changed
@@ -756,7 +718,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
assert.Equal(t, true, updateOIDC.AllowLinking) assert.Equal(t, true, updateOIDC.AllowLinking)
assert.Equal(t, true, updateOIDC.AllowCreation) assert.Equal(t, true, updateOIDC.AllowCreation)
assert.Equal(t, true, updateOIDC.AllowAutoUpdate) assert.Equal(t, true, updateOIDC.AllowAutoUpdate)
assert.Equal(t, domain.IDPAutoLinkingFieldUserName, domain.IDPAutoLinkingField(*updateOIDC.AutoLinkingField)) assert.Equal(t, domain.IDPAutoLinkingFieldUsername, domain.IDPAutoLinkingField(*updateOIDC.AutoLinkingField))
assert.WithinRange(t, updateOIDC.UpdatedAt, before, after) assert.WithinRange(t, updateOIDC.UpdatedAt, before, after)
// oidc // oidc
@@ -795,7 +757,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
var oidc *domain.IDPOIDC var oidc *domain.IDPOIDC
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
oidc, err = idpRepo.GetOIDC(IAMCTX, pool, idpRepo.IDCondition(addOIDC.Id), instanceID, &orgID) oidc, err = idpRepo.GetOIDC(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.IDCondition(addOIDC.Id))))
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, domain.IDPTypeOIDC, domain.IDPType(*oidc.Type)) assert.Equal(t, domain.IDPTypeOIDC, domain.IDPType(*oidc.Type))
}, retryDuration, tick) }, retryDuration, tick)
@@ -830,7 +792,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
azure, err := idpRepo.GetAzureAD(IAMCTX, pool, idpRepo.IDCondition(addOIDC.Id), instanceID, &orgID) azure, err := idpRepo.GetAzureAD(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.IDCondition(addOIDC.Id))))
require.NoError(t, err) require.NoError(t, err)
// event org.idp.oidc.migrated.azure // event org.idp.oidc.migrated.azure
@@ -844,7 +806,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
assert.Equal(t, true, azure.AllowLinking) assert.Equal(t, true, azure.AllowLinking)
assert.Equal(t, true, azure.AllowCreation) assert.Equal(t, true, azure.AllowCreation)
assert.Equal(t, true, azure.AllowAutoUpdate) assert.Equal(t, true, azure.AllowAutoUpdate)
assert.Equal(t, domain.IDPAutoLinkingFieldUserName, domain.IDPAutoLinkingField(*azure.AutoLinkingField)) assert.Equal(t, domain.IDPAutoLinkingFieldUsername, domain.IDPAutoLinkingField(*azure.AutoLinkingField))
assert.WithinRange(t, azure.UpdatedAt, before, after) assert.WithinRange(t, azure.UpdatedAt, before, after)
// oidc // oidc
@@ -883,7 +845,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
var oidc *domain.IDPOIDC var oidc *domain.IDPOIDC
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
oidc, err = idpRepo.GetOIDC(IAMCTX, pool, idpRepo.IDCondition(addOIDC.Id), instanceID, &orgID) oidc, err = idpRepo.GetOIDC(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.IDCondition(addOIDC.Id))))
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, domain.IDPTypeOIDC, domain.IDPType(*oidc.Type)) assert.Equal(t, domain.IDPTypeOIDC, domain.IDPType(*oidc.Type))
}, retryDuration, tick) }, retryDuration, tick)
@@ -912,7 +874,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
google, err := idpRepo.GetGoogle(IAMCTX, pool, idpRepo.IDCondition(addOIDC.Id), instanceID, &orgID) google, err := idpRepo.GetGoogle(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.IDCondition(addOIDC.Id))))
require.NoError(t, err) require.NoError(t, err)
// event org.idp.oidc.migrated.google // event org.idp.oidc.migrated.google
@@ -926,7 +888,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
assert.Equal(t, true, google.AllowLinking) assert.Equal(t, true, google.AllowLinking)
assert.Equal(t, true, google.AllowCreation) assert.Equal(t, true, google.AllowCreation)
assert.Equal(t, true, google.AllowAutoUpdate) assert.Equal(t, true, google.AllowAutoUpdate)
assert.Equal(t, domain.IDPAutoLinkingFieldUserName, domain.IDPAutoLinkingField(*google.AutoLinkingField)) assert.Equal(t, domain.IDPAutoLinkingFieldUsername, domain.IDPAutoLinkingField(*google.AutoLinkingField))
assert.WithinRange(t, google.UpdatedAt, before, after) assert.WithinRange(t, google.UpdatedAt, before, after)
// oidc // oidc
@@ -963,7 +925,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
// check values for jwt // check values for jwt
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
jwt, err := idpRepo.GetJWT(IAMCTX, pool, idpRepo.IDCondition(addJWT.Id), instanceID, &orgID) jwt, err := idpRepo.GetJWT(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.IDCondition(addJWT.Id))))
require.NoError(t, err) require.NoError(t, err)
// event org.idp.jwt.added // event org.idp.jwt.added
@@ -1034,7 +996,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
// check values for jwt // check values for jwt
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
updateJwt, err := idpRepo.GetJWT(IAMCTX, pool, idpRepo.IDCondition(addJWT.Id), instanceID, &orgID) updateJwt, err := idpRepo.GetJWT(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.IDCondition(addJWT.Id))))
require.NoError(t, err) require.NoError(t, err)
// event org.idp.jwt.added // event org.idp.jwt.added
@@ -1047,7 +1009,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
assert.Equal(t, true, updateJwt.AllowLinking) assert.Equal(t, true, updateJwt.AllowLinking)
assert.Equal(t, true, updateJwt.AllowCreation) assert.Equal(t, true, updateJwt.AllowCreation)
assert.Equal(t, true, updateJwt.AllowAutoUpdate) assert.Equal(t, true, updateJwt.AllowAutoUpdate)
assert.Equal(t, domain.IDPAutoLinkingFieldUserName, domain.IDPAutoLinkingField(*updateJwt.AutoLinkingField)) assert.Equal(t, domain.IDPAutoLinkingFieldUsername, domain.IDPAutoLinkingField(*updateJwt.AutoLinkingField))
assert.WithinRange(t, updateJwt.UpdatedAt, before, after) assert.WithinRange(t, updateJwt.UpdatedAt, before, after)
// jwt // jwt
@@ -1090,7 +1052,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
// check values for azure // check values for azure
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
azure, err := idpRepo.GetAzureAD(IAMCTX, pool, idpRepo.IDCondition(addAzure.Id), instanceID, &orgID) azure, err := idpRepo.GetAzureAD(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.IDCondition(addAzure.Id))))
require.NoError(t, err) require.NoError(t, err)
// event org.idp.azure.added // event org.idp.azure.added
@@ -1103,7 +1065,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
assert.Equal(t, true, azure.AllowLinking) assert.Equal(t, true, azure.AllowLinking)
assert.Equal(t, true, azure.AllowCreation) assert.Equal(t, true, azure.AllowCreation)
assert.Equal(t, true, azure.AllowAutoUpdate) assert.Equal(t, true, azure.AllowAutoUpdate)
assert.Equal(t, domain.IDPAutoLinkingFieldUserName, domain.IDPAutoLinkingField(*azure.AutoLinkingField)) assert.Equal(t, domain.IDPAutoLinkingFieldUsername, domain.IDPAutoLinkingField(*azure.AutoLinkingField))
assert.WithinRange(t, azure.UpdatedAt, before, after) assert.WithinRange(t, azure.UpdatedAt, before, after)
// azure // azure
@@ -1145,7 +1107,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
var azure *domain.IDPAzureAD var azure *domain.IDPAzureAD
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
azure, err = idpRepo.GetAzureAD(IAMCTX, pool, idpRepo.IDCondition(addAzure.Id), instanceID, &orgID) azure, err = idpRepo.GetAzureAD(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.IDCondition(addAzure.Id))))
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, addAzure.Id, azure.ID) assert.Equal(t, addAzure.Id, azure.ID)
}, retryDuration, tick) }, retryDuration, tick)
@@ -1179,7 +1141,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
// check values for azure // check values for azure
retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
updateAzure, err := idpRepo.GetAzureAD(IAMCTX, pool, idpRepo.IDCondition(addAzure.Id), instanceID, &orgID) updateAzure, err := idpRepo.GetAzureAD(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.IDCondition(addAzure.Id))))
require.NoError(t, err) require.NoError(t, err)
// event org.idp.azure.changed // event org.idp.azure.changed
@@ -1230,7 +1192,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
// check values for github // check values for github
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
github, err := idpRepo.GetGithub(IAMCTX, pool, idpRepo.IDCondition(addGithub.Id), instanceID, &orgID) github, err := idpRepo.GetGithub(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.IDCondition(addGithub.Id))))
require.NoError(t, err) require.NoError(t, err)
// event org.idp.github.added // event org.idp.github.added
@@ -1243,7 +1205,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
assert.Equal(t, false, github.AllowLinking) assert.Equal(t, false, github.AllowLinking)
assert.Equal(t, false, github.AllowCreation) assert.Equal(t, false, github.AllowCreation)
assert.Equal(t, false, github.AllowAutoUpdate) assert.Equal(t, false, github.AllowAutoUpdate)
assert.Equal(t, domain.IDPAutoLinkingFieldUserName, domain.IDPAutoLinkingField(*github.AutoLinkingField)) assert.Equal(t, domain.IDPAutoLinkingFieldUsername, domain.IDPAutoLinkingField(*github.AutoLinkingField))
assert.WithinRange(t, github.UpdatedAt, before, after) assert.WithinRange(t, github.UpdatedAt, before, after)
assert.Equal(t, "clientId", github.ClientID) assert.Equal(t, "clientId", github.ClientID)
@@ -1276,7 +1238,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
var github *domain.IDPGithub var github *domain.IDPGithub
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
github, err = idpRepo.GetGithub(IAMCTX, pool, idpRepo.IDCondition(addGithub.Id), instanceID, &orgID) github, err = idpRepo.GetGithub(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.IDCondition(addGithub.Id))))
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, addGithub.Id, github.ID) assert.Equal(t, addGithub.Id, github.ID)
}, retryDuration, tick) }, retryDuration, tick)
@@ -1304,7 +1266,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
// check values for azure // check values for azure
retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
updateGithub, err := idpRepo.GetGithub(IAMCTX, pool, idpRepo.IDCondition(addGithub.Id), instanceID, &orgID) updateGithub, err := idpRepo.GetGithub(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.IDCondition(addGithub.Id))))
require.NoError(t, err) require.NoError(t, err)
// event org.idp.github.changed // event org.idp.github.changed
@@ -1317,7 +1279,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
assert.Equal(t, true, updateGithub.AllowLinking) assert.Equal(t, true, updateGithub.AllowLinking)
assert.Equal(t, true, updateGithub.AllowCreation) assert.Equal(t, true, updateGithub.AllowCreation)
assert.Equal(t, true, updateGithub.AllowAutoUpdate) assert.Equal(t, true, updateGithub.AllowAutoUpdate)
assert.Equal(t, domain.IDPAutoLinkingFieldUserName, domain.IDPAutoLinkingField(*updateGithub.AutoLinkingField)) assert.Equal(t, domain.IDPAutoLinkingFieldUsername, domain.IDPAutoLinkingField(*updateGithub.AutoLinkingField))
assert.WithinRange(t, updateGithub.UpdatedAt, before, after) assert.WithinRange(t, updateGithub.UpdatedAt, before, after)
// github // github
@@ -1356,7 +1318,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
// check values for github enterprise // check values for github enterprise
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
githubEnterprise, err := idpRepo.GetGithubEnterprise(IAMCTX, pool, idpRepo.IDCondition(addGithubEnterprise.Id), instanceID, &orgID) githubEnterprise, err := idpRepo.GetGithubEnterprise(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.IDCondition(addGithubEnterprise.Id))))
require.NoError(t, err) require.NoError(t, err)
// event org.idp.github_enterprise.added // event org.idp.github_enterprise.added
@@ -1410,7 +1372,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
var githubEnterprise *domain.IDPGithubEnterprise var githubEnterprise *domain.IDPGithubEnterprise
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
githubEnterprise, err = idpRepo.GetGithubEnterprise(IAMCTX, pool, idpRepo.IDCondition(addGithubEnterprise.Id), instanceID, &orgID) githubEnterprise, err = idpRepo.GetGithubEnterprise(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.IDCondition(addGithubEnterprise.Id))))
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, addGithubEnterprise.Id, githubEnterprise.ID) assert.Equal(t, addGithubEnterprise.Id, githubEnterprise.ID)
}, retryDuration, tick) }, retryDuration, tick)
@@ -1441,7 +1403,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
// check values for azure // check values for azure
retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
updateGithubEnterprise, err := idpRepo.GetGithubEnterprise(IAMCTX, pool, idpRepo.IDCondition(addGithubEnterprise.Id), instanceID, &orgID) updateGithubEnterprise, err := idpRepo.GetGithubEnterprise(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.IDCondition(addGithubEnterprise.Id))))
require.NoError(t, err) require.NoError(t, err)
// event org.idp.github_enterprise.changed // event org.idp.github_enterprise.changed
@@ -1493,7 +1455,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
// check values for gitlab // check values for gitlab
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
gitlab, err := idpRepo.GetGitlab(IAMCTX, pool, idpRepo.IDCondition(addGithub.Id), instanceID, &orgID) gitlab, err := idpRepo.GetGitlab(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.IDCondition(addGithub.Id))))
require.NoError(t, err) require.NoError(t, err)
// event org.idp.gitlab.added // event org.idp.gitlab.added
@@ -1541,7 +1503,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
var gitlab *domain.IDPGitlab var gitlab *domain.IDPGitlab
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
gitlab, err = idpRepo.GetGitlab(IAMCTX, pool, idpRepo.IDCondition(addGitlab.Id), instanceID, &orgID) gitlab, err = idpRepo.GetGitlab(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.IDCondition(addGitlab.Id))))
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, addGitlab.Id, gitlab.ID) assert.Equal(t, addGitlab.Id, gitlab.ID)
}, retryDuration, tick) }, retryDuration, tick)
@@ -1569,7 +1531,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
// check values for gitlab // check values for gitlab
retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
updateGitlab, err := idpRepo.GetGitlab(IAMCTX, pool, idpRepo.IDCondition(addGitlab.Id), instanceID, &orgID) updateGitlab, err := idpRepo.GetGitlab(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.IDCondition(addGitlab.Id))))
require.NoError(t, err) require.NoError(t, err)
// event org.idp.gitlab.changed // event org.idp.gitlab.changed
@@ -1581,7 +1543,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
assert.Equal(t, true, updateGitlab.AllowLinking) assert.Equal(t, true, updateGitlab.AllowLinking)
assert.Equal(t, true, updateGitlab.AllowCreation) assert.Equal(t, true, updateGitlab.AllowCreation)
assert.Equal(t, true, updateGitlab.AllowAutoUpdate) assert.Equal(t, true, updateGitlab.AllowAutoUpdate)
assert.Equal(t, domain.IDPAutoLinkingFieldUserName, domain.IDPAutoLinkingField(*updateGitlab.AutoLinkingField)) assert.Equal(t, domain.IDPAutoLinkingFieldUsername, domain.IDPAutoLinkingField(*updateGitlab.AutoLinkingField))
assert.WithinRange(t, updateGitlab.UpdatedAt, before, after) assert.WithinRange(t, updateGitlab.UpdatedAt, before, after)
// gitlab // gitlab
@@ -1619,7 +1581,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
// check values for gitlab self hosted // check values for gitlab self hosted
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
gitlabSelfHosted, err := idpRepo.GetGitlabSelfHosting(IAMCTX, pool, idpRepo.IDCondition(addGitlabSelfHosted.Id), instanceID, &orgID) gitlabSelfHosted, err := idpRepo.GetGitlabSelfHosted(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.IDCondition(addGitlabSelfHosted.Id))))
require.NoError(t, err) require.NoError(t, err)
// event org.idp.gitlab_self_hosted.added // event org.idp.gitlab_self_hosted.added
@@ -1666,10 +1628,10 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
idpRepo := repository.IDProviderRepository() idpRepo := repository.IDProviderRepository()
var githlabSelfHosted *domain.IDPGitlabSelfHosting var githlabSelfHosted *domain.IDPGitlabSelfHosted
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
githlabSelfHosted, err = idpRepo.GetGitlabSelfHosting(IAMCTX, pool, idpRepo.IDCondition(addGitlabSelfHosted.Id), instanceID, &orgID) githlabSelfHosted, err = idpRepo.GetGitlabSelfHosted(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.IDCondition(addGitlabSelfHosted.Id))))
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, addGitlabSelfHosted.Id, githlabSelfHosted.ID) assert.Equal(t, addGitlabSelfHosted.Id, githlabSelfHosted.ID)
}, retryDuration, tick) }, retryDuration, tick)
@@ -1698,7 +1660,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
// check values for gitlab self hosted // check values for gitlab self hosted
retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
updateGitlabSelfHosted, err := idpRepo.GetGitlabSelfHosting(IAMCTX, pool, idpRepo.IDCondition(addGitlabSelfHosted.Id), instanceID, &orgID) updateGitlabSelfHosted, err := idpRepo.GetGitlabSelfHosted(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.IDCondition(addGitlabSelfHosted.Id))))
require.NoError(t, err) require.NoError(t, err)
// event org.idp.gitlab_self_hosted.changed // event org.idp.gitlab_self_hosted.changed
@@ -1711,7 +1673,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
assert.Equal(t, true, updateGitlabSelfHosted.AllowLinking) assert.Equal(t, true, updateGitlabSelfHosted.AllowLinking)
assert.Equal(t, true, updateGitlabSelfHosted.AllowCreation) assert.Equal(t, true, updateGitlabSelfHosted.AllowCreation)
assert.Equal(t, true, updateGitlabSelfHosted.AllowAutoUpdate) assert.Equal(t, true, updateGitlabSelfHosted.AllowAutoUpdate)
assert.Equal(t, domain.IDPAutoLinkingFieldUserName, domain.IDPAutoLinkingField(*updateGitlabSelfHosted.AutoLinkingField)) assert.Equal(t, domain.IDPAutoLinkingFieldUsername, domain.IDPAutoLinkingField(*updateGitlabSelfHosted.AutoLinkingField))
assert.WithinRange(t, updateGitlabSelfHosted.UpdatedAt, before, after) assert.WithinRange(t, updateGitlabSelfHosted.UpdatedAt, before, after)
// gitlab self hosted // gitlab self hosted
@@ -1748,7 +1710,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
// check values for google // check values for google
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
google, err := idpRepo.GetGoogle(IAMCTX, pool, idpRepo.IDCondition(addGoogle.Id), instanceID, &orgID) google, err := idpRepo.GetGoogle(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.IDCondition(addGoogle.Id))))
require.NoError(t, err) require.NoError(t, err)
// event org.idp.google.added // event org.idp.google.added
@@ -1796,7 +1758,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
var google *domain.IDPGoogle var google *domain.IDPGoogle
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
google, err = idpRepo.GetGoogle(IAMCTX, pool, idpRepo.IDCondition(addGoogle.Id), instanceID, &orgID) google, err = idpRepo.GetGoogle(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.IDCondition(addGoogle.Id))))
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, addGoogle.Id, google.ID) assert.Equal(t, addGoogle.Id, google.ID)
}, retryDuration, tick) }, retryDuration, tick)
@@ -1824,7 +1786,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
// check values for google // check values for google
retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
updateGoogle, err := idpRepo.GetGoogle(IAMCTX, pool, idpRepo.IDCondition(addGoogle.Id), instanceID, &orgID) updateGoogle, err := idpRepo.GetGoogle(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.IDCondition(addGoogle.Id))))
require.NoError(t, err) require.NoError(t, err)
// event org.idp.google.changed // event org.idp.google.changed
@@ -1837,7 +1799,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
assert.Equal(t, true, updateGoogle.AllowLinking) assert.Equal(t, true, updateGoogle.AllowLinking)
assert.Equal(t, true, updateGoogle.AllowCreation) assert.Equal(t, true, updateGoogle.AllowCreation)
assert.Equal(t, true, updateGoogle.AllowAutoUpdate) assert.Equal(t, true, updateGoogle.AllowAutoUpdate)
assert.Equal(t, domain.IDPAutoLinkingFieldUserName, domain.IDPAutoLinkingField(*updateGoogle.AutoLinkingField)) assert.Equal(t, domain.IDPAutoLinkingFieldUsername, domain.IDPAutoLinkingField(*updateGoogle.AutoLinkingField))
assert.WithinRange(t, updateGoogle.UpdatedAt, before, after) assert.WithinRange(t, updateGoogle.UpdatedAt, before, after)
// google // google
@@ -1860,7 +1822,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
ldap, err := idpRepo.GetLDAP(IAMCTX, pool, idpRepo.IDCondition(addLdap.Id), instanceID, &orgID) ldap, err := idpRepo.GetLDAP(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.IDCondition(addLdap.Id))))
require.NoError(t, err) require.NoError(t, err)
// event org.idp.ldap.v2.added // event org.idp.ldap.v2.added
@@ -1915,7 +1877,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
var ldap *domain.IDPLDAP var ldap *domain.IDPLDAP
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
ldap, err = idpRepo.GetLDAP(IAMCTX, pool, idpRepo.IDCondition(addLdap.Id), instanceID, &orgID) ldap, err = idpRepo.GetLDAP(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.IDCondition(addLdap.Id))))
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, addLdap.Id, ldap.ID) assert.Equal(t, addLdap.Id, ldap.ID)
}, retryDuration, tick) }, retryDuration, tick)
@@ -1964,7 +1926,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
// check values for ldap // check values for ldap
retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
updateLdap, err := idpRepo.GetLDAP(IAMCTX, pool, idpRepo.IDCondition(addLdap.Id), instanceID, &orgID) updateLdap, err := idpRepo.GetLDAP(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.IDCondition(addLdap.Id))))
require.NoError(t, err) require.NoError(t, err)
// event org.idp.ldap.v2.changed // event org.idp.ldap.v2.changed
@@ -1977,7 +1939,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
assert.Equal(t, true, updateLdap.AllowLinking) assert.Equal(t, true, updateLdap.AllowLinking)
assert.Equal(t, true, updateLdap.AllowCreation) assert.Equal(t, true, updateLdap.AllowCreation)
assert.Equal(t, true, updateLdap.AllowAutoUpdate) assert.Equal(t, true, updateLdap.AllowAutoUpdate)
assert.Equal(t, domain.IDPAutoLinkingFieldUserName, domain.IDPAutoLinkingField(*updateLdap.AutoLinkingField)) assert.Equal(t, domain.IDPAutoLinkingFieldUsername, domain.IDPAutoLinkingField(*updateLdap.AutoLinkingField))
assert.WithinRange(t, updateLdap.UpdatedAt, before, after) assert.WithinRange(t, updateLdap.UpdatedAt, before, after)
// ldap // ldap
@@ -2033,7 +1995,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
apple, err := idpRepo.GetApple(IAMCTX, pool, idpRepo.IDCondition(addApple.Id), instanceID, &orgID) apple, err := idpRepo.GetApple(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.IDCondition(addApple.Id))))
require.NoError(t, err) require.NoError(t, err)
// event org.idp.apple.added // event org.idp.apple.added
@@ -2085,7 +2047,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
var apple *domain.IDPApple var apple *domain.IDPApple
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
apple, err = idpRepo.GetApple(IAMCTX, pool, idpRepo.IDCondition(addApple.Id), instanceID, &orgID) apple, err = idpRepo.GetApple(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.IDCondition(addApple.Id))))
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, addApple.Id, apple.ID) assert.Equal(t, addApple.Id, apple.ID)
}, retryDuration, tick) }, retryDuration, tick)
@@ -2115,7 +2077,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
// check values for apple // check values for apple
retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
updateApple, err := idpRepo.GetApple(IAMCTX, pool, idpRepo.IDCondition(addApple.Id), instanceID, &orgID) updateApple, err := idpRepo.GetApple(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.IDCondition(addApple.Id))))
require.NoError(t, err) require.NoError(t, err)
// event nstance.idp.apple.changed // event nstance.idp.apple.changed
@@ -2128,7 +2090,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
assert.Equal(t, true, updateApple.AllowLinking) assert.Equal(t, true, updateApple.AllowLinking)
assert.Equal(t, true, updateApple.AllowCreation) assert.Equal(t, true, updateApple.AllowCreation)
assert.Equal(t, true, updateApple.AllowAutoUpdate) assert.Equal(t, true, updateApple.AllowAutoUpdate)
assert.Equal(t, domain.IDPAutoLinkingFieldUserName, domain.IDPAutoLinkingField(*updateApple.AutoLinkingField)) assert.Equal(t, domain.IDPAutoLinkingFieldUsername, domain.IDPAutoLinkingField(*updateApple.AutoLinkingField))
assert.WithinRange(t, updateApple.UpdatedAt, before, after) assert.WithinRange(t, updateApple.UpdatedAt, before, after)
// apple // apple
@@ -2172,7 +2134,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
saml, err := idpRepo.GetSAML(IAMCTX, pool, idpRepo.IDCondition(addSAML.Id), instanceID, &orgID) saml, err := idpRepo.GetSAML(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.IDCondition(addSAML.Id))))
require.NoError(t, err) require.NoError(t, err)
// event org.idp.saml.added // event org.idp.saml.added
@@ -2233,7 +2195,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
var saml *domain.IDPSAML var saml *domain.IDPSAML
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
saml, err = idpRepo.GetSAML(IAMCTX, pool, idpRepo.IDCondition(addSAML.Id), instanceID, &orgID) saml, err = idpRepo.GetSAML(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.IDCondition(addSAML.Id))))
require.NoError(t, err) require.NoError(t, err)
assert.Equal(t, addSAML.Id, saml.ID) assert.Equal(t, addSAML.Id, saml.ID)
}, retryDuration, tick) }, retryDuration, tick)
@@ -2268,7 +2230,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
// check values for apple // check values for apple
retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
updateSAML, err := idpRepo.GetSAML(IAMCTX, pool, idpRepo.IDCondition(addSAML.Id), instanceID, &orgID) updateSAML, err := idpRepo.GetSAML(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.IDCondition(addSAML.Id))))
require.NoError(t, err) require.NoError(t, err)
// event org.idp.saml.changed // event org.idp.saml.changed
@@ -2281,7 +2243,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
assert.Equal(t, true, updateSAML.AllowLinking) assert.Equal(t, true, updateSAML.AllowLinking)
assert.Equal(t, true, updateSAML.AllowCreation) assert.Equal(t, true, updateSAML.AllowCreation)
assert.Equal(t, true, updateSAML.AllowAutoUpdate) assert.Equal(t, true, updateSAML.AllowAutoUpdate)
assert.Equal(t, domain.IDPAutoLinkingFieldUserName, domain.IDPAutoLinkingField(*updateSAML.AutoLinkingField)) assert.Equal(t, domain.IDPAutoLinkingFieldUsername, domain.IDPAutoLinkingField(*updateSAML.AutoLinkingField))
assert.WithinRange(t, updateSAML.UpdatedAt, before, after) assert.WithinRange(t, updateSAML.UpdatedAt, before, after)
// saml // saml
@@ -2320,11 +2282,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
// check idp exists // check idp exists
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick := integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
_, err := idpRepo.Get(IAMCTX, pool, _, err := idpRepo.Get(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.IDCondition(addOIDC.IdpId))))
idpRepo.IDCondition(addOIDC.IdpId),
instanceID,
&orgID,
)
require.NoError(t, err) require.NoError(t, err)
}, retryDuration, tick) }, retryDuration, tick)
@@ -2337,11 +2295,7 @@ func TestServer_TestIDProviderOrgReduces(t *testing.T) {
// check idp is removed // check idp is removed
retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute) retryDuration, tick = integration.WaitForAndTickWithMaxDuration(IAMCTX, time.Minute)
assert.EventuallyWithT(t, func(t *assert.CollectT) { assert.EventuallyWithT(t, func(t *assert.CollectT) {
_, err := idpRepo.Get(IAMCTX, pool, _, err := idpRepo.Get(IAMCTX, pool, database.WithCondition(database.And(idpRepo.InstanceIDCondition(instanceID), idpRepo.OrgIDCondition(&orgID), idpRepo.IDCondition(addOIDC.IdpId))))
idpRepo.IDCondition(addOIDC.IdpId),
instanceID,
&orgID,
)
require.ErrorIs(t, &database.NoRowFoundError{}, err) require.ErrorIs(t, &database.NoRowFoundError{}, err)
}, retryDuration, tick) }, retryDuration, tick)
}) })
@@ -17,49 +17,54 @@ func IDProviderRepository() domain.IDProviderRepository {
return new(idProvider) return new(idProvider)
} }
const queryIDProviderStmt = `SELECT instance_id, org_id, id, state, name, type, auto_register, allow_creation, allow_auto_creation,` + func (idProvider) qualifiedTableName() string {
` allow_auto_update, allow_linking, auto_linking_field, styling_type, payload, created_at, updated_at` + return "zitadel.identity_providers"
}
const queryIDProviderStmt = `SELECT instance_id, org_id, id, state, name, type, allow_creation, allow_auto_creation,` +
` allow_auto_update, allow_linking, auto_linking_field, payload, created_at, updated_at` +
` FROM zitadel.identity_providers` ` FROM zitadel.identity_providers`
func (i *idProvider) Get(ctx context.Context, client database.QueryExecutor, id domain.IDPIdentifierCondition, instanceID string, orgID *string) (*domain.IdentityProvider, error) { func (i *idProvider) Get(ctx context.Context, client database.QueryExecutor, opts ...database.QueryOption) (*domain.IdentityProvider, error) {
builder := database.StatementBuilder{} options := new(database.QueryOpts)
for _, opt := range opts {
builder.WriteString(queryIDProviderStmt) opt(options)
}
conditions := []database.Condition{id, i.InstanceIDCondition(instanceID), i.OrgIDCondition(orgID)} if err := checkRestrictingColumns(options.Condition, i.InstanceIDColumn()); err != nil {
return nil, err
writeCondition(&builder, database.And(conditions...))
return scanIDProvider(ctx, client, &builder)
}
func (i *idProvider) List(ctx context.Context, client database.QueryExecutor, conditions ...database.Condition) ([]*domain.IdentityProvider, error) {
builder := database.StatementBuilder{}
builder.WriteString(queryIDProviderStmt)
if conditions != nil {
writeCondition(&builder, database.And(conditions...))
} }
orderBy := database.OrderBy(i.CreatedAtColumn()) builder := database.NewStatementBuilder(queryIDProviderStmt)
orderBy.Write(&builder) options.Write(builder)
return scanIDProviders(ctx, client, &builder) return scanIDProvider(ctx, client, builder)
} }
const createIDProviderStmtStart = `INSERT INTO zitadel.identity_providers` + func (i *idProvider) List(ctx context.Context, client database.QueryExecutor, opts ...database.QueryOption) ([]*domain.IdentityProvider, error) {
` (instance_id, org_id, id, state, name, type, allow_creation, allow_auto_creation,` + options := new(database.QueryOpts)
` allow_auto_update, allow_linking, styling_type, payload) VALUES (` for _, opt := range opts {
opt(options)
}
const createIDProviderStmtEnd = `) RETURNING created_at, updated_at` if err := checkRestrictingColumns(options.Condition, i.InstanceIDColumn()); err != nil {
return nil, err
}
builder := database.NewStatementBuilder(queryIDProviderStmt)
options.Write(builder)
return scanIDProviders(ctx, client, builder)
}
const (
createIDProviderStmtStart = `INSERT INTO zitadel.identity_providers` +
` (instance_id, org_id, id, state, name, type, allow_creation, allow_auto_creation,` +
` allow_auto_update, allow_linking, auto_linking_field, payload, created_at, updated_at) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, `
createIDProviderStmtEnd = `) RETURNING created_at, updated_at`
)
func (i *idProvider) Create(ctx context.Context, client database.QueryExecutor, idp *domain.IdentityProvider) error { func (i *idProvider) Create(ctx context.Context, client database.QueryExecutor, idp *domain.IdentityProvider) error {
builder := database.StatementBuilder{} builder := database.NewStatementBuilder(createIDProviderStmtStart,
builder.WriteString(createIDProviderStmtStart)
builder.WriteArgs(
idp.InstanceID, idp.InstanceID,
idp.OrgID, idp.OrgID,
idp.ID, idp.ID,
@@ -70,364 +75,227 @@ func (i *idProvider) Create(ctx context.Context, client database.QueryExecutor,
idp.AllowAutoCreation, idp.AllowAutoCreation,
idp.AllowAutoUpdate, idp.AllowAutoUpdate,
idp.AllowLinking, idp.AllowLinking,
idp.StylingType, idp.AutoLinkingField,
string(idp.Payload)) idp.Payload,
)
var createdAt any = database.NowInstruction
if !idp.CreatedAt.IsZero() {
createdAt = idp.CreatedAt
}
builder.WriteArgs(createdAt, createdAt)
builder.WriteString(createIDProviderStmtEnd) builder.WriteString(createIDProviderStmtEnd)
err := client.QueryRow(ctx, builder.String(), builder.Args()...).Scan(&idp.CreatedAt, &idp.UpdatedAt) return client.QueryRow(ctx, builder.String(), builder.Args()...).Scan(&idp.CreatedAt, &idp.UpdatedAt)
return err
} }
func (i *idProvider) Update(ctx context.Context, client database.QueryExecutor, id domain.IDPIdentifierCondition, instanceID string, orgID *string, changes ...database.Change) (int64, error) { func (i *idProvider) Update(ctx context.Context, client database.QueryExecutor, condition database.Condition, changes ...database.Change) (int64, error) {
if changes == nil { if changes == nil {
return 0, database.ErrNoChanges return 0, database.ErrNoChanges
} }
changes = append(changes, i.SetUpdatedAt(nil)) if err := checkRestrictingColumns(condition, i.InstanceIDColumn(), i.IDColumn()); err != nil {
builder := database.StatementBuilder{} return 0, err
builder.WriteString(`UPDATE zitadel.identity_providers SET `)
conditions := []database.Condition{
id,
i.InstanceIDCondition(instanceID),
i.OrgIDCondition(orgID),
} }
err := database.Changes(changes).Write(&builder) dbChanges := database.Changes(changes)
if !dbChanges.IsOnColumn(i.UpdatedAtColumn()) {
dbChanges = append(dbChanges, i.SetUpdatedAt(nil))
}
builder := database.NewStatementBuilder(`UPDATE zitadel.identity_providers SET `)
err := dbChanges.Write(builder)
if err != nil { if err != nil {
return 0, err return 0, err
} }
writeCondition(&builder, database.And(conditions...)) writeCondition(builder, condition)
stmt := builder.String()
return client.Exec(ctx, stmt, builder.Args()...)
}
func (i *idProvider) Delete(ctx context.Context, client database.QueryExecutor, id domain.IDPIdentifierCondition, instanceID string, orgID *string) (int64, error) {
builder := database.StatementBuilder{}
builder.WriteString(`DELETE FROM zitadel.identity_providers`)
conditions := []database.Condition{
id,
i.InstanceIDCondition(instanceID),
i.OrgIDCondition(orgID),
}
writeCondition(&builder, database.And(conditions...))
return client.Exec(ctx, builder.String(), builder.Args()...) return client.Exec(ctx, builder.String(), builder.Args()...)
} }
func (i *idProvider) GetOIDC(ctx context.Context, client database.QueryExecutor, id domain.IDPIdentifierCondition, instanceID string, orgID *string) (*domain.IDPOIDC, error) { func (i *idProvider) Delete(ctx context.Context, client database.QueryExecutor, condition database.Condition) (int64, error) {
idpOIDC := &domain.IDPOIDC{} if err := checkRestrictingColumns(condition, i.InstanceIDColumn(), i.IDColumn()); err != nil {
var err error return 0, err
idpOIDC.IdentityProvider, err = i.Get(ctx, client, id, instanceID, orgID)
if err != nil {
return nil, err
} }
var idpType domain.IDPType builder := database.NewStatementBuilder(`DELETE FROM `)
if idpOIDC.Type != nil { builder.WriteString(i.qualifiedTableName())
idpType = *idpOIDC.Type writeCondition(builder, condition)
}
if idpType != domain.IDPTypeOIDC { return client.Exec(ctx, builder.String(), builder.Args()...)
return nil, domain.NewIDPWrongTypeError(domain.IDPTypeOIDC, idpType)
}
err = json.Unmarshal(idpOIDC.Payload, idpOIDC)
if err != nil {
return nil, err
}
return idpOIDC, nil
} }
func (i *idProvider) GetJWT(ctx context.Context, client database.QueryExecutor, id domain.IDPIdentifierCondition, instanceID string, orgID *string) (*domain.IDPJWT, error) { func (i *idProvider) GetOIDC(ctx context.Context, client database.QueryExecutor, opts ...database.QueryOption) (*domain.IDPOIDC, error) {
idpJWT := &domain.IDPJWT{} idp, typ, err := getIDP[domain.OIDC](ctx, client, i, domain.IDPTypeOIDC, opts...)
var err error
idpJWT.IdentityProvider, err = i.Get(ctx, client, id, instanceID, orgID)
if err != nil { if err != nil {
return nil, err return nil, err
} }
var idpType domain.IDPType return &domain.IDPOIDC{
if idpJWT.Type != nil { IdentityProvider: idp,
idpType = *idpJWT.Type OIDC: typ,
} }, nil
if idpType != domain.IDPTypeJWT {
return nil, domain.NewIDPWrongTypeError(domain.IDPTypeJWT, idpType)
}
err = json.Unmarshal(idpJWT.Payload, idpJWT)
if err != nil {
return nil, err
}
return idpJWT, nil
} }
func (i *idProvider) GetOAuth(ctx context.Context, client database.QueryExecutor, id domain.IDPIdentifierCondition, instanceID string, orgID *string) (*domain.IDPOAuth, error) { func (i *idProvider) GetJWT(ctx context.Context, client database.QueryExecutor, opts ...database.QueryOption) (*domain.IDPJWT, error) {
idpOAuth := &domain.IDPOAuth{} idp, typ, err := getIDP[domain.JWT](ctx, client, i, domain.IDPTypeJWT, opts...)
var err error
idpOAuth.IdentityProvider, err = i.Get(ctx, client, id, instanceID, orgID)
if err != nil { if err != nil {
return nil, err return nil, err
} }
var idpType domain.IDPType return &domain.IDPJWT{
if idpOAuth.Type != nil { IdentityProvider: idp,
idpType = *idpOAuth.Type JWT: typ,
} }, nil
if idpType != domain.IDPTypeOAuth {
return nil, domain.NewIDPWrongTypeError(domain.IDPTypeOAuth, idpType)
}
err = json.Unmarshal(idpOAuth.Payload, idpOAuth)
if err != nil {
return nil, err
}
return idpOAuth, nil
} }
func (i *idProvider) GetAzureAD(ctx context.Context, client database.QueryExecutor, id domain.IDPIdentifierCondition, instanceID string, orgID *string) (*domain.IDPAzureAD, error) { func (i *idProvider) GetOAuth(ctx context.Context, client database.QueryExecutor, opts ...database.QueryOption) (*domain.IDPOAuth, error) {
idpAzure := &domain.IDPAzureAD{} idp, typ, err := getIDP[domain.OAuth](ctx, client, i, domain.IDPTypeOAuth, opts...)
var err error
idpAzure.IdentityProvider, err = i.Get(ctx, client, id, instanceID, orgID)
if err != nil { if err != nil {
return nil, err return nil, err
} }
var idpType domain.IDPType return &domain.IDPOAuth{
if idpAzure.Type != nil { IdentityProvider: idp,
idpType = *idpAzure.Type OAuth: typ,
} }, nil
if idpType != domain.IDPTypeAzure {
return nil, domain.NewIDPWrongTypeError(domain.IDPTypeAzure, idpType)
}
err = json.Unmarshal(idpAzure.Payload, idpAzure)
if err != nil {
return nil, err
}
return idpAzure, nil
} }
func (i *idProvider) GetGoogle(ctx context.Context, client database.QueryExecutor, id domain.IDPIdentifierCondition, instanceID string, orgID *string) (*domain.IDPGoogle, error) { func (i *idProvider) GetAzureAD(ctx context.Context, client database.QueryExecutor, opts ...database.QueryOption) (*domain.IDPAzureAD, error) {
idpGoogle := &domain.IDPGoogle{} idp, typ, err := getIDP[domain.Azure](ctx, client, i, domain.IDPTypeAzure, opts...)
var err error
idpGoogle.IdentityProvider, err = i.Get(ctx, client, id, instanceID, orgID)
if err != nil { if err != nil {
return nil, err return nil, err
} }
var idpType domain.IDPType return &domain.IDPAzureAD{
if idpGoogle.Type != nil { IdentityProvider: idp,
idpType = *idpGoogle.Type Azure: typ,
} }, nil
if idpType != domain.IDPTypeGoogle {
return nil, domain.NewIDPWrongTypeError(domain.IDPTypeGoogle, idpType)
}
err = json.Unmarshal(idpGoogle.Payload, idpGoogle)
if err != nil {
return nil, err
}
return idpGoogle, nil
} }
func (i *idProvider) GetGithub(ctx context.Context, client database.QueryExecutor, id domain.IDPIdentifierCondition, instanceID string, orgID *string) (*domain.IDPGithub, error) { func (i *idProvider) GetGoogle(ctx context.Context, client database.QueryExecutor, opts ...database.QueryOption) (*domain.IDPGoogle, error) {
idpGithub := &domain.IDPGithub{} idp, typ, err := getIDP[domain.Google](ctx, client, i, domain.IDPTypeGoogle, opts...)
var err error
idpGithub.IdentityProvider, err = i.Get(ctx, client, id, instanceID, orgID)
if err != nil { if err != nil {
return nil, err return nil, err
} }
var idpType domain.IDPType return &domain.IDPGoogle{
if idpGithub.Type != nil { IdentityProvider: idp,
idpType = *idpGithub.Type Google: typ,
} }, nil
if idpType != domain.IDPTypeGitHub {
return nil, domain.NewIDPWrongTypeError(domain.IDPTypeGitHub, idpType)
}
err = json.Unmarshal(idpGithub.Payload, idpGithub)
if err != nil {
return nil, err
}
return idpGithub, nil
} }
func (i *idProvider) GetGithubEnterprise(ctx context.Context, client database.QueryExecutor, id domain.IDPIdentifierCondition, instanceID string, orgID *string) (*domain.IDPGithubEnterprise, error) { func (i *idProvider) GetGithub(ctx context.Context, client database.QueryExecutor, opts ...database.QueryOption) (*domain.IDPGithub, error) {
idpGithubEnterprise := &domain.IDPGithubEnterprise{} idp, typ, err := getIDP[domain.Github](ctx, client, i, domain.IDPTypeGitHub, opts...)
var err error
idpGithubEnterprise.IdentityProvider, err = i.Get(ctx, client, id, instanceID, orgID)
if err != nil { if err != nil {
return nil, err return nil, err
} }
var idpType domain.IDPType return &domain.IDPGithub{
if idpGithubEnterprise.Type != nil { IdentityProvider: idp,
idpType = *idpGithubEnterprise.Type Github: typ,
} }, nil
if idpType != domain.IDPTypeGitHubEnterprise {
return nil, domain.NewIDPWrongTypeError(domain.IDPTypeGitHubEnterprise, idpType)
}
err = json.Unmarshal(idpGithubEnterprise.Payload, idpGithubEnterprise)
if err != nil {
return nil, err
}
return idpGithubEnterprise, nil
} }
func (i *idProvider) GetGitlab(ctx context.Context, client database.QueryExecutor, id domain.IDPIdentifierCondition, instanceID string, orgID *string) (*domain.IDPGitlab, error) { func (i *idProvider) GetGithubEnterprise(ctx context.Context, client database.QueryExecutor, opts ...database.QueryOption) (*domain.IDPGithubEnterprise, error) {
idpGitlab := &domain.IDPGitlab{} idp, typ, err := getIDP[domain.GithubEnterprise](ctx, client, i, domain.IDPTypeGitHubEnterprise, opts...)
var err error
idpGitlab.IdentityProvider, err = i.Get(ctx, client, id, instanceID, orgID)
if err != nil { if err != nil {
return nil, err return nil, err
} }
var idpType domain.IDPType return &domain.IDPGithubEnterprise{
if idpGitlab.Type != nil { IdentityProvider: idp,
idpType = *idpGitlab.Type GithubEnterprise: typ,
} }, nil
if idpType != domain.IDPTypeGitLab {
return nil, domain.NewIDPWrongTypeError(domain.IDPTypeGitLab, idpType)
}
err = json.Unmarshal(idpGitlab.Payload, idpGitlab)
if err != nil {
return nil, err
}
return idpGitlab, nil
} }
func (i *idProvider) GetGitlabSelfHosting(ctx context.Context, client database.QueryExecutor, id domain.IDPIdentifierCondition, instanceID string, orgID *string) (*domain.IDPGitlabSelfHosting, error) { func (i *idProvider) GetGitlab(ctx context.Context, client database.QueryExecutor, opts ...database.QueryOption) (*domain.IDPGitlab, error) {
idpGitlabSelfHosting := &domain.IDPGitlabSelfHosting{} idp, typ, err := getIDP[domain.Gitlab](ctx, client, i, domain.IDPTypeGitLab, opts...)
var err error
idpGitlabSelfHosting.IdentityProvider, err = i.Get(ctx, client, id, instanceID, orgID)
if err != nil { if err != nil {
return nil, err return nil, err
} }
var idpType domain.IDPType return &domain.IDPGitlab{
if idpGitlabSelfHosting.Type != nil { IdentityProvider: idp,
idpType = *idpGitlabSelfHosting.Type Gitlab: typ,
} }, nil
if idpType != domain.IDPTypeGitLabSelfHosted {
return nil, domain.NewIDPWrongTypeError(domain.IDPTypeGitLabSelfHosted, idpType)
}
err = json.Unmarshal(idpGitlabSelfHosting.Payload, idpGitlabSelfHosting)
if err != nil {
return nil, err
}
return idpGitlabSelfHosting, nil
} }
func (i *idProvider) GetLDAP(ctx context.Context, client database.QueryExecutor, id domain.IDPIdentifierCondition, instanceID string, orgID *string) (*domain.IDPLDAP, error) { func (i *idProvider) GetGitlabSelfHosted(ctx context.Context, client database.QueryExecutor, opts ...database.QueryOption) (*domain.IDPGitlabSelfHosted, error) {
ldap := &domain.IDPLDAP{} idp, typ, err := getIDP[domain.GitlabSelfHosted](ctx, client, i, domain.IDPTypeGitLabSelfHosted, opts...)
var err error
ldap.IdentityProvider, err = i.Get(ctx, client, id, instanceID, orgID)
if err != nil { if err != nil {
return nil, err return nil, err
} }
var idpType domain.IDPType return &domain.IDPGitlabSelfHosted{
if ldap.Type != nil { IdentityProvider: idp,
idpType = *ldap.Type GitlabSelfHosted: typ,
} }, nil
if idpType != domain.IDPTypeLDAP {
return nil, domain.NewIDPWrongTypeError(domain.IDPTypeLDAP, idpType)
}
err = json.Unmarshal(ldap.Payload, ldap)
if err != nil {
return nil, err
}
return ldap, nil
} }
func (i *idProvider) GetApple(ctx context.Context, client database.QueryExecutor, id domain.IDPIdentifierCondition, instanceID string, orgID *string) (*domain.IDPApple, error) { func (i *idProvider) GetLDAP(ctx context.Context, client database.QueryExecutor, opts ...database.QueryOption) (*domain.IDPLDAP, error) {
apple := &domain.IDPApple{} idp, typ, err := getIDP[domain.LDAP](ctx, client, i, domain.IDPTypeLDAP, opts...)
var err error
apple.IdentityProvider, err = i.Get(ctx, client, id, instanceID, orgID)
if err != nil { if err != nil {
return nil, err return nil, err
} }
var idpType domain.IDPType return &domain.IDPLDAP{
if apple.Type != nil { IdentityProvider: idp,
idpType = *apple.Type LDAP: typ,
} }, nil
if idpType != domain.IDPTypeApple {
return nil, domain.NewIDPWrongTypeError(domain.IDPTypeApple, idpType)
}
err = json.Unmarshal(apple.Payload, apple)
if err != nil {
return nil, err
}
return apple, nil
} }
func (i *idProvider) GetSAML(ctx context.Context, client database.QueryExecutor, id domain.IDPIdentifierCondition, instanceID string, orgID *string) (*domain.IDPSAML, error) { func (i *idProvider) GetApple(ctx context.Context, client database.QueryExecutor, opts ...database.QueryOption) (*domain.IDPApple, error) {
saml := &domain.IDPSAML{} idp, typ, err := getIDP[domain.Apple](ctx, client, i, domain.IDPTypeApple, opts...)
var err error
saml.IdentityProvider, err = i.Get(ctx, client, id, instanceID, orgID)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return &domain.IDPApple{
IdentityProvider: idp,
Apple: typ,
}, nil
}
func (i *idProvider) GetSAML(ctx context.Context, client database.QueryExecutor, opts ...database.QueryOption) (*domain.IDPSAML, error) {
idp, typ, err := getIDP[domain.SAML](ctx, client, i, domain.IDPTypeSAML, opts...)
if err != nil {
return nil, err
}
return &domain.IDPSAML{
IdentityProvider: idp,
SAML: typ,
}, nil
}
type idpType interface {
domain.OIDC | domain.JWT | domain.OAuth | domain.Azure | domain.Google |
domain.Github | domain.GithubEnterprise | domain.Gitlab | domain.GitlabSelfHosted |
domain.LDAP | domain.Apple | domain.SAML
}
func getIDP[T idpType](ctx context.Context, client database.QueryExecutor, repo *idProvider, expectedType domain.IDPType, opts ...database.QueryOption) (*domain.IdentityProvider, T, error) {
var zero T
idp, err := repo.Get(ctx, client, opts...)
if err != nil {
return nil, zero, err
}
var idpType domain.IDPType var idpType domain.IDPType
if saml.Type != nil { if idp.Type != nil {
idpType = *saml.Type idpType = *idp.Type
} }
if idpType != domain.IDPTypeSAML { if idpType != expectedType {
return nil, domain.NewIDPWrongTypeError(domain.IDPTypeSAML, idpType) return nil, zero, domain.NewIDPWrongTypeError(expectedType, idpType)
} }
err = json.Unmarshal(saml.Payload, saml) var specificIDP T
err = json.Unmarshal(idp.Payload, &specificIDP)
if err != nil { if err != nil {
return nil, err return nil, zero, err
} }
return saml, nil return idp, specificIDP, nil
} }
// ------------------------------------------------------------- // -------------------------------------------------------------
@@ -466,10 +334,6 @@ func (idProvider) TypeColumn() database.Column {
return database.NewColumn("identity_providers", "type") return database.NewColumn("identity_providers", "type")
} }
func (idProvider) AutoRegisterColumn() database.Column {
return database.NewColumn("identity_providers", "auto_register")
}
func (idProvider) AllowCreationColumn() database.Column { func (idProvider) AllowCreationColumn() database.Column {
return database.NewColumn("identity_providers", "allow_creation") return database.NewColumn("identity_providers", "allow_creation")
} }
@@ -486,14 +350,10 @@ func (idProvider) AllowLinkingColumn() database.Column {
return database.NewColumn("identity_providers", "allow_linking") return database.NewColumn("identity_providers", "allow_linking")
} }
func (idProvider) AllowAutoLinkingColumn() database.Column { func (idProvider) AutoLinkingFieldColumn() database.Column {
return database.NewColumn("identity_providers", "auto_linking_field") return database.NewColumn("identity_providers", "auto_linking_field")
} }
func (idProvider) StylingTypeColumn() database.Column {
return database.NewColumn("identity_providers", "styling_type")
}
func (idProvider) PayloadColumn() database.Column { func (idProvider) PayloadColumn() database.Column {
return database.NewColumn("identity_providers", "payload") return database.NewColumn("identity_providers", "payload")
} }
@@ -528,7 +388,7 @@ func (i idProvider) OrgIDCondition(id *string) database.Condition {
return database.NewTextCondition(i.OrgIDColumn(), database.TextOperationEqual, *id) return database.NewTextCondition(i.OrgIDColumn(), database.TextOperationEqual, *id)
} }
func (i idProvider) IDCondition(id string) domain.IDPIdentifierCondition { func (i idProvider) IDCondition(id string) database.Condition {
return database.NewTextCondition(i.IDColumn(), database.TextOperationEqual, id) return database.NewTextCondition(i.IDColumn(), database.TextOperationEqual, id)
} }
@@ -536,46 +396,14 @@ func (i idProvider) StateCondition(state domain.IDPState) database.Condition {
return database.NewTextCondition(i.StateColumn(), database.TextOperationEqual, state.String()) return database.NewTextCondition(i.StateColumn(), database.TextOperationEqual, state.String())
} }
func (i idProvider) NameCondition(name string) domain.IDPIdentifierCondition { func (i idProvider) NameCondition(op database.TextOperation, name string) database.Condition {
return database.NewTextCondition(i.NameColumn(), database.TextOperationEqual, name) return database.NewTextCondition(i.NameColumn(), op, name)
} }
func (i idProvider) TypeCondition(typ domain.IDPType) database.Condition { func (i idProvider) TypeCondition(typ domain.IDPType) database.Condition {
return database.NewNumberCondition(i.TypeColumn(), database.NumberOperationEqual, typ) return database.NewNumberCondition(i.TypeColumn(), database.NumberOperationEqual, typ)
} }
func (i idProvider) AutoRegisterCondition(allow bool) database.Condition {
return database.NewBooleanCondition(i.AutoRegisterColumn(), allow)
}
func (i idProvider) AllowCreationCondition(allow bool) database.Condition {
return database.NewBooleanCondition(i.AllowCreationColumn(), allow)
}
func (i idProvider) AllowAutoCreationCondition(allow bool) database.Condition {
return database.NewBooleanCondition(i.AllowAutoCreationColumn(), allow)
}
func (i idProvider) AllowAutoUpdateCondition(allow bool) database.Condition {
return database.NewBooleanCondition(i.AllowAutoUpdateColumn(), allow)
}
func (i idProvider) AllowLinkingCondition(allow bool) database.Condition {
return database.NewBooleanCondition(i.AllowLinkingColumn(), allow)
}
func (i idProvider) AllowAutoLinkingCondition(linkingType domain.IDPAutoLinkingField) database.Condition {
return database.NewTextCondition(i.AllowAutoLinkingColumn(), database.TextOperationEqual, linkingType.String())
}
func (i idProvider) StylingTypeCondition(style int16) database.Condition {
return database.NewNumberCondition(i.StylingTypeColumn(), database.NumberOperationEqual, style)
}
func (i idProvider) PayloadCondition(payload string) database.Condition {
return database.NewTextCondition(i.PayloadColumn(), database.TextOperationEqual, payload)
}
// ------------------------------------------------------------- // -------------------------------------------------------------
// changes // changes
// ------------------------------------------------------------- // -------------------------------------------------------------
@@ -592,10 +420,6 @@ func (i idProvider) SetAllowCreation(allow bool) database.Change {
return database.NewChange(i.AllowCreationColumn(), allow) return database.NewChange(i.AllowCreationColumn(), allow)
} }
func (i idProvider) SetAutoRegister(allow bool) database.Change {
return database.NewChange(i.AutoRegisterColumn(), allow)
}
func (i idProvider) SetAllowAutoCreation(allow bool) database.Change { func (i idProvider) SetAllowAutoCreation(allow bool) database.Change {
return database.NewChange(i.AllowAutoCreationColumn(), allow) return database.NewChange(i.AllowAutoCreationColumn(), allow)
} }
@@ -608,12 +432,8 @@ func (i idProvider) SetAllowLinking(allow bool) database.Change {
return database.NewChange(i.AllowLinkingColumn(), allow) return database.NewChange(i.AllowLinkingColumn(), allow)
} }
func (i idProvider) SetAutoAllowLinking(allow bool) database.Change { func (i idProvider) SetAutoLinkingField(field *domain.IDPAutoLinkingField) database.Change {
return database.NewChange(i.AllowAutoLinkingColumn(), allow) return database.NewChangePtr(i.AutoLinkingFieldColumn(), field)
}
func (i idProvider) SetStylingType(stylingType int16) database.Change {
return database.NewChange(i.StylingTypeColumn(), stylingType)
} }
func (i idProvider) SetPayload(payload string) database.Change { func (i idProvider) SetPayload(payload string) database.Change {
@@ -624,6 +444,10 @@ func (i idProvider) SetUpdatedAt(updatedAt *time.Time) database.Change {
return database.NewChangePtr(i.UpdatedAtColumn(), updatedAt) return database.NewChangePtr(i.UpdatedAtColumn(), updatedAt)
} }
func (i idProvider) SetType(typee domain.IDPType) database.Change {
return database.NewChange(i.TypeColumn(), typee)
}
func scanIDProvider(ctx context.Context, querier database.Querier, builder *database.StatementBuilder) (*domain.IdentityProvider, error) { func scanIDProvider(ctx context.Context, querier database.Querier, builder *database.StatementBuilder) (*domain.IdentityProvider, error) {
idp := &domain.IdentityProvider{} idp := &domain.IdentityProvider{}
rows, err := querier.Query(ctx, builder.String(), builder.Args()...) rows, err := querier.Query(ctx, builder.String(), builder.Args()...)
File diff suppressed because it is too large Load Diff
@@ -199,7 +199,7 @@ func createIdentityProvider(t *testing.T, tx database.QueryExecutor, instanceID,
AllowAutoCreation: true, AllowAutoCreation: true,
AllowAutoUpdate: true, AllowAutoUpdate: true,
AllowLinking: true, AllowLinking: true,
StylingType: &stylingType, AutoLinkingField: gu.Ptr(domain.IDPAutoLinkingFieldEmail),
Payload: []byte("{}"), Payload: []byte("{}"),
} }
idpRepo := repository.IDProviderRepository() idpRepo := repository.IDProviderRepository()
File diff suppressed because it is too large Load Diff