mirror of
https://github.com/zitadel/zitadel.git
synced 2025-02-28 19:17:24 +00:00
fix: improve performance by reducing full table scans (#4684)
* use instance id on update in projections * create index on domain in instance_domain projection * add missing instanceID filter to app queries
This commit is contained in:
parent
ac66a54df9
commit
78ae64471a
@ -279,6 +279,7 @@ func (q *Queries) AppBySAMLEntityID(ctx context.Context, entityID string) (*App,
|
||||
query, args, err := stmt.Where(
|
||||
sq.Eq{
|
||||
AppSAMLConfigColumnEntityID.identifier(): entityID,
|
||||
AppColumnInstanceID.identifier(): authz.GetInstance(ctx).InstanceID(),
|
||||
},
|
||||
).ToSql()
|
||||
if err != nil {
|
||||
@ -292,11 +293,14 @@ func (q *Queries) AppBySAMLEntityID(ctx context.Context, entityID string) (*App,
|
||||
func (q *Queries) ProjectByClientID(ctx context.Context, appID string) (*Project, error) {
|
||||
stmt, scan := prepareProjectByAppQuery()
|
||||
query, args, err := stmt.Where(
|
||||
sq.And{
|
||||
sq.Eq{AppColumnInstanceID.identifier(): authz.GetInstance(ctx).InstanceID()},
|
||||
sq.Or{
|
||||
sq.Eq{AppOIDCConfigColumnClientID.identifier(): appID},
|
||||
sq.Eq{AppAPIConfigColumnClientID.identifier(): appID},
|
||||
sq.Eq{AppSAMLConfigColumnAppID.identifier(): appID},
|
||||
},
|
||||
},
|
||||
).ToSql()
|
||||
if err != nil {
|
||||
return nil, errors.ThrowInternal(err, "QUERY-XhJi3", "Errors.Query.SQLStatement")
|
||||
|
@ -145,6 +145,7 @@ func (p *actionProjection) reduceActionChanged(event eventstore.Event) (*handler
|
||||
values,
|
||||
[]handler.Condition{
|
||||
handler.NewCond(ActionIDCol, e.Aggregate().ID),
|
||||
handler.NewCond(ActionInstanceIDCol, event.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
@ -163,6 +164,7 @@ func (p *actionProjection) reduceActionDeactivated(event eventstore.Event) (*han
|
||||
},
|
||||
[]handler.Condition{
|
||||
handler.NewCond(ActionIDCol, e.Aggregate().ID),
|
||||
handler.NewCond(ActionInstanceIDCol, event.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
@ -181,6 +183,7 @@ func (p *actionProjection) reduceActionReactivated(event eventstore.Event) (*han
|
||||
},
|
||||
[]handler.Condition{
|
||||
handler.NewCond(ActionIDCol, e.Aggregate().ID),
|
||||
handler.NewCond(ActionInstanceIDCol, event.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
@ -194,6 +197,7 @@ func (p *actionProjection) reduceActionRemoved(event eventstore.Event) (*handler
|
||||
e,
|
||||
[]handler.Condition{
|
||||
handler.NewCond(ActionIDCol, e.Aggregate().ID),
|
||||
handler.NewCond(ActionInstanceIDCol, event.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
|
@ -76,13 +76,14 @@ func TestActionProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.actions2 SET (change_date, sequence, name, script) = ($1, $2, $3, $4) WHERE (id = $5)",
|
||||
expectedStmt: "UPDATE projections.actions2 SET (change_date, sequence, name, script) = ($1, $2, $3, $4) WHERE (id = $5) AND (instance_id = $6)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
"name2",
|
||||
"name2(){}",
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -106,12 +107,13 @@ func TestActionProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.actions2 SET (change_date, sequence, action_state) = ($1, $2, $3) WHERE (id = $4)",
|
||||
expectedStmt: "UPDATE projections.actions2 SET (change_date, sequence, action_state) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
domain.ActionStateInactive,
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -135,12 +137,13 @@ func TestActionProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.actions2 SET (change_date, sequence, action_state) = ($1, $2, $3) WHERE (id = $4)",
|
||||
expectedStmt: "UPDATE projections.actions2 SET (change_date, sequence, action_state) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
domain.ActionStateActive,
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -164,9 +167,10 @@ func TestActionProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.actions2 WHERE (id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.actions2 WHERE (id = $1) AND (instance_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -25,7 +25,7 @@ func TestAppProjection_reduces(t *testing.T) {
|
||||
want wantReduce
|
||||
}{
|
||||
{
|
||||
name: "project.reduceAppAdded",
|
||||
name: "project reduceAppAdded",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(project.ApplicationAddedType),
|
||||
@ -62,7 +62,7 @@ func TestAppProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "project.reduceAppChanged",
|
||||
name: "project reduceAppChanged",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(project.ApplicationChangedType),
|
||||
@ -95,7 +95,7 @@ func TestAppProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "project.reduceAppDeactivated",
|
||||
name: "project reduceAppDeactivated",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(project.ApplicationDeactivatedType),
|
||||
@ -127,7 +127,7 @@ func TestAppProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "project.reduceAppReactivated",
|
||||
name: "project reduceAppReactivated",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(project.ApplicationReactivatedType),
|
||||
@ -159,7 +159,7 @@ func TestAppProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "project.reduceAppRemoved",
|
||||
name: "project reduceAppRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(project.ApplicationRemovedType),
|
||||
@ -188,7 +188,7 @@ func TestAppProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "project.reduceProjectRemoved",
|
||||
name: "project reduceProjectRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(project.ProjectRemovedType),
|
||||
@ -215,7 +215,7 @@ func TestAppProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceInstanceRemoved",
|
||||
name: "instance reduceInstanceRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.InstanceRemovedEventType),
|
||||
@ -241,7 +241,7 @@ func TestAppProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "project.reduceAPIConfigAdded",
|
||||
name: "project reduceAPIConfigAdded",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(project.APIConfigAddedType),
|
||||
@ -285,7 +285,7 @@ func TestAppProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "project.reduceAPIConfigChanged",
|
||||
name: "project reduceAPIConfigChanged",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(project.APIConfigChangedType),
|
||||
@ -328,7 +328,7 @@ func TestAppProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "project.reduceAPIConfigChanged noop",
|
||||
name: "project reduceAPIConfigChanged noop",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(project.APIConfigChangedType),
|
||||
@ -349,7 +349,7 @@ func TestAppProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "project.reduceAPIConfigSecretChanged",
|
||||
name: "project reduceAPIConfigSecretChanged",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(project.APIConfigSecretChangedType),
|
||||
@ -389,7 +389,7 @@ func TestAppProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "project.reduceOIDCConfigAdded",
|
||||
name: "project reduceOIDCConfigAdded",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(project.OIDCConfigAddedType),
|
||||
@ -459,7 +459,7 @@ func TestAppProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "project.reduceOIDCConfigChanged",
|
||||
name: "project reduceOIDCConfigChanged",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(project.OIDCConfigChangedType),
|
||||
@ -525,7 +525,7 @@ func TestAppProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "project.reduceOIDCConfigChanged noop",
|
||||
name: "project reduceOIDCConfigChanged noop",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(project.OIDCConfigChangedType),
|
||||
@ -546,7 +546,7 @@ func TestAppProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "project.reduceOIDCConfigSecretChanged",
|
||||
name: "project reduceOIDCConfigSecretChanged",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(project.OIDCConfigSecretChangedType),
|
||||
|
@ -194,7 +194,10 @@ func (p *authNKeyProjection) reduceAuthNKeyEnabledChanged(event eventstore.Event
|
||||
return crdb.NewUpdateStatement(
|
||||
event,
|
||||
[]handler.Column{handler.NewCol(AuthNKeyEnabledCol, enabled)},
|
||||
[]handler.Condition{handler.NewCond(AuthNKeyObjectIDCol, appID)},
|
||||
[]handler.Condition{
|
||||
handler.NewCond(AuthNKeyObjectIDCol, appID),
|
||||
handler.NewCond(AuthNKeyInstanceIDCol, event.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
|
||||
@ -216,6 +219,9 @@ func (p *authNKeyProjection) reduceAuthNKeyRemoved(event eventstore.Event) (*han
|
||||
}
|
||||
return crdb.NewDeleteStatement(
|
||||
event,
|
||||
[]handler.Condition{condition},
|
||||
[]handler.Condition{
|
||||
condition,
|
||||
handler.NewCond(AuthNKeyInstanceIDCol, event.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
|
@ -112,9 +112,10 @@ func TestAuthNKeyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.authn_keys WHERE (id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.authn_keys WHERE (id = $1) AND (instance_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"keyId",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -157,10 +158,11 @@ func TestAuthNKeyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.authn_keys SET enabled = $1 WHERE (object_id = $2)",
|
||||
expectedStmt: "UPDATE projections.authn_keys SET enabled = $1 WHERE (object_id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
false,
|
||||
"appId",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -184,10 +186,11 @@ func TestAuthNKeyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.authn_keys SET enabled = $1 WHERE (object_id = $2)",
|
||||
expectedStmt: "UPDATE projections.authn_keys SET enabled = $1 WHERE (object_id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
true,
|
||||
"appId",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -211,9 +214,10 @@ func TestAuthNKeyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.authn_keys WHERE (id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.authn_keys WHERE (id = $1) AND (instance_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"keyId",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -282,10 +286,11 @@ func TestAuthNKeyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.authn_keys SET enabled = $1 WHERE (object_id = $2)",
|
||||
expectedStmt: "UPDATE projections.authn_keys SET enabled = $1 WHERE (object_id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
false,
|
||||
"appId",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -309,10 +314,11 @@ func TestAuthNKeyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.authn_keys SET enabled = $1 WHERE (object_id = $2)",
|
||||
expectedStmt: "UPDATE projections.authn_keys SET enabled = $1 WHERE (object_id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
true,
|
||||
"appId",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -336,9 +342,10 @@ func TestAuthNKeyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.authn_keys WHERE (id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.authn_keys WHERE (id = $1) AND (instance_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"keyId",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -362,9 +369,10 @@ func TestAuthNKeyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.authn_keys WHERE (object_id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.authn_keys WHERE (object_id = $1) AND (instance_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"appId",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -388,9 +396,10 @@ func TestAuthNKeyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.authn_keys WHERE (aggregate_id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.authn_keys WHERE (aggregate_id = $1) AND (instance_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -414,9 +423,10 @@ func TestAuthNKeyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.authn_keys WHERE (id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.authn_keys WHERE (id = $1) AND (instance_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"keyId",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -440,9 +450,10 @@ func TestAuthNKeyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.authn_keys WHERE (aggregate_id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.authn_keys WHERE (aggregate_id = $1) AND (instance_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -151,6 +151,7 @@ func (p *customTextProjection) reduceRemoved(event eventstore.Event) (*handler.S
|
||||
handler.NewCond(CustomTextTemplateCol, customTextEvent.Template),
|
||||
handler.NewCond(CustomTextKeyCol, customTextEvent.Key),
|
||||
handler.NewCond(CustomTextLanguageCol, customTextEvent.Language.String()),
|
||||
handler.NewCond(CustomTextInstanceIDCol, customTextEvent.Aggregate().InstanceID),
|
||||
}), nil
|
||||
}
|
||||
|
||||
@ -170,5 +171,6 @@ func (p *customTextProjection) reduceTemplateRemoved(event eventstore.Event) (*h
|
||||
handler.NewCond(CustomTextAggregateIDCol, customTextEvent.Aggregate().ID),
|
||||
handler.NewCond(CustomTextTemplateCol, customTextEvent.Template),
|
||||
handler.NewCond(CustomTextLanguageCol, customTextEvent.Language.String()),
|
||||
handler.NewCond(CustomTextInstanceIDCol, customTextEvent.Aggregate().InstanceID),
|
||||
}), nil
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ func TestCustomTextProjection_reduces(t *testing.T) {
|
||||
want wantReduce
|
||||
}{
|
||||
{
|
||||
name: "org.reduceSet",
|
||||
name: "org reduceSet",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.CustomTextSetEventType),
|
||||
@ -62,7 +62,7 @@ func TestCustomTextProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceRemoved",
|
||||
name: "org reduceRemoved",
|
||||
reduce: (&customTextProjection{}).reduceRemoved,
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
@ -82,12 +82,13 @@ func TestCustomTextProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.custom_texts WHERE (aggregate_id = $1) AND (template = $2) AND (key = $3) AND (language = $4)",
|
||||
expectedStmt: "DELETE FROM projections.custom_texts WHERE (aggregate_id = $1) AND (template = $2) AND (key = $3) AND (language = $4) AND (instance_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"InitCode",
|
||||
"Text",
|
||||
"en",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -95,7 +96,7 @@ func TestCustomTextProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceTemplateRemoved",
|
||||
name: "org reduceTemplateRemoved",
|
||||
reduce: (&customTextProjection{}).reduceTemplateRemoved,
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
@ -115,11 +116,12 @@ func TestCustomTextProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.custom_texts WHERE (aggregate_id = $1) AND (template = $2) AND (language = $3)",
|
||||
expectedStmt: "DELETE FROM projections.custom_texts WHERE (aggregate_id = $1) AND (template = $2) AND (language = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"InitCode",
|
||||
"en",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -127,7 +129,7 @@ func TestCustomTextProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceInstanceRemoved",
|
||||
name: "instance reduceInstanceRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.InstanceRemovedEventType),
|
||||
@ -153,7 +155,7 @@ func TestCustomTextProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "iam.reduceAdded",
|
||||
name: "instance reduceAdded",
|
||||
reduce: (&customTextProjection{}).reduceSet,
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
@ -193,7 +195,7 @@ func TestCustomTextProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "iam.reduceRemoved",
|
||||
name: "instance reduceRemoved",
|
||||
reduce: (&customTextProjection{}).reduceRemoved,
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
@ -213,12 +215,13 @@ func TestCustomTextProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.custom_texts WHERE (aggregate_id = $1) AND (template = $2) AND (key = $3) AND (language = $4)",
|
||||
expectedStmt: "DELETE FROM projections.custom_texts WHERE (aggregate_id = $1) AND (template = $2) AND (key = $3) AND (language = $4) AND (instance_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"InitCode",
|
||||
"Text",
|
||||
"en",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -226,7 +229,7 @@ func TestCustomTextProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "iam.reduceTemplateRemoved",
|
||||
name: "instance reduceTemplateRemoved",
|
||||
reduce: (&customTextProjection{}).reduceTemplateRemoved,
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
@ -246,11 +249,12 @@ func TestCustomTextProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.custom_texts WHERE (aggregate_id = $1) AND (template = $2) AND (language = $3)",
|
||||
expectedStmt: "DELETE FROM projections.custom_texts WHERE (aggregate_id = $1) AND (template = $2) AND (language = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"InitCode",
|
||||
"en",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -147,6 +147,7 @@ func (p *debugNotificationProviderProjection) reduceDebugNotificationProviderCha
|
||||
[]handler.Condition{
|
||||
handler.NewCond(DebugNotificationProviderAggIDCol, providerEvent.Aggregate().ID),
|
||||
handler.NewCond(DebugNotificationProviderTypeCol, providerType),
|
||||
handler.NewCond(DebugNotificationProviderInstanceIDCol, providerEvent.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
@ -170,6 +171,7 @@ func (p *debugNotificationProviderProjection) reduceDebugNotificationProviderRem
|
||||
[]handler.Condition{
|
||||
handler.NewCond(DebugNotificationProviderAggIDCol, providerEvent.Aggregate().ID),
|
||||
handler.NewCond(DebugNotificationProviderTypeCol, providerType),
|
||||
handler.NewCond(DebugNotificationProviderInstanceIDCol, providerEvent.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ func TestDebugNotificationProviderProjection_reduces(t *testing.T) {
|
||||
want wantReduce
|
||||
}{
|
||||
{
|
||||
name: "instance.reduceNotificationProviderFileAdded",
|
||||
name: "instance reduceNotificationProviderFileAdded",
|
||||
reduce: (&debugNotificationProviderProjection{}).reduceDebugNotificationProviderAdded,
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
@ -58,7 +58,7 @@ func TestDebugNotificationProviderProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceNotificationProviderFileChanged",
|
||||
name: "instance reduceNotificationProviderFileChanged",
|
||||
reduce: (&debugNotificationProviderProjection{}).reduceDebugNotificationProviderChanged,
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
@ -76,13 +76,14 @@ func TestDebugNotificationProviderProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.notification_providers SET (change_date, sequence, compact) = ($1, $2, $3) WHERE (aggregate_id = $4) AND (provider_type = $5)",
|
||||
expectedStmt: "UPDATE projections.notification_providers SET (change_date, sequence, compact) = ($1, $2, $3) WHERE (aggregate_id = $4) AND (provider_type = $5) AND (instance_id = $6)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
true,
|
||||
"agg-id",
|
||||
domain.NotificationProviderTypeFile,
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -90,7 +91,7 @@ func TestDebugNotificationProviderProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceNotificationProviderFileRemoved",
|
||||
name: "instance reduceNotificationProviderFileRemoved",
|
||||
reduce: (&debugNotificationProviderProjection{}).reduceDebugNotificationProviderRemoved,
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
@ -106,10 +107,11 @@ func TestDebugNotificationProviderProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.notification_providers WHERE (aggregate_id = $1) AND (provider_type = $2)",
|
||||
expectedStmt: "DELETE FROM projections.notification_providers WHERE (aggregate_id = $1) AND (provider_type = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
domain.NotificationProviderTypeFile,
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -117,7 +119,7 @@ func TestDebugNotificationProviderProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceNotificationProviderLogAdded",
|
||||
name: "instance reduceNotificationProviderLogAdded",
|
||||
reduce: (&debugNotificationProviderProjection{}).reduceDebugNotificationProviderAdded,
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
@ -153,7 +155,7 @@ func TestDebugNotificationProviderProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceNotificationProviderLogChanged",
|
||||
name: "instance reduceNotificationProviderLogChanged",
|
||||
reduce: (&debugNotificationProviderProjection{}).reduceDebugNotificationProviderChanged,
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
@ -171,13 +173,14 @@ func TestDebugNotificationProviderProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.notification_providers SET (change_date, sequence, compact) = ($1, $2, $3) WHERE (aggregate_id = $4) AND (provider_type = $5)",
|
||||
expectedStmt: "UPDATE projections.notification_providers SET (change_date, sequence, compact) = ($1, $2, $3) WHERE (aggregate_id = $4) AND (provider_type = $5) AND (instance_id = $6)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
true,
|
||||
"agg-id",
|
||||
domain.NotificationProviderTypeLog,
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -185,7 +188,7 @@ func TestDebugNotificationProviderProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceNotificationProviderLogRemoved",
|
||||
name: "instance reduceNotificationProviderLogRemoved",
|
||||
reduce: (&debugNotificationProviderProjection{}).reduceDebugNotificationProviderRemoved,
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
@ -201,10 +204,11 @@ func TestDebugNotificationProviderProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.notification_providers WHERE (aggregate_id = $1) AND (provider_type = $2)",
|
||||
expectedStmt: "DELETE FROM projections.notification_providers WHERE (aggregate_id = $1) AND (provider_type = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
domain.NotificationProviderTypeLog,
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -212,7 +216,7 @@ func TestDebugNotificationProviderProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceInstanceRemoved",
|
||||
name: "instance reduceInstanceRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.InstanceRemovedEventType),
|
||||
|
@ -155,6 +155,7 @@ func (p *domainPolicyProjection) reduceChanged(event eventstore.Event) (*handler
|
||||
cols,
|
||||
[]handler.Condition{
|
||||
handler.NewCond(DomainPolicyIDCol, policyEvent.Aggregate().ID),
|
||||
handler.NewCond(DomainPolicyInstanceIDCol, policyEvent.Aggregate().InstanceID),
|
||||
}), nil
|
||||
}
|
||||
|
||||
@ -167,5 +168,6 @@ func (p *domainPolicyProjection) reduceRemoved(event eventstore.Event) (*handler
|
||||
policyEvent,
|
||||
[]handler.Condition{
|
||||
handler.NewCond(DomainPolicyIDCol, policyEvent.Aggregate().ID),
|
||||
handler.NewCond(DomainPolicyInstanceIDCol, policyEvent.Aggregate().InstanceID),
|
||||
}), nil
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ func TestDomainPolicyProjection_reduces(t *testing.T) {
|
||||
want wantReduce
|
||||
}{
|
||||
{
|
||||
name: "org.reduceAdded",
|
||||
name: "org reduceAdded",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.DomainPolicyAddedEventType),
|
||||
@ -63,7 +63,7 @@ func TestDomainPolicyProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceChanged",
|
||||
name: "org reduceChanged",
|
||||
reduce: (&domainPolicyProjection{}).reduceChanged,
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
@ -83,7 +83,7 @@ func TestDomainPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.domain_policies SET (change_date, sequence, user_login_must_be_domain, validate_org_domains, smtp_sender_address_matches_instance_domain) = ($1, $2, $3, $4, $5) WHERE (id = $6)",
|
||||
expectedStmt: "UPDATE projections.domain_policies SET (change_date, sequence, user_login_must_be_domain, validate_org_domains, smtp_sender_address_matches_instance_domain) = ($1, $2, $3, $4, $5) WHERE (id = $6) AND (instance_id = $7)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@ -91,6 +91,7 @@ func TestDomainPolicyProjection_reduces(t *testing.T) {
|
||||
true,
|
||||
true,
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -98,7 +99,7 @@ func TestDomainPolicyProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceRemoved",
|
||||
name: "org reduceRemoved",
|
||||
reduce: (&domainPolicyProjection{}).reduceRemoved,
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
@ -114,9 +115,10 @@ func TestDomainPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.domain_policies WHERE (id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.domain_policies WHERE (id = $1) AND (instance_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -124,7 +126,7 @@ func TestDomainPolicyProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceInstanceRemoved",
|
||||
name: "instance reduceInstanceRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.InstanceRemovedEventType),
|
||||
@ -150,7 +152,7 @@ func TestDomainPolicyProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceAdded",
|
||||
name: "instance reduceAdded",
|
||||
reduce: (&domainPolicyProjection{}).reduceAdded,
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
@ -190,7 +192,7 @@ func TestDomainPolicyProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceChanged",
|
||||
name: "instance reduceChanged",
|
||||
reduce: (&domainPolicyProjection{}).reduceChanged,
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
@ -210,7 +212,7 @@ func TestDomainPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.domain_policies SET (change_date, sequence, user_login_must_be_domain, validate_org_domains, smtp_sender_address_matches_instance_domain) = ($1, $2, $3, $4, $5) WHERE (id = $6)",
|
||||
expectedStmt: "UPDATE projections.domain_policies SET (change_date, sequence, user_login_must_be_domain, validate_org_domains, smtp_sender_address_matches_instance_domain) = ($1, $2, $3, $4, $5) WHERE (id = $6) AND (instance_id = $7)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@ -218,6 +220,7 @@ func TestDomainPolicyProjection_reduces(t *testing.T) {
|
||||
true,
|
||||
true,
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -87,6 +87,7 @@ func (p *flowProjection) reduceTriggerActionsSetEventType(event eventstore.Event
|
||||
handler.NewCond(FlowTypeCol, e.FlowType),
|
||||
handler.NewCond(FlowTriggerTypeCol, e.TriggerType),
|
||||
handler.NewCond(FlowResourceOwnerCol, e.Aggregate().ResourceOwner),
|
||||
handler.NewCond(FlowInstanceIDCol, e.Aggregate().InstanceID),
|
||||
},
|
||||
)
|
||||
for i, id := range e.ActionIDs {
|
||||
@ -116,6 +117,7 @@ func (p *flowProjection) reduceFlowClearedEventType(event eventstore.Event) (*ha
|
||||
[]handler.Condition{
|
||||
handler.NewCond(FlowTypeCol, e.FlowType),
|
||||
handler.NewCond(FlowResourceOwnerCol, e.Aggregate().ResourceOwner),
|
||||
handler.NewCond(FlowInstanceIDCol, e.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
|
@ -39,11 +39,12 @@ func TestFlowProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.flows_triggers WHERE (flow_type = $1) AND (trigger_type = $2) AND (resource_owner = $3)",
|
||||
expectedStmt: "DELETE FROM projections.flows_triggers WHERE (flow_type = $1) AND (trigger_type = $2) AND (resource_owner = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
domain.FlowTypeExternalAuthentication,
|
||||
domain.TriggerTypePostAuthentication,
|
||||
"ro-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -93,10 +94,11 @@ func TestFlowProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.flows_triggers WHERE (flow_type = $1) AND (resource_owner = $2)",
|
||||
expectedStmt: "DELETE FROM projections.flows_triggers WHERE (flow_type = $1) AND (resource_owner = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
domain.FlowTypeExternalAuthentication,
|
||||
"ro-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -104,7 +106,7 @@ func TestFlowProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceInstanceRemoved",
|
||||
name: "instance reduceInstanceRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.InstanceRemovedEventType),
|
||||
|
@ -159,6 +159,7 @@ func (p *idpLoginPolicyLinkProjection) reduceRemoved(event eventstore.Event) (*h
|
||||
[]handler.Condition{
|
||||
handler.NewCond(IDPLoginPolicyLinkIDPIDCol, idp.IDPConfigID),
|
||||
handler.NewCond(IDPLoginPolicyLinkAggregateIDCol, idp.Aggregate().ID),
|
||||
handler.NewCond(IDPLoginPolicyLinkInstanceIDCol, event.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
@ -179,6 +180,7 @@ func (p *idpLoginPolicyLinkProjection) reduceCascadeRemoved(event eventstore.Eve
|
||||
[]handler.Condition{
|
||||
handler.NewCond(IDPLoginPolicyLinkIDPIDCol, idp.IDPConfigID),
|
||||
handler.NewCond(IDPLoginPolicyLinkAggregateIDCol, idp.Aggregate().ID),
|
||||
handler.NewCond(IDPLoginPolicyLinkInstanceIDCol, idp.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
@ -199,6 +201,7 @@ func (p *idpLoginPolicyLinkProjection) reduceIDPConfigRemoved(event eventstore.E
|
||||
[]handler.Condition{
|
||||
handler.NewCond(IDPLoginPolicyLinkIDPIDCol, idpID),
|
||||
handler.NewCond(IDPLoginPolicyLinkResourceOwnerCol, event.Aggregate().ResourceOwner),
|
||||
handler.NewCond(IDPLoginPolicyLinkInstanceIDCol, event.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
@ -211,6 +214,7 @@ func (p *idpLoginPolicyLinkProjection) reduceOrgRemoved(event eventstore.Event)
|
||||
return crdb.NewDeleteStatement(e,
|
||||
[]handler.Condition{
|
||||
handler.NewCond(IDPLoginPolicyLinkResourceOwnerCol, e.Aggregate().ID),
|
||||
handler.NewCond(IDPLoginPolicyLinkInstanceIDCol, event.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
@ -223,6 +227,7 @@ func (p *idpLoginPolicyLinkProjection) reducePolicyRemoved(event eventstore.Even
|
||||
return crdb.NewDeleteStatement(e,
|
||||
[]handler.Condition{
|
||||
handler.NewCond(IDPLoginPolicyLinkAggregateIDCol, e.Aggregate().ID),
|
||||
handler.NewCond(IDPLoginPolicyLinkInstanceIDCol, event.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) {
|
||||
want wantReduce
|
||||
}{
|
||||
{
|
||||
name: "iam.reduceAdded",
|
||||
name: "iam reduceAdded",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.LoginPolicyIDPProviderAddedEventType),
|
||||
@ -59,7 +59,7 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "iam.reduceRemoved",
|
||||
name: "iam reduceRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.LoginPolicyIDPProviderRemovedEventType),
|
||||
@ -78,10 +78,11 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.idp_login_policy_links3 WHERE (idp_id = $1) AND (aggregate_id = $2)",
|
||||
expectedStmt: "DELETE FROM projections.idp_login_policy_links3 WHERE (idp_id = $1) AND (aggregate_id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
"idp-config-id",
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -89,7 +90,7 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "iam.reduceCascadeRemoved",
|
||||
name: "iam reduceCascadeRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.LoginPolicyIDPProviderCascadeRemovedEventType),
|
||||
@ -108,10 +109,11 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.idp_login_policy_links3 WHERE (idp_id = $1) AND (aggregate_id = $2)",
|
||||
expectedStmt: "DELETE FROM projections.idp_login_policy_links3 WHERE (idp_id = $1) AND (aggregate_id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
"idp-config-id",
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -119,7 +121,7 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceAdded",
|
||||
name: "org reduceAdded",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.LoginPolicyIDPProviderAddedEventType),
|
||||
@ -155,7 +157,7 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceRemoved",
|
||||
name: "org reduceRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.LoginPolicyIDPProviderRemovedEventType),
|
||||
@ -174,10 +176,11 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.idp_login_policy_links3 WHERE (idp_id = $1) AND (aggregate_id = $2)",
|
||||
expectedStmt: "DELETE FROM projections.idp_login_policy_links3 WHERE (idp_id = $1) AND (aggregate_id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
"idp-config-id",
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -185,7 +188,7 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceInstanceRemoved",
|
||||
name: "instance reduceInstanceRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.InstanceRemovedEventType),
|
||||
@ -211,7 +214,7 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceCascadeRemoved",
|
||||
name: "org reduceCascadeRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.LoginPolicyIDPProviderCascadeRemovedEventType),
|
||||
@ -230,10 +233,11 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.idp_login_policy_links3 WHERE (idp_id = $1) AND (aggregate_id = $2)",
|
||||
expectedStmt: "DELETE FROM projections.idp_login_policy_links3 WHERE (idp_id = $1) AND (aggregate_id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
"idp-config-id",
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -257,9 +261,10 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.idp_login_policy_links3 WHERE (resource_owner = $1)",
|
||||
expectedStmt: "DELETE FROM projections.idp_login_policy_links3 WHERE (resource_owner = $1) AND (instance_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -283,9 +288,10 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.idp_login_policy_links3 WHERE (aggregate_id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.idp_login_policy_links3 WHERE (aggregate_id = $1) AND (instance_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -293,7 +299,7 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.IDPConfigRemovedEvent",
|
||||
name: "org IDPConfigRemovedEvent",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.IDPConfigRemovedEventType),
|
||||
@ -311,10 +317,11 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.idp_login_policy_links3 WHERE (idp_id = $1) AND (resource_owner = $2)",
|
||||
expectedStmt: "DELETE FROM projections.idp_login_policy_links3 WHERE (idp_id = $1) AND (resource_owner = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
"idp-config-id",
|
||||
"ro-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -322,7 +329,7 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "iam.IDPConfigRemovedEvent",
|
||||
name: "iam IDPConfigRemovedEvent",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.IDPConfigRemovedEventType),
|
||||
@ -340,10 +347,11 @@ func TestIDPLoginPolicyLinkProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.idp_login_policy_links3 WHERE (idp_id = $1) AND (resource_owner = $2)",
|
||||
expectedStmt: "DELETE FROM projections.idp_login_policy_links3 WHERE (idp_id = $1) AND (resource_owner = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
"idp-config-id",
|
||||
"ro-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -24,7 +24,7 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
want wantReduce
|
||||
}{
|
||||
{
|
||||
name: "instance.reduceIDPAdded",
|
||||
name: "instance reduceIDPAdded",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.IDPConfigAddedEventType),
|
||||
@ -66,7 +66,7 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceIDPChanged",
|
||||
name: "instance reduceIDPChanged",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.IDPConfigChangedEventType),
|
||||
@ -103,7 +103,7 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceIDPDeactivated",
|
||||
name: "instance reduceIDPDeactivated",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.IDPConfigDeactivatedEventType),
|
||||
@ -135,7 +135,7 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceIDPReactivated",
|
||||
name: "instance reduceIDPReactivated",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.IDPConfigReactivatedEventType),
|
||||
@ -167,7 +167,7 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceIDPRemoved",
|
||||
name: "instance reduceIDPRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.IDPConfigRemovedEventType),
|
||||
@ -196,7 +196,7 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceInstanceRemoved",
|
||||
name: "instance reduceInstanceRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.InstanceRemovedEventType),
|
||||
@ -222,7 +222,7 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceOIDCConfigAdded",
|
||||
name: "instance reduceOIDCConfigAdded",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.IDPOIDCConfigAddedEventType),
|
||||
@ -281,7 +281,7 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceOIDCConfigChanged",
|
||||
name: "instance reduceOIDCConfigChanged",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.IDPOIDCConfigChangedEventType),
|
||||
@ -339,7 +339,7 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceOIDCConfigChanged: no op",
|
||||
name: "instance reduceOIDCConfigChanged: no op",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.IDPOIDCConfigChangedEventType),
|
||||
@ -358,7 +358,7 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceJWTConfigAdded",
|
||||
name: "instance reduceJWTConfigAdded",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.IDPJWTConfigAddedEventType),
|
||||
@ -405,7 +405,7 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceJWTConfigChanged",
|
||||
name: "instance reduceJWTConfigChanged",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.IDPJWTConfigChangedEventType),
|
||||
@ -451,7 +451,7 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceJWTConfigChanged: no op",
|
||||
name: "instance reduceJWTConfigChanged: no op",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.IDPJWTConfigChangedEventType),
|
||||
@ -470,7 +470,7 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceIDPAdded",
|
||||
name: "org reduceIDPAdded",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.IDPConfigAddedEventType),
|
||||
@ -512,7 +512,7 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceIDPChanged",
|
||||
name: "org reduceIDPChanged",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.IDPConfigChangedEventType),
|
||||
@ -549,7 +549,7 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceIDPDeactivated",
|
||||
name: "org reduceIDPDeactivated",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.IDPConfigDeactivatedEventType),
|
||||
@ -581,7 +581,7 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceIDPReactivated",
|
||||
name: "org reduceIDPReactivated",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.IDPConfigReactivatedEventType),
|
||||
@ -613,7 +613,7 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceIDPRemoved",
|
||||
name: "org reduceIDPRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.IDPConfigRemovedEventType),
|
||||
@ -642,7 +642,7 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceOIDCConfigAdded",
|
||||
name: "org reduceOIDCConfigAdded",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.IDPOIDCConfigAddedEventType),
|
||||
@ -701,7 +701,7 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceOIDCConfigChanged",
|
||||
name: "org reduceOIDCConfigChanged",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.IDPOIDCConfigChangedEventType),
|
||||
@ -759,7 +759,7 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceOIDCConfigChanged: no op",
|
||||
name: "org reduceOIDCConfigChanged: no op",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.IDPOIDCConfigChangedEventType),
|
||||
@ -778,7 +778,7 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceJWTConfigAdded",
|
||||
name: "org reduceJWTConfigAdded",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.IDPJWTConfigAddedEventType),
|
||||
@ -825,7 +825,7 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceJWTConfigChanged",
|
||||
name: "org reduceJWTConfigChanged",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.IDPJWTConfigChangedEventType),
|
||||
@ -871,7 +871,7 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceJWTConfigChanged: no op",
|
||||
name: "org reduceJWTConfigChanged: no op",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.IDPJWTConfigChangedEventType),
|
||||
|
@ -137,6 +137,7 @@ func (p *idpUserLinkProjection) reduceRemoved(event eventstore.Event) (*handler.
|
||||
handler.NewCond(IDPUserLinkIDPIDCol, e.IDPConfigID),
|
||||
handler.NewCond(IDPUserLinkUserIDCol, e.Aggregate().ID),
|
||||
handler.NewCond(IDPUserLinkExternalUserIDCol, e.ExternalUserID),
|
||||
handler.NewCond(IDPUserLinkInstanceIDCol, e.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
@ -152,6 +153,7 @@ func (p *idpUserLinkProjection) reduceCascadeRemoved(event eventstore.Event) (*h
|
||||
handler.NewCond(IDPUserLinkIDPIDCol, e.IDPConfigID),
|
||||
handler.NewCond(IDPUserLinkUserIDCol, e.Aggregate().ID),
|
||||
handler.NewCond(IDPUserLinkExternalUserIDCol, e.ExternalUserID),
|
||||
handler.NewCond(IDPUserLinkInstanceIDCol, e.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
@ -165,6 +167,7 @@ func (p *idpUserLinkProjection) reduceOrgRemoved(event eventstore.Event) (*handl
|
||||
return crdb.NewDeleteStatement(e,
|
||||
[]handler.Condition{
|
||||
handler.NewCond(IDPUserLinkResourceOwnerCol, e.Aggregate().ID),
|
||||
handler.NewCond(IDPUserLinkInstanceIDCol, e.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
@ -178,6 +181,7 @@ func (p *idpUserLinkProjection) reduceUserRemoved(event eventstore.Event) (*hand
|
||||
return crdb.NewDeleteStatement(e,
|
||||
[]handler.Condition{
|
||||
handler.NewCond(IDPUserLinkUserIDCol, e.Aggregate().ID),
|
||||
handler.NewCond(IDPUserLinkInstanceIDCol, e.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
@ -198,6 +202,7 @@ func (p *idpUserLinkProjection) reduceIDPConfigRemoved(event eventstore.Event) (
|
||||
[]handler.Condition{
|
||||
handler.NewCond(IDPUserLinkIDPIDCol, idpID),
|
||||
handler.NewCond(IDPUserLinkResourceOwnerCol, event.Aggregate().ResourceOwner),
|
||||
handler.NewCond(IDPUserLinkInstanceIDCol, event.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
|
@ -80,11 +80,12 @@ func TestIDPUserLinkProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.idp_user_links2 WHERE (idp_id = $1) AND (user_id = $2) AND (external_user_id = $3)",
|
||||
expectedStmt: "DELETE FROM projections.idp_user_links2 WHERE (idp_id = $1) AND (user_id = $2) AND (external_user_id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
"idp-config-id",
|
||||
"agg-id",
|
||||
"external-user-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -111,11 +112,12 @@ func TestIDPUserLinkProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.idp_user_links2 WHERE (idp_id = $1) AND (user_id = $2) AND (external_user_id = $3)",
|
||||
expectedStmt: "DELETE FROM projections.idp_user_links2 WHERE (idp_id = $1) AND (user_id = $2) AND (external_user_id = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
"idp-config-id",
|
||||
"agg-id",
|
||||
"external-user-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -139,9 +141,10 @@ func TestIDPUserLinkProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.idp_user_links2 WHERE (resource_owner = $1)",
|
||||
expectedStmt: "DELETE FROM projections.idp_user_links2 WHERE (resource_owner = $1) AND (instance_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -149,7 +152,7 @@ func TestIDPUserLinkProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceInstanceRemoved",
|
||||
name: "instance reduceInstanceRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.InstanceRemovedEventType),
|
||||
@ -191,9 +194,10 @@ func TestIDPUserLinkProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.idp_user_links2 WHERE (user_id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.idp_user_links2 WHERE (user_id = $1) AND (instance_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -201,7 +205,7 @@ func TestIDPUserLinkProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.IDPConfigRemovedEvent",
|
||||
name: "org IDPConfigRemovedEvent",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.IDPConfigRemovedEventType),
|
||||
@ -219,10 +223,11 @@ func TestIDPUserLinkProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.idp_user_links2 WHERE (idp_id = $1) AND (resource_owner = $2)",
|
||||
expectedStmt: "DELETE FROM projections.idp_user_links2 WHERE (idp_id = $1) AND (resource_owner = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
"idp-config-id",
|
||||
"ro-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -230,7 +235,7 @@ func TestIDPUserLinkProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "iam.IDPConfigRemovedEvent",
|
||||
name: "iam IDPConfigRemovedEvent",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.IDPConfigRemovedEventType),
|
||||
@ -248,10 +253,11 @@ func TestIDPUserLinkProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.idp_user_links2 WHERE (idp_id = $1) AND (resource_owner = $2)",
|
||||
expectedStmt: "DELETE FROM projections.idp_user_links2 WHERE (idp_id = $1) AND (resource_owner = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
"idp-config-id",
|
||||
"ro-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -41,6 +41,7 @@ func newInstanceDomainProjection(ctx context.Context, config crdb.StatementHandl
|
||||
crdb.NewColumn(InstanceDomainIsPrimaryCol, crdb.ColumnTypeBool),
|
||||
},
|
||||
crdb.NewPrimaryKey(InstanceDomainInstanceIDCol, InstanceDomainDomainCol),
|
||||
crdb.WithIndex(crdb.NewIndex("instance_domain", []string{InstanceDomainDomainCol})),
|
||||
),
|
||||
)
|
||||
p.StatementHandler = crdb.NewStatementHandler(ctx, config)
|
||||
|
@ -80,7 +80,7 @@ func TestInstanceDomainProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceInstanceRemoved",
|
||||
name: "instance reduceInstanceRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.InstanceRemovedEventType),
|
||||
|
@ -23,7 +23,7 @@ func TestInstanceMemberProjection_reduces(t *testing.T) {
|
||||
want wantReduce
|
||||
}{
|
||||
{
|
||||
name: "instance.MemberAddedType",
|
||||
name: "instance MemberAddedType",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.MemberAddedEventType),
|
||||
@ -59,7 +59,7 @@ func TestInstanceMemberProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.MemberChangedType",
|
||||
name: "instance MemberChangedType",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.MemberChangedEventType),
|
||||
@ -78,11 +78,12 @@ func TestInstanceMemberProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.instance_members2 SET (roles, change_date, sequence) = ($1, $2, $3) WHERE (user_id = $4)",
|
||||
expectedStmt: "UPDATE projections.instance_members2 SET (roles, change_date, sequence) = ($1, $2, $3) WHERE (instance_id = $4) AND (user_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
database.StringArray{"role", "changed"},
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
"instance-id",
|
||||
"user-id",
|
||||
},
|
||||
},
|
||||
@ -91,7 +92,7 @@ func TestInstanceMemberProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.MemberCascadeRemovedType",
|
||||
name: "instance MemberCascadeRemovedType",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.MemberCascadeRemovedEventType),
|
||||
@ -109,8 +110,9 @@ func TestInstanceMemberProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.instance_members2 WHERE (user_id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.instance_members2 WHERE (instance_id = $1) AND (user_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"instance-id",
|
||||
"user-id",
|
||||
},
|
||||
},
|
||||
@ -119,7 +121,7 @@ func TestInstanceMemberProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.MemberRemovedType",
|
||||
name: "instance MemberRemovedType",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.MemberRemovedEventType),
|
||||
@ -137,8 +139,9 @@ func TestInstanceMemberProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.instance_members2 WHERE (user_id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.instance_members2 WHERE (instance_id = $1) AND (user_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"instance-id",
|
||||
"user-id",
|
||||
},
|
||||
},
|
||||
@ -147,7 +150,7 @@ func TestInstanceMemberProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "user.UserRemoved",
|
||||
name: "user UserRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(user.UserRemovedType),
|
||||
@ -163,8 +166,9 @@ func TestInstanceMemberProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.instance_members2 WHERE (user_id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.instance_members2 WHERE (instance_id = $1) AND (user_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"instance-id",
|
||||
"agg-id",
|
||||
},
|
||||
},
|
||||
@ -173,7 +177,7 @@ func TestInstanceMemberProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceInstanceRemoved",
|
||||
name: "instance reduceInstanceRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.InstanceRemovedEventType),
|
||||
|
@ -101,7 +101,7 @@ func TestKeyProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceInstanceRemoved",
|
||||
name: "instance reduceInstanceRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.InstanceRemovedEventType),
|
||||
|
@ -312,6 +312,7 @@ func (p *labelPolicyProjection) reduceChanged(event eventstore.Event) (*handler.
|
||||
[]handler.Condition{
|
||||
handler.NewCond(LabelPolicyIDCol, policyEvent.Aggregate().ID),
|
||||
handler.NewCond(LabelPolicyStateCol, domain.LabelPolicyStatePreview),
|
||||
handler.NewCond(LabelPolicyInstanceIDCol, event.Aggregate().InstanceID),
|
||||
}), nil
|
||||
}
|
||||
|
||||
@ -324,6 +325,7 @@ func (p *labelPolicyProjection) reduceRemoved(event eventstore.Event) (*handler.
|
||||
policyEvent,
|
||||
[]handler.Condition{
|
||||
handler.NewCond(LabelPolicyIDCol, policyEvent.Aggregate().ID),
|
||||
handler.NewCond(LabelPolicyInstanceIDCol, event.Aggregate().InstanceID),
|
||||
}), nil
|
||||
}
|
||||
|
||||
@ -425,6 +427,7 @@ func (p *labelPolicyProjection) reduceLogoAdded(event eventstore.Event) (*handle
|
||||
[]handler.Condition{
|
||||
handler.NewCond(LabelPolicyIDCol, event.Aggregate().ID),
|
||||
handler.NewCond(LabelPolicyStateCol, domain.LabelPolicyStatePreview),
|
||||
handler.NewCond(LabelPolicyInstanceIDCol, event.Aggregate().InstanceID),
|
||||
}), nil
|
||||
}
|
||||
|
||||
@ -453,6 +456,7 @@ func (p *labelPolicyProjection) reduceLogoRemoved(event eventstore.Event) (*hand
|
||||
[]handler.Condition{
|
||||
handler.NewCond(LabelPolicyIDCol, event.Aggregate().ID),
|
||||
handler.NewCond(LabelPolicyStateCol, domain.LabelPolicyStatePreview),
|
||||
handler.NewCond(LabelPolicyInstanceIDCol, event.Aggregate().InstanceID),
|
||||
}), nil
|
||||
}
|
||||
|
||||
@ -481,6 +485,7 @@ func (p *labelPolicyProjection) reduceIconAdded(event eventstore.Event) (*handle
|
||||
[]handler.Condition{
|
||||
handler.NewCond(LabelPolicyIDCol, event.Aggregate().ID),
|
||||
handler.NewCond(LabelPolicyStateCol, domain.LabelPolicyStatePreview),
|
||||
handler.NewCond(LabelPolicyInstanceIDCol, event.Aggregate().InstanceID),
|
||||
}), nil
|
||||
}
|
||||
|
||||
@ -509,6 +514,7 @@ func (p *labelPolicyProjection) reduceIconRemoved(event eventstore.Event) (*hand
|
||||
[]handler.Condition{
|
||||
handler.NewCond(LabelPolicyIDCol, event.Aggregate().ID),
|
||||
handler.NewCond(LabelPolicyStateCol, domain.LabelPolicyStatePreview),
|
||||
handler.NewCond(LabelPolicyInstanceIDCol, event.Aggregate().InstanceID),
|
||||
}), nil
|
||||
}
|
||||
|
||||
@ -533,6 +539,7 @@ func (p *labelPolicyProjection) reduceFontAdded(event eventstore.Event) (*handle
|
||||
[]handler.Condition{
|
||||
handler.NewCond(LabelPolicyIDCol, event.Aggregate().ID),
|
||||
handler.NewCond(LabelPolicyStateCol, domain.LabelPolicyStatePreview),
|
||||
handler.NewCond(LabelPolicyInstanceIDCol, event.Aggregate().InstanceID),
|
||||
}), nil
|
||||
}
|
||||
|
||||
@ -557,6 +564,7 @@ func (p *labelPolicyProjection) reduceFontRemoved(event eventstore.Event) (*hand
|
||||
[]handler.Condition{
|
||||
handler.NewCond(LabelPolicyIDCol, event.Aggregate().ID),
|
||||
handler.NewCond(LabelPolicyStateCol, domain.LabelPolicyStatePreview),
|
||||
handler.NewCond(LabelPolicyInstanceIDCol, event.Aggregate().InstanceID),
|
||||
}), nil
|
||||
}
|
||||
|
||||
@ -582,5 +590,6 @@ func (p *labelPolicyProjection) reduceAssetsRemoved(event eventstore.Event) (*ha
|
||||
[]handler.Condition{
|
||||
handler.NewCond(LabelPolicyIDCol, event.Aggregate().ID),
|
||||
handler.NewCond(LabelPolicyStateCol, domain.LabelPolicyStatePreview),
|
||||
handler.NewCond(LabelPolicyInstanceIDCol, event.Aggregate().InstanceID),
|
||||
}), nil
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
want wantReduce
|
||||
}{
|
||||
{
|
||||
name: "org.reduceAdded",
|
||||
name: "org reduceAdded",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.LabelPolicyAddedEventType),
|
||||
@ -67,7 +67,7 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceChanged",
|
||||
name: "org reduceChanged",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.LabelPolicyChangedEventType),
|
||||
@ -83,7 +83,7 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.label_policies SET (change_date, sequence, light_primary_color, light_background_color, light_warn_color, light_font_color) = ($1, $2, $3, $4, $5, $6) WHERE (id = $7) AND (state = $8)",
|
||||
expectedStmt: "UPDATE projections.label_policies SET (change_date, sequence, light_primary_color, light_background_color, light_warn_color, light_font_color) = ($1, $2, $3, $4, $5, $6) WHERE (id = $7) AND (state = $8) AND (instance_id = $9)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@ -93,6 +93,7 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
"#ffffff",
|
||||
"agg-id",
|
||||
domain.LabelPolicyStatePreview,
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -100,7 +101,7 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceRemoved",
|
||||
name: "org reduceRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.LabelPolicyRemovedEventType),
|
||||
@ -116,9 +117,10 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.label_policies WHERE (id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.label_policies WHERE (id = $1) AND (instance_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -126,7 +128,7 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceInstanceRemoved",
|
||||
name: "instance reduceInstanceRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.InstanceRemovedEventType),
|
||||
@ -152,7 +154,7 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceActivated",
|
||||
name: "org reduceActivated",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.LabelPolicyActivatedEventType),
|
||||
@ -183,7 +185,7 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceLogoAdded light",
|
||||
name: "org reduceLogoAdded light",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.LabelPolicyLogoAddedEventType),
|
||||
@ -199,13 +201,14 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.label_policies SET (change_date, sequence, light_logo_url) = ($1, $2, $3) WHERE (id = $4) AND (state = $5)",
|
||||
expectedStmt: "UPDATE projections.label_policies SET (change_date, sequence, light_logo_url) = ($1, $2, $3) WHERE (id = $4) AND (state = $5) AND (instance_id = $6)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
"/path/to/logo.png",
|
||||
"agg-id",
|
||||
domain.LabelPolicyStatePreview,
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -213,7 +216,7 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceLogoAdded dark",
|
||||
name: "org reduceLogoAdded dark",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.LabelPolicyLogoDarkAddedEventType),
|
||||
@ -229,13 +232,14 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.label_policies SET (change_date, sequence, dark_logo_url) = ($1, $2, $3) WHERE (id = $4) AND (state = $5)",
|
||||
expectedStmt: "UPDATE projections.label_policies SET (change_date, sequence, dark_logo_url) = ($1, $2, $3) WHERE (id = $4) AND (state = $5) AND (instance_id = $6)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
"/path/to/logo.png",
|
||||
"agg-id",
|
||||
domain.LabelPolicyStatePreview,
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -243,7 +247,7 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceIconAdded light",
|
||||
name: "org reduceIconAdded light",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.LabelPolicyIconAddedEventType),
|
||||
@ -259,13 +263,14 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.label_policies SET (change_date, sequence, light_icon_url) = ($1, $2, $3) WHERE (id = $4) AND (state = $5)",
|
||||
expectedStmt: "UPDATE projections.label_policies SET (change_date, sequence, light_icon_url) = ($1, $2, $3) WHERE (id = $4) AND (state = $5) AND (instance_id = $6)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
"/path/to/icon.png",
|
||||
"agg-id",
|
||||
domain.LabelPolicyStatePreview,
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -273,7 +278,7 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceIconAdded dark",
|
||||
name: "org reduceIconAdded dark",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.LabelPolicyIconDarkAddedEventType),
|
||||
@ -289,13 +294,14 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.label_policies SET (change_date, sequence, dark_icon_url) = ($1, $2, $3) WHERE (id = $4) AND (state = $5)",
|
||||
expectedStmt: "UPDATE projections.label_policies SET (change_date, sequence, dark_icon_url) = ($1, $2, $3) WHERE (id = $4) AND (state = $5) AND (instance_id = $6)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
"/path/to/icon.png",
|
||||
"agg-id",
|
||||
domain.LabelPolicyStatePreview,
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -303,7 +309,7 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceLogoRemoved light",
|
||||
name: "org reduceLogoRemoved light",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.LabelPolicyLogoRemovedEventType),
|
||||
@ -319,13 +325,14 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.label_policies SET (change_date, sequence, light_logo_url) = ($1, $2, $3) WHERE (id = $4) AND (state = $5)",
|
||||
expectedStmt: "UPDATE projections.label_policies SET (change_date, sequence, light_logo_url) = ($1, $2, $3) WHERE (id = $4) AND (state = $5) AND (instance_id = $6)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
nil,
|
||||
"agg-id",
|
||||
domain.LabelPolicyStatePreview,
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -333,7 +340,7 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceLogoRemoved dark",
|
||||
name: "org reduceLogoRemoved dark",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.LabelPolicyLogoDarkRemovedEventType),
|
||||
@ -349,13 +356,14 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.label_policies SET (change_date, sequence, dark_logo_url) = ($1, $2, $3) WHERE (id = $4) AND (state = $5)",
|
||||
expectedStmt: "UPDATE projections.label_policies SET (change_date, sequence, dark_logo_url) = ($1, $2, $3) WHERE (id = $4) AND (state = $5) AND (instance_id = $6)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
nil,
|
||||
"agg-id",
|
||||
domain.LabelPolicyStatePreview,
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -363,7 +371,7 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceIconRemoved light",
|
||||
name: "org reduceIconRemoved light",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.LabelPolicyIconRemovedEventType),
|
||||
@ -379,13 +387,14 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.label_policies SET (change_date, sequence, light_icon_url) = ($1, $2, $3) WHERE (id = $4) AND (state = $5)",
|
||||
expectedStmt: "UPDATE projections.label_policies SET (change_date, sequence, light_icon_url) = ($1, $2, $3) WHERE (id = $4) AND (state = $5) AND (instance_id = $6)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
nil,
|
||||
"agg-id",
|
||||
domain.LabelPolicyStatePreview,
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -393,7 +402,7 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceIconRemoved dark",
|
||||
name: "org reduceIconRemoved dark",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.LabelPolicyIconDarkRemovedEventType),
|
||||
@ -409,13 +418,14 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.label_policies SET (change_date, sequence, dark_icon_url) = ($1, $2, $3) WHERE (id = $4) AND (state = $5)",
|
||||
expectedStmt: "UPDATE projections.label_policies SET (change_date, sequence, dark_icon_url) = ($1, $2, $3) WHERE (id = $4) AND (state = $5) AND (instance_id = $6)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
nil,
|
||||
"agg-id",
|
||||
domain.LabelPolicyStatePreview,
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -423,7 +433,7 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceFontAdded",
|
||||
name: "org reduceFontAdded",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.LabelPolicyFontAddedEventType),
|
||||
@ -439,13 +449,14 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.label_policies SET (change_date, sequence, font_url) = ($1, $2, $3) WHERE (id = $4) AND (state = $5)",
|
||||
expectedStmt: "UPDATE projections.label_policies SET (change_date, sequence, font_url) = ($1, $2, $3) WHERE (id = $4) AND (state = $5) AND (instance_id = $6)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
"/path/to/font.ttf",
|
||||
"agg-id",
|
||||
domain.LabelPolicyStatePreview,
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -453,7 +464,7 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceFontRemoved",
|
||||
name: "org reduceFontRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.LabelPolicyFontRemovedEventType),
|
||||
@ -469,13 +480,14 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.label_policies SET (change_date, sequence, font_url) = ($1, $2, $3) WHERE (id = $4) AND (state = $5)",
|
||||
expectedStmt: "UPDATE projections.label_policies SET (change_date, sequence, font_url) = ($1, $2, $3) WHERE (id = $4) AND (state = $5) AND (instance_id = $6)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
nil,
|
||||
"agg-id",
|
||||
domain.LabelPolicyStatePreview,
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -483,7 +495,7 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceAssetsRemoved",
|
||||
name: "org reduceAssetsRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.LabelPolicyAssetsRemovedEventType),
|
||||
@ -499,7 +511,7 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.label_policies SET (change_date, sequence, light_logo_url, light_icon_url, dark_logo_url, dark_icon_url, font_url) = ($1, $2, $3, $4, $5, $6, $7) WHERE (id = $8) AND (state = $9)",
|
||||
expectedStmt: "UPDATE projections.label_policies SET (change_date, sequence, light_logo_url, light_icon_url, dark_logo_url, dark_icon_url, font_url) = ($1, $2, $3, $4, $5, $6, $7) WHERE (id = $8) AND (state = $9) AND (instance_id = $10)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@ -510,6 +522,7 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
nil,
|
||||
"agg-id",
|
||||
domain.LabelPolicyStatePreview,
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -517,7 +530,7 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceAdded",
|
||||
name: "instance reduceAdded",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.LabelPolicyAddedEventType),
|
||||
@ -561,7 +574,7 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceChanged",
|
||||
name: "instance reduceChanged",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.LabelPolicyChangedEventType),
|
||||
@ -577,7 +590,7 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.label_policies SET (change_date, sequence, light_primary_color, light_background_color, light_warn_color, light_font_color, dark_primary_color, dark_background_color, dark_warn_color, dark_font_color, hide_login_name_suffix, should_error_popup, watermark_disabled) = ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13) WHERE (id = $14) AND (state = $15)",
|
||||
expectedStmt: "UPDATE projections.label_policies SET (change_date, sequence, light_primary_color, light_background_color, light_warn_color, light_font_color, dark_primary_color, dark_background_color, dark_warn_color, dark_font_color, hide_login_name_suffix, should_error_popup, watermark_disabled) = ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13) WHERE (id = $14) AND (state = $15) AND (instance_id = $16)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@ -594,6 +607,7 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
true,
|
||||
"agg-id",
|
||||
domain.LabelPolicyStatePreview,
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -601,7 +615,7 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceActivated",
|
||||
name: "instance reduceActivated",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.LabelPolicyActivatedEventType),
|
||||
@ -632,7 +646,7 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceLogoAdded light",
|
||||
name: "instance reduceLogoAdded light",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.LabelPolicyLogoAddedEventType),
|
||||
@ -648,13 +662,14 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.label_policies SET (change_date, sequence, light_logo_url) = ($1, $2, $3) WHERE (id = $4) AND (state = $5)",
|
||||
expectedStmt: "UPDATE projections.label_policies SET (change_date, sequence, light_logo_url) = ($1, $2, $3) WHERE (id = $4) AND (state = $5) AND (instance_id = $6)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
"/path/to/logo.png",
|
||||
"agg-id",
|
||||
domain.LabelPolicyStatePreview,
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -662,7 +677,7 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceLogoAdded dark",
|
||||
name: "instance reduceLogoAdded dark",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.LabelPolicyLogoDarkAddedEventType),
|
||||
@ -678,13 +693,14 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.label_policies SET (change_date, sequence, dark_logo_url) = ($1, $2, $3) WHERE (id = $4) AND (state = $5)",
|
||||
expectedStmt: "UPDATE projections.label_policies SET (change_date, sequence, dark_logo_url) = ($1, $2, $3) WHERE (id = $4) AND (state = $5) AND (instance_id = $6)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
"/path/to/logo.png",
|
||||
"agg-id",
|
||||
domain.LabelPolicyStatePreview,
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -692,7 +708,7 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceIconAdded light",
|
||||
name: "instance reduceIconAdded light",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.LabelPolicyIconAddedEventType),
|
||||
@ -708,13 +724,14 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.label_policies SET (change_date, sequence, light_icon_url) = ($1, $2, $3) WHERE (id = $4) AND (state = $5)",
|
||||
expectedStmt: "UPDATE projections.label_policies SET (change_date, sequence, light_icon_url) = ($1, $2, $3) WHERE (id = $4) AND (state = $5) AND (instance_id = $6)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
"/path/to/icon.png",
|
||||
"agg-id",
|
||||
domain.LabelPolicyStatePreview,
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -722,7 +739,7 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceIconAdded dark",
|
||||
name: "instance reduceIconAdded dark",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.LabelPolicyIconDarkAddedEventType),
|
||||
@ -738,13 +755,14 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.label_policies SET (change_date, sequence, dark_icon_url) = ($1, $2, $3) WHERE (id = $4) AND (state = $5)",
|
||||
expectedStmt: "UPDATE projections.label_policies SET (change_date, sequence, dark_icon_url) = ($1, $2, $3) WHERE (id = $4) AND (state = $5) AND (instance_id = $6)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
"/path/to/icon.png",
|
||||
"agg-id",
|
||||
domain.LabelPolicyStatePreview,
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -752,7 +770,7 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceLogoRemoved light",
|
||||
name: "instance reduceLogoRemoved light",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.LabelPolicyLogoRemovedEventType),
|
||||
@ -768,13 +786,14 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.label_policies SET (change_date, sequence, light_logo_url) = ($1, $2, $3) WHERE (id = $4) AND (state = $5)",
|
||||
expectedStmt: "UPDATE projections.label_policies SET (change_date, sequence, light_logo_url) = ($1, $2, $3) WHERE (id = $4) AND (state = $5) AND (instance_id = $6)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
nil,
|
||||
"agg-id",
|
||||
domain.LabelPolicyStatePreview,
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -782,7 +801,7 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceLogoRemoved dark",
|
||||
name: "instance reduceLogoRemoved dark",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.LabelPolicyLogoDarkRemovedEventType),
|
||||
@ -798,13 +817,14 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.label_policies SET (change_date, sequence, dark_logo_url) = ($1, $2, $3) WHERE (id = $4) AND (state = $5)",
|
||||
expectedStmt: "UPDATE projections.label_policies SET (change_date, sequence, dark_logo_url) = ($1, $2, $3) WHERE (id = $4) AND (state = $5) AND (instance_id = $6)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
nil,
|
||||
"agg-id",
|
||||
domain.LabelPolicyStatePreview,
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -812,7 +832,7 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceIconRemoved light",
|
||||
name: "instance reduceIconRemoved light",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.LabelPolicyIconRemovedEventType),
|
||||
@ -828,13 +848,14 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.label_policies SET (change_date, sequence, light_icon_url) = ($1, $2, $3) WHERE (id = $4) AND (state = $5)",
|
||||
expectedStmt: "UPDATE projections.label_policies SET (change_date, sequence, light_icon_url) = ($1, $2, $3) WHERE (id = $4) AND (state = $5) AND (instance_id = $6)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
nil,
|
||||
"agg-id",
|
||||
domain.LabelPolicyStatePreview,
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -842,7 +863,7 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceIconRemoved dark",
|
||||
name: "instance reduceIconRemoved dark",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.LabelPolicyIconDarkRemovedEventType),
|
||||
@ -858,13 +879,14 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.label_policies SET (change_date, sequence, dark_icon_url) = ($1, $2, $3) WHERE (id = $4) AND (state = $5)",
|
||||
expectedStmt: "UPDATE projections.label_policies SET (change_date, sequence, dark_icon_url) = ($1, $2, $3) WHERE (id = $4) AND (state = $5) AND (instance_id = $6)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
nil,
|
||||
"agg-id",
|
||||
domain.LabelPolicyStatePreview,
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -872,7 +894,7 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceFontAdded",
|
||||
name: "instance reduceFontAdded",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.LabelPolicyFontAddedEventType),
|
||||
@ -888,13 +910,14 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.label_policies SET (change_date, sequence, font_url) = ($1, $2, $3) WHERE (id = $4) AND (state = $5)",
|
||||
expectedStmt: "UPDATE projections.label_policies SET (change_date, sequence, font_url) = ($1, $2, $3) WHERE (id = $4) AND (state = $5) AND (instance_id = $6)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
"/path/to/font.ttf",
|
||||
"agg-id",
|
||||
domain.LabelPolicyStatePreview,
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -902,7 +925,7 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceFontRemoved",
|
||||
name: "instance reduceFontRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.LabelPolicyFontRemovedEventType),
|
||||
@ -918,13 +941,14 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.label_policies SET (change_date, sequence, font_url) = ($1, $2, $3) WHERE (id = $4) AND (state = $5)",
|
||||
expectedStmt: "UPDATE projections.label_policies SET (change_date, sequence, font_url) = ($1, $2, $3) WHERE (id = $4) AND (state = $5) AND (instance_id = $6)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
nil,
|
||||
"agg-id",
|
||||
domain.LabelPolicyStatePreview,
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -932,7 +956,7 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceAssetsRemoved",
|
||||
name: "instance reduceAssetsRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.LabelPolicyAssetsRemovedEventType),
|
||||
@ -948,7 +972,7 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.label_policies SET (change_date, sequence, light_logo_url, light_icon_url, dark_logo_url, dark_icon_url, font_url) = ($1, $2, $3, $4, $5, $6, $7) WHERE (id = $8) AND (state = $9)",
|
||||
expectedStmt: "UPDATE projections.label_policies SET (change_date, sequence, light_logo_url, light_icon_url, dark_logo_url, dark_icon_url, font_url) = ($1, $2, $3, $4, $5, $6, $7) WHERE (id = $8) AND (state = $9) AND (instance_id = $10)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@ -959,6 +983,7 @@ func TestLabelPolicyProjection_reduces(t *testing.T) {
|
||||
nil,
|
||||
"agg-id",
|
||||
domain.LabelPolicyStatePreview,
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -149,6 +149,7 @@ func (p *lockoutPolicyProjection) reduceChanged(event eventstore.Event) (*handle
|
||||
cols,
|
||||
[]handler.Condition{
|
||||
handler.NewCond(LockoutPolicyIDCol, policyEvent.Aggregate().ID),
|
||||
handler.NewCond(LabelPolicyInstanceIDCol, event.Aggregate().InstanceID),
|
||||
}), nil
|
||||
}
|
||||
|
||||
@ -161,5 +162,6 @@ func (p *lockoutPolicyProjection) reduceRemoved(event eventstore.Event) (*handle
|
||||
policyEvent,
|
||||
[]handler.Condition{
|
||||
handler.NewCond(LockoutPolicyIDCol, policyEvent.Aggregate().ID),
|
||||
handler.NewCond(LabelPolicyInstanceIDCol, event.Aggregate().InstanceID),
|
||||
}), nil
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ func TestLockoutPolicyProjection_reduces(t *testing.T) {
|
||||
want wantReduce
|
||||
}{
|
||||
{
|
||||
name: "org.reduceAdded",
|
||||
name: "org reduceAdded",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.LockoutPolicyAddedEventType),
|
||||
@ -61,7 +61,7 @@ func TestLockoutPolicyProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceChanged",
|
||||
name: "org reduceChanged",
|
||||
reduce: (&lockoutPolicyProjection{}).reduceChanged,
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
@ -80,13 +80,14 @@ func TestLockoutPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.lockout_policies SET (change_date, sequence, max_password_attempts, show_failure) = ($1, $2, $3, $4) WHERE (id = $5)",
|
||||
expectedStmt: "UPDATE projections.lockout_policies SET (change_date, sequence, max_password_attempts, show_failure) = ($1, $2, $3, $4) WHERE (id = $5) AND (instance_id = $6)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
uint64(10),
|
||||
true,
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -94,7 +95,7 @@ func TestLockoutPolicyProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceRemoved",
|
||||
name: "org reduceRemoved",
|
||||
reduce: (&lockoutPolicyProjection{}).reduceRemoved,
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
@ -110,9 +111,10 @@ func TestLockoutPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.lockout_policies WHERE (id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.lockout_policies WHERE (id = $1) AND (instance_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -120,7 +122,7 @@ func TestLockoutPolicyProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceInstanceRemoved",
|
||||
name: "instance reduceInstanceRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.InstanceRemovedEventType),
|
||||
@ -146,7 +148,7 @@ func TestLockoutPolicyProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceAdded",
|
||||
name: "instance reduceAdded",
|
||||
reduce: (&lockoutPolicyProjection{}).reduceAdded,
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
@ -184,7 +186,7 @@ func TestLockoutPolicyProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceChanged",
|
||||
name: "instance reduceChanged",
|
||||
reduce: (&lockoutPolicyProjection{}).reduceChanged,
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
@ -203,13 +205,14 @@ func TestLockoutPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.lockout_policies SET (change_date, sequence, max_password_attempts, show_failure) = ($1, $2, $3, $4) WHERE (id = $5)",
|
||||
expectedStmt: "UPDATE projections.lockout_policies SET (change_date, sequence, max_password_attempts, show_failure) = ($1, $2, $3, $4) WHERE (id = $5) AND (instance_id = $6)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
uint64(10),
|
||||
true,
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -256,6 +256,7 @@ func (p *loginNameProjection) reduceUserRemoved(event eventstore.Event) (*handle
|
||||
event,
|
||||
[]handler.Condition{
|
||||
handler.NewCond(LoginNameUserIDCol, e.Aggregate().ID),
|
||||
handler.NewCond(LoginNameUserInstanceIDCol, e.Aggregate().InstanceID),
|
||||
},
|
||||
crdb.WithTableSuffix(loginNameUserSuffix),
|
||||
), nil
|
||||
@ -274,6 +275,7 @@ func (p *loginNameProjection) reduceUserNameChanged(event eventstore.Event) (*ha
|
||||
},
|
||||
[]handler.Condition{
|
||||
handler.NewCond(LoginNameUserIDCol, e.Aggregate().ID),
|
||||
handler.NewCond(LoginNameUserInstanceIDCol, e.Aggregate().InstanceID),
|
||||
},
|
||||
crdb.WithTableSuffix(loginNameUserSuffix),
|
||||
), nil
|
||||
@ -292,6 +294,7 @@ func (p *loginNameProjection) reduceUserDomainClaimed(event eventstore.Event) (*
|
||||
},
|
||||
[]handler.Condition{
|
||||
handler.NewCond(LoginNameUserIDCol, e.Aggregate().ID),
|
||||
handler.NewCond(LoginNameUserInstanceIDCol, e.Aggregate().InstanceID),
|
||||
},
|
||||
crdb.WithTableSuffix(loginNameUserSuffix),
|
||||
), nil
|
||||
@ -349,6 +352,7 @@ func (p *loginNameProjection) reduceDomainPolicyChanged(event eventstore.Event)
|
||||
},
|
||||
[]handler.Condition{
|
||||
handler.NewCond(LoginNamePoliciesResourceOwnerCol, policyEvent.Aggregate().ResourceOwner),
|
||||
handler.NewCond(LoginNamePoliciesInstanceIDCol, policyEvent.Aggregate().InstanceID),
|
||||
},
|
||||
crdb.WithTableSuffix(loginNamePolicySuffix),
|
||||
), nil
|
||||
@ -364,6 +368,7 @@ func (p *loginNameProjection) reduceDomainPolicyRemoved(event eventstore.Event)
|
||||
event,
|
||||
[]handler.Condition{
|
||||
handler.NewCond(LoginNamePoliciesResourceOwnerCol, e.Aggregate().ResourceOwner),
|
||||
handler.NewCond(LoginNamePoliciesInstanceIDCol, e.Aggregate().InstanceID),
|
||||
},
|
||||
crdb.WithTableSuffix(loginNamePolicySuffix),
|
||||
), nil
|
||||
@ -401,6 +406,7 @@ func (p *loginNameProjection) reducePrimaryDomainSet(event eventstore.Event) (*h
|
||||
[]handler.Condition{
|
||||
handler.NewCond(LoginNameDomainResourceOwnerCol, e.Aggregate().ResourceOwner),
|
||||
handler.NewCond(LoginNameDomainIsPrimaryCol, true),
|
||||
handler.NewCond(LoginNameDomainInstanceIDCol, e.Aggregate().InstanceID),
|
||||
},
|
||||
crdb.WithTableSuffix(loginNameDomainSuffix),
|
||||
),
|
||||
@ -411,6 +417,7 @@ func (p *loginNameProjection) reducePrimaryDomainSet(event eventstore.Event) (*h
|
||||
[]handler.Condition{
|
||||
handler.NewCond(LoginNameDomainNameCol, e.Domain),
|
||||
handler.NewCond(LoginNameDomainResourceOwnerCol, e.Aggregate().ResourceOwner),
|
||||
handler.NewCond(LoginNameDomainInstanceIDCol, e.Aggregate().InstanceID),
|
||||
},
|
||||
crdb.WithTableSuffix(loginNameDomainSuffix),
|
||||
),
|
||||
@ -428,6 +435,7 @@ func (p *loginNameProjection) reduceDomainRemoved(event eventstore.Event) (*hand
|
||||
[]handler.Condition{
|
||||
handler.NewCond(LoginNameDomainNameCol, e.Domain),
|
||||
handler.NewCond(LoginNameDomainResourceOwnerCol, e.Aggregate().ResourceOwner),
|
||||
handler.NewCond(LoginNameDomainInstanceIDCol, e.Aggregate().InstanceID),
|
||||
},
|
||||
crdb.WithTableSuffix(loginNameDomainSuffix),
|
||||
), nil
|
||||
|
@ -23,7 +23,7 @@ func TestLoginNameProjection_reduces(t *testing.T) {
|
||||
want wantReduce
|
||||
}{
|
||||
{
|
||||
name: "user.HumanAddedType",
|
||||
name: "user HumanAddedType",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(user.HumanAddedType),
|
||||
@ -54,7 +54,7 @@ func TestLoginNameProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "user.HumanRegisteredType",
|
||||
name: "user HumanRegisteredType",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(user.HumanRegisteredType),
|
||||
@ -85,7 +85,7 @@ func TestLoginNameProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "user.MachineAddedEventType",
|
||||
name: "user MachineAddedEventType",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(user.MachineAddedEventType),
|
||||
@ -116,7 +116,7 @@ func TestLoginNameProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "user.UserRemovedType",
|
||||
name: "user UserRemovedType",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(user.UserRemovedType),
|
||||
@ -132,9 +132,10 @@ func TestLoginNameProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.login_names_users WHERE (id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.login_names_users WHERE (id = $1) AND (instance_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -142,7 +143,7 @@ func TestLoginNameProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "user.UserUserNameChangedType",
|
||||
name: "user UserUserNameChangedType",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(user.UserUserNameChangedType),
|
||||
@ -160,10 +161,11 @@ func TestLoginNameProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.login_names_users SET user_name = $1 WHERE (id = $2)",
|
||||
expectedStmt: "UPDATE projections.login_names_users SET user_name = $1 WHERE (id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
"changed",
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -171,7 +173,7 @@ func TestLoginNameProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "user.UserDomainClaimedType",
|
||||
name: "user UserDomainClaimedType",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(user.UserDomainClaimedType),
|
||||
@ -189,10 +191,11 @@ func TestLoginNameProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.login_names_users SET user_name = $1 WHERE (id = $2)",
|
||||
expectedStmt: "UPDATE projections.login_names_users SET user_name = $1 WHERE (id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
"claimed",
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -200,7 +203,7 @@ func TestLoginNameProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.OrgDomainPolicyAddedEventType",
|
||||
name: "org OrgDomainPolicyAddedEventType",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.DomainPolicyAddedEventType),
|
||||
@ -231,7 +234,7 @@ func TestLoginNameProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.OrgDomainPolicyChangedEventType",
|
||||
name: "org OrgDomainPolicyChangedEventType",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.DomainPolicyChangedEventType),
|
||||
@ -249,10 +252,11 @@ func TestLoginNameProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.login_names_policies SET must_be_domain = $1 WHERE (resource_owner = $2)",
|
||||
expectedStmt: "UPDATE projections.login_names_policies SET must_be_domain = $1 WHERE (resource_owner = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
false,
|
||||
"ro-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -260,7 +264,7 @@ func TestLoginNameProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.OrgDomainPolicyChangedEventType no change",
|
||||
name: "org OrgDomainPolicyChangedEventType no change",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.DomainPolicyChangedEventType),
|
||||
@ -279,7 +283,7 @@ func TestLoginNameProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.OrgDomainPolicyRemovedEventType",
|
||||
name: "org OrgDomainPolicyRemovedEventType",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.DomainPolicyRemovedEventType),
|
||||
@ -295,9 +299,10 @@ func TestLoginNameProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.login_names_policies WHERE (resource_owner = $1)",
|
||||
expectedStmt: "DELETE FROM projections.login_names_policies WHERE (resource_owner = $1) AND (instance_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"ro-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -305,7 +310,7 @@ func TestLoginNameProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.OrgDomainVerifiedEventType",
|
||||
name: "org OrgDomainVerifiedEventType",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.OrgDomainVerifiedEventType),
|
||||
@ -335,7 +340,7 @@ func TestLoginNameProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.OrgDomainRemovedEventType",
|
||||
name: "org OrgDomainRemovedEventType",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.OrgDomainRemovedEventType),
|
||||
@ -353,10 +358,11 @@ func TestLoginNameProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.login_names_domains WHERE (name = $1) AND (resource_owner = $2)",
|
||||
expectedStmt: "DELETE FROM projections.login_names_domains WHERE (name = $1) AND (resource_owner = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
"remove",
|
||||
"ro-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -364,7 +370,7 @@ func TestLoginNameProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.OrgDomainPrimarySetEventType",
|
||||
name: "org OrgDomainPrimarySetEventType",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.OrgDomainPrimarySetEventType),
|
||||
@ -382,19 +388,21 @@ func TestLoginNameProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.login_names_domains SET is_primary = $1 WHERE (resource_owner = $2) AND (is_primary = $3)",
|
||||
expectedStmt: "UPDATE projections.login_names_domains SET is_primary = $1 WHERE (resource_owner = $2) AND (is_primary = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
false,
|
||||
"ro-id",
|
||||
true,
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
{
|
||||
expectedStmt: "UPDATE projections.login_names_domains SET is_primary = $1 WHERE (name = $2) AND (resource_owner = $3)",
|
||||
expectedStmt: "UPDATE projections.login_names_domains SET is_primary = $1 WHERE (name = $2) AND (resource_owner = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
true,
|
||||
"primary",
|
||||
"ro-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -402,7 +410,7 @@ func TestLoginNameProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "iam.OrgDomainPolicyAddedEventType",
|
||||
name: "iam OrgDomainPolicyAddedEventType",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.DomainPolicyAddedEventType),
|
||||
@ -433,7 +441,7 @@ func TestLoginNameProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "iam.OrgDomainPolicyChangedEventType",
|
||||
name: "iam OrgDomainPolicyChangedEventType",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.DomainPolicyChangedEventType),
|
||||
@ -451,10 +459,11 @@ func TestLoginNameProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.login_names_policies SET must_be_domain = $1 WHERE (resource_owner = $2)",
|
||||
expectedStmt: "UPDATE projections.login_names_policies SET must_be_domain = $1 WHERE (resource_owner = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
false,
|
||||
"ro-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -462,7 +471,7 @@ func TestLoginNameProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "iam.OrgDomainPolicyChangedEventType no change",
|
||||
name: "iam OrgDomainPolicyChangedEventType no change",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.DomainPolicyChangedEventType),
|
||||
@ -481,7 +490,7 @@ func TestLoginNameProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceInstanceRemoved",
|
||||
name: "instance reduceInstanceRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.InstanceRemovedEventType),
|
||||
|
@ -263,6 +263,7 @@ func (p *loginPolicyProjection) reduceLoginPolicyChanged(event eventstore.Event)
|
||||
cols,
|
||||
[]handler.Condition{
|
||||
handler.NewCond(LoginPolicyIDCol, policyEvent.Aggregate().ID),
|
||||
handler.NewCond(LoginPolicyInstanceIDCol, policyEvent.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
@ -287,6 +288,7 @@ func (p *loginPolicyProjection) reduceMFAAdded(event eventstore.Event) (*handler
|
||||
},
|
||||
[]handler.Condition{
|
||||
handler.NewCond(LoginPolicyIDCol, policyEvent.Aggregate().ID),
|
||||
handler.NewCond(LoginPolicyInstanceIDCol, policyEvent.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
@ -311,6 +313,7 @@ func (p *loginPolicyProjection) reduceMFARemoved(event eventstore.Event) (*handl
|
||||
},
|
||||
[]handler.Condition{
|
||||
handler.NewCond(LoginPolicyIDCol, policyEvent.Aggregate().ID),
|
||||
handler.NewCond(LoginPolicyInstanceIDCol, policyEvent.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
@ -324,6 +327,7 @@ func (p *loginPolicyProjection) reduceLoginPolicyRemoved(event eventstore.Event)
|
||||
e,
|
||||
[]handler.Condition{
|
||||
handler.NewCond(LoginPolicyIDCol, e.Aggregate().ID),
|
||||
handler.NewCond(LoginPolicyInstanceIDCol, e.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
@ -348,6 +352,7 @@ func (p *loginPolicyProjection) reduce2FAAdded(event eventstore.Event) (*handler
|
||||
},
|
||||
[]handler.Condition{
|
||||
handler.NewCond(LoginPolicyIDCol, policyEvent.Aggregate().ID),
|
||||
handler.NewCond(LoginPolicyInstanceIDCol, policyEvent.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
@ -372,6 +377,7 @@ func (p *loginPolicyProjection) reduce2FARemoved(event eventstore.Event) (*handl
|
||||
},
|
||||
[]handler.Condition{
|
||||
handler.NewCond(LoginPolicyIDCol, policyEvent.Aggregate().ID),
|
||||
handler.NewCond(LoginPolicyInstanceIDCol, policyEvent.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ func TestLoginPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.login_policies3 SET (change_date, sequence, allow_register, allow_username_password, allow_external_idps, force_mfa, passwordless_type, hide_password_reset, ignore_unknown_usernames, allow_domain_discovery, disable_login_with_email, disable_login_with_phone, default_redirect_uri, password_check_lifetime, external_login_check_lifetime, mfa_init_skip_lifetime, second_factor_check_lifetime, multi_factor_check_lifetime) = ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18) WHERE (aggregate_id = $19)",
|
||||
expectedStmt: "UPDATE projections.login_policies3 SET (change_date, sequence, allow_register, allow_username_password, allow_external_idps, force_mfa, passwordless_type, hide_password_reset, ignore_unknown_usernames, allow_domain_discovery, disable_login_with_email, disable_login_with_phone, default_redirect_uri, password_check_lifetime, external_login_check_lifetime, mfa_init_skip_lifetime, second_factor_check_lifetime, multi_factor_check_lifetime) = ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18) WHERE (aggregate_id = $19) AND (instance_id = $20)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@ -142,6 +142,7 @@ func TestLoginPolicyProjection_reduces(t *testing.T) {
|
||||
time.Millisecond * 10,
|
||||
time.Millisecond * 10,
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -167,12 +168,13 @@ func TestLoginPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.login_policies3 SET (change_date, sequence, multi_factors) = ($1, $2, array_append(multi_factors, $3)) WHERE (aggregate_id = $4)",
|
||||
expectedStmt: "UPDATE projections.login_policies3 SET (change_date, sequence, multi_factors) = ($1, $2, array_append(multi_factors, $3)) WHERE (aggregate_id = $4) AND (instance_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
domain.MultiFactorTypeU2FWithPIN,
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -198,12 +200,13 @@ func TestLoginPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.login_policies3 SET (change_date, sequence, multi_factors) = ($1, $2, array_remove(multi_factors, $3)) WHERE (aggregate_id = $4)",
|
||||
expectedStmt: "UPDATE projections.login_policies3 SET (change_date, sequence, multi_factors) = ($1, $2, array_remove(multi_factors, $3)) WHERE (aggregate_id = $4) AND (instance_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
domain.MultiFactorTypeU2FWithPIN,
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -227,9 +230,10 @@ func TestLoginPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.login_policies3 WHERE (aggregate_id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.login_policies3 WHERE (aggregate_id = $1) AND (instance_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -255,12 +259,13 @@ func TestLoginPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.login_policies3 SET (change_date, sequence, second_factors) = ($1, $2, array_append(second_factors, $3)) WHERE (aggregate_id = $4)",
|
||||
expectedStmt: "UPDATE projections.login_policies3 SET (change_date, sequence, second_factors) = ($1, $2, array_append(second_factors, $3)) WHERE (aggregate_id = $4) AND (instance_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
domain.SecondFactorTypeU2F,
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -286,12 +291,13 @@ func TestLoginPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.login_policies3 SET (change_date, sequence, second_factors) = ($1, $2, array_remove(second_factors, $3)) WHERE (aggregate_id = $4)",
|
||||
expectedStmt: "UPDATE projections.login_policies3 SET (change_date, sequence, second_factors) = ($1, $2, array_remove(second_factors, $3)) WHERE (aggregate_id = $4) AND (instance_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
domain.SecondFactorTypeU2F,
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -391,7 +397,7 @@ func TestLoginPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.login_policies3 SET (change_date, sequence, allow_register, allow_username_password, allow_external_idps, force_mfa, passwordless_type, hide_password_reset, ignore_unknown_usernames, allow_domain_discovery, disable_login_with_email, disable_login_with_phone, default_redirect_uri) = ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13) WHERE (aggregate_id = $14)",
|
||||
expectedStmt: "UPDATE projections.login_policies3 SET (change_date, sequence, allow_register, allow_username_password, allow_external_idps, force_mfa, passwordless_type, hide_password_reset, ignore_unknown_usernames, allow_domain_discovery, disable_login_with_email, disable_login_with_phone, default_redirect_uri) = ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13) WHERE (aggregate_id = $14) AND (instance_id = $15)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@ -407,6 +413,7 @@ func TestLoginPolicyProjection_reduces(t *testing.T) {
|
||||
true,
|
||||
"https://example.com/redirect",
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -432,12 +439,13 @@ func TestLoginPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.login_policies3 SET (change_date, sequence, multi_factors) = ($1, $2, array_append(multi_factors, $3)) WHERE (aggregate_id = $4)",
|
||||
expectedStmt: "UPDATE projections.login_policies3 SET (change_date, sequence, multi_factors) = ($1, $2, array_append(multi_factors, $3)) WHERE (aggregate_id = $4) AND (instance_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
domain.MultiFactorTypeU2FWithPIN,
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -463,12 +471,13 @@ func TestLoginPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.login_policies3 SET (change_date, sequence, multi_factors) = ($1, $2, array_remove(multi_factors, $3)) WHERE (aggregate_id = $4)",
|
||||
expectedStmt: "UPDATE projections.login_policies3 SET (change_date, sequence, multi_factors) = ($1, $2, array_remove(multi_factors, $3)) WHERE (aggregate_id = $4) AND (instance_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
domain.MultiFactorTypeU2FWithPIN,
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -494,12 +503,13 @@ func TestLoginPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.login_policies3 SET (change_date, sequence, second_factors) = ($1, $2, array_append(second_factors, $3)) WHERE (aggregate_id = $4)",
|
||||
expectedStmt: "UPDATE projections.login_policies3 SET (change_date, sequence, second_factors) = ($1, $2, array_append(second_factors, $3)) WHERE (aggregate_id = $4) AND (instance_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
domain.SecondFactorTypeU2F,
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -525,12 +535,13 @@ func TestLoginPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.login_policies3 SET (change_date, sequence, second_factors) = ($1, $2, array_remove(second_factors, $3)) WHERE (aggregate_id = $4)",
|
||||
expectedStmt: "UPDATE projections.login_policies3 SET (change_date, sequence, second_factors) = ($1, $2, array_remove(second_factors, $3)) WHERE (aggregate_id = $4) AND (instance_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
domain.SecondFactorTypeU2F,
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -140,6 +140,7 @@ func (p *mailTemplateProjection) reduceChanged(event eventstore.Event) (*handler
|
||||
cols,
|
||||
[]handler.Condition{
|
||||
handler.NewCond(MailTemplateAggregateIDCol, policyEvent.Aggregate().ID),
|
||||
handler.NewCond(MailTemplateInstanceIDCol, policyEvent.Aggregate().InstanceID),
|
||||
}), nil
|
||||
}
|
||||
|
||||
@ -152,5 +153,6 @@ func (p *mailTemplateProjection) reduceRemoved(event eventstore.Event) (*handler
|
||||
policyEvent,
|
||||
[]handler.Condition{
|
||||
handler.NewCond(MailTemplateAggregateIDCol, policyEvent.Aggregate().ID),
|
||||
handler.NewCond(MailTemplateInstanceIDCol, policyEvent.Aggregate().InstanceID),
|
||||
}), nil
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ func TestMailTemplateProjection_reduces(t *testing.T) {
|
||||
want wantReduce
|
||||
}{
|
||||
{
|
||||
name: "org.reduceAdded",
|
||||
name: "org reduceAdded",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.MailTemplateAddedEventType),
|
||||
@ -58,7 +58,7 @@ func TestMailTemplateProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceChanged",
|
||||
name: "org reduceChanged",
|
||||
reduce: (&mailTemplateProjection{}).reduceChanged,
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
@ -76,12 +76,13 @@ func TestMailTemplateProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.mail_templates SET (change_date, sequence, template) = ($1, $2, $3) WHERE (aggregate_id = $4)",
|
||||
expectedStmt: "UPDATE projections.mail_templates SET (change_date, sequence, template) = ($1, $2, $3) WHERE (aggregate_id = $4) AND (instance_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
[]byte("<table></table>"),
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -89,7 +90,7 @@ func TestMailTemplateProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceRemoved",
|
||||
name: "org reduceRemoved",
|
||||
reduce: (&mailTemplateProjection{}).reduceRemoved,
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
@ -105,9 +106,10 @@ func TestMailTemplateProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.mail_templates WHERE (aggregate_id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.mail_templates WHERE (aggregate_id = $1) AND (instance_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -115,7 +117,7 @@ func TestMailTemplateProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceInstanceRemoved",
|
||||
name: "instance reduceInstanceRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.InstanceRemovedEventType),
|
||||
@ -141,7 +143,7 @@ func TestMailTemplateProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceAdded",
|
||||
name: "instance reduceAdded",
|
||||
reduce: (&mailTemplateProjection{}).reduceAdded,
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
@ -176,7 +178,7 @@ func TestMailTemplateProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceChanged",
|
||||
name: "instance reduceChanged",
|
||||
reduce: (&mailTemplateProjection{}).reduceChanged,
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
@ -194,12 +196,13 @@ func TestMailTemplateProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.mail_templates SET (change_date, sequence, template) = ($1, $2, $3) WHERE (aggregate_id = $4)",
|
||||
expectedStmt: "UPDATE projections.mail_templates SET (change_date, sequence, template) = ($1, $2, $3) WHERE (aggregate_id = $4) AND (instance_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
[]byte("<table></table>"),
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -79,6 +79,7 @@ func reduceMemberChanged(e member.MemberChangedEvent, opts ...reduceMemberOpt) (
|
||||
handler.NewCol(MemberSequence, e.Sequence()),
|
||||
},
|
||||
conds: []handler.Condition{
|
||||
handler.NewCond(MemberInstanceID, e.Aggregate().InstanceID),
|
||||
handler.NewCond(MemberUserIDCol, e.UserID),
|
||||
}}
|
||||
|
||||
@ -92,6 +93,7 @@ func reduceMemberChanged(e member.MemberChangedEvent, opts ...reduceMemberOpt) (
|
||||
func reduceMemberCascadeRemoved(e member.MemberCascadeRemovedEvent, opts ...reduceMemberOpt) (*handler.Statement, error) {
|
||||
config := reduceMemberConfig{
|
||||
conds: []handler.Condition{
|
||||
handler.NewCond(MemberInstanceID, e.Aggregate().InstanceID),
|
||||
handler.NewCond(MemberUserIDCol, e.UserID),
|
||||
}}
|
||||
|
||||
@ -103,7 +105,9 @@ func reduceMemberCascadeRemoved(e member.MemberCascadeRemovedEvent, opts ...redu
|
||||
|
||||
func reduceMemberRemoved(e eventstore.Event, opts ...reduceMemberOpt) (*handler.Statement, error) {
|
||||
config := reduceMemberConfig{
|
||||
conds: []handler.Condition{},
|
||||
conds: []handler.Condition{
|
||||
handler.NewCond(MemberInstanceID, e.Aggregate().InstanceID),
|
||||
},
|
||||
}
|
||||
|
||||
for _, opt := range opts {
|
||||
|
@ -23,7 +23,7 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
want wantReduce
|
||||
}{
|
||||
{
|
||||
name: "org.reduceAdded.Title",
|
||||
name: "org reduceAdded Title",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.CustomTextSetEventType),
|
||||
@ -62,7 +62,7 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceAdded.PreHeader",
|
||||
name: "org reduceAdded PreHeader",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.CustomTextSetEventType),
|
||||
@ -101,7 +101,7 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceAdded.Subject",
|
||||
name: "org reduceAdded Subject",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.CustomTextSetEventType),
|
||||
@ -140,7 +140,7 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceAdded.Greeting",
|
||||
name: "org reduceAdded Greeting",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.CustomTextSetEventType),
|
||||
@ -179,7 +179,7 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceAdded.Text",
|
||||
name: "org reduceAdded Text",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.CustomTextSetEventType),
|
||||
@ -218,7 +218,7 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceAdded.ButtonText",
|
||||
name: "org reduceAdded ButtonText",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.CustomTextSetEventType),
|
||||
@ -257,7 +257,7 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceAdded.Footer",
|
||||
name: "org reduceAdded Footer",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.CustomTextSetEventType),
|
||||
@ -296,7 +296,7 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceRemoved.Title",
|
||||
name: "org reduceRemoved Title",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.CustomTextRemovedEventType),
|
||||
@ -316,7 +316,7 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.message_texts SET (change_date, sequence, title) = ($1, $2, $3) WHERE (aggregate_id = $4) AND (type = $5) AND (language = $6)",
|
||||
expectedStmt: "UPDATE projections.message_texts SET (change_date, sequence, title) = ($1, $2, $3) WHERE (aggregate_id = $4) AND (type = $5) AND (language = $6) AND (instance_id = $7)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@ -324,6 +324,7 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
"agg-id",
|
||||
"InitCode",
|
||||
"en",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -331,7 +332,7 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceInstanceRemoved",
|
||||
name: "instance reduceInstanceRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.InstanceRemovedEventType),
|
||||
@ -357,7 +358,7 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceRemoved.PreHeader",
|
||||
name: "org reduceRemoved PreHeader",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.CustomTextRemovedEventType),
|
||||
@ -377,7 +378,7 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.message_texts SET (change_date, sequence, pre_header) = ($1, $2, $3) WHERE (aggregate_id = $4) AND (type = $5) AND (language = $6)",
|
||||
expectedStmt: "UPDATE projections.message_texts SET (change_date, sequence, pre_header) = ($1, $2, $3) WHERE (aggregate_id = $4) AND (type = $5) AND (language = $6) AND (instance_id = $7)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@ -385,6 +386,7 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
"agg-id",
|
||||
"InitCode",
|
||||
"en",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -392,7 +394,7 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceRemoved.Subject",
|
||||
name: "org reduceRemoved Subject",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.CustomTextRemovedEventType),
|
||||
@ -412,7 +414,7 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.message_texts SET (change_date, sequence, subject) = ($1, $2, $3) WHERE (aggregate_id = $4) AND (type = $5) AND (language = $6)",
|
||||
expectedStmt: "UPDATE projections.message_texts SET (change_date, sequence, subject) = ($1, $2, $3) WHERE (aggregate_id = $4) AND (type = $5) AND (language = $6) AND (instance_id = $7)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@ -420,6 +422,7 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
"agg-id",
|
||||
"InitCode",
|
||||
"en",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -427,7 +430,7 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceRemoved.Greeting",
|
||||
name: "org reduceRemoved Greeting",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.CustomTextRemovedEventType),
|
||||
@ -447,7 +450,7 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.message_texts SET (change_date, sequence, greeting) = ($1, $2, $3) WHERE (aggregate_id = $4) AND (type = $5) AND (language = $6)",
|
||||
expectedStmt: "UPDATE projections.message_texts SET (change_date, sequence, greeting) = ($1, $2, $3) WHERE (aggregate_id = $4) AND (type = $5) AND (language = $6) AND (instance_id = $7)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@ -455,6 +458,7 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
"agg-id",
|
||||
"InitCode",
|
||||
"en",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -462,7 +466,7 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceRemoved.Text",
|
||||
name: "org reduceRemoved Text",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.CustomTextRemovedEventType),
|
||||
@ -482,7 +486,7 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.message_texts SET (change_date, sequence, text) = ($1, $2, $3) WHERE (aggregate_id = $4) AND (type = $5) AND (language = $6)",
|
||||
expectedStmt: "UPDATE projections.message_texts SET (change_date, sequence, text) = ($1, $2, $3) WHERE (aggregate_id = $4) AND (type = $5) AND (language = $6) AND (instance_id = $7)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@ -490,6 +494,7 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
"agg-id",
|
||||
"InitCode",
|
||||
"en",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -497,7 +502,7 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceRemoved.ButtonText",
|
||||
name: "org reduceRemoved ButtonText",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.CustomTextRemovedEventType),
|
||||
@ -517,7 +522,7 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.message_texts SET (change_date, sequence, button_text) = ($1, $2, $3) WHERE (aggregate_id = $4) AND (type = $5) AND (language = $6)",
|
||||
expectedStmt: "UPDATE projections.message_texts SET (change_date, sequence, button_text) = ($1, $2, $3) WHERE (aggregate_id = $4) AND (type = $5) AND (language = $6) AND (instance_id = $7)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@ -525,6 +530,7 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
"agg-id",
|
||||
"InitCode",
|
||||
"en",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -532,7 +538,7 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceRemoved.Footer",
|
||||
name: "org reduceRemoved Footer",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.CustomTextRemovedEventType),
|
||||
@ -552,7 +558,7 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.message_texts SET (change_date, sequence, footer_text) = ($1, $2, $3) WHERE (aggregate_id = $4) AND (type = $5) AND (language = $6)",
|
||||
expectedStmt: "UPDATE projections.message_texts SET (change_date, sequence, footer_text) = ($1, $2, $3) WHERE (aggregate_id = $4) AND (type = $5) AND (language = $6) AND (instance_id = $7)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@ -560,6 +566,7 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
"agg-id",
|
||||
"InitCode",
|
||||
"en",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -567,7 +574,7 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceRemoved",
|
||||
name: "org reduceRemoved",
|
||||
reduce: (&messageTextProjection{}).reduceTemplateRemoved,
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
@ -587,11 +594,12 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.message_texts WHERE (aggregate_id = $1) AND (type = $2) AND (language = $3)",
|
||||
expectedStmt: "DELETE FROM projections.message_texts WHERE (aggregate_id = $1) AND (type = $2) AND (language = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"InitCode",
|
||||
"en",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -599,7 +607,7 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceAdded",
|
||||
name: "instance reduceAdded",
|
||||
reduce: (&messageTextProjection{}).reduceAdded,
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
@ -638,7 +646,7 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceRemoved.Title",
|
||||
name: "instance reduceRemoved Title",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.CustomTextRemovedEventType),
|
||||
@ -658,7 +666,7 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.message_texts SET (change_date, sequence, title) = ($1, $2, $3) WHERE (aggregate_id = $4) AND (type = $5) AND (language = $6)",
|
||||
expectedStmt: "UPDATE projections.message_texts SET (change_date, sequence, title) = ($1, $2, $3) WHERE (aggregate_id = $4) AND (type = $5) AND (language = $6) AND (instance_id = $7)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@ -666,6 +674,7 @@ func TestMessageTextProjection_reduces(t *testing.T) {
|
||||
"agg-id",
|
||||
"InitCode",
|
||||
"en",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -211,6 +211,7 @@ func (p *messageTextProjection) reduceRemoved(event eventstore.Event) (*handler.
|
||||
handler.NewCond(MessageTextAggregateIDCol, templateEvent.Aggregate().ID),
|
||||
handler.NewCond(MessageTextTypeCol, templateEvent.Template),
|
||||
handler.NewCond(MessageTextLanguageCol, templateEvent.Language.String()),
|
||||
handler.NewCond(MessageTextInstanceIDCol, templateEvent.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
@ -234,6 +235,7 @@ func (p *messageTextProjection) reduceTemplateRemoved(event eventstore.Event) (*
|
||||
handler.NewCond(MessageTextAggregateIDCol, templateEvent.Aggregate().ID),
|
||||
handler.NewCond(MessageTextTypeCol, templateEvent.Template),
|
||||
handler.NewCond(MessageTextLanguageCol, templateEvent.Language.String()),
|
||||
handler.NewCond(MessageTextInstanceIDCol, templateEvent.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
|
@ -125,6 +125,7 @@ func (p *oidcSettingsProjection) reduceOIDCSettingsChanged(event eventstore.Even
|
||||
columns,
|
||||
[]handler.Condition{
|
||||
handler.NewCond(OIDCSettingsColumnAggregateID, e.Aggregate().ID),
|
||||
handler.NewCond(OIDCSettingsColumnInstanceID, e.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ func TestOIDCSettingsProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.oidc_settings SET (change_date, sequence, access_token_lifetime, id_token_lifetime, refresh_token_idle_expiration, refresh_token_expiration) = ($1, $2, $3, $4, $5, $6) WHERE (aggregate_id = $7)",
|
||||
expectedStmt: "UPDATE projections.oidc_settings SET (change_date, sequence, access_token_lifetime, id_token_lifetime, refresh_token_idle_expiration, refresh_token_expiration) = ($1, $2, $3, $4, $5, $6) WHERE (aggregate_id = $7) AND (instance_id = $8)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@ -47,6 +47,7 @@ func TestOIDCSettingsProjection_reduces(t *testing.T) {
|
||||
time.Millisecond * 10,
|
||||
time.Millisecond * 10,
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -89,7 +90,7 @@ func TestOIDCSettingsProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceInstanceRemoved",
|
||||
name: "instance reduceInstanceRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.InstanceRemovedEventType),
|
||||
|
@ -131,6 +131,7 @@ func (p *orgProjection) reduceOrgChanged(event eventstore.Event) (*handler.State
|
||||
},
|
||||
[]handler.Condition{
|
||||
handler.NewCond(OrgColumnID, e.Aggregate().ID),
|
||||
handler.NewCond(OrgColumnInstanceID, e.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
@ -149,6 +150,7 @@ func (p *orgProjection) reduceOrgDeactivated(event eventstore.Event) (*handler.S
|
||||
},
|
||||
[]handler.Condition{
|
||||
handler.NewCond(OrgColumnID, e.Aggregate().ID),
|
||||
handler.NewCond(OrgColumnInstanceID, e.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
@ -167,6 +169,7 @@ func (p *orgProjection) reduceOrgReactivated(event eventstore.Event) (*handler.S
|
||||
},
|
||||
[]handler.Condition{
|
||||
handler.NewCond(OrgColumnID, e.Aggregate().ID),
|
||||
handler.NewCond(OrgColumnInstanceID, e.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
@ -185,6 +188,7 @@ func (p *orgProjection) reducePrimaryDomainSet(event eventstore.Event) (*handler
|
||||
},
|
||||
[]handler.Condition{
|
||||
handler.NewCond(OrgColumnID, e.Aggregate().ID),
|
||||
handler.NewCond(OrgColumnInstanceID, e.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ func TestOrgDomainProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceInstanceRemoved",
|
||||
name: "instance reduceInstanceRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.InstanceRemovedEventType),
|
||||
|
@ -24,7 +24,7 @@ func TestOrgMemberProjection_reduces(t *testing.T) {
|
||||
want wantReduce
|
||||
}{
|
||||
{
|
||||
name: "org.MemberAddedType",
|
||||
name: "org MemberAddedType",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.MemberAddedEventType),
|
||||
@ -60,7 +60,7 @@ func TestOrgMemberProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.MemberChangedType",
|
||||
name: "org MemberChangedType",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.MemberChangedEventType),
|
||||
@ -79,11 +79,12 @@ func TestOrgMemberProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.org_members2 SET (roles, change_date, sequence) = ($1, $2, $3) WHERE (user_id = $4) AND (org_id = $5)",
|
||||
expectedStmt: "UPDATE projections.org_members2 SET (roles, change_date, sequence) = ($1, $2, $3) WHERE (instance_id = $4) AND (user_id = $5) AND (org_id = $6)",
|
||||
expectedArgs: []interface{}{
|
||||
database.StringArray{"role", "changed"},
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
"instance-id",
|
||||
"user-id",
|
||||
"agg-id",
|
||||
},
|
||||
@ -93,7 +94,7 @@ func TestOrgMemberProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.MemberCascadeRemovedType",
|
||||
name: "org MemberCascadeRemovedType",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.MemberCascadeRemovedEventType),
|
||||
@ -111,8 +112,9 @@ func TestOrgMemberProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.org_members2 WHERE (user_id = $1) AND (org_id = $2)",
|
||||
expectedStmt: "DELETE FROM projections.org_members2 WHERE (instance_id = $1) AND (user_id = $2) AND (org_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
"instance-id",
|
||||
"user-id",
|
||||
"agg-id",
|
||||
},
|
||||
@ -122,7 +124,7 @@ func TestOrgMemberProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.MemberRemovedType",
|
||||
name: "org MemberRemovedType",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.MemberRemovedEventType),
|
||||
@ -140,8 +142,9 @@ func TestOrgMemberProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.org_members2 WHERE (user_id = $1) AND (org_id = $2)",
|
||||
expectedStmt: "DELETE FROM projections.org_members2 WHERE (instance_id = $1) AND (user_id = $2) AND (org_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
"instance-id",
|
||||
"user-id",
|
||||
"agg-id",
|
||||
},
|
||||
@ -151,7 +154,7 @@ func TestOrgMemberProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "user.UserRemovedEventType",
|
||||
name: "user UserRemovedEventType",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(user.UserRemovedType),
|
||||
@ -167,8 +170,9 @@ func TestOrgMemberProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.org_members2 WHERE (user_id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.org_members2 WHERE (instance_id = $1) AND (user_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"instance-id",
|
||||
"agg-id",
|
||||
},
|
||||
},
|
||||
@ -177,7 +181,7 @@ func TestOrgMemberProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.OrgRemovedEventType",
|
||||
name: "org OrgRemovedEventType",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.OrgRemovedEventType),
|
||||
@ -193,8 +197,9 @@ func TestOrgMemberProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.org_members2 WHERE (org_id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.org_members2 WHERE (instance_id = $1) AND (org_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"instance-id",
|
||||
"agg-id",
|
||||
},
|
||||
},
|
||||
@ -203,7 +208,7 @@ func TestOrgMemberProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceInstanceRemoved",
|
||||
name: "instance reduceInstanceRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.InstanceRemovedEventType),
|
||||
|
@ -121,6 +121,7 @@ func (p *orgMetadataProjection) reduceMetadataRemoved(event eventstore.Event) (*
|
||||
[]handler.Condition{
|
||||
handler.NewCond(OrgMetadataColumnOrgID, e.Aggregate().ID),
|
||||
handler.NewCond(OrgMetadataColumnKey, e.Key),
|
||||
handler.NewCond(OrgMetadataColumnInstanceID, e.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
@ -137,6 +138,7 @@ func (p *orgMetadataProjection) reduceMetadataRemovedAll(event eventstore.Event)
|
||||
event,
|
||||
[]handler.Condition{
|
||||
handler.NewCond(OrgMetadataColumnOrgID, event.Aggregate().ID),
|
||||
handler.NewCond(OrgMetadataColumnInstanceID, event.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
|
@ -76,10 +76,11 @@ func TestOrgMetadataProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.org_metadata WHERE (org_id = $1) AND (key = $2)",
|
||||
expectedStmt: "DELETE FROM projections.org_metadata WHERE (org_id = $1) AND (key = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"key",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -103,9 +104,10 @@ func TestOrgMetadataProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.org_metadata WHERE (org_id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.org_metadata WHERE (org_id = $1) AND (instance_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -129,9 +131,10 @@ func TestOrgMetadataProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.org_metadata WHERE (org_id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.org_metadata WHERE (org_id = $1) AND (instance_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -39,12 +39,13 @@ func TestOrgProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.orgs SET (change_date, sequence, primary_domain) = ($1, $2, $3) WHERE (id = $4)",
|
||||
expectedStmt: "UPDATE projections.orgs SET (change_date, sequence, primary_domain) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
"domain.new",
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -68,12 +69,13 @@ func TestOrgProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.orgs SET (change_date, sequence, org_state) = ($1, $2, $3) WHERE (id = $4)",
|
||||
expectedStmt: "UPDATE projections.orgs SET (change_date, sequence, org_state) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
domain.OrgStateActive,
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -97,12 +99,13 @@ func TestOrgProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.orgs SET (change_date, sequence, org_state) = ($1, $2, $3) WHERE (id = $4)",
|
||||
expectedStmt: "UPDATE projections.orgs SET (change_date, sequence, org_state) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
domain.OrgStateInactive,
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -126,12 +129,13 @@ func TestOrgProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.orgs SET (change_date, sequence, name) = ($1, $2, $3) WHERE (id = $4)",
|
||||
expectedStmt: "UPDATE projections.orgs SET (change_date, sequence, name) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
"new name",
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -189,7 +193,7 @@ func TestOrgProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceInstanceRemoved",
|
||||
name: "instance reduceInstanceRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.InstanceRemovedEventType),
|
||||
|
@ -149,6 +149,7 @@ func (p *passwordAgeProjection) reduceChanged(event eventstore.Event) (*handler.
|
||||
cols,
|
||||
[]handler.Condition{
|
||||
handler.NewCond(AgePolicyIDCol, policyEvent.Aggregate().ID),
|
||||
handler.NewCond(AgePolicyInstanceIDCol, policyEvent.Aggregate().InstanceID),
|
||||
}), nil
|
||||
}
|
||||
|
||||
@ -161,5 +162,6 @@ func (p *passwordAgeProjection) reduceRemoved(event eventstore.Event) (*handler.
|
||||
policyEvent,
|
||||
[]handler.Condition{
|
||||
handler.NewCond(AgePolicyIDCol, policyEvent.Aggregate().ID),
|
||||
handler.NewCond(AgePolicyInstanceIDCol, policyEvent.Aggregate().InstanceID),
|
||||
}), nil
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ func TestPasswordAgeProjection_reduces(t *testing.T) {
|
||||
want wantReduce
|
||||
}{
|
||||
{
|
||||
name: "org.reduceAdded",
|
||||
name: "org reduceAdded",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.PasswordAgePolicyAddedEventType),
|
||||
@ -61,7 +61,7 @@ func TestPasswordAgeProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceChanged",
|
||||
name: "org reduceChanged",
|
||||
reduce: (&passwordAgeProjection{}).reduceChanged,
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
@ -80,13 +80,14 @@ func TestPasswordAgeProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.password_age_policies SET (change_date, sequence, expire_warn_days, max_age_days) = ($1, $2, $3, $4) WHERE (id = $5)",
|
||||
expectedStmt: "UPDATE projections.password_age_policies SET (change_date, sequence, expire_warn_days, max_age_days) = ($1, $2, $3, $4) WHERE (id = $5) AND (instance_id = $6)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
uint64(10),
|
||||
uint64(13),
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -94,7 +95,7 @@ func TestPasswordAgeProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceRemoved",
|
||||
name: "org reduceRemoved",
|
||||
reduce: (&passwordAgeProjection{}).reduceRemoved,
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
@ -110,9 +111,10 @@ func TestPasswordAgeProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.password_age_policies WHERE (id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.password_age_policies WHERE (id = $1) AND (instance_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -120,7 +122,7 @@ func TestPasswordAgeProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceInstanceRemoved",
|
||||
name: "instance reduceInstanceRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.InstanceRemovedEventType),
|
||||
@ -146,7 +148,7 @@ func TestPasswordAgeProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceAdded",
|
||||
name: "instance reduceAdded",
|
||||
reduce: (&passwordAgeProjection{}).reduceAdded,
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
@ -184,7 +186,7 @@ func TestPasswordAgeProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceChanged",
|
||||
name: "instance reduceChanged",
|
||||
reduce: (&passwordAgeProjection{}).reduceChanged,
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
@ -203,13 +205,14 @@ func TestPasswordAgeProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.password_age_policies SET (change_date, sequence, expire_warn_days, max_age_days) = ($1, $2, $3, $4) WHERE (id = $5)",
|
||||
expectedStmt: "UPDATE projections.password_age_policies SET (change_date, sequence, expire_warn_days, max_age_days) = ($1, $2, $3, $4) WHERE (id = $5) AND (instance_id = $6)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
uint64(10),
|
||||
uint64(13),
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -167,6 +167,7 @@ func (p *passwordComplexityProjection) reduceChanged(event eventstore.Event) (*h
|
||||
cols,
|
||||
[]handler.Condition{
|
||||
handler.NewCond(ComplexityPolicyIDCol, policyEvent.Aggregate().ID),
|
||||
handler.NewCond(ComplexityPolicyInstanceIDCol, policyEvent.Aggregate().InstanceID),
|
||||
}), nil
|
||||
}
|
||||
|
||||
@ -179,5 +180,6 @@ func (p *passwordComplexityProjection) reduceRemoved(event eventstore.Event) (*h
|
||||
policyEvent,
|
||||
[]handler.Condition{
|
||||
handler.NewCond(ComplexityPolicyIDCol, policyEvent.Aggregate().ID),
|
||||
handler.NewCond(ComplexityPolicyInstanceIDCol, policyEvent.Aggregate().InstanceID),
|
||||
}), nil
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ func TestPasswordComplexityProjection_reduces(t *testing.T) {
|
||||
want wantReduce
|
||||
}{
|
||||
{
|
||||
name: "org.reduceAdded",
|
||||
name: "org reduceAdded",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.PasswordComplexityPolicyAddedEventType),
|
||||
@ -67,7 +67,7 @@ func TestPasswordComplexityProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceChanged",
|
||||
name: "org reduceChanged",
|
||||
reduce: (&passwordComplexityProjection{}).reduceChanged,
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
@ -89,7 +89,7 @@ func TestPasswordComplexityProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.password_complexity_policies SET (change_date, sequence, min_length, has_lowercase, has_uppercase, has_symbol, has_number) = ($1, $2, $3, $4, $5, $6, $7) WHERE (id = $8)",
|
||||
expectedStmt: "UPDATE projections.password_complexity_policies SET (change_date, sequence, min_length, has_lowercase, has_uppercase, has_symbol, has_number) = ($1, $2, $3, $4, $5, $6, $7) WHERE (id = $8) AND (instance_id = $9)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@ -99,6 +99,7 @@ func TestPasswordComplexityProjection_reduces(t *testing.T) {
|
||||
true,
|
||||
true,
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -106,7 +107,7 @@ func TestPasswordComplexityProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceRemoved",
|
||||
name: "org reduceRemoved",
|
||||
reduce: (&passwordComplexityProjection{}).reduceRemoved,
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
@ -122,9 +123,10 @@ func TestPasswordComplexityProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.password_complexity_policies WHERE (id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.password_complexity_policies WHERE (id = $1) AND (instance_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -132,7 +134,7 @@ func TestPasswordComplexityProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceInstanceRemoved",
|
||||
name: "instance reduceInstanceRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.InstanceRemovedEventType),
|
||||
@ -158,7 +160,7 @@ func TestPasswordComplexityProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceAdded",
|
||||
name: "instance reduceAdded",
|
||||
reduce: (&passwordComplexityProjection{}).reduceAdded,
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
@ -202,7 +204,7 @@ func TestPasswordComplexityProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceChanged",
|
||||
name: "instance reduceChanged",
|
||||
reduce: (&passwordComplexityProjection{}).reduceChanged,
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
@ -224,7 +226,7 @@ func TestPasswordComplexityProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.password_complexity_policies SET (change_date, sequence, min_length, has_lowercase, has_uppercase, has_symbol, has_number) = ($1, $2, $3, $4, $5, $6, $7) WHERE (id = $8)",
|
||||
expectedStmt: "UPDATE projections.password_complexity_policies SET (change_date, sequence, min_length, has_lowercase, has_uppercase, has_symbol, has_number) = ($1, $2, $3, $4, $5, $6, $7) WHERE (id = $8) AND (instance_id = $9)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@ -234,6 +236,7 @@ func TestPasswordComplexityProjection_reduces(t *testing.T) {
|
||||
true,
|
||||
true,
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -155,6 +155,7 @@ func (p *privacyPolicyProjection) reduceChanged(event eventstore.Event) (*handle
|
||||
cols,
|
||||
[]handler.Condition{
|
||||
handler.NewCond(PrivacyPolicyIDCol, policyEvent.Aggregate().ID),
|
||||
handler.NewCond(PrivacyPolicyInstanceIDCol, policyEvent.Aggregate().InstanceID),
|
||||
}), nil
|
||||
}
|
||||
|
||||
@ -167,5 +168,6 @@ func (p *privacyPolicyProjection) reduceRemoved(event eventstore.Event) (*handle
|
||||
policyEvent,
|
||||
[]handler.Condition{
|
||||
handler.NewCond(PrivacyPolicyIDCol, policyEvent.Aggregate().ID),
|
||||
handler.NewCond(PrivacyPolicyInstanceIDCol, policyEvent.Aggregate().InstanceID),
|
||||
}), nil
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ func TestPrivacyPolicyProjection_reduces(t *testing.T) {
|
||||
want wantReduce
|
||||
}{
|
||||
{
|
||||
name: "org.reduceAdded",
|
||||
name: "org reduceAdded",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.PrivacyPolicyAddedEventType),
|
||||
@ -63,7 +63,7 @@ func TestPrivacyPolicyProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceChanged",
|
||||
name: "org reduceChanged",
|
||||
reduce: (&privacyPolicyProjection{}).reduceChanged,
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
@ -83,7 +83,7 @@ func TestPrivacyPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.privacy_policies SET (change_date, sequence, privacy_link, tos_link, help_link) = ($1, $2, $3, $4, $5) WHERE (id = $6)",
|
||||
expectedStmt: "UPDATE projections.privacy_policies SET (change_date, sequence, privacy_link, tos_link, help_link) = ($1, $2, $3, $4, $5) WHERE (id = $6) AND (instance_id = $7)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@ -91,6 +91,7 @@ func TestPrivacyPolicyProjection_reduces(t *testing.T) {
|
||||
"http://tos.link",
|
||||
"http://help.link",
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -98,7 +99,7 @@ func TestPrivacyPolicyProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceRemoved",
|
||||
name: "org reduceRemoved",
|
||||
reduce: (&privacyPolicyProjection{}).reduceRemoved,
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
@ -114,16 +115,17 @@ func TestPrivacyPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.privacy_policies WHERE (id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.privacy_policies WHERE (id = $1) AND (instance_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}, {
|
||||
name: "instance.reduceInstanceRemoved",
|
||||
name: "instance reduceInstanceRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.InstanceRemovedEventType),
|
||||
@ -149,7 +151,7 @@ func TestPrivacyPolicyProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceAdded",
|
||||
name: "instance reduceAdded",
|
||||
reduce: (&privacyPolicyProjection{}).reduceAdded,
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
@ -189,7 +191,7 @@ func TestPrivacyPolicyProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceChanged",
|
||||
name: "instance reduceChanged",
|
||||
reduce: (&privacyPolicyProjection{}).reduceChanged,
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
@ -209,7 +211,7 @@ func TestPrivacyPolicyProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.privacy_policies SET (change_date, sequence, privacy_link, tos_link, help_link) = ($1, $2, $3, $4, $5) WHERE (id = $6)",
|
||||
expectedStmt: "UPDATE projections.privacy_policies SET (change_date, sequence, privacy_link, tos_link, help_link) = ($1, $2, $3, $4, $5) WHERE (id = $6) AND (instance_id = $7)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@ -217,6 +219,7 @@ func TestPrivacyPolicyProjection_reduces(t *testing.T) {
|
||||
"http://tos.link",
|
||||
"http://help.link",
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -155,6 +155,7 @@ func (p *projectProjection) reduceProjectChanged(event eventstore.Event) (*handl
|
||||
columns,
|
||||
[]handler.Condition{
|
||||
handler.NewCond(ProjectColumnID, e.Aggregate().ID),
|
||||
handler.NewCond(ProjectColumnInstanceID, e.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
@ -173,6 +174,7 @@ func (p *projectProjection) reduceProjectDeactivated(event eventstore.Event) (*h
|
||||
},
|
||||
[]handler.Condition{
|
||||
handler.NewCond(ProjectColumnID, e.Aggregate().ID),
|
||||
handler.NewCond(ProjectColumnInstanceID, e.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
@ -191,6 +193,7 @@ func (p *projectProjection) reduceProjectReactivated(event eventstore.Event) (*h
|
||||
},
|
||||
[]handler.Condition{
|
||||
handler.NewCond(ProjectColumnID, e.Aggregate().ID),
|
||||
handler.NewCond(ProjectColumnInstanceID, e.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
@ -204,6 +207,7 @@ func (p *projectProjection) reduceProjectRemoved(event eventstore.Event) (*handl
|
||||
e,
|
||||
[]handler.Condition{
|
||||
handler.NewCond(ProjectColumnID, e.Aggregate().ID),
|
||||
handler.NewCond(ProjectColumnInstanceID, e.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
|
@ -142,6 +142,7 @@ func (p *projectGrantProjection) reduceProjectGrantChanged(event eventstore.Even
|
||||
[]handler.Condition{
|
||||
handler.NewCond(ProjectGrantColumnGrantID, e.GrantID),
|
||||
handler.NewCond(ProjectGrantColumnProjectID, e.Aggregate().ID),
|
||||
handler.NewCond(ProjectGrantColumnInstanceID, e.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
@ -161,6 +162,7 @@ func (p *projectGrantProjection) reduceProjectGrantCascadeChanged(event eventsto
|
||||
[]handler.Condition{
|
||||
handler.NewCond(ProjectGrantColumnGrantID, e.GrantID),
|
||||
handler.NewCond(ProjectGrantColumnProjectID, e.Aggregate().ID),
|
||||
handler.NewCond(ProjectGrantColumnInstanceID, e.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
@ -180,6 +182,7 @@ func (p *projectGrantProjection) reduceProjectGrantDeactivated(event eventstore.
|
||||
[]handler.Condition{
|
||||
handler.NewCond(ProjectGrantColumnGrantID, e.GrantID),
|
||||
handler.NewCond(ProjectGrantColumnProjectID, e.Aggregate().ID),
|
||||
handler.NewCond(ProjectGrantColumnInstanceID, e.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
@ -199,6 +202,7 @@ func (p *projectGrantProjection) reduceProjectGrantReactivated(event eventstore.
|
||||
[]handler.Condition{
|
||||
handler.NewCond(ProjectGrantColumnGrantID, e.GrantID),
|
||||
handler.NewCond(ProjectGrantColumnProjectID, e.Aggregate().ID),
|
||||
handler.NewCond(ProjectGrantColumnInstanceID, e.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
@ -213,6 +217,7 @@ func (p *projectGrantProjection) reduceProjectGrantRemoved(event eventstore.Even
|
||||
[]handler.Condition{
|
||||
handler.NewCond(ProjectGrantColumnGrantID, e.GrantID),
|
||||
handler.NewCond(ProjectGrantColumnProjectID, e.Aggregate().ID),
|
||||
handler.NewCond(ProjectGrantColumnInstanceID, e.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
@ -226,6 +231,7 @@ func (p *projectGrantProjection) reduceProjectRemoved(event eventstore.Event) (*
|
||||
e,
|
||||
[]handler.Condition{
|
||||
handler.NewCond(ProjectGrantColumnProjectID, e.Aggregate().ID),
|
||||
handler.NewCond(ProjectGrantColumnInstanceID, e.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ func TestProjectGrantMemberProjection_reduces(t *testing.T) {
|
||||
want wantReduce
|
||||
}{
|
||||
{
|
||||
name: "project.GrantMemberAddedType",
|
||||
name: "project GrantMemberAddedType",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(project.GrantMemberAddedType),
|
||||
@ -63,7 +63,7 @@ func TestProjectGrantMemberProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "project.GrantMemberChangedType",
|
||||
name: "project GrantMemberChangedType",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(project.GrantMemberChangedType),
|
||||
@ -83,11 +83,12 @@ func TestProjectGrantMemberProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.project_grant_members2 SET (roles, change_date, sequence) = ($1, $2, $3) WHERE (user_id = $4) AND (project_id = $5) AND (grant_id = $6)",
|
||||
expectedStmt: "UPDATE projections.project_grant_members2 SET (roles, change_date, sequence) = ($1, $2, $3) WHERE (instance_id = $4) AND (user_id = $5) AND (project_id = $6) AND (grant_id = $7)",
|
||||
expectedArgs: []interface{}{
|
||||
database.StringArray{"role", "changed"},
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
"instance-id",
|
||||
"user-id",
|
||||
"agg-id",
|
||||
"grant-id",
|
||||
@ -98,7 +99,7 @@ func TestProjectGrantMemberProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "project.GrantMemberCascadeRemovedType",
|
||||
name: "project GrantMemberCascadeRemovedType",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(project.GrantMemberCascadeRemovedType),
|
||||
@ -117,8 +118,9 @@ func TestProjectGrantMemberProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.project_grant_members2 WHERE (user_id = $1) AND (project_id = $2) AND (grant_id = $3)",
|
||||
expectedStmt: "DELETE FROM projections.project_grant_members2 WHERE (instance_id = $1) AND (user_id = $2) AND (project_id = $3) AND (grant_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
"instance-id",
|
||||
"user-id",
|
||||
"agg-id",
|
||||
"grant-id",
|
||||
@ -129,7 +131,7 @@ func TestProjectGrantMemberProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "project.GrantMemberRemovedType",
|
||||
name: "project GrantMemberRemovedType",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(project.GrantMemberRemovedType),
|
||||
@ -148,8 +150,9 @@ func TestProjectGrantMemberProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.project_grant_members2 WHERE (user_id = $1) AND (project_id = $2) AND (grant_id = $3)",
|
||||
expectedStmt: "DELETE FROM projections.project_grant_members2 WHERE (instance_id = $1) AND (user_id = $2) AND (project_id = $3) AND (grant_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
"instance-id",
|
||||
"user-id",
|
||||
"agg-id",
|
||||
"grant-id",
|
||||
@ -160,7 +163,7 @@ func TestProjectGrantMemberProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "user.UserRemovedEventType",
|
||||
name: "user UserRemovedEventType",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(user.UserRemovedType),
|
||||
@ -176,8 +179,9 @@ func TestProjectGrantMemberProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.project_grant_members2 WHERE (user_id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.project_grant_members2 WHERE (instance_id = $1) AND (user_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"instance-id",
|
||||
"agg-id",
|
||||
},
|
||||
},
|
||||
@ -186,7 +190,7 @@ func TestProjectGrantMemberProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.OrgRemovedEventType",
|
||||
name: "org OrgRemovedEventType",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.OrgRemovedEventType),
|
||||
@ -202,8 +206,9 @@ func TestProjectGrantMemberProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.project_grant_members2 WHERE (resource_owner = $1)",
|
||||
expectedStmt: "DELETE FROM projections.project_grant_members2 WHERE (instance_id = $1) AND (resource_owner = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"instance-id",
|
||||
"agg-id",
|
||||
},
|
||||
},
|
||||
@ -211,7 +216,7 @@ func TestProjectGrantMemberProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}, {
|
||||
name: "instance.reduceInstanceRemoved",
|
||||
name: "instance reduceInstanceRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.InstanceRemovedEventType),
|
||||
@ -237,7 +242,7 @@ func TestProjectGrantMemberProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "project.ProjectRemovedEventType",
|
||||
name: "project ProjectRemovedEventType",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(project.ProjectRemovedType),
|
||||
@ -253,8 +258,9 @@ func TestProjectGrantMemberProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.project_grant_members2 WHERE (project_id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.project_grant_members2 WHERE (instance_id = $1) AND (project_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"instance-id",
|
||||
"agg-id",
|
||||
},
|
||||
},
|
||||
@ -263,7 +269,7 @@ func TestProjectGrantMemberProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "project.GrantRemovedEventType",
|
||||
name: "project GrantRemovedEventType",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(project.GrantRemovedType),
|
||||
@ -279,8 +285,9 @@ func TestProjectGrantMemberProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.project_grant_members2 WHERE (grant_id = $1) AND (project_id = $2)",
|
||||
expectedStmt: "DELETE FROM projections.project_grant_members2 WHERE (instance_id = $1) AND (grant_id = $2) AND (project_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
"instance-id",
|
||||
"grant-id",
|
||||
"agg-id",
|
||||
},
|
||||
|
@ -40,9 +40,10 @@ func TestProjectGrantProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.project_grants2 WHERE (project_id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.project_grants2 WHERE (project_id = $1) AND (instance_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -50,7 +51,7 @@ func TestProjectGrantProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceInstanceRemoved",
|
||||
name: "instance reduceInstanceRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.InstanceRemovedEventType),
|
||||
@ -92,10 +93,11 @@ func TestProjectGrantProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.project_grants2 WHERE (grant_id = $1) AND (project_id = $2)",
|
||||
expectedStmt: "DELETE FROM projections.project_grants2 WHERE (grant_id = $1) AND (project_id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
"grant-id",
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -119,13 +121,14 @@ func TestProjectGrantProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.project_grants2 SET (change_date, sequence, state) = ($1, $2, $3) WHERE (grant_id = $4) AND (project_id = $5)",
|
||||
expectedStmt: "UPDATE projections.project_grants2 SET (change_date, sequence, state) = ($1, $2, $3) WHERE (grant_id = $4) AND (project_id = $5) AND (instance_id = $6)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
domain.ProjectGrantStateActive,
|
||||
"grant-id",
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -149,13 +152,14 @@ func TestProjectGrantProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.project_grants2 SET (change_date, sequence, state) = ($1, $2, $3) WHERE (grant_id = $4) AND (project_id = $5)",
|
||||
expectedStmt: "UPDATE projections.project_grants2 SET (change_date, sequence, state) = ($1, $2, $3) WHERE (grant_id = $4) AND (project_id = $5) AND (instance_id = $6)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
domain.ProjectGrantStateInactive,
|
||||
"grant-id",
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -179,13 +183,14 @@ func TestProjectGrantProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.project_grants2 SET (change_date, sequence, granted_role_keys) = ($1, $2, $3) WHERE (grant_id = $4) AND (project_id = $5)",
|
||||
expectedStmt: "UPDATE projections.project_grants2 SET (change_date, sequence, granted_role_keys) = ($1, $2, $3) WHERE (grant_id = $4) AND (project_id = $5) AND (instance_id = $6)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
database.StringArray{"admin", "user"},
|
||||
"grant-id",
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -209,13 +214,14 @@ func TestProjectGrantProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.project_grants2 SET (change_date, sequence, granted_role_keys) = ($1, $2, $3) WHERE (grant_id = $4) AND (project_id = $5)",
|
||||
expectedStmt: "UPDATE projections.project_grants2 SET (change_date, sequence, granted_role_keys) = ($1, $2, $3) WHERE (grant_id = $4) AND (project_id = $5) AND (instance_id = $6)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
database.StringArray{"admin", "user"},
|
||||
"grant-id",
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -25,7 +25,7 @@ func TestProjectMemberProjection_reduces(t *testing.T) {
|
||||
want wantReduce
|
||||
}{
|
||||
{
|
||||
name: "project.MemberAddedType",
|
||||
name: "project MemberAddedType",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(project.MemberAddedType),
|
||||
@ -61,7 +61,7 @@ func TestProjectMemberProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "project.MemberChangedType",
|
||||
name: "project MemberChangedType",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(project.MemberChangedType),
|
||||
@ -80,11 +80,12 @@ func TestProjectMemberProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.project_members2 SET (roles, change_date, sequence) = ($1, $2, $3) WHERE (user_id = $4) AND (project_id = $5)",
|
||||
expectedStmt: "UPDATE projections.project_members2 SET (roles, change_date, sequence) = ($1, $2, $3) WHERE (instance_id = $4) AND (user_id = $5) AND (project_id = $6)",
|
||||
expectedArgs: []interface{}{
|
||||
database.StringArray{"role", "changed"},
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
"instance-id",
|
||||
"user-id",
|
||||
"agg-id",
|
||||
},
|
||||
@ -94,7 +95,7 @@ func TestProjectMemberProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "project.MemberCascadeRemovedType",
|
||||
name: "project MemberCascadeRemovedType",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(project.MemberCascadeRemovedType),
|
||||
@ -112,8 +113,9 @@ func TestProjectMemberProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.project_members2 WHERE (user_id = $1) AND (project_id = $2)",
|
||||
expectedStmt: "DELETE FROM projections.project_members2 WHERE (instance_id = $1) AND (user_id = $2) AND (project_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
"instance-id",
|
||||
"user-id",
|
||||
"agg-id",
|
||||
},
|
||||
@ -123,7 +125,7 @@ func TestProjectMemberProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "project.MemberRemovedType",
|
||||
name: "project MemberRemovedType",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(project.MemberRemovedType),
|
||||
@ -141,8 +143,9 @@ func TestProjectMemberProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.project_members2 WHERE (user_id = $1) AND (project_id = $2)",
|
||||
expectedStmt: "DELETE FROM projections.project_members2 WHERE (instance_id = $1) AND (user_id = $2) AND (project_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
"instance-id",
|
||||
"user-id",
|
||||
"agg-id",
|
||||
},
|
||||
@ -152,7 +155,7 @@ func TestProjectMemberProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "user.UserRemovedEventType",
|
||||
name: "user UserRemovedEventType",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(user.UserRemovedType),
|
||||
@ -168,8 +171,9 @@ func TestProjectMemberProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.project_members2 WHERE (user_id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.project_members2 WHERE (instance_id = $1) AND (user_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"instance-id",
|
||||
"agg-id",
|
||||
},
|
||||
},
|
||||
@ -178,7 +182,7 @@ func TestProjectMemberProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.OrgRemovedEventType",
|
||||
name: "org OrgRemovedEventType",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.OrgRemovedEventType),
|
||||
@ -194,8 +198,9 @@ func TestProjectMemberProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.project_members2 WHERE (resource_owner = $1)",
|
||||
expectedStmt: "DELETE FROM projections.project_members2 WHERE (instance_id = $1) AND (resource_owner = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"instance-id",
|
||||
"agg-id",
|
||||
},
|
||||
},
|
||||
@ -204,7 +209,7 @@ func TestProjectMemberProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceInstanceRemoved",
|
||||
name: "instance reduceInstanceRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.InstanceRemovedEventType),
|
||||
@ -230,7 +235,7 @@ func TestProjectMemberProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "project.ProjectRemovedEventType",
|
||||
name: "project ProjectRemovedEventType",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(project.ProjectRemovedType),
|
||||
@ -246,8 +251,9 @@ func TestProjectMemberProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.project_members2 WHERE (project_id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.project_members2 WHERE (instance_id = $1) AND (project_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"instance-id",
|
||||
"agg-id",
|
||||
},
|
||||
},
|
||||
|
@ -131,6 +131,7 @@ func (p *projectRoleProjection) reduceProjectRoleChanged(event eventstore.Event)
|
||||
[]handler.Condition{
|
||||
handler.NewCond(ProjectRoleColumnKey, e.Key),
|
||||
handler.NewCond(ProjectRoleColumnProjectID, e.Aggregate().ID),
|
||||
handler.NewCond(ProjectRoleColumnInstanceID, e.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
@ -145,6 +146,7 @@ func (p *projectRoleProjection) reduceProjectRoleRemoved(event eventstore.Event)
|
||||
[]handler.Condition{
|
||||
handler.NewCond(ProjectRoleColumnKey, e.Key),
|
||||
handler.NewCond(ProjectRoleColumnProjectID, e.Aggregate().ID),
|
||||
handler.NewCond(ProjectRoleColumnInstanceID, e.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
@ -158,6 +160,7 @@ func (p *projectRoleProjection) reduceProjectRemoved(event eventstore.Event) (*h
|
||||
e,
|
||||
[]handler.Condition{
|
||||
handler.NewCond(ProjectRoleColumnProjectID, e.Aggregate().ID),
|
||||
handler.NewCond(ProjectRoleColumnInstanceID, e.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
|
@ -38,9 +38,10 @@ func TestProjectRoleProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.project_roles WHERE (project_id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.project_roles WHERE (project_id = $1) AND (instance_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -48,7 +49,7 @@ func TestProjectRoleProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceInstanceRemoved",
|
||||
name: "instance reduceInstanceRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.InstanceRemovedEventType),
|
||||
@ -90,10 +91,11 @@ func TestProjectRoleProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.project_roles WHERE (role_key = $1) AND (project_id = $2)",
|
||||
expectedStmt: "DELETE FROM projections.project_roles WHERE (role_key = $1) AND (project_id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
"key",
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -117,7 +119,7 @@ func TestProjectRoleProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.project_roles SET (change_date, sequence, display_name, group_name) = ($1, $2, $3, $4) WHERE (role_key = $5) AND (project_id = $6)",
|
||||
expectedStmt: "UPDATE projections.project_roles SET (change_date, sequence, display_name, group_name) = ($1, $2, $3, $4) WHERE (role_key = $5) AND (project_id = $6) AND (instance_id = $7)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@ -125,6 +127,7 @@ func TestProjectRoleProjection_reduces(t *testing.T) {
|
||||
"New Group",
|
||||
"key",
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -39,9 +39,10 @@ func TestProjectProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.projects2 WHERE (id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.projects2 WHERE (id = $1) AND (instance_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -49,7 +50,7 @@ func TestProjectProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceInstanceRemoved",
|
||||
name: "instance reduceInstanceRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.InstanceRemovedEventType),
|
||||
@ -91,12 +92,13 @@ func TestProjectProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.projects2 SET (change_date, sequence, state) = ($1, $2, $3) WHERE (id = $4)",
|
||||
expectedStmt: "UPDATE projections.projects2 SET (change_date, sequence, state) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
domain.ProjectStateActive,
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -120,12 +122,13 @@ func TestProjectProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.projects2 SET (change_date, sequence, state) = ($1, $2, $3) WHERE (id = $4)",
|
||||
expectedStmt: "UPDATE projections.projects2 SET (change_date, sequence, state) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
domain.ProjectStateInactive,
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -149,7 +152,7 @@ func TestProjectProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.projects2 SET (change_date, sequence, name, project_role_assertion, project_role_check, has_project_check, private_labeling_setting) = ($1, $2, $3, $4, $5, $6, $7) WHERE (id = $8)",
|
||||
expectedStmt: "UPDATE projections.projects2 SET (change_date, sequence, name, project_role_assertion, project_role_check, has_project_check, private_labeling_setting) = ($1, $2, $3, $4, $5, $6, $7) WHERE (id = $8) AND (instance_id = $9)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@ -159,6 +162,7 @@ func TestProjectProjection_reduces(t *testing.T) {
|
||||
true,
|
||||
domain.PrivateLabelingSettingEnforceProjectResourceOwnerPolicy,
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -143,6 +143,7 @@ func (p *secretGeneratorProjection) reduceSecretGeneratorChanged(event eventstor
|
||||
[]handler.Condition{
|
||||
handler.NewCond(SecretGeneratorColumnAggregateID, e.Aggregate().ID),
|
||||
handler.NewCond(SecretGeneratorColumnGeneratorType, e.GeneratorType),
|
||||
handler.NewCond(SecretGeneratorColumnInstanceID, e.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
@ -157,6 +158,7 @@ func (p *secretGeneratorProjection) reduceSecretGeneratorRemoved(event eventstor
|
||||
[]handler.Condition{
|
||||
handler.NewCond(SecretGeneratorColumnAggregateID, e.Aggregate().ID),
|
||||
handler.NewCond(SecretGeneratorColumnGeneratorType, e.GeneratorType),
|
||||
handler.NewCond(SecretGeneratorColumnInstanceID, e.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
|
@ -39,10 +39,11 @@ func TestSecretGeneratorProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.secret_generators2 WHERE (aggregate_id = $1) AND (generator_type = $2)",
|
||||
expectedStmt: "DELETE FROM projections.secret_generators2 WHERE (aggregate_id = $1) AND (generator_type = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
domain.SecretGeneratorTypeInitCode,
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -66,7 +67,7 @@ func TestSecretGeneratorProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.secret_generators2 SET (change_date, sequence, length, expiry, include_lower_letters, include_upper_letters, include_digits, include_symbols) = ($1, $2, $3, $4, $5, $6, $7, $8) WHERE (aggregate_id = $9) AND (generator_type = $10)",
|
||||
expectedStmt: "UPDATE projections.secret_generators2 SET (change_date, sequence, length, expiry, include_lower_letters, include_upper_letters, include_digits, include_symbols) = ($1, $2, $3, $4, $5, $6, $7, $8) WHERE (aggregate_id = $9) AND (generator_type = $10) AND (instance_id = $11)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@ -78,6 +79,7 @@ func TestSecretGeneratorProjection_reduces(t *testing.T) {
|
||||
true,
|
||||
"agg-id",
|
||||
domain.SecretGeneratorTypeInitCode,
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -23,7 +23,7 @@ func TestSMSProjection_reduces(t *testing.T) {
|
||||
want wantReduce
|
||||
}{
|
||||
{
|
||||
name: "instance.reduceSMSTwilioAdded",
|
||||
name: "instance reduceSMSTwilioAdded",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.SMSConfigTwilioAddedEventType),
|
||||
@ -81,7 +81,7 @@ func TestSMSProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceSMSConfigTwilioChanged",
|
||||
name: "instance reduceSMSConfigTwilioChanged",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.SMSConfigTwilioChangedEventType),
|
||||
@ -123,7 +123,7 @@ func TestSMSProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceSMSConfigTwilioTokenChanged",
|
||||
name: "instance reduceSMSConfigTwilioTokenChanged",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.SMSConfigTwilioTokenChangedEventType),
|
||||
@ -173,7 +173,7 @@ func TestSMSProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceSMSConfigActivated",
|
||||
name: "instance reduceSMSConfigActivated",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.SMSConfigActivatedEventType),
|
||||
@ -205,7 +205,7 @@ func TestSMSProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceSMSConfigDeactivated",
|
||||
name: "instance reduceSMSConfigDeactivated",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.SMSConfigDeactivatedEventType),
|
||||
@ -237,7 +237,7 @@ func TestSMSProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceSMSConfigRemoved",
|
||||
name: "instance reduceSMSConfigRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.SMSConfigRemovedEventType),
|
||||
@ -266,7 +266,7 @@ func TestSMSProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceInstanceRemoved",
|
||||
name: "instance reduceInstanceRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.InstanceRemovedEventType),
|
||||
|
@ -146,7 +146,7 @@ func TestSMTPConfigProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceInstanceRemoved",
|
||||
name: "instance reduceInstanceRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.InstanceRemovedEventType),
|
||||
|
@ -184,6 +184,7 @@ func (p *userAuthMethodProjection) reduceActivateEvent(event eventstore.Event) (
|
||||
handler.NewCond(UserAuthMethodTypeCol, methodType),
|
||||
handler.NewCond(UserAuthMethodResourceOwnerCol, event.Aggregate().ResourceOwner),
|
||||
handler.NewCond(UserAuthMethodTokenIDCol, tokenID),
|
||||
handler.NewCond(UserAuthMethodInstanceIDCol, event.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
@ -208,6 +209,7 @@ func (p *userAuthMethodProjection) reduceRemoveAuthMethod(event eventstore.Event
|
||||
handler.NewCond(UserAuthMethodUserIDCol, event.Aggregate().ID),
|
||||
handler.NewCond(UserAuthMethodTypeCol, methodType),
|
||||
handler.NewCond(UserAuthMethodResourceOwnerCol, event.Aggregate().ResourceOwner),
|
||||
handler.NewCond(UserAuthMethodInstanceIDCol, event.Aggregate().InstanceID),
|
||||
}
|
||||
if tokenID != "" {
|
||||
conditions = append(conditions, handler.NewCond(UserAuthMethodTokenIDCol, tokenID))
|
||||
|
@ -152,7 +152,7 @@ func TestUserAuthMethodProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.user_auth_methods3 SET (change_date, sequence, name, state) = ($1, $2, $3, $4) WHERE (user_id = $5) AND (method_type = $6) AND (resource_owner = $7) AND (token_id = $8)",
|
||||
expectedStmt: "UPDATE projections.user_auth_methods3 SET (change_date, sequence, name, state) = ($1, $2, $3, $4) WHERE (user_id = $5) AND (method_type = $6) AND (resource_owner = $7) AND (token_id = $8) AND (instance_id = $9)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@ -162,6 +162,7 @@ func TestUserAuthMethodProjection_reduces(t *testing.T) {
|
||||
domain.UserAuthMethodTypePasswordless,
|
||||
"ro-id",
|
||||
"token-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -188,7 +189,7 @@ func TestUserAuthMethodProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.user_auth_methods3 SET (change_date, sequence, name, state) = ($1, $2, $3, $4) WHERE (user_id = $5) AND (method_type = $6) AND (resource_owner = $7) AND (token_id = $8)",
|
||||
expectedStmt: "UPDATE projections.user_auth_methods3 SET (change_date, sequence, name, state) = ($1, $2, $3, $4) WHERE (user_id = $5) AND (method_type = $6) AND (resource_owner = $7) AND (token_id = $8) AND (instance_id = $9)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@ -198,6 +199,7 @@ func TestUserAuthMethodProjection_reduces(t *testing.T) {
|
||||
domain.UserAuthMethodTypeU2F,
|
||||
"ro-id",
|
||||
"token-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -222,7 +224,7 @@ func TestUserAuthMethodProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.user_auth_methods3 SET (change_date, sequence, name, state) = ($1, $2, $3, $4) WHERE (user_id = $5) AND (method_type = $6) AND (resource_owner = $7) AND (token_id = $8)",
|
||||
expectedStmt: "UPDATE projections.user_auth_methods3 SET (change_date, sequence, name, state) = ($1, $2, $3, $4) WHERE (user_id = $5) AND (method_type = $6) AND (resource_owner = $7) AND (token_id = $8) AND (instance_id = $9)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
uint64(15),
|
||||
@ -232,6 +234,7 @@ func TestUserAuthMethodProjection_reduces(t *testing.T) {
|
||||
domain.UserAuthMethodTypeOTP,
|
||||
"ro-id",
|
||||
"",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -239,7 +242,7 @@ func TestUserAuthMethodProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceInstanceRemoved",
|
||||
name: "instance reduceInstanceRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.InstanceRemovedEventType),
|
||||
|
@ -188,6 +188,7 @@ func (p *userGrantProjection) reduceChanged(event eventstore.Event) (*handler.St
|
||||
},
|
||||
[]handler.Condition{
|
||||
handler.NewCond(UserGrantID, event.Aggregate().ID),
|
||||
handler.NewCond(UserGrantInstanceID, event.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
@ -204,6 +205,7 @@ func (p *userGrantProjection) reduceRemoved(event eventstore.Event) (*handler.St
|
||||
event,
|
||||
[]handler.Condition{
|
||||
handler.NewCond(UserGrantID, event.Aggregate().ID),
|
||||
handler.NewCond(UserGrantInstanceID, event.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
@ -222,6 +224,7 @@ func (p *userGrantProjection) reduceDeactivated(event eventstore.Event) (*handle
|
||||
},
|
||||
[]handler.Condition{
|
||||
handler.NewCond(UserGrantID, event.Aggregate().ID),
|
||||
handler.NewCond(UserGrantInstanceID, event.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
@ -240,6 +243,7 @@ func (p *userGrantProjection) reduceReactivated(event eventstore.Event) (*handle
|
||||
},
|
||||
[]handler.Condition{
|
||||
handler.NewCond(UserGrantID, event.Aggregate().ID),
|
||||
handler.NewCond(UserGrantInstanceID, event.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
@ -253,6 +257,7 @@ func (p *userGrantProjection) reduceUserRemoved(event eventstore.Event) (*handle
|
||||
event,
|
||||
[]handler.Condition{
|
||||
handler.NewCond(UserGrantUserID, event.Aggregate().ID),
|
||||
handler.NewCond(UserGrantInstanceID, event.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
@ -266,6 +271,7 @@ func (p *userGrantProjection) reduceProjectRemoved(event eventstore.Event) (*han
|
||||
event,
|
||||
[]handler.Condition{
|
||||
handler.NewCond(UserGrantProjectID, event.Aggregate().ID),
|
||||
handler.NewCond(UserGrantInstanceID, event.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
@ -280,6 +286,7 @@ func (p *userGrantProjection) reduceProjectGrantRemoved(event eventstore.Event)
|
||||
event,
|
||||
[]handler.Condition{
|
||||
handler.NewCond(UserGrantGrantID, e.GrantID),
|
||||
handler.NewCond(UserGrantInstanceID, event.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
@ -297,6 +304,7 @@ func (p *userGrantProjection) reduceRoleRemoved(event eventstore.Event) (*handle
|
||||
},
|
||||
[]handler.Condition{
|
||||
handler.NewCond(UserGrantProjectID, e.Aggregate().ID),
|
||||
handler.NewCond(UserGrantInstanceID, event.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
@ -322,6 +330,7 @@ func (p *userGrantProjection) reduceProjectGrantChanged(event eventstore.Event)
|
||||
},
|
||||
[]handler.Condition{
|
||||
handler.NewCond(UserGrantGrantID, grantID),
|
||||
handler.NewCond(UserGrantInstanceID, event.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
|
@ -84,12 +84,13 @@ func TestUserGrantProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.user_grants2 SET (change_date, roles, sequence) = ($1, $2, $3) WHERE (id = $4)",
|
||||
expectedStmt: "UPDATE projections.user_grants2 SET (change_date, roles, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
database.StringArray{"role"},
|
||||
uint64(15),
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -115,12 +116,13 @@ func TestUserGrantProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.user_grants2 SET (change_date, roles, sequence) = ($1, $2, $3) WHERE (id = $4)",
|
||||
expectedStmt: "UPDATE projections.user_grants2 SET (change_date, roles, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
database.StringArray{"role"},
|
||||
uint64(15),
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -144,9 +146,10 @@ func TestUserGrantProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.user_grants2 WHERE (id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.user_grants2 WHERE (id = $1) AND (instance_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -154,7 +157,7 @@ func TestUserGrantProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceInstanceRemoved",
|
||||
name: "instance reduceInstanceRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.InstanceRemovedEventType),
|
||||
@ -196,9 +199,10 @@ func TestUserGrantProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.user_grants2 WHERE (id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.user_grants2 WHERE (id = $1) AND (instance_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -222,12 +226,13 @@ func TestUserGrantProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.user_grants2 SET (change_date, state, sequence) = ($1, $2, $3) WHERE (id = $4)",
|
||||
expectedStmt: "UPDATE projections.user_grants2 SET (change_date, state, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
domain.UserGrantStateInactive,
|
||||
uint64(15),
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -251,12 +256,13 @@ func TestUserGrantProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.user_grants2 SET (change_date, state, sequence) = ($1, $2, $3) WHERE (id = $4)",
|
||||
expectedStmt: "UPDATE projections.user_grants2 SET (change_date, state, sequence) = ($1, $2, $3) WHERE (id = $4) AND (instance_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
domain.UserGrantStateActive,
|
||||
uint64(15),
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -280,9 +286,10 @@ func TestUserGrantProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.user_grants2 WHERE (user_id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.user_grants2 WHERE (user_id = $1) AND (instance_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -306,9 +313,10 @@ func TestUserGrantProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.user_grants2 WHERE (project_id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.user_grants2 WHERE (project_id = $1) AND (instance_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
anyArg{},
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -332,9 +340,10 @@ func TestUserGrantProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.user_grants2 WHERE (grant_id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.user_grants2 WHERE (grant_id = $1) AND (instance_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"grantID",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -358,10 +367,11 @@ func TestUserGrantProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.user_grants2 SET roles = array_remove(roles, $1) WHERE (project_id = $2)",
|
||||
expectedStmt: "UPDATE projections.user_grants2 SET roles = array_remove(roles, $1) WHERE (project_id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
"key",
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -385,10 +395,11 @@ func TestUserGrantProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE projections.user_grants2 SET (roles) = (SELECT ARRAY( SELECT UNNEST(roles) INTERSECT SELECT UNNEST ($1::TEXT[]))) WHERE (grant_id = $2)",
|
||||
expectedStmt: "UPDATE projections.user_grants2 SET (roles) = (SELECT ARRAY( SELECT UNNEST(roles) INTERSECT SELECT UNNEST ($1::TEXT[]))) WHERE (grant_id = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
database.StringArray{"key"},
|
||||
"grantID",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -122,6 +122,7 @@ func (p *userMetadataProjection) reduceMetadataRemoved(event eventstore.Event) (
|
||||
[]handler.Condition{
|
||||
handler.NewCond(UserMetadataColumnUserID, e.Aggregate().ID),
|
||||
handler.NewCond(UserMetadataColumnKey, e.Key),
|
||||
handler.NewCond(UserAuthMethodInstanceIDCol, e.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
@ -138,6 +139,7 @@ func (p *userMetadataProjection) reduceMetadataRemovedAll(event eventstore.Event
|
||||
event,
|
||||
[]handler.Condition{
|
||||
handler.NewCond(UserMetadataColumnUserID, event.Aggregate().ID),
|
||||
handler.NewCond(UserAuthMethodInstanceIDCol, event.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
|
@ -76,10 +76,11 @@ func TestUserMetadataProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.user_metadata3 WHERE (user_id = $1) AND (key = $2)",
|
||||
expectedStmt: "DELETE FROM projections.user_metadata3 WHERE (user_id = $1) AND (key = $2) AND (instance_id = $3)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"key",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -103,9 +104,10 @@ func TestUserMetadataProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.user_metadata3 WHERE (user_id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.user_metadata3 WHERE (user_id = $1) AND (instance_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -129,9 +131,10 @@ func TestUserMetadataProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.user_metadata3 WHERE (user_id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.user_metadata3 WHERE (user_id = $1) AND (instance_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -139,7 +142,7 @@ func TestUserMetadataProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceInstanceRemoved",
|
||||
name: "instance reduceInstanceRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.InstanceRemovedEventType),
|
||||
|
@ -117,6 +117,7 @@ func (p *personalAccessTokenProjection) reducePersonalAccessTokenRemoved(event e
|
||||
e,
|
||||
[]handler.Condition{
|
||||
handler.NewCond(PersonalAccessTokenColumnID, e.TokenID),
|
||||
handler.NewCond(PersonalAccessTokenColumnInstanceID, e.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
@ -130,6 +131,7 @@ func (p *personalAccessTokenProjection) reduceUserRemoved(event eventstore.Event
|
||||
e,
|
||||
[]handler.Condition{
|
||||
handler.NewCond(PersonalAccessTokenColumnUserID, e.Aggregate().ID),
|
||||
handler.NewCond(PersonalAccessTokenColumnInstanceID, e.Aggregate().InstanceID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
|
@ -74,9 +74,10 @@ func TestPersonalAccessTokenProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.personal_access_tokens2 WHERE (id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.personal_access_tokens2 WHERE (id = $1) AND (instance_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"tokenID",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -100,9 +101,10 @@ func TestPersonalAccessTokenProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.personal_access_tokens2 WHERE (user_id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.personal_access_tokens2 WHERE (user_id = $1) AND (instance_id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -110,7 +112,7 @@ func TestPersonalAccessTokenProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceInstanceRemoved",
|
||||
name: "instance reduceInstanceRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.InstanceRemovedEventType),
|
||||
|
@ -1618,7 +1618,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceInstanceRemoved",
|
||||
name: "instance reduceInstanceRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.InstanceRemovedEventType),
|
||||
|
Loading…
x
Reference in New Issue
Block a user