mirror of
https://github.com/grafana/grafana.git
synced 2025-07-29 15:52:28 +08:00
Replace AddHandler with AddHandlerCtx in tests (#42585)
This commit is contained in:
@ -132,7 +132,7 @@ func TestGetUserFromLDAPAPIEndpoint_OrgNotfound(t *testing.T) {
|
||||
{Id: 1, Name: "Main Org."},
|
||||
}
|
||||
|
||||
bus.AddHandler("test", func(query *models.SearchOrgsQuery) error {
|
||||
bus.AddHandlerCtx("test", func(ctx context.Context, query *models.SearchOrgsQuery) error {
|
||||
query.Result = mockOrgSearchResult
|
||||
return nil
|
||||
})
|
||||
@ -194,7 +194,7 @@ func TestGetUserFromLDAPAPIEndpoint(t *testing.T) {
|
||||
{Id: 1, Name: "Main Org."},
|
||||
}
|
||||
|
||||
bus.AddHandler("test", func(query *models.SearchOrgsQuery) error {
|
||||
bus.AddHandlerCtx("test", func(ctx context.Context, query *models.SearchOrgsQuery) error {
|
||||
query.Result = mockOrgSearchResult
|
||||
return nil
|
||||
})
|
||||
@ -269,12 +269,12 @@ func TestGetUserFromLDAPAPIEndpoint_WithTeamHandler(t *testing.T) {
|
||||
{Id: 1, Name: "Main Org."},
|
||||
}
|
||||
|
||||
bus.AddHandler("test", func(query *models.SearchOrgsQuery) error {
|
||||
bus.AddHandlerCtx("test", func(ctx context.Context, query *models.SearchOrgsQuery) error {
|
||||
query.Result = mockOrgSearchResult
|
||||
return nil
|
||||
})
|
||||
|
||||
bus.AddHandler("test", func(cmd *models.GetTeamsForLDAPGroupCommand) error {
|
||||
bus.AddHandlerCtx("test", func(ctx context.Context, cmd *models.GetTeamsForLDAPGroupCommand) error {
|
||||
cmd.Result = []models.TeamOrgGroupDTO{}
|
||||
return nil
|
||||
})
|
||||
@ -430,7 +430,7 @@ func TestPostSyncUserWithLDAPAPIEndpoint_Success(t *testing.T) {
|
||||
Login: "ldap-daniel",
|
||||
}
|
||||
|
||||
bus.AddHandler("test", func(cmd *models.UpsertUserCommand) error {
|
||||
bus.AddHandlerCtx("test", func(ctx context.Context, cmd *models.UpsertUserCommand) error {
|
||||
require.Equal(t, "ldap-daniel", cmd.ExternalUser.Login)
|
||||
return nil
|
||||
})
|
||||
@ -442,7 +442,7 @@ func TestPostSyncUserWithLDAPAPIEndpoint_Success(t *testing.T) {
|
||||
return nil
|
||||
})
|
||||
|
||||
bus.AddHandler("test", func(q *models.GetAuthInfoQuery) error {
|
||||
bus.AddHandlerCtx("test", func(ctx context.Context, q *models.GetAuthInfoQuery) error {
|
||||
require.Equal(t, q.UserId, int64(34))
|
||||
require.Equal(t, q.AuthModule, models.AuthModuleLDAP)
|
||||
|
||||
@ -510,7 +510,7 @@ func TestPostSyncUserWithLDAPAPIEndpoint_WhenGrafanaAdmin(t *testing.T) {
|
||||
return nil
|
||||
})
|
||||
|
||||
bus.AddHandler("test", func(q *models.GetAuthInfoQuery) error {
|
||||
bus.AddHandlerCtx("test", func(ctx context.Context, q *models.GetAuthInfoQuery) error {
|
||||
require.Equal(t, q.UserId, int64(34))
|
||||
require.Equal(t, q.AuthModule, models.AuthModuleLDAP)
|
||||
|
||||
@ -542,7 +542,7 @@ func TestPostSyncUserWithLDAPAPIEndpoint_WhenUserNotInLDAP(t *testing.T) {
|
||||
|
||||
userSearchResult = nil
|
||||
|
||||
bus.AddHandler("test", func(cmd *models.UpsertUserCommand) error {
|
||||
bus.AddHandlerCtx("test", func(ctx context.Context, cmd *models.UpsertUserCommand) error {
|
||||
require.Equal(t, "ldap-daniel", cmd.ExternalUser.Login)
|
||||
return nil
|
||||
})
|
||||
@ -554,14 +554,14 @@ func TestPostSyncUserWithLDAPAPIEndpoint_WhenUserNotInLDAP(t *testing.T) {
|
||||
return nil
|
||||
})
|
||||
|
||||
bus.AddHandler("test", func(q *models.GetExternalUserInfoByLoginQuery) error {
|
||||
bus.AddHandlerCtx("test", func(ctx context.Context, q *models.GetExternalUserInfoByLoginQuery) error {
|
||||
assert.Equal(t, "ldap-daniel", q.LoginOrEmail)
|
||||
q.Result = &models.ExternalUserInfo{IsDisabled: true, UserId: 34}
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
bus.AddHandler("test", func(cmd *models.DisableUserCommand) error {
|
||||
bus.AddHandlerCtx("test", func(ctx context.Context, cmd *models.DisableUserCommand) error {
|
||||
assert.Equal(t, 34, cmd.UserId)
|
||||
return nil
|
||||
})
|
||||
@ -693,11 +693,11 @@ func TestLDAP_AccessControl(t *testing.T) {
|
||||
return nil
|
||||
})
|
||||
|
||||
bus.AddHandler("test", func(q *models.GetAuthInfoQuery) error {
|
||||
bus.AddHandlerCtx("test", func(ctx context.Context, q *models.GetAuthInfoQuery) error {
|
||||
return nil
|
||||
})
|
||||
|
||||
bus.AddHandler("test", func(cmd *models.UpsertUserCommand) error {
|
||||
bus.AddHandlerCtx("test", func(ctx context.Context, cmd *models.UpsertUserCommand) error {
|
||||
return nil
|
||||
})
|
||||
|
||||
|
Reference in New Issue
Block a user