mirror of
https://github.com/grafana/grafana.git
synced 2025-07-30 14:12:26 +08:00

* wip * wip + tests * wip * wip opt2 * Use authn.Identity struct's SessionToken * Merge fixes * Handle disabling the feature flag correctly * Fix test * Cleanup * Remove HasOAuthEntry from the OAuthTokenService interface * Remove unused function
122 lines
3.3 KiB
Go
122 lines
3.3 KiB
Go
// Code generated by mockery v2.42.1. DO NOT EDIT.
|
|
|
|
package oauthtokentest
|
|
|
|
import (
|
|
context "context"
|
|
|
|
identity "github.com/grafana/grafana/pkg/apimachinery/identity"
|
|
datasources "github.com/grafana/grafana/pkg/services/datasources"
|
|
|
|
mock "github.com/stretchr/testify/mock"
|
|
|
|
oauth2 "golang.org/x/oauth2"
|
|
|
|
usertoken "github.com/grafana/grafana/pkg/models/usertoken"
|
|
)
|
|
|
|
// MockService is an autogenerated mock type for the OAuthTokenService type
|
|
type MockService struct {
|
|
mock.Mock
|
|
}
|
|
|
|
// GetCurrentOAuthToken provides a mock function with given fields: _a0, _a1, _a2
|
|
func (_m *MockService) GetCurrentOAuthToken(_a0 context.Context, _a1 identity.Requester, _a2 *usertoken.UserToken) *oauth2.Token {
|
|
ret := _m.Called(_a0, _a1, _a2)
|
|
|
|
if len(ret) == 0 {
|
|
panic("no return value specified for GetCurrentOAuthToken")
|
|
}
|
|
|
|
var r0 *oauth2.Token
|
|
if rf, ok := ret.Get(0).(func(context.Context, identity.Requester, *usertoken.UserToken) *oauth2.Token); ok {
|
|
r0 = rf(_a0, _a1, _a2)
|
|
} else {
|
|
if ret.Get(0) != nil {
|
|
r0 = ret.Get(0).(*oauth2.Token)
|
|
}
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// InvalidateOAuthTokens provides a mock function with given fields: _a0, _a1, _a2
|
|
func (_m *MockService) InvalidateOAuthTokens(_a0 context.Context, _a1 identity.Requester, _a2 *usertoken.UserToken) error {
|
|
ret := _m.Called(_a0, _a1, _a2)
|
|
|
|
if len(ret) == 0 {
|
|
panic("no return value specified for InvalidateOAuthTokens")
|
|
}
|
|
|
|
var r0 error
|
|
if rf, ok := ret.Get(0).(func(context.Context, identity.Requester, *usertoken.UserToken) error); ok {
|
|
r0 = rf(_a0, _a1, _a2)
|
|
} else {
|
|
r0 = ret.Error(0)
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// IsOAuthPassThruEnabled provides a mock function with given fields: _a0
|
|
func (_m *MockService) IsOAuthPassThruEnabled(_a0 *datasources.DataSource) bool {
|
|
ret := _m.Called(_a0)
|
|
|
|
if len(ret) == 0 {
|
|
panic("no return value specified for IsOAuthPassThruEnabled")
|
|
}
|
|
|
|
var r0 bool
|
|
if rf, ok := ret.Get(0).(func(*datasources.DataSource) bool); ok {
|
|
r0 = rf(_a0)
|
|
} else {
|
|
r0 = ret.Get(0).(bool)
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// TryTokenRefresh provides a mock function with given fields: _a0, _a1, _a2
|
|
func (_m *MockService) TryTokenRefresh(_a0 context.Context, _a1 identity.Requester, _a2 *usertoken.UserToken) (*oauth2.Token, error) {
|
|
ret := _m.Called(_a0, _a1, _a2)
|
|
|
|
if len(ret) == 0 {
|
|
panic("no return value specified for TryTokenRefresh")
|
|
}
|
|
|
|
var r0 *oauth2.Token
|
|
var r1 error
|
|
if rf, ok := ret.Get(0).(func(context.Context, identity.Requester, *usertoken.UserToken) (*oauth2.Token, error)); ok {
|
|
return rf(_a0, _a1, _a2)
|
|
}
|
|
if rf, ok := ret.Get(0).(func(context.Context, identity.Requester, *usertoken.UserToken) *oauth2.Token); ok {
|
|
r0 = rf(_a0, _a1, _a2)
|
|
} else {
|
|
if ret.Get(0) != nil {
|
|
r0 = ret.Get(0).(*oauth2.Token)
|
|
}
|
|
}
|
|
|
|
if rf, ok := ret.Get(1).(func(context.Context, identity.Requester, *usertoken.UserToken) error); ok {
|
|
r1 = rf(_a0, _a1, _a2)
|
|
} else {
|
|
r1 = ret.Error(1)
|
|
}
|
|
|
|
return r0, r1
|
|
}
|
|
|
|
// NewMockService creates a new instance of MockService. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
|
// The first argument is typically a *testing.T value.
|
|
func NewMockService(t interface {
|
|
mock.TestingT
|
|
Cleanup(func())
|
|
}) *MockService {
|
|
mock := &MockService{}
|
|
mock.Mock.Test(t)
|
|
|
|
t.Cleanup(func() { mock.AssertExpectations(t) })
|
|
|
|
return mock
|
|
}
|