mirror of
https://github.com/zitadel/zitadel.git
synced 2025-02-28 21:27:22 +00:00
fix: remove idps from org login policy after reset (#4327)
This commit is contained in:
parent
f71d158fb0
commit
04ce8b2479
@ -70,6 +70,10 @@ func (p *idpLoginPolicyLinkProjection) reducers() []handler.AggregateReducer {
|
|||||||
Event: org.LoginPolicyIDPProviderRemovedEventType,
|
Event: org.LoginPolicyIDPProviderRemovedEventType,
|
||||||
Reduce: p.reduceRemoved,
|
Reduce: p.reduceRemoved,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Event: org.LoginPolicyRemovedEventType,
|
||||||
|
Reduce: p.reducePolicyRemoved,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Event: org.OrgRemovedEventType,
|
Event: org.OrgRemovedEventType,
|
||||||
Reduce: p.reduceOrgRemoved,
|
Reduce: p.reduceOrgRemoved,
|
||||||
@ -206,3 +210,15 @@ func (p *idpLoginPolicyLinkProjection) reduceOrgRemoved(event eventstore.Event)
|
|||||||
},
|
},
|
||||||
), nil
|
), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *idpLoginPolicyLinkProjection) reducePolicyRemoved(event eventstore.Event) (*handler.Statement, error) {
|
||||||
|
e, ok := event.(*org.LoginPolicyRemovedEvent)
|
||||||
|
if !ok {
|
||||||
|
return nil, errors.ThrowInvalidArgumentf(nil, "HANDL-SF3dg", "reduce.wrong.event.type %s", org.LoginPolicyRemovedEventType)
|
||||||
|
}
|
||||||
|
return crdb.NewDeleteStatement(e,
|
||||||
|
[]handler.Condition{
|
||||||
|
handler.NewCond(IDPLoginPolicyLinkAggregateIDCol, e.Aggregate().ID),
|
||||||
|
},
|
||||||
|
), nil
|
||||||
|
}
|
||||||
|
@ -247,6 +247,33 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "reducePolicyRemoved",
|
||||||
|
args: args{
|
||||||
|
event: getEvent(testEvent(
|
||||||
|
repository.EventType(org.LoginPolicyRemovedEventType),
|
||||||
|
org.AggregateType,
|
||||||
|
nil,
|
||||||
|
), org.LoginPolicyRemovedEventMapper),
|
||||||
|
},
|
||||||
|
reduce: (&idpLoginPolicyLinkProjection{}).reducePolicyRemoved,
|
||||||
|
want: wantReduce{
|
||||||
|
aggregateType: org.AggregateType,
|
||||||
|
sequence: 15,
|
||||||
|
previousSequence: 10,
|
||||||
|
projection: IDPLoginPolicyLinkTable,
|
||||||
|
executer: &testExecuter{
|
||||||
|
executions: []execution{
|
||||||
|
{
|
||||||
|
expectedStmt: "DELETE FROM projections.idp_login_policy_links3 WHERE (aggregate_id = $1)",
|
||||||
|
expectedArgs: []interface{}{
|
||||||
|
"agg-id",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "org.IDPConfigRemovedEvent",
|
name: "org.IDPConfigRemovedEvent",
|
||||||
args: args{
|
args: args{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user