mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 04:57:33 +00:00
feat(eventstore): increase parallel write capabilities (#5940)
This implementation increases parallel write capabilities of the eventstore. Please have a look at the technical advisories: [05](https://zitadel.com/docs/support/advisory/a10005) and [06](https://zitadel.com/docs/support/advisory/a10006). The implementation of eventstore.push is rewritten and stored events are migrated to a new table `eventstore.events2`. If you are using cockroach: make sure that the database user of ZITADEL has `VIEWACTIVITY` grant. This is used to query events.
This commit is contained in:
@@ -7,8 +7,7 @@ import (
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
"github.com/zitadel/zitadel/internal/errors"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/eventstore/handler"
|
||||
"github.com/zitadel/zitadel/internal/eventstore/repository"
|
||||
"github.com/zitadel/zitadel/internal/eventstore/handler/v2"
|
||||
"github.com/zitadel/zitadel/internal/repository/instance"
|
||||
"github.com/zitadel/zitadel/internal/repository/org"
|
||||
)
|
||||
@@ -26,23 +25,23 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
{
|
||||
name: "instance reduceIDPAdded",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.IDPConfigAddedEventType),
|
||||
instance.AggregateType,
|
||||
[]byte(`{
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
instance.IDPConfigAddedEventType,
|
||||
instance.AggregateType,
|
||||
[]byte(`{
|
||||
"idpConfigId": "idp-config-id",
|
||||
"name": "custom-zitadel-instance",
|
||||
"idpType": 0,
|
||||
"stylingType": 0,
|
||||
"autoRegister": true
|
||||
}`),
|
||||
), instance.IDPConfigAddedEventMapper),
|
||||
), instance.IDPConfigAddedEventMapper),
|
||||
},
|
||||
reduce: (&idpProjection{}).reduceIDPAdded,
|
||||
want: wantReduce{
|
||||
aggregateType: eventstore.AggregateType("instance"),
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
aggregateType: eventstore.AggregateType("instance"),
|
||||
sequence: 15,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
@@ -68,22 +67,22 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
{
|
||||
name: "instance reduceIDPChanged",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.IDPConfigChangedEventType),
|
||||
instance.AggregateType,
|
||||
[]byte(`{
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
instance.IDPConfigChangedEventType,
|
||||
instance.AggregateType,
|
||||
[]byte(`{
|
||||
"idpConfigId": "idp-config-id",
|
||||
"name": "custom-zitadel-instance",
|
||||
"stylingType": 1,
|
||||
"autoRegister": true
|
||||
}`),
|
||||
), instance.IDPConfigChangedEventMapper),
|
||||
), instance.IDPConfigChangedEventMapper),
|
||||
},
|
||||
reduce: (&idpProjection{}).reduceIDPChanged,
|
||||
want: wantReduce{
|
||||
aggregateType: eventstore.AggregateType("instance"),
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
aggregateType: eventstore.AggregateType("instance"),
|
||||
sequence: 15,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
@@ -105,19 +104,19 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
{
|
||||
name: "instance reduceIDPDeactivated",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.IDPConfigDeactivatedEventType),
|
||||
instance.AggregateType,
|
||||
[]byte(`{
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
instance.IDPConfigDeactivatedEventType,
|
||||
instance.AggregateType,
|
||||
[]byte(`{
|
||||
"idpConfigId": "idp-config-id"
|
||||
}`),
|
||||
), instance.IDPConfigDeactivatedEventMapper),
|
||||
), instance.IDPConfigDeactivatedEventMapper),
|
||||
},
|
||||
reduce: (&idpProjection{}).reduceIDPDeactivated,
|
||||
want: wantReduce{
|
||||
aggregateType: eventstore.AggregateType("instance"),
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
aggregateType: eventstore.AggregateType("instance"),
|
||||
sequence: 15,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
@@ -137,19 +136,19 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
{
|
||||
name: "instance reduceIDPReactivated",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.IDPConfigReactivatedEventType),
|
||||
instance.AggregateType,
|
||||
[]byte(`{
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
instance.IDPConfigReactivatedEventType,
|
||||
instance.AggregateType,
|
||||
[]byte(`{
|
||||
"idpConfigId": "idp-config-id"
|
||||
}`),
|
||||
), instance.IDPConfigReactivatedEventMapper),
|
||||
), instance.IDPConfigReactivatedEventMapper),
|
||||
},
|
||||
reduce: (&idpProjection{}).reduceIDPReactivated,
|
||||
want: wantReduce{
|
||||
aggregateType: eventstore.AggregateType("instance"),
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
aggregateType: eventstore.AggregateType("instance"),
|
||||
sequence: 15,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
@@ -169,19 +168,19 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
{
|
||||
name: "instance reduceIDPRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.IDPConfigRemovedEventType),
|
||||
instance.AggregateType,
|
||||
[]byte(`{
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
instance.IDPConfigRemovedEventType,
|
||||
instance.AggregateType,
|
||||
[]byte(`{
|
||||
"idpConfigId": "idp-config-id"
|
||||
}`),
|
||||
), instance.IDPConfigRemovedEventMapper),
|
||||
), instance.IDPConfigRemovedEventMapper),
|
||||
},
|
||||
reduce: (&idpProjection{}).reduceIDPRemoved,
|
||||
want: wantReduce{
|
||||
aggregateType: eventstore.AggregateType("instance"),
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
aggregateType: eventstore.AggregateType("instance"),
|
||||
sequence: 15,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
@@ -198,17 +197,17 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
{
|
||||
name: "instance reduceInstanceRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.InstanceRemovedEventType),
|
||||
instance.AggregateType,
|
||||
nil,
|
||||
), instance.InstanceRemovedEventMapper),
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
instance.InstanceRemovedEventType,
|
||||
instance.AggregateType,
|
||||
nil,
|
||||
), instance.InstanceRemovedEventMapper),
|
||||
},
|
||||
reduce: reduceInstanceRemovedHelper(IDPInstanceIDCol),
|
||||
want: wantReduce{
|
||||
aggregateType: eventstore.AggregateType("instance"),
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
aggregateType: eventstore.AggregateType("instance"),
|
||||
sequence: 15,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
@@ -224,10 +223,11 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
{
|
||||
name: "instance reduceOIDCConfigAdded",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.IDPOIDCConfigAddedEventType),
|
||||
instance.AggregateType,
|
||||
[]byte(`{
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
instance.IDPOIDCConfigAddedEventType,
|
||||
instance.AggregateType,
|
||||
[]byte(`{
|
||||
"idpConfigId": "idp-config-id",
|
||||
"clientId": "client-id",
|
||||
"clientSecret": {
|
||||
@@ -242,13 +242,12 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
"idpDisplayNameMapping": 0,
|
||||
"usernameMapping": 1
|
||||
}`),
|
||||
), instance.IDPOIDCConfigAddedEventMapper),
|
||||
), instance.IDPOIDCConfigAddedEventMapper),
|
||||
},
|
||||
reduce: (&idpProjection{}).reduceOIDCConfigAdded,
|
||||
want: wantReduce{
|
||||
aggregateType: eventstore.AggregateType("instance"),
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
aggregateType: eventstore.AggregateType("instance"),
|
||||
sequence: 15,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
@@ -269,7 +268,7 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
"client-id",
|
||||
anyArg{},
|
||||
"issuer",
|
||||
database.StringArray{"profile"},
|
||||
database.TextArray[string]{"profile"},
|
||||
domain.OIDCMappingFieldUnspecified,
|
||||
domain.OIDCMappingFieldPreferredLoginName,
|
||||
"https://api.zitadel.ch/authorize",
|
||||
@@ -283,10 +282,11 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
{
|
||||
name: "instance reduceOIDCConfigChanged",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.IDPOIDCConfigChangedEventType),
|
||||
instance.AggregateType,
|
||||
[]byte(`{
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
instance.IDPOIDCConfigChangedEventType,
|
||||
instance.AggregateType,
|
||||
[]byte(`{
|
||||
"idpConfigId": "idp-config-id",
|
||||
"clientId": "client-id",
|
||||
"clientSecret": {
|
||||
@@ -301,13 +301,12 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
"idpDisplayNameMapping": 0,
|
||||
"usernameMapping": 1
|
||||
}`),
|
||||
), instance.IDPOIDCConfigChangedEventMapper),
|
||||
), instance.IDPOIDCConfigChangedEventMapper),
|
||||
},
|
||||
reduce: (&idpProjection{}).reduceOIDCConfigChanged,
|
||||
want: wantReduce{
|
||||
aggregateType: eventstore.AggregateType("instance"),
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
aggregateType: eventstore.AggregateType("instance"),
|
||||
sequence: 15,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
@@ -327,7 +326,7 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
"issuer",
|
||||
"https://api.zitadel.ch/authorize",
|
||||
"https://api.zitadel.ch/token",
|
||||
database.StringArray{"profile"},
|
||||
database.TextArray[string]{"profile"},
|
||||
domain.OIDCMappingFieldUnspecified,
|
||||
domain.OIDCMappingFieldPreferredLoginName,
|
||||
"idp-config-id",
|
||||
@@ -341,17 +340,17 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
{
|
||||
name: "instance reduceOIDCConfigChanged: no op",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.IDPOIDCConfigChangedEventType),
|
||||
instance.AggregateType,
|
||||
[]byte("{}"),
|
||||
), instance.IDPOIDCConfigChangedEventMapper),
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
instance.IDPOIDCConfigChangedEventType,
|
||||
instance.AggregateType,
|
||||
[]byte("{}"),
|
||||
), instance.IDPOIDCConfigChangedEventMapper),
|
||||
},
|
||||
reduce: (&idpProjection{}).reduceOIDCConfigChanged,
|
||||
want: wantReduce{
|
||||
aggregateType: eventstore.AggregateType("instance"),
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
aggregateType: eventstore.AggregateType("instance"),
|
||||
sequence: 15,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{},
|
||||
},
|
||||
@@ -360,23 +359,23 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
{
|
||||
name: "instance reduceJWTConfigAdded",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.IDPJWTConfigAddedEventType),
|
||||
instance.AggregateType,
|
||||
[]byte(`{
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
instance.IDPJWTConfigAddedEventType,
|
||||
instance.AggregateType,
|
||||
[]byte(`{
|
||||
"idpConfigId": "idp-config-id",
|
||||
"jwtEndpoint": "https://api.zitadel.ch/jwt",
|
||||
"issuer": "issuer",
|
||||
"keysEndpoint": "https://api.zitadel.ch/keys",
|
||||
"headerName": "hodor"
|
||||
}`),
|
||||
), instance.IDPJWTConfigAddedEventMapper),
|
||||
), instance.IDPJWTConfigAddedEventMapper),
|
||||
},
|
||||
reduce: (&idpProjection{}).reduceJWTConfigAdded,
|
||||
want: wantReduce{
|
||||
aggregateType: eventstore.AggregateType("instance"),
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
aggregateType: eventstore.AggregateType("instance"),
|
||||
sequence: 15,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
@@ -407,23 +406,23 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
{
|
||||
name: "instance reduceJWTConfigChanged",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.IDPJWTConfigChangedEventType),
|
||||
instance.AggregateType,
|
||||
[]byte(`{
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
instance.IDPJWTConfigChangedEventType,
|
||||
instance.AggregateType,
|
||||
[]byte(`{
|
||||
"idpConfigId": "idp-config-id",
|
||||
"jwtEndpoint": "https://api.zitadel.ch/jwt",
|
||||
"issuer": "issuer",
|
||||
"keysEndpoint": "https://api.zitadel.ch/keys",
|
||||
"headerName": "hodor"
|
||||
}`),
|
||||
), instance.IDPJWTConfigChangedEventMapper),
|
||||
), instance.IDPJWTConfigChangedEventMapper),
|
||||
},
|
||||
reduce: (&idpProjection{}).reduceJWTConfigChanged,
|
||||
want: wantReduce{
|
||||
aggregateType: eventstore.AggregateType("instance"),
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
aggregateType: eventstore.AggregateType("instance"),
|
||||
sequence: 15,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
@@ -453,17 +452,17 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
{
|
||||
name: "instance reduceJWTConfigChanged: no op",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.IDPJWTConfigChangedEventType),
|
||||
instance.AggregateType,
|
||||
[]byte(`{}`),
|
||||
), instance.IDPJWTConfigChangedEventMapper),
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
instance.IDPJWTConfigChangedEventType,
|
||||
instance.AggregateType,
|
||||
[]byte(`{}`),
|
||||
), instance.IDPJWTConfigChangedEventMapper),
|
||||
},
|
||||
reduce: (&idpProjection{}).reduceJWTConfigChanged,
|
||||
want: wantReduce{
|
||||
aggregateType: eventstore.AggregateType("instance"),
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
aggregateType: eventstore.AggregateType("instance"),
|
||||
sequence: 15,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{},
|
||||
},
|
||||
@@ -472,23 +471,23 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
{
|
||||
name: "org reduceIDPAdded",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.IDPConfigAddedEventType),
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
org.IDPConfigAddedEventType,
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
"idpConfigId": "idp-config-id",
|
||||
"name": "custom-zitadel-instance",
|
||||
"idpType": 0,
|
||||
"stylingType": 0,
|
||||
"autoRegister": true
|
||||
}`),
|
||||
), org.IDPConfigAddedEventMapper),
|
||||
), org.IDPConfigAddedEventMapper),
|
||||
},
|
||||
reduce: (&idpProjection{}).reduceIDPAdded,
|
||||
want: wantReduce{
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
@@ -514,22 +513,22 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
{
|
||||
name: "org reduceIDPChanged",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.IDPConfigChangedEventType),
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
org.IDPConfigChangedEventType,
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
"idpConfigId": "idp-config-id",
|
||||
"name": "custom-zitadel-instance",
|
||||
"stylingType": 1,
|
||||
"autoRegister": true
|
||||
}`),
|
||||
), org.IDPConfigChangedEventMapper),
|
||||
), org.IDPConfigChangedEventMapper),
|
||||
},
|
||||
reduce: (&idpProjection{}).reduceIDPChanged,
|
||||
want: wantReduce{
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
@@ -551,19 +550,19 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
{
|
||||
name: "org reduceIDPDeactivated",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.IDPConfigDeactivatedEventType),
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
org.IDPConfigDeactivatedEventType,
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
"idpConfigId": "idp-config-id"
|
||||
}`),
|
||||
), org.IDPConfigDeactivatedEventMapper),
|
||||
), org.IDPConfigDeactivatedEventMapper),
|
||||
},
|
||||
reduce: (&idpProjection{}).reduceIDPDeactivated,
|
||||
want: wantReduce{
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
@@ -583,19 +582,19 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
{
|
||||
name: "org reduceIDPReactivated",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.IDPConfigReactivatedEventType),
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
org.IDPConfigReactivatedEventType,
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
"idpConfigId": "idp-config-id"
|
||||
}`),
|
||||
), org.IDPConfigReactivatedEventMapper),
|
||||
), org.IDPConfigReactivatedEventMapper),
|
||||
},
|
||||
reduce: (&idpProjection{}).reduceIDPReactivated,
|
||||
want: wantReduce{
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
@@ -615,19 +614,19 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
{
|
||||
name: "org reduceIDPRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.IDPConfigRemovedEventType),
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
org.IDPConfigRemovedEventType,
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
"idpConfigId": "idp-config-id"
|
||||
}`),
|
||||
), org.IDPConfigRemovedEventMapper),
|
||||
), org.IDPConfigRemovedEventMapper),
|
||||
},
|
||||
reduce: (&idpProjection{}).reduceIDPRemoved,
|
||||
want: wantReduce{
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
@@ -644,10 +643,11 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
{
|
||||
name: "org reduceOIDCConfigAdded",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.IDPOIDCConfigAddedEventType),
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
org.IDPOIDCConfigAddedEventType,
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
"idpConfigId": "idp-config-id",
|
||||
"clientId": "client-id",
|
||||
"clientSecret": {
|
||||
@@ -662,13 +662,12 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
"idpDisplayNameMapping": 0,
|
||||
"usernameMapping": 1
|
||||
}`),
|
||||
), org.IDPOIDCConfigAddedEventMapper),
|
||||
), org.IDPOIDCConfigAddedEventMapper),
|
||||
},
|
||||
reduce: (&idpProjection{}).reduceOIDCConfigAdded,
|
||||
want: wantReduce{
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
@@ -689,7 +688,7 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
"client-id",
|
||||
anyArg{},
|
||||
"issuer",
|
||||
database.StringArray{"profile"},
|
||||
database.TextArray[string]{"profile"},
|
||||
domain.OIDCMappingFieldUnspecified,
|
||||
domain.OIDCMappingFieldPreferredLoginName,
|
||||
"https://api.zitadel.ch/authorize",
|
||||
@@ -703,10 +702,11 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
{
|
||||
name: "org reduceOIDCConfigChanged",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.IDPOIDCConfigChangedEventType),
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
org.IDPOIDCConfigChangedEventType,
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
"idpConfigId": "idp-config-id",
|
||||
"clientId": "client-id",
|
||||
"clientSecret": {
|
||||
@@ -721,13 +721,12 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
"idpDisplayNameMapping": 0,
|
||||
"usernameMapping": 1
|
||||
}`),
|
||||
), org.IDPOIDCConfigChangedEventMapper),
|
||||
), org.IDPOIDCConfigChangedEventMapper),
|
||||
},
|
||||
reduce: (&idpProjection{}).reduceOIDCConfigChanged,
|
||||
want: wantReduce{
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
@@ -747,7 +746,7 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
"issuer",
|
||||
"https://api.zitadel.ch/authorize",
|
||||
"https://api.zitadel.ch/token",
|
||||
database.StringArray{"profile"},
|
||||
database.TextArray[string]{"profile"},
|
||||
domain.OIDCMappingFieldUnspecified,
|
||||
domain.OIDCMappingFieldPreferredLoginName,
|
||||
"idp-config-id",
|
||||
@@ -761,17 +760,17 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
{
|
||||
name: "org reduceOIDCConfigChanged: no op",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.IDPOIDCConfigChangedEventType),
|
||||
org.AggregateType,
|
||||
[]byte("{}"),
|
||||
), org.IDPOIDCConfigChangedEventMapper),
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
org.IDPOIDCConfigChangedEventType,
|
||||
org.AggregateType,
|
||||
[]byte("{}"),
|
||||
), org.IDPOIDCConfigChangedEventMapper),
|
||||
},
|
||||
reduce: (&idpProjection{}).reduceOIDCConfigChanged,
|
||||
want: wantReduce{
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{},
|
||||
},
|
||||
@@ -780,23 +779,23 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
{
|
||||
name: "org reduceJWTConfigAdded",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.IDPJWTConfigAddedEventType),
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
org.IDPJWTConfigAddedEventType,
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
"idpConfigId": "idp-config-id",
|
||||
"jwtEndpoint": "https://api.zitadel.ch/jwt",
|
||||
"issuer": "issuer",
|
||||
"keysEndpoint": "https://api.zitadel.ch/keys",
|
||||
"headerName": "hodor"
|
||||
}`),
|
||||
), org.IDPJWTConfigAddedEventMapper),
|
||||
), org.IDPJWTConfigAddedEventMapper),
|
||||
},
|
||||
reduce: (&idpProjection{}).reduceJWTConfigAdded,
|
||||
want: wantReduce{
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
@@ -827,23 +826,23 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
{
|
||||
name: "org reduceJWTConfigChanged",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.IDPJWTConfigChangedEventType),
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
org.IDPJWTConfigChangedEventType,
|
||||
org.AggregateType,
|
||||
[]byte(`{
|
||||
"idpConfigId": "idp-config-id",
|
||||
"jwtEndpoint": "https://api.zitadel.ch/jwt",
|
||||
"issuer": "issuer",
|
||||
"keysEndpoint": "https://api.zitadel.ch/keys",
|
||||
"headerName": "hodor"
|
||||
}`),
|
||||
), org.IDPJWTConfigChangedEventMapper),
|
||||
), org.IDPJWTConfigChangedEventMapper),
|
||||
},
|
||||
reduce: (&idpProjection{}).reduceJWTConfigChanged,
|
||||
want: wantReduce{
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
@@ -873,17 +872,17 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
{
|
||||
name: "org reduceJWTConfigChanged: no op",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.IDPJWTConfigChangedEventType),
|
||||
org.AggregateType,
|
||||
[]byte(`{}`),
|
||||
), org.IDPJWTConfigChangedEventMapper),
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
org.IDPJWTConfigChangedEventType,
|
||||
org.AggregateType,
|
||||
[]byte(`{}`),
|
||||
), org.IDPJWTConfigChangedEventMapper),
|
||||
},
|
||||
reduce: (&idpProjection{}).reduceJWTConfigChanged,
|
||||
want: wantReduce{
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{},
|
||||
},
|
||||
@@ -893,16 +892,16 @@ func TestIDPProjection_reduces(t *testing.T) {
|
||||
name: "org.reduceOwnerRemoved",
|
||||
reduce: (&idpProjection{}).reduceOwnerRemoved,
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.OrgRemovedEventType),
|
||||
org.AggregateType,
|
||||
nil,
|
||||
), org.OrgRemovedEventMapper),
|
||||
event: getEvent(
|
||||
testEvent(
|
||||
org.OrgRemovedEventType,
|
||||
org.AggregateType,
|
||||
nil,
|
||||
), org.OrgRemovedEventMapper),
|
||||
},
|
||||
want: wantReduce{
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
aggregateType: eventstore.AggregateType("org"),
|
||||
sequence: 15,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
|
Reference in New Issue
Block a user