redhatsso

package
v0.0.0-...-9b598c7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 28, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SSOClient

type SSOClient interface {
	GetToken() (string, error)
	GetConfig() *keycloak.KeycloakConfig
	GetRealmConfig() *keycloak.KeycloakRealmConfig
	GetServiceAccounts(accessToken string, first int, max int) ([]serviceaccountsclient.ServiceAccountData, error)
	GetServiceAccount(accessToken string, clientId string) (*serviceaccountsclient.ServiceAccountData, bool, error)
	CreateServiceAccount(accessToken string, name string, description string) (serviceaccountsclient.ServiceAccountData, error)
	DeleteServiceAccount(accessToken string, clientId string) error
	UpdateServiceAccount(accessToken string, clientId string, name string, description string) (serviceaccountsclient.ServiceAccountData, error)
	RegenerateClientSecret(accessToken string, id string) (serviceaccountsclient.ServiceAccountData, error)
}

func NewSSOClient

func NewSSOClient(config *keycloak.KeycloakConfig, realmConfig *keycloak.KeycloakRealmConfig) SSOClient

type SSOClientMock

type SSOClientMock struct {
	// CreateServiceAccountFunc mocks the CreateServiceAccount method.
	CreateServiceAccountFunc func(accessToken string, name string, description string) (serviceaccountsclient.ServiceAccountData, error)

	// DeleteServiceAccountFunc mocks the DeleteServiceAccount method.
	DeleteServiceAccountFunc func(accessToken string, clientId string) error

	// GetConfigFunc mocks the GetConfig method.
	GetConfigFunc func() *keycloak.KeycloakConfig

	// GetRealmConfigFunc mocks the GetRealmConfig method.
	GetRealmConfigFunc func() *keycloak.KeycloakRealmConfig

	// GetServiceAccountFunc mocks the GetServiceAccount method.
	GetServiceAccountFunc func(accessToken string, clientId string) (*serviceaccountsclient.ServiceAccountData, bool, error)

	// GetServiceAccountsFunc mocks the GetServiceAccounts method.
	GetServiceAccountsFunc func(accessToken string, first int, max int) ([]serviceaccountsclient.ServiceAccountData, error)

	// GetTokenFunc mocks the GetToken method.
	GetTokenFunc func() (string, error)

	// RegenerateClientSecretFunc mocks the RegenerateClientSecret method.
	RegenerateClientSecretFunc func(accessToken string, id string) (serviceaccountsclient.ServiceAccountData, error)

	// UpdateServiceAccountFunc mocks the UpdateServiceAccount method.
	UpdateServiceAccountFunc func(accessToken string, clientId string, name string, description string) (serviceaccountsclient.ServiceAccountData, error)
	// contains filtered or unexported fields
}

SSOClientMock is a mock implementation of SSOClient.

func TestSomethingThatUsesSSOClient(t *testing.T) {

	// make and configure a mocked SSOClient
	mockedSSOClient := &SSOClientMock{
		CreateServiceAccountFunc: func(accessToken string, name string, description string) (serviceaccountsclient.ServiceAccountData, error) {
			panic("mock out the CreateServiceAccount method")
		},
		DeleteServiceAccountFunc: func(accessToken string, clientId string) error {
			panic("mock out the DeleteServiceAccount method")
		},
		GetConfigFunc: func() *keycloak.KeycloakConfig {
			panic("mock out the GetConfig method")
		},
		GetRealmConfigFunc: func() *keycloak.KeycloakRealmConfig {
			panic("mock out the GetRealmConfig method")
		},
		GetServiceAccountFunc: func(accessToken string, clientId string) (*serviceaccountsclient.ServiceAccountData, bool, error) {
			panic("mock out the GetServiceAccount method")
		},
		GetServiceAccountsFunc: func(accessToken string, first int, max int) ([]serviceaccountsclient.ServiceAccountData, error) {
			panic("mock out the GetServiceAccounts method")
		},
		GetTokenFunc: func() (string, error) {
			panic("mock out the GetToken method")
		},
		RegenerateClientSecretFunc: func(accessToken string, id string) (serviceaccountsclient.ServiceAccountData, error) {
			panic("mock out the RegenerateClientSecret method")
		},
		UpdateServiceAccountFunc: func(accessToken string, clientId string, name string, description string) (serviceaccountsclient.ServiceAccountData, error) {
			panic("mock out the UpdateServiceAccount method")
		},
	}

	// use mockedSSOClient in code that requires SSOClient
	// and then make assertions.

}

func (*SSOClientMock) CreateServiceAccount

func (mock *SSOClientMock) CreateServiceAccount(accessToken string, name string, description string) (serviceaccountsclient.ServiceAccountData, error)

CreateServiceAccount calls CreateServiceAccountFunc.

func (*SSOClientMock) CreateServiceAccountCalls

func (mock *SSOClientMock) CreateServiceAccountCalls() []struct {
	AccessToken string
	Name        string
	Description string
}

CreateServiceAccountCalls gets all the calls that were made to CreateServiceAccount. Check the length with:

len(mockedSSOClient.CreateServiceAccountCalls())

func (*SSOClientMock) DeleteServiceAccount

func (mock *SSOClientMock) DeleteServiceAccount(accessToken string, clientId string) error

DeleteServiceAccount calls DeleteServiceAccountFunc.

func (*SSOClientMock) DeleteServiceAccountCalls

func (mock *SSOClientMock) DeleteServiceAccountCalls() []struct {
	AccessToken string
	ClientId    string
}

DeleteServiceAccountCalls gets all the calls that were made to DeleteServiceAccount. Check the length with:

len(mockedSSOClient.DeleteServiceAccountCalls())

func (*SSOClientMock) GetConfig

func (mock *SSOClientMock) GetConfig() *keycloak.KeycloakConfig

GetConfig calls GetConfigFunc.

func (*SSOClientMock) GetConfigCalls

func (mock *SSOClientMock) GetConfigCalls() []struct {
}

GetConfigCalls gets all the calls that were made to GetConfig. Check the length with:

len(mockedSSOClient.GetConfigCalls())

func (*SSOClientMock) GetRealmConfig

func (mock *SSOClientMock) GetRealmConfig() *keycloak.KeycloakRealmConfig

GetRealmConfig calls GetRealmConfigFunc.

func (*SSOClientMock) GetRealmConfigCalls

func (mock *SSOClientMock) GetRealmConfigCalls() []struct {
}

GetRealmConfigCalls gets all the calls that were made to GetRealmConfig. Check the length with:

len(mockedSSOClient.GetRealmConfigCalls())

func (*SSOClientMock) GetServiceAccount

func (mock *SSOClientMock) GetServiceAccount(accessToken string, clientId string) (*serviceaccountsclient.ServiceAccountData, bool, error)

GetServiceAccount calls GetServiceAccountFunc.

func (*SSOClientMock) GetServiceAccountCalls

func (mock *SSOClientMock) GetServiceAccountCalls() []struct {
	AccessToken string
	ClientId    string
}

GetServiceAccountCalls gets all the calls that were made to GetServiceAccount. Check the length with:

len(mockedSSOClient.GetServiceAccountCalls())

func (*SSOClientMock) GetServiceAccounts

func (mock *SSOClientMock) GetServiceAccounts(accessToken string, first int, max int) ([]serviceaccountsclient.ServiceAccountData, error)

GetServiceAccounts calls GetServiceAccountsFunc.

func (*SSOClientMock) GetServiceAccountsCalls

func (mock *SSOClientMock) GetServiceAccountsCalls() []struct {
	AccessToken string
	First       int
	Max         int
}

GetServiceAccountsCalls gets all the calls that were made to GetServiceAccounts. Check the length with:

len(mockedSSOClient.GetServiceAccountsCalls())

func (*SSOClientMock) GetToken

func (mock *SSOClientMock) GetToken() (string, error)

GetToken calls GetTokenFunc.

func (*SSOClientMock) GetTokenCalls

func (mock *SSOClientMock) GetTokenCalls() []struct {
}

GetTokenCalls gets all the calls that were made to GetToken. Check the length with:

len(mockedSSOClient.GetTokenCalls())

func (*SSOClientMock) RegenerateClientSecret

func (mock *SSOClientMock) RegenerateClientSecret(accessToken string, id string) (serviceaccountsclient.ServiceAccountData, error)

RegenerateClientSecret calls RegenerateClientSecretFunc.

func (*SSOClientMock) RegenerateClientSecretCalls

func (mock *SSOClientMock) RegenerateClientSecretCalls() []struct {
	AccessToken string
	ID          string
}

RegenerateClientSecretCalls gets all the calls that were made to RegenerateClientSecret. Check the length with:

len(mockedSSOClient.RegenerateClientSecretCalls())

func (*SSOClientMock) UpdateServiceAccount

func (mock *SSOClientMock) UpdateServiceAccount(accessToken string, clientId string, name string, description string) (serviceaccountsclient.ServiceAccountData, error)

UpdateServiceAccount calls UpdateServiceAccountFunc.

func (*SSOClientMock) UpdateServiceAccountCalls

func (mock *SSOClientMock) UpdateServiceAccountCalls() []struct {
	AccessToken string
	ClientId    string
	Name        string
	Description string
}

UpdateServiceAccountCalls gets all the calls that were made to UpdateServiceAccount. Check the length with:

len(mockedSSOClient.UpdateServiceAccountCalls())

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL