mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 10:49:25 +00:00
fix: change to repository event types and removed unused code (#3386)
* fix: change to repository event types and removed unused code * some fixes * remove unused code
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
"github.com/caos/zitadel/internal/crypto"
|
||||
es_models "github.com/caos/zitadel/internal/eventstore/v1/models"
|
||||
"github.com/caos/zitadel/internal/repository/user"
|
||||
es_model "github.com/caos/zitadel/internal/user/repository/eventsourcing/model"
|
||||
)
|
||||
|
||||
@@ -29,7 +30,7 @@ func TestAppendEvent(t *testing.T) {
|
||||
{
|
||||
name: "append user password check succeeded event",
|
||||
args: args{
|
||||
event: &es_models.Event{CreationDate: now(), Type: es_model.UserPasswordCheckSucceeded},
|
||||
event: &es_models.Event{CreationDate: now(), Type: es_models.EventType(user.UserV1PasswordCheckSucceededType)},
|
||||
userView: &UserSessionView{},
|
||||
},
|
||||
result: &UserSessionView{ChangeDate: now(), PasswordVerification: now()},
|
||||
@@ -37,7 +38,7 @@ func TestAppendEvent(t *testing.T) {
|
||||
{
|
||||
name: "append human password check succeeded event",
|
||||
args: args{
|
||||
event: &es_models.Event{CreationDate: now(), Type: es_model.HumanPasswordCheckSucceeded},
|
||||
event: &es_models.Event{CreationDate: now(), Type: es_models.EventType(user.HumanPasswordCheckSucceededType)},
|
||||
userView: &UserSessionView{},
|
||||
},
|
||||
result: &UserSessionView{ChangeDate: now(), PasswordVerification: now()},
|
||||
@@ -45,7 +46,7 @@ func TestAppendEvent(t *testing.T) {
|
||||
{
|
||||
name: "append user password check failed event",
|
||||
args: args{
|
||||
event: &es_models.Event{CreationDate: now(), Type: es_model.UserPasswordCheckFailed},
|
||||
event: &es_models.Event{CreationDate: now(), Type: es_models.EventType(user.UserV1PasswordCheckFailedType)},
|
||||
userView: &UserSessionView{PasswordVerification: now()},
|
||||
},
|
||||
result: &UserSessionView{ChangeDate: now(), PasswordVerification: time.Time{}},
|
||||
@@ -53,7 +54,7 @@ func TestAppendEvent(t *testing.T) {
|
||||
{
|
||||
name: "append human password check failed event",
|
||||
args: args{
|
||||
event: &es_models.Event{CreationDate: now(), Type: es_model.HumanPasswordCheckFailed},
|
||||
event: &es_models.Event{CreationDate: now(), Type: es_models.EventType(user.HumanPasswordCheckFailedType)},
|
||||
userView: &UserSessionView{PasswordVerification: now()},
|
||||
},
|
||||
result: &UserSessionView{ChangeDate: now(), PasswordVerification: time.Time{}},
|
||||
@@ -63,7 +64,7 @@ func TestAppendEvent(t *testing.T) {
|
||||
args: args{
|
||||
event: &es_models.Event{
|
||||
CreationDate: now(),
|
||||
Type: es_model.UserPasswordChanged,
|
||||
Type: es_models.EventType(user.UserV1PasswordChangedType),
|
||||
Data: func() []byte {
|
||||
d, _ := json.Marshal(&es_model.Password{
|
||||
Secret: &crypto.CryptoValue{Crypted: []byte("test")},
|
||||
@@ -80,7 +81,7 @@ func TestAppendEvent(t *testing.T) {
|
||||
args: args{
|
||||
event: &es_models.Event{
|
||||
CreationDate: now(),
|
||||
Type: es_model.HumanPasswordChanged,
|
||||
Type: es_models.EventType(user.HumanPasswordChangedType),
|
||||
Data: func() []byte {
|
||||
d, _ := json.Marshal(&es_model.PasswordChange{
|
||||
Password: es_model.Password{
|
||||
@@ -99,7 +100,7 @@ func TestAppendEvent(t *testing.T) {
|
||||
args: args{
|
||||
event: &es_models.Event{
|
||||
CreationDate: now(),
|
||||
Type: es_model.HumanPasswordChanged,
|
||||
Type: es_models.EventType(user.HumanPasswordChangedType),
|
||||
Data: func() []byte {
|
||||
d, _ := json.Marshal(&es_model.PasswordChange{
|
||||
Password: es_model.Password{
|
||||
@@ -119,7 +120,7 @@ func TestAppendEvent(t *testing.T) {
|
||||
args: args{
|
||||
event: &es_models.Event{
|
||||
CreationDate: now(),
|
||||
Type: es_model.HumanMFAOTPVerified,
|
||||
Type: es_models.EventType(user.HumanMFAOTPVerifiedType),
|
||||
Data: nil,
|
||||
},
|
||||
userView: &UserSessionView{UserAgentID: "id"},
|
||||
@@ -131,7 +132,7 @@ func TestAppendEvent(t *testing.T) {
|
||||
args: args{
|
||||
event: &es_models.Event{
|
||||
CreationDate: now(),
|
||||
Type: es_model.HumanMFAOTPVerified,
|
||||
Type: es_models.EventType(user.HumanMFAOTPVerifiedType),
|
||||
Data: func() []byte {
|
||||
d, _ := json.Marshal(&es_model.OTPVerified{
|
||||
UserAgentID: "id",
|
||||
@@ -146,7 +147,7 @@ func TestAppendEvent(t *testing.T) {
|
||||
{
|
||||
name: "append user otp check succeeded event",
|
||||
args: args{
|
||||
event: &es_models.Event{CreationDate: now(), Type: es_model.MFAOTPCheckSucceeded},
|
||||
event: &es_models.Event{CreationDate: now(), Type: es_models.EventType(user.UserV1MFAOTPCheckSucceededType)},
|
||||
userView: &UserSessionView{},
|
||||
},
|
||||
result: &UserSessionView{ChangeDate: now(), SecondFactorVerification: now()},
|
||||
@@ -154,7 +155,7 @@ func TestAppendEvent(t *testing.T) {
|
||||
{
|
||||
name: "append human otp check succeeded event",
|
||||
args: args{
|
||||
event: &es_models.Event{CreationDate: now(), Type: es_model.HumanMFAOTPCheckSucceeded},
|
||||
event: &es_models.Event{CreationDate: now(), Type: es_models.EventType(user.HumanMFAOTPCheckSucceededType)},
|
||||
userView: &UserSessionView{},
|
||||
},
|
||||
result: &UserSessionView{ChangeDate: now(), SecondFactorVerification: now()},
|
||||
@@ -162,7 +163,7 @@ func TestAppendEvent(t *testing.T) {
|
||||
{
|
||||
name: "append user otp check failed event",
|
||||
args: args{
|
||||
event: &es_models.Event{CreationDate: now(), Type: es_model.MFAOTPCheckFailed},
|
||||
event: &es_models.Event{CreationDate: now(), Type: es_models.EventType(user.UserV1MFAOTPCheckFailedType)},
|
||||
userView: &UserSessionView{SecondFactorVerification: now()},
|
||||
},
|
||||
result: &UserSessionView{ChangeDate: now(), SecondFactorVerification: time.Time{}},
|
||||
@@ -170,7 +171,7 @@ func TestAppendEvent(t *testing.T) {
|
||||
{
|
||||
name: "append human otp check failed event",
|
||||
args: args{
|
||||
event: &es_models.Event{CreationDate: now(), Type: es_model.HumanMFAOTPCheckFailed},
|
||||
event: &es_models.Event{CreationDate: now(), Type: es_models.EventType(user.HumanMFAOTPCheckFailedType)},
|
||||
userView: &UserSessionView{SecondFactorVerification: now()},
|
||||
},
|
||||
result: &UserSessionView{ChangeDate: now(), SecondFactorVerification: time.Time{}},
|
||||
@@ -178,7 +179,7 @@ func TestAppendEvent(t *testing.T) {
|
||||
{
|
||||
name: "append user otp removed event",
|
||||
args: args{
|
||||
event: &es_models.Event{CreationDate: now(), Type: es_model.MFAOTPRemoved},
|
||||
event: &es_models.Event{CreationDate: now(), Type: es_models.EventType(user.UserV1MFAOTPRemovedType)},
|
||||
userView: &UserSessionView{SecondFactorVerification: now()},
|
||||
},
|
||||
result: &UserSessionView{ChangeDate: now(), SecondFactorVerification: time.Time{}},
|
||||
@@ -186,7 +187,7 @@ func TestAppendEvent(t *testing.T) {
|
||||
{
|
||||
name: "append human otp removed event",
|
||||
args: args{
|
||||
event: &es_models.Event{CreationDate: now(), Type: es_model.HumanMFAOTPRemoved},
|
||||
event: &es_models.Event{CreationDate: now(), Type: es_models.EventType(user.HumanMFAOTPRemovedType)},
|
||||
userView: &UserSessionView{SecondFactorVerification: now()},
|
||||
},
|
||||
result: &UserSessionView{ChangeDate: now(), SecondFactorVerification: time.Time{}},
|
||||
@@ -194,7 +195,7 @@ func TestAppendEvent(t *testing.T) {
|
||||
{
|
||||
name: "append user signed out event",
|
||||
args: args{
|
||||
event: &es_models.Event{CreationDate: now(), Type: es_model.SignedOut},
|
||||
event: &es_models.Event{CreationDate: now(), Type: es_models.EventType(user.UserV1SignedOutType)},
|
||||
userView: &UserSessionView{PasswordVerification: now(), SecondFactorVerification: now()},
|
||||
},
|
||||
result: &UserSessionView{ChangeDate: now(), PasswordVerification: time.Time{}, SecondFactorVerification: time.Time{}, State: 1},
|
||||
@@ -202,7 +203,7 @@ func TestAppendEvent(t *testing.T) {
|
||||
{
|
||||
name: "append human signed out event",
|
||||
args: args{
|
||||
event: &es_models.Event{CreationDate: now(), Type: es_model.HumanSignedOut},
|
||||
event: &es_models.Event{CreationDate: now(), Type: es_models.EventType(user.HumanSignedOutType)},
|
||||
userView: &UserSessionView{PasswordVerification: now(), SecondFactorVerification: now()},
|
||||
},
|
||||
result: &UserSessionView{ChangeDate: now(), PasswordVerification: time.Time{}, SecondFactorVerification: time.Time{}, State: 1},
|
||||
|
Reference in New Issue
Block a user