Make getUserByParams private.

This commit is contained in:
Daniël Franke
2023-04-19 10:46:50 +02:00
parent 81491efdc7
commit a52ebd1f79
3 changed files with 4 additions and 33 deletions

View File

@@ -90,8 +90,8 @@ func (c *ConcreteClient) SendActionsMail(ctx context.Context, realm, userID stri
return c.keycloak.ExecuteActionsEmail(ctx, token.AccessToken, realm, params)
}
// GetUserByParams looks up a user by the given parameters.
func (c *ConcreteClient) GetUserByParams(ctx context.Context, realm string, params gocloak.GetUsersParams) (*libregraph.User, error) {
// getUserByParams looks up a user by the given parameters.
func (c *ConcreteClient) getUserByParams(ctx context.Context, realm string, params gocloak.GetUsersParams) (*libregraph.User, error) {
token, err := c.getToken(ctx)
if err != nil {
return nil, err
@@ -115,7 +115,7 @@ func (c *ConcreteClient) GetUserByParams(ctx context.Context, realm string, para
// GetUserByUsername looks up a user by username.
func (c *ConcreteClient) GetUserByUsername(ctx context.Context, realm, username string) (*libregraph.User, error) {
return c.GetUserByParams(ctx, realm, gocloak.GetUsersParams{
return c.getUserByParams(ctx, realm, gocloak.GetUsersParams{
Username: &username,
})
}

View File

@@ -34,7 +34,6 @@ type PIIReport struct {
type Client interface {
CreateUser(ctx context.Context, realm string, user *libregraph.User, userActions []UserAction) (string, error)
SendActionsMail(ctx context.Context, realm, userID string, userActions []UserAction) error
GetUserByParams(ctx context.Context, realm string, params gocloak.GetUsersParams) (*libregraph.User, error)
GetUserByUsername(ctx context.Context, realm, username string) (*libregraph.User, error)
GetPIIReport(ctx context.Context, realm, username string) (*PIIReport, error)
}

View File

@@ -5,10 +5,8 @@ package mocks
import (
context "context"
gocloak "github.com/Nerzal/gocloak/v13"
keycloak "github.com/owncloud/ocis/v2/ocis-pkg/keycloak"
libregraph "github.com/owncloud/libre-graph-api-go"
keycloak "github.com/owncloud/ocis/v2/ocis-pkg/keycloak"
mock "github.com/stretchr/testify/mock"
)
@@ -68,32 +66,6 @@ func (_m *Client) GetPIIReport(ctx context.Context, realm string, username strin
return r0, r1
}
// GetUserByParams provides a mock function with given fields: ctx, realm, params
func (_m *Client) GetUserByParams(ctx context.Context, realm string, params gocloak.GetUsersParams) (*libregraph.User, error) {
ret := _m.Called(ctx, realm, params)
var r0 *libregraph.User
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, string, gocloak.GetUsersParams) (*libregraph.User, error)); ok {
return rf(ctx, realm, params)
}
if rf, ok := ret.Get(0).(func(context.Context, string, gocloak.GetUsersParams) *libregraph.User); ok {
r0 = rf(ctx, realm, params)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*libregraph.User)
}
}
if rf, ok := ret.Get(1).(func(context.Context, string, gocloak.GetUsersParams) error); ok {
r1 = rf(ctx, realm, params)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// GetUserByUsername provides a mock function with given fields: ctx, realm, username
func (_m *Client) GetUserByUsername(ctx context.Context, realm string, username string) (*libregraph.User, error) {
ret := _m.Called(ctx, realm, username)