From a52ebd1f79810a0547f1629f2b04b19ffc945cd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20Franke?= Date: Wed, 19 Apr 2023 10:46:50 +0200 Subject: [PATCH] Make `getUserByParams` private. --- ocis-pkg/keycloak/client.go | 6 ++--- ocis-pkg/keycloak/types.go | 1 - services/invitations/pkg/mocks/client.go | 30 +----------------------- 3 files changed, 4 insertions(+), 33 deletions(-) diff --git a/ocis-pkg/keycloak/client.go b/ocis-pkg/keycloak/client.go index d5c9d5de1..8b191d5dc 100644 --- a/ocis-pkg/keycloak/client.go +++ b/ocis-pkg/keycloak/client.go @@ -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, }) } diff --git a/ocis-pkg/keycloak/types.go b/ocis-pkg/keycloak/types.go index ce3862bb7..632d0975c 100644 --- a/ocis-pkg/keycloak/types.go +++ b/ocis-pkg/keycloak/types.go @@ -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) } diff --git a/services/invitations/pkg/mocks/client.go b/services/invitations/pkg/mocks/client.go index a5580a39e..a83ddafe4 100644 --- a/services/invitations/pkg/mocks/client.go +++ b/services/invitations/pkg/mocks/client.go @@ -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)