mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 21:07:31 +00:00
fix: state on user projection (#3109)
* fix: state on user projection * fix: state on user projection * don't change user state on HumanEmailVerifiedEvent
This commit is contained in:
@@ -56,7 +56,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
anyArg{},
|
||||
anyArg{},
|
||||
"ro-id",
|
||||
domain.UserStateInitial,
|
||||
domain.UserStateActive,
|
||||
uint64(15),
|
||||
"user-name",
|
||||
domain.UserTypeHuman,
|
||||
@@ -114,7 +114,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
anyArg{},
|
||||
anyArg{},
|
||||
"ro-id",
|
||||
domain.UserStateInitial,
|
||||
domain.UserStateActive,
|
||||
uint64(15),
|
||||
"user-name",
|
||||
domain.UserTypeHuman,
|
||||
@@ -167,7 +167,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
anyArg{},
|
||||
anyArg{},
|
||||
"ro-id",
|
||||
domain.UserStateInitial,
|
||||
domain.UserStateActive,
|
||||
uint64(15),
|
||||
"user-name",
|
||||
domain.UserTypeHuman,
|
||||
@@ -225,7 +225,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
anyArg{},
|
||||
anyArg{},
|
||||
"ro-id",
|
||||
domain.UserStateInitial,
|
||||
domain.UserStateActive,
|
||||
uint64(15),
|
||||
"user-name",
|
||||
domain.UserTypeHuman,
|
||||
@@ -283,7 +283,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
anyArg{},
|
||||
anyArg{},
|
||||
"ro-id",
|
||||
domain.UserStateInitial,
|
||||
domain.UserStateActive,
|
||||
uint64(15),
|
||||
"user-name",
|
||||
domain.UserTypeHuman,
|
||||
@@ -336,7 +336,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
anyArg{},
|
||||
anyArg{},
|
||||
"ro-id",
|
||||
domain.UserStateInitial,
|
||||
domain.UserStateActive,
|
||||
uint64(15),
|
||||
"user-name",
|
||||
domain.UserTypeHuman,
|
||||
@@ -360,6 +360,118 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "reduceHumanInitCodeAdded",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(user.HumanInitialCodeAddedType),
|
||||
user.AggregateType,
|
||||
[]byte(`{}`),
|
||||
), user.HumanInitialCodeAddedEventMapper),
|
||||
},
|
||||
reduce: (&UserProjection{}).reduceHumanInitCodeAdded,
|
||||
want: wantReduce{
|
||||
aggregateType: user.AggregateType,
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
projection: UserTable,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE zitadel.projections.users SET (state) = ($1) WHERE (id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
domain.UserStateInitial,
|
||||
"agg-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "reduceUserV1InitCodeAdded",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(user.UserV1InitialCodeAddedType),
|
||||
user.AggregateType,
|
||||
[]byte(`{}`),
|
||||
), user.HumanInitialCodeAddedEventMapper),
|
||||
},
|
||||
reduce: (&UserProjection{}).reduceHumanInitCodeAdded,
|
||||
want: wantReduce{
|
||||
aggregateType: user.AggregateType,
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
projection: UserTable,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE zitadel.projections.users SET (state) = ($1) WHERE (id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
domain.UserStateInitial,
|
||||
"agg-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "reduceHumanInitCodeSucceeded",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(user.HumanInitializedCheckSucceededType),
|
||||
user.AggregateType,
|
||||
[]byte(`{}`),
|
||||
), user.HumanInitializedCheckSucceededEventMapper),
|
||||
},
|
||||
reduce: (&UserProjection{}).reduceHumanInitCodeSucceeded,
|
||||
want: wantReduce{
|
||||
aggregateType: user.AggregateType,
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
projection: UserTable,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE zitadel.projections.users SET (state) = ($1) WHERE (id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
domain.UserStateActive,
|
||||
"agg-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "reduceUserV1InitCodeAdded",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(user.UserV1InitializedCheckSucceededType),
|
||||
user.AggregateType,
|
||||
[]byte(`{}`),
|
||||
), user.HumanInitializedCheckSucceededEventMapper),
|
||||
},
|
||||
reduce: (&UserProjection{}).reduceHumanInitCodeSucceeded,
|
||||
want: wantReduce{
|
||||
aggregateType: user.AggregateType,
|
||||
sequence: 15,
|
||||
previousSequence: 10,
|
||||
projection: UserTable,
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPDATE zitadel.projections.users SET (state) = ($1) WHERE (id = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
domain.UserStateActive,
|
||||
"agg-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "reduceUserLocked",
|
||||
args: args{
|
||||
@@ -1110,7 +1222,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
anyArg{},
|
||||
anyArg{},
|
||||
"ro-id",
|
||||
domain.UserStateInitial,
|
||||
domain.UserStateActive,
|
||||
uint64(15),
|
||||
"username",
|
||||
domain.UserTypeMachine,
|
||||
@@ -1156,7 +1268,7 @@ func TestUserProjection_reduces(t *testing.T) {
|
||||
anyArg{},
|
||||
anyArg{},
|
||||
"ro-id",
|
||||
domain.UserStateInitial,
|
||||
domain.UserStateActive,
|
||||
uint64(15),
|
||||
"username",
|
||||
domain.UserTypeMachine,
|
||||
|
Reference in New Issue
Block a user