Chore: Remove some bus from login package (login attempts) (#47310)

This commit is contained in:
Serge Zaitsev
2022-04-05 13:07:27 +02:00
committed by GitHub
parent f722986b83
commit bf9e0e8bc8
6 changed files with 35 additions and 45 deletions
+12 -3
View File
@@ -12,8 +12,9 @@ type OrgListResponse []struct {
Response error
}
type SQLStoreMock struct {
LastGetAlertsQuery *models.GetAlertsQuery
LatestUserId int64
LastGetAlertsQuery *models.GetAlertsQuery
LastLoginAttemptCommand *models.CreateLoginAttemptCommand
LatestUserId int64
ExpectedUser *models.User
ExpectedDatasource *models.DataSource
@@ -40,7 +41,9 @@ type SQLStoreMock struct {
ExpectedPersistedDashboards models.HitList
ExpectedSignedInUser *models.SignedInUser
ExpectedUserStars map[int64]bool
ExpectedError error
ExpectedLoginAttempts int64
ExpectedError error
}
func NewSQLStoreMock() *SQLStoreMock {
@@ -130,6 +133,12 @@ func (m SQLStoreMock) DeleteOrphanedProvisionedDashboards(ctx context.Context, c
}
func (m *SQLStoreMock) CreateLoginAttempt(ctx context.Context, cmd *models.CreateLoginAttemptCommand) error {
m.LastLoginAttemptCommand = cmd
return m.ExpectedError
}
func (m *SQLStoreMock) GetUserLoginAttemptCount(ctx context.Context, query *models.GetUserLoginAttemptCountQuery) error {
query.Result = m.ExpectedLoginAttempts
return m.ExpectedError
}
+1
View File
@@ -26,6 +26,7 @@ type Store interface {
GetOrgById(context.Context, *models.GetOrgByIdQuery) error
GetOrgByNameHandler(ctx context.Context, query *models.GetOrgByNameQuery) error
CreateLoginAttempt(ctx context.Context, cmd *models.CreateLoginAttemptCommand) error
GetUserLoginAttemptCount(ctx context.Context, query *models.GetUserLoginAttemptCountQuery) error
DeleteOldLoginAttempts(ctx context.Context, cmd *models.DeleteOldLoginAttemptsCommand) error
CreateUser(ctx context.Context, cmd models.CreateUserCommand) (*models.User, error)
GetUserById(ctx context.Context, query *models.GetUserByIdQuery) error