mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 13:19:21 +00:00
fixup! fixup! fixup! added first event
This commit is contained in:
@@ -53,9 +53,11 @@ type IdentityProvider struct {
|
||||
Name string `json:"name,omitempty" db:"name"`
|
||||
Type string `json:"type,omitempty" db:"type"`
|
||||
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"`
|
||||
AllowAutoUpdate bool `json:"allowAutoUpdate,omitempty" db:"allow_auto_update"`
|
||||
AllowLinking bool `json:"allowLinking,omitempty" db:"allow_linking"`
|
||||
AllowAutoLinking bool `json:"allowAutoLinking,omitempty" db:"allow_auto_linking"`
|
||||
StylingType int16 `json:"stylingType,omitempty" db:"styling_type"`
|
||||
Payload *string `json:"payload,omitempty" db:"payload"`
|
||||
CreatedAt time.Time `json:"createdAt,omitempty" db:"created_at"`
|
||||
@@ -107,9 +109,11 @@ type idProviderColumns interface {
|
||||
NameColumn() database.Column
|
||||
TypeColumn() database.Column
|
||||
AllowCreationColumn() database.Column
|
||||
AutoRegisterColumn() database.Column
|
||||
AllowAutoCreationColumn() database.Column
|
||||
AllowAutoUpdateColumn() database.Column
|
||||
AllowLinkingColumn() database.Column
|
||||
AllowAutoLinkingColumn() database.Column
|
||||
StylingTypeColumn() database.Column
|
||||
PayloadColumn() database.Column
|
||||
CreatedAtColumn() database.Column
|
||||
@@ -123,10 +127,12 @@ type idProviderConditions interface {
|
||||
StateCondition(state IDPState) database.Condition
|
||||
NameCondition(name string) IDPIdentifierCondition
|
||||
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(allow bool) database.Condition
|
||||
StylingTypeCondition(style int16) database.Condition
|
||||
PayloadCondition(payload string) database.Condition
|
||||
}
|
||||
@@ -135,9 +141,11 @@ type idProviderChanges interface {
|
||||
SetName(name string) database.Change
|
||||
SetState(state IDPState) database.Change
|
||||
SetAllowCreation(allow bool) database.Change
|
||||
SetAutoRegister(allow bool) database.Change
|
||||
SetAllowAutoCreation(allow bool) database.Change
|
||||
SetAllowAutoUpdate(allow bool) database.Change
|
||||
SetAllowLinking(allow bool) database.Change
|
||||
SetAutoAllowLinking(allow bool) database.Change
|
||||
SetStylingType(stylingType int16) database.Change
|
||||
SetPayload(payload string) database.Change
|
||||
}
|
||||
|
@@ -22,10 +22,12 @@ CREATE TABLE zitadel.identity_providers (
|
||||
, state zitadel.idp_state NOT NULL DEFAULT 'active'
|
||||
, name TEXT NOT NULL CHECK (name <> '')
|
||||
, type zitadel.idp_type -- NOT NULL
|
||||
, auto_register BOOLEAN NOT NULL DEFAULT TRUE
|
||||
, allow_creation BOOLEAN NOT NULL DEFAULT TRUE
|
||||
, allow_auto_creation BOOLEAN NOT NULL DEFAULT TRUE
|
||||
, allow_auto_update BOOLEAN NOT NULL DEFAULT TRUE
|
||||
, allow_linking BOOLEAN NOT NULL DEFAULT TRUE
|
||||
, allow_auto_linking BOOLEAN NOT NULL DEFAULT TRUE
|
||||
, styling_type SMALLINT
|
||||
, payload JSONB
|
||||
|
||||
|
@@ -56,7 +56,7 @@ func TestServer_TestIDProviderReduces(t *testing.T) {
|
||||
assert.Equal(t, name, idp.Name)
|
||||
assert.Equal(t, instanceID, idp.InstanceID)
|
||||
assert.Equal(t, domain.IDPStateActive.String(), idp.State)
|
||||
assert.Equal(t, true, idp.AllowAutoCreation)
|
||||
assert.Equal(t, true, idp.AutoRegister)
|
||||
assert.Equal(t, int16(idp_grpc.IDPStylingType_STYLING_TYPE_GOOGLE), idp.StylingType)
|
||||
assert.WithinRange(t, idp.UpdatedAt, beforeCreate, afterCreate)
|
||||
assert.WithinRange(t, idp.CreatedAt, beforeCreate, afterCreate)
|
||||
@@ -93,7 +93,7 @@ func TestServer_TestIDProviderReduces(t *testing.T) {
|
||||
|
||||
idpRepo := repository.IDProviderRepository(pool)
|
||||
|
||||
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(CTX, time.Minute)
|
||||
retryDuration, tick := integration.WaitForAndTickWithMaxDuration(CTX, time.Second*5)
|
||||
assert.EventuallyWithT(t, func(t *assert.CollectT) {
|
||||
idp, err := idpRepo.Get(CTX,
|
||||
idpRepo.NameCondition(name),
|
||||
@@ -105,7 +105,7 @@ func TestServer_TestIDProviderReduces(t *testing.T) {
|
||||
// event iam.idp.config.changed
|
||||
assert.Equal(t, addOIDC.IdpId, idp.ID)
|
||||
assert.Equal(t, name, idp.Name)
|
||||
assert.Equal(t, false, idp.AllowAutoCreation)
|
||||
assert.Equal(t, false, idp.AutoRegister)
|
||||
assert.Equal(t, int16(idp_grpc.IDPStylingType_STYLING_TYPE_UNSPECIFIED), idp.StylingType)
|
||||
assert.WithinRange(t, idp.UpdatedAt, beforeCreate, afterCreate)
|
||||
}, retryDuration, tick)
|
||||
|
@@ -191,6 +191,10 @@ func (idProvider) TypeColumn() database.Column {
|
||||
return database.NewColumn("type")
|
||||
}
|
||||
|
||||
func (idProvider) AutoRegisterColumn() database.Column {
|
||||
return database.NewColumn("auto_register")
|
||||
}
|
||||
|
||||
func (idProvider) AllowCreationColumn() database.Column {
|
||||
return database.NewColumn("allow_creation")
|
||||
}
|
||||
@@ -207,6 +211,10 @@ func (idProvider) AllowLinkingColumn() database.Column {
|
||||
return database.NewColumn("allow_linking")
|
||||
}
|
||||
|
||||
func (idProvider) AllowAutoLinkingColumn() database.Column {
|
||||
return database.NewColumn("allow_auto_linking")
|
||||
}
|
||||
|
||||
func (idProvider) StylingTypeColumn() database.Column {
|
||||
return database.NewColumn("styling_type")
|
||||
}
|
||||
@@ -254,6 +262,10 @@ func (i idProvider) TypeCondition(typee domain.IDPType) database.Condition {
|
||||
return database.NewTextCondition(i.TypeColumn(), database.TextOperationEqual, typee.String())
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
@@ -270,6 +282,10 @@ func (i idProvider) AllowLinkingCondition(allow bool) database.Condition {
|
||||
return database.NewBooleanCondition(i.AllowLinkingColumn(), allow)
|
||||
}
|
||||
|
||||
func (i idProvider) AllowAutoLinkingCondition(allow bool) database.Condition {
|
||||
return database.NewBooleanCondition(i.AllowAutoLinkingColumn(), allow)
|
||||
}
|
||||
|
||||
func (i idProvider) StylingTypeCondition(style int16) database.Condition {
|
||||
return database.NewNumberCondition(i.StylingTypeColumn(), database.NumberOperationEqual, style)
|
||||
}
|
||||
@@ -294,6 +310,10 @@ func (i idProvider) SetAllowCreation(allow bool) database.Change {
|
||||
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 {
|
||||
return database.NewChange(i.AllowAutoCreationColumn(), allow)
|
||||
}
|
||||
@@ -306,6 +326,10 @@ func (i idProvider) SetAllowLinking(allow bool) database.Change {
|
||||
return database.NewChange(i.AllowLinkingColumn(), allow)
|
||||
}
|
||||
|
||||
func (i idProvider) SetAutoAllowLinking(allow bool) database.Change {
|
||||
return database.NewChange(i.AllowAutoLinkingColumn(), allow)
|
||||
}
|
||||
|
||||
func (i idProvider) SetStylingType(stylingType int16) database.Change {
|
||||
return database.NewChange(i.StylingTypeColumn(), stylingType)
|
||||
}
|
||||
|
@@ -15,10 +15,10 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
IDPRelationalTable = "zitadel.identity_providers"
|
||||
IDPRelationalOrgIdCol = "org_id"
|
||||
IDPRelationalAllowAutoCreationCol = "allow_auto_creation"
|
||||
IDPRelationalPayloadCol = "payload"
|
||||
IDPRelationalTable = "zitadel.identity_providers"
|
||||
IDPRelationalOrgIdCol = "org_id"
|
||||
IDPRelationalAutoRegisterCol = "auto_register"
|
||||
IDPRelationalPayloadCol = "payload"
|
||||
)
|
||||
|
||||
type idpRelationalProjection struct {
|
||||
@@ -103,8 +103,7 @@ func (p *idpRelationalProjection) reduceIDPRelationalAdded(event eventstore.Even
|
||||
handler.NewCol(IDPStateCol, domain.IDPStateActive.String()),
|
||||
handler.NewCol(IDPNameCol, e.Name),
|
||||
handler.NewCol(IDPStylingTypeCol, e.StylingType),
|
||||
handler.NewCol(IDPRelationalAllowAutoCreationCol, e.AutoRegister),
|
||||
// handler.NewCol(IDPTypeCol, domain.IDPTypeOIDC.String()),
|
||||
handler.NewCol(IDPRelationalAutoRegisterCol, e.AutoRegister),
|
||||
handler.NewCol(CreatedAt, e.CreationDate()),
|
||||
},
|
||||
), nil
|
||||
@@ -118,13 +117,13 @@ func (p *idpRelationalProjection) reduceIDPRelationalChanged(event eventstore.Ev
|
||||
|
||||
cols := make([]handler.Column, 0, 5)
|
||||
if e.Name != nil {
|
||||
cols = append(cols, handler.NewCol(IDPNameCol, e.Name))
|
||||
cols = append(cols, handler.NewCol(IDPNameCol, *e.Name))
|
||||
}
|
||||
if e.StylingType != nil {
|
||||
cols = append(cols, handler.NewCol(IDPStylingTypeCol, e.StylingType))
|
||||
cols = append(cols, handler.NewCol(IDPStylingTypeCol, *e.StylingType))
|
||||
}
|
||||
if e.AutoRegister != nil {
|
||||
cols = append(cols, handler.NewCol(IDPRelationalAllowAutoCreationCol, e.AutoRegister))
|
||||
cols = append(cols, handler.NewCol(IDPRelationalAutoRegisterCol, *e.AutoRegister))
|
||||
}
|
||||
if len(cols) == 0 {
|
||||
return handler.NewNoOpStatement(e), nil
|
||||
|
2176
internal/query/projection/idp_template_relational.go
Normal file
2176
internal/query/projection/idp_template_relational.go
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user