mirror of
https://github.com/grafana/grafana.git
synced 2025-08-06 08:29:33 +08:00
Chore: split APIKey store (#52781)
* move apikey store into a separate service * add apikey service to wire graph * fix linter * switch api to use apikey service * fix provideservice in tests * add apikey service test double * try different sql syntax * rolling back the dialect * trigger drone * trigger drone
This commit is contained in:
42
pkg/services/apikey/apikeytest/fake.go
Normal file
42
pkg/services/apikey/apikeytest/fake.go
Normal file
@ -0,0 +1,42 @@
|
||||
package apikeytest
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
)
|
||||
|
||||
type Service struct {
|
||||
ExpectedError error
|
||||
ExpectedAPIKeys []*models.ApiKey
|
||||
ExpectedAPIKey *models.ApiKey
|
||||
}
|
||||
|
||||
func (s *Service) GetAPIKeys(ctx context.Context, query *models.GetApiKeysQuery) error {
|
||||
query.Result = s.ExpectedAPIKeys
|
||||
return s.ExpectedError
|
||||
}
|
||||
func (s *Service) GetAllAPIKeys(ctx context.Context, orgID int64) []*models.ApiKey {
|
||||
return s.ExpectedAPIKeys
|
||||
}
|
||||
func (s *Service) GetApiKeyById(ctx context.Context, query *models.GetApiKeyByIdQuery) error {
|
||||
query.Result = s.ExpectedAPIKey
|
||||
return s.ExpectedError
|
||||
}
|
||||
func (s *Service) GetApiKeyByName(ctx context.Context, query *models.GetApiKeyByNameQuery) error {
|
||||
query.Result = s.ExpectedAPIKey
|
||||
return s.ExpectedError
|
||||
}
|
||||
func (s *Service) GetAPIKeyByHash(ctx context.Context, hash string) (*models.ApiKey, error) {
|
||||
return s.ExpectedAPIKey, s.ExpectedError
|
||||
}
|
||||
func (s *Service) DeleteApiKey(ctx context.Context, cmd *models.DeleteApiKeyCommand) error {
|
||||
return s.ExpectedError
|
||||
}
|
||||
func (s *Service) AddAPIKey(ctx context.Context, cmd *models.AddApiKeyCommand) error {
|
||||
cmd.Result = s.ExpectedAPIKey
|
||||
return s.ExpectedError
|
||||
}
|
||||
func (s *Service) UpdateAPIKeyLastUsedDate(ctx context.Context, tokenID int64) error {
|
||||
return s.ExpectedError
|
||||
}
|
Reference in New Issue
Block a user