fix: migrate external id of federated users (#6312)

* feat: migrate external id

* implement tests and some renaming

* fix projection

* cleanup

* i18n

* fix event type

* handle migration for new services as well

* typo
This commit is contained in:
Livio Spring
2023-08-04 11:35:36 +02:00
committed by GitHub
parent d33a4fbb2f
commit 45262e6829
28 changed files with 611 additions and 9 deletions

View File

@@ -207,6 +207,42 @@ func TestIDPUserLinkProjection_reduces(t *testing.T) {
},
},
},
{
name: "reduceExternalIDMigrated",
args: args{
event: getEvent(testEvent(
repository.EventType(user.UserIDPExternalIDMigratedType),
user.AggregateType,
[]byte(`{
"idpConfigId": "idp-config-id",
"previousId": "previous-id",
"newId": "new-id"
}`),
), eventstore.GenericEventMapper[user.UserIDPExternalIDMigratedEvent]),
},
reduce: (&idpUserLinkProjection{}).reduceExternalIDMigrated,
want: wantReduce{
aggregateType: user.AggregateType,
sequence: 15,
previousSequence: 10,
executer: &testExecuter{
executions: []execution{
{
expectedStmt: "UPDATE projections.idp_user_links3 SET (change_date, sequence, external_user_id) = ($1, $2, $3) WHERE (idp_id = $4) AND (user_id = $5) AND (external_user_id = $6) AND (instance_id = $7)",
expectedArgs: []interface{}{
anyArg{},
uint64(15),
"new-id",
"idp-config-id",
"agg-id",
"previous-id",
"instance-id",
},
},
},
},
},
},
{
name: "org IDPConfigRemovedEvent",
args: args{