Fix tests for invitations service.

This commit is contained in:
Daniël Franke
2023-03-30 11:12:00 +02:00
parent 5793970e5d
commit bc9ba63b06
7 changed files with 203 additions and 237 deletions
+122
View File
@@ -0,0 +1,122 @@
// Code generated by mockery v2.22.1. DO NOT EDIT.
package mocks
import (
context "context"
libregraph "github.com/owncloud/libre-graph-api-go"
keycloak "github.com/owncloud/ocis/v2/ocis-pkg/keycloak"
mock "github.com/stretchr/testify/mock"
)
// Client is an autogenerated mock type for the Client type
type Client struct {
mock.Mock
}
// CreateUser provides a mock function with given fields: ctx, realm, user, userActions
func (_m *Client) CreateUser(ctx context.Context, realm string, user *libregraph.User, userActions []keycloak.UserAction) (string, error) {
ret := _m.Called(ctx, realm, user, userActions)
var r0 string
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, string, *libregraph.User, []keycloak.UserAction) (string, error)); ok {
return rf(ctx, realm, user, userActions)
}
if rf, ok := ret.Get(0).(func(context.Context, string, *libregraph.User, []keycloak.UserAction) string); ok {
r0 = rf(ctx, realm, user, userActions)
} else {
r0 = ret.Get(0).(string)
}
if rf, ok := ret.Get(1).(func(context.Context, string, *libregraph.User, []keycloak.UserAction) error); ok {
r1 = rf(ctx, realm, user, userActions)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// GetPIIReport provides a mock function with given fields: ctx, realm, user
func (_m *Client) GetPIIReport(ctx context.Context, realm string, user *libregraph.User) (*keycloak.PIIReport, error) {
ret := _m.Called(ctx, realm, user)
var r0 *keycloak.PIIReport
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, string, *libregraph.User) (*keycloak.PIIReport, error)); ok {
return rf(ctx, realm, user)
}
if rf, ok := ret.Get(0).(func(context.Context, string, *libregraph.User) *keycloak.PIIReport); ok {
r0 = rf(ctx, realm, user)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*keycloak.PIIReport)
}
}
if rf, ok := ret.Get(1).(func(context.Context, string, *libregraph.User) error); ok {
r1 = rf(ctx, realm, user)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// GetUserByEmail provides a mock function with given fields: ctx, realm, email
func (_m *Client) GetUserByEmail(ctx context.Context, realm string, email string) (*libregraph.User, error) {
ret := _m.Called(ctx, realm, email)
var r0 *libregraph.User
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, string, string) (*libregraph.User, error)); ok {
return rf(ctx, realm, email)
}
if rf, ok := ret.Get(0).(func(context.Context, string, string) *libregraph.User); ok {
r0 = rf(ctx, realm, email)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*libregraph.User)
}
}
if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok {
r1 = rf(ctx, realm, email)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// SendActionsMail provides a mock function with given fields: ctx, realm, userID, userActions
func (_m *Client) SendActionsMail(ctx context.Context, realm string, userID string, userActions []keycloak.UserAction) error {
ret := _m.Called(ctx, realm, userID, userActions)
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, string, string, []keycloak.UserAction) error); ok {
r0 = rf(ctx, realm, userID, userActions)
} else {
r0 = ret.Error(0)
}
return r0
}
type mockConstructorTestingTNewClient interface {
mock.TestingT
Cleanup(func())
}
// NewClient creates a new instance of Client. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
func NewClient(t mockConstructorTestingTNewClient) *Client {
mock := &Client{}
mock.Mock.Test(t)
t.Cleanup(func() { mock.AssertExpectations(t) })
return mock
}
-112
View File
@@ -1,112 +0,0 @@
// Code generated by mockery v2.14.1. DO NOT EDIT.
package mocks
import (
context "context"
gocloak "github.com/Nerzal/gocloak/v13"
mock "github.com/stretchr/testify/mock"
)
// GoCloak is an autogenerated mock type for the GoCloak type
type GoCloak struct {
mock.Mock
}
// CreateUser provides a mock function with given fields: ctx, token, realm, user
func (_m *GoCloak) CreateUser(ctx context.Context, token string, realm string, user gocloak.User) (string, error) {
ret := _m.Called(ctx, token, realm, user)
var r0 string
if rf, ok := ret.Get(0).(func(context.Context, string, string, gocloak.User) string); ok {
r0 = rf(ctx, token, realm, user)
} else {
r0 = ret.Get(0).(string)
}
var r1 error
if rf, ok := ret.Get(1).(func(context.Context, string, string, gocloak.User) error); ok {
r1 = rf(ctx, token, realm, user)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// ExecuteActionsEmail provides a mock function with given fields: ctx, token, realm, params
func (_m *GoCloak) ExecuteActionsEmail(ctx context.Context, token string, realm string, params gocloak.ExecuteActionsEmail) error {
ret := _m.Called(ctx, token, realm, params)
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, string, string, gocloak.ExecuteActionsEmail) error); ok {
r0 = rf(ctx, token, realm, params)
} else {
r0 = ret.Error(0)
}
return r0
}
// LoginClient provides a mock function with given fields: ctx, clientID, clientSecret, realm
func (_m *GoCloak) LoginClient(ctx context.Context, clientID string, clientSecret string, realm string) (*gocloak.JWT, error) {
ret := _m.Called(ctx, clientID, clientSecret, realm)
var r0 *gocloak.JWT
if rf, ok := ret.Get(0).(func(context.Context, string, string, string) *gocloak.JWT); ok {
r0 = rf(ctx, clientID, clientSecret, realm)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*gocloak.JWT)
}
}
var r1 error
if rf, ok := ret.Get(1).(func(context.Context, string, string, string) error); ok {
r1 = rf(ctx, clientID, clientSecret, realm)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// RetrospectToken provides a mock function with given fields: ctx, accessToken, clientID, clientSecret, realm
func (_m *GoCloak) RetrospectToken(ctx context.Context, accessToken string, clientID string, clientSecret string, realm string) (*gocloak.IntroSpectTokenResult, error) {
ret := _m.Called(ctx, accessToken, clientID, clientSecret, realm)
var r0 *gocloak.IntroSpectTokenResult
if rf, ok := ret.Get(0).(func(context.Context, string, string, string, string) *gocloak.IntroSpectTokenResult); ok {
r0 = rf(ctx, accessToken, clientID, clientSecret, realm)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*gocloak.IntroSpectTokenResult)
}
}
var r1 error
if rf, ok := ret.Get(1).(func(context.Context, string, string, string, string) error); ok {
r1 = rf(ctx, accessToken, clientID, clientSecret, realm)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
type mockConstructorTestingTNewGoCloak interface {
mock.TestingT
Cleanup(func())
}
// NewGoCloak creates a new instance of GoCloak. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
func NewGoCloak(t mockConstructorTestingTNewGoCloak) *GoCloak {
mock := &GoCloak{}
mock.Mock.Test(t)
t.Cleanup(func() { mock.AssertExpectations(t) })
return mock
}