mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 20:17:32 +00:00
fixup! fixup! fixup! fixup! feat(db): Adding identity_providers table for relational database
This commit is contained in:
@@ -106,5 +106,5 @@ type IDProviderRepository interface {
|
|||||||
|
|
||||||
Create(ctx context.Context, idp *IdentityProvider) error
|
Create(ctx context.Context, idp *IdentityProvider) error
|
||||||
Update(ctx context.Context, id IDPIdentifierCondition, instnaceID string, orgID string, changes ...database.Change) (int64, error)
|
Update(ctx context.Context, id IDPIdentifierCondition, instnaceID string, orgID string, changes ...database.Change) (int64, error)
|
||||||
Delete(ctx context.Context, id IDPIdentifierCondition) (int64, error)
|
Delete(ctx context.Context, id IDPIdentifierCondition, instnaceID string, orgID string) (int64, error)
|
||||||
}
|
}
|
||||||
|
@@ -137,6 +137,6 @@ const (
|
|||||||
|
|
||||||
func writeBooleanOperation[T Boolean](builder *StatementBuilder, col Column, value T) {
|
func writeBooleanOperation[T Boolean](builder *StatementBuilder, col Column, value T) {
|
||||||
col.Write(builder)
|
col.Write(builder)
|
||||||
builder.WriteString(" IS ")
|
builder.WriteString(" = ")
|
||||||
builder.WriteArg(value)
|
builder.WriteArg(value)
|
||||||
}
|
}
|
||||||
|
@@ -103,13 +103,17 @@ func (i *idProvider) Update(ctx context.Context, id domain.IDPIdentifierConditio
|
|||||||
return i.client.Exec(ctx, stmt, builder.Args()...)
|
return i.client.Exec(ctx, stmt, builder.Args()...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *idProvider) Delete(ctx context.Context, id domain.IDPIdentifierCondition) (int64, error) {
|
func (i *idProvider) Delete(ctx context.Context, id domain.IDPIdentifierCondition, instnaceID string, orgID string) (int64, error) {
|
||||||
builder := database.StatementBuilder{}
|
builder := database.StatementBuilder{}
|
||||||
|
|
||||||
builder.WriteString(`DELETE FROM zitadel.identity_providers`)
|
builder.WriteString(`DELETE FROM zitadel.identity_providers`)
|
||||||
|
|
||||||
// conditions := []database.Condition{i.IDCondition(id)}
|
conditions := []database.Condition{
|
||||||
// writeCondition(&builder, database.And(conditions...))
|
id,
|
||||||
|
i.InstanceIDCondition(instnaceID),
|
||||||
|
i.OrgIDCondition(orgID),
|
||||||
|
}
|
||||||
|
writeCondition(&builder, database.And(conditions...))
|
||||||
|
|
||||||
return i.client.Exec(ctx, builder.String(), builder.Args()...)
|
return i.client.Exec(ctx, builder.String(), builder.Args()...)
|
||||||
}
|
}
|
||||||
@@ -191,7 +195,7 @@ func (i idProvider) IDCondition(id string) domain.IDPIdentifierCondition {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (i idProvider) StateCondition(state domain.IDPState) database.Condition {
|
func (i idProvider) StateCondition(state domain.IDPState) database.Condition {
|
||||||
return database.NewTextCondition(i.OrgIDColumn(), 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(name string) domain.IDPIdentifierCondition {
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -810,8 +810,7 @@ func TestDeleteOrganization(t *testing.T) {
|
|||||||
return test{
|
return test{
|
||||||
name: "happy path delete organization filter id",
|
name: "happy path delete organization filter id",
|
||||||
testFunc: func(ctx context.Context, t *testing.T) {
|
testFunc: func(ctx context.Context, t *testing.T) {
|
||||||
organizations := make([]*domain.Organization, noOfOrganizations)
|
for range noOfOrganizations {
|
||||||
for i := range noOfOrganizations {
|
|
||||||
|
|
||||||
org := domain.Organization{
|
org := domain.Organization{
|
||||||
ID: organizationId,
|
ID: organizationId,
|
||||||
@@ -824,7 +823,6 @@ func TestDeleteOrganization(t *testing.T) {
|
|||||||
err := organizationRepo.Create(ctx, &org)
|
err := organizationRepo.Create(ctx, &org)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
organizations[i] = &org
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
orgIdentifierCondition: organizationRepo.IDCondition(organizationId),
|
orgIdentifierCondition: organizationRepo.IDCondition(organizationId),
|
||||||
@@ -838,8 +836,7 @@ func TestDeleteOrganization(t *testing.T) {
|
|||||||
return test{
|
return test{
|
||||||
name: "happy path delete organization filter name",
|
name: "happy path delete organization filter name",
|
||||||
testFunc: func(ctx context.Context, t *testing.T) {
|
testFunc: func(ctx context.Context, t *testing.T) {
|
||||||
organizations := make([]*domain.Organization, noOfOrganizations)
|
for range noOfOrganizations {
|
||||||
for i := range noOfOrganizations {
|
|
||||||
|
|
||||||
org := domain.Organization{
|
org := domain.Organization{
|
||||||
ID: gofakeit.Name(),
|
ID: gofakeit.Name(),
|
||||||
@@ -852,7 +849,6 @@ func TestDeleteOrganization(t *testing.T) {
|
|||||||
err := organizationRepo.Create(ctx, &org)
|
err := organizationRepo.Create(ctx, &org)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
organizations[i] = &org
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
orgIdentifierCondition: organizationRepo.NameCondition(organizationName),
|
orgIdentifierCondition: organizationRepo.NameCondition(organizationName),
|
||||||
@@ -874,8 +870,7 @@ func TestDeleteOrganization(t *testing.T) {
|
|||||||
name: "deleted already deleted organization",
|
name: "deleted already deleted organization",
|
||||||
testFunc: func(ctx context.Context, t *testing.T) {
|
testFunc: func(ctx context.Context, t *testing.T) {
|
||||||
noOfOrganizations := 1
|
noOfOrganizations := 1
|
||||||
organizations := make([]*domain.Organization, noOfOrganizations)
|
for range noOfOrganizations {
|
||||||
for i := range noOfOrganizations {
|
|
||||||
|
|
||||||
org := domain.Organization{
|
org := domain.Organization{
|
||||||
ID: gofakeit.Name(),
|
ID: gofakeit.Name(),
|
||||||
@@ -888,13 +883,12 @@ func TestDeleteOrganization(t *testing.T) {
|
|||||||
err := organizationRepo.Create(ctx, &org)
|
err := organizationRepo.Create(ctx, &org)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
organizations[i] = &org
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// delete organization
|
// delete organization
|
||||||
affectedRows, err := organizationRepo.Delete(ctx,
|
affectedRows, err := organizationRepo.Delete(ctx,
|
||||||
organizationRepo.NameCondition(organizationName),
|
organizationRepo.NameCondition(organizationName),
|
||||||
organizations[0].InstanceID,
|
instanceId,
|
||||||
)
|
)
|
||||||
assert.Equal(t, int64(1), affectedRows)
|
assert.Equal(t, int64(1), affectedRows)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
Reference in New Issue
Block a user