grafana/pkg/services/stats/statstest/stats.go
Eric Leijonmarck 59bdff0280
Auth: Add anonymous users view and stats (#78685)
* Add anonymous stats and user table

- anonymous users users page
- add feature toggle `anonymousAccess`
- remove check for enterprise for `Device-Id` header in request
- add anonusers/device count to stats

* promise all, review comments

* make use of promise all settled

* refactoring: devices instead of users

* review comments, moved countdevices to httpserver

* fakeAnonService for tests and generate openapi spec

* do not commit openapi3 and api-merged

* add openapi

* Apply suggestions from code review

Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>

* formatin

* precise anon devices to avoid confusion

---------

Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com>
Co-authored-by: jguer <me@jguer.space>
2023-11-29 17:58:41 +01:00

46 lines
1.6 KiB
Go

package statstest
import (
"context"
"github.com/grafana/grafana/pkg/services/stats"
)
type FakeService struct {
ExpectedAdminStats *stats.AdminStats
ExpectedSystemStats *stats.SystemStats
ExpectedDataSourceStats []*stats.DataSourceStats
ExpectedDataSourcesAccessStats []*stats.DataSourceAccessStats
ExpectedNotifierUsageStats []*stats.NotifierUsageStats
ExpectedError error
}
func NewFakeService() *FakeService {
return &FakeService{}
}
func (s *FakeService) GetAdminStats(ctx context.Context, query *stats.GetAdminStatsQuery) (*stats.AdminStats, error) {
return s.ExpectedAdminStats, s.ExpectedError
}
func (s *FakeService) GetAlertNotifiersUsageStats(ctx context.Context, query *stats.GetAlertNotifierUsageStatsQuery) ([]*stats.NotifierUsageStats, error) {
return s.ExpectedNotifierUsageStats, s.ExpectedError
}
func (s *FakeService) GetDataSourceStats(ctx context.Context, query *stats.GetDataSourceStatsQuery) ([]*stats.DataSourceStats, error) {
return s.ExpectedDataSourceStats, s.ExpectedError
}
func (s *FakeService) GetDataSourceAccessStats(ctx context.Context, query *stats.GetDataSourceAccessStatsQuery) ([]*stats.DataSourceAccessStats, error) {
return s.ExpectedDataSourcesAccessStats, s.ExpectedError
}
func (s *FakeService) GetSystemStats(ctx context.Context, query *stats.GetSystemStatsQuery) (*stats.SystemStats, error) {
return s.ExpectedSystemStats, s.ExpectedError
}
func (s *FakeService) GetSystemUserCountStats(ctx context.Context, query *stats.GetSystemUserCountStatsQuery) (*stats.SystemUserCountStats, error) {
return nil, s.ExpectedError
}