mirror of
https://github.com/zitadel/zitadel.git
synced 2025-07-28 16:03:41 +00:00
fix: delete SMTP correctly (#6391)
This commit is contained in:
parent
90a62b777b
commit
8b44794c75
@ -74,6 +74,10 @@ func (p *smtpConfigProjection) reducers() []handler.AggregateReducer {
|
|||||||
Event: instance.SMTPConfigPasswordChangedEventType,
|
Event: instance.SMTPConfigPasswordChangedEventType,
|
||||||
Reduce: p.reduceSMTPConfigPasswordChanged,
|
Reduce: p.reduceSMTPConfigPasswordChanged,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Event: instance.SMTPConfigRemovedEventType,
|
||||||
|
Reduce: p.reduceSMTPConfigRemoved,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Event: instance.InstanceRemovedEventType,
|
Event: instance.InstanceRemovedEventType,
|
||||||
Reduce: reduceInstanceRemovedHelper(SMTPConfigColumnInstanceID),
|
Reduce: reduceInstanceRemovedHelper(SMTPConfigColumnInstanceID),
|
||||||
@ -160,3 +164,17 @@ func (p *smtpConfigProjection) reduceSMTPConfigPasswordChanged(event eventstore.
|
|||||||
},
|
},
|
||||||
), nil
|
), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *smtpConfigProjection) reduceSMTPConfigRemoved(event eventstore.Event) (*handler.Statement, error) {
|
||||||
|
e, err := assertEvent[*instance.SMTPConfigRemovedEvent](event)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return crdb.NewDeleteStatement(
|
||||||
|
e,
|
||||||
|
[]handler.Condition{
|
||||||
|
handler.NewCond(SMTPConfigColumnAggregateID, e.Aggregate().ID),
|
||||||
|
handler.NewCond(SMTPConfigColumnInstanceID, e.Aggregate().InstanceID),
|
||||||
|
},
|
||||||
|
), nil
|
||||||
|
}
|
||||||
|
@ -145,6 +145,33 @@ func TestSMTPConfigProjection_reduces(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "reduceSMTPConfigRemoved",
|
||||||
|
args: args{
|
||||||
|
event: getEvent(testEvent(
|
||||||
|
repository.EventType(instance.SMTPConfigRemovedEventType),
|
||||||
|
instance.AggregateType,
|
||||||
|
[]byte(`{}`),
|
||||||
|
), instance.SMTPConfigRemovedEventMapper),
|
||||||
|
},
|
||||||
|
reduce: (&smtpConfigProjection{}).reduceSMTPConfigRemoved,
|
||||||
|
want: wantReduce{
|
||||||
|
aggregateType: eventstore.AggregateType("instance"),
|
||||||
|
sequence: 15,
|
||||||
|
previousSequence: 10,
|
||||||
|
executer: &testExecuter{
|
||||||
|
executions: []execution{
|
||||||
|
{
|
||||||
|
expectedStmt: "DELETE FROM projections.smtp_configs WHERE (aggregate_id = $1) AND (instance_id = $2)",
|
||||||
|
expectedArgs: []interface{}{
|
||||||
|
"agg-id",
|
||||||
|
"instance-id",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "instance reduceInstanceRemoved",
|
name: "instance reduceInstanceRemoved",
|
||||||
args: args{
|
args: args{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user