Documentation ¶
Index ¶
- Constants
- func GetUserSignupSpecs(username string) *toolchainApi.UserSignup
- func GetUserSignupSpecsBanned(username string) *toolchainApi.UserSignup
- func GetUserSignupSpecsDeactivated(username string) *toolchainApi.UserSignup
- func NewHttpClient() (*http.Client, error)
- type HttpClient
- type KeycloakAuth
- type KeycloakUser
- type KeycloakUserCredentials
- type LoggingRoundTripper
- type SandboxController
- func (s *SandboxController) CheckUserCreated(userName string) (compliantUsername string, err error)
- func (s *SandboxController) CheckUserCreatedWithSignUp(userName string, userSignup *toolchainApi.UserSignup) (compliantUsername string, err error)
- func (s *SandboxController) DeleteUserSignup(userName string) (bool, error)
- func (s *SandboxController) GetKeycloakAdminSecret() (adminPassword string, err error)
- func (k *SandboxController) GetKeycloakToken(clientID string, userName string, password string, realm string) (keycloakAuth *KeycloakAuth, err error)
- func (k *SandboxController) GetKeycloakTokenStage(userName, tokenURL, refreshToken string) (keycloakAuth *KeycloakAuth, err error)
- func (s *SandboxController) GetKubeconfigPathForSpecificUser(isStage bool, toolchainApiUrl string, userName string, kubeconfigPath string, ...) (*SandboxUserAuthInfo, error)
- func (s *SandboxController) GetOpenshiftRouteHost(namespace string, name string) (string, error)
- func (s *SandboxController) GetUserProvisionedNamespace(userName string) (namespace string, err error)
- func (s *SandboxController) IsKeycloakRunning() error
- func (s *SandboxController) KeycloakUserExists(realm string, token string, username string) bool
- func (k *SandboxController) MakeRequestKeyCloak(req *http.Request, userName string) (keycloakAuth *KeycloakAuth, err error)
- func (s *SandboxController) ReconcileUserCreation(userName string) (*SandboxUserAuthInfo, error)
- func (s *SandboxController) ReconcileUserCreationStage(userName, toolchainApiUrl, keycloakUrl, offlineToken string) (*SandboxUserAuthInfo, error)
- func (s *SandboxController) RegisterBannedSandboxUser(userName string) (compliantUsername string, err error)
- func (s *SandboxController) RegisterDeactivatedSandboxUser(userName string) (compliantUsername string, err error)
- func (k *SandboxController) RegisterKeycloakUser(userName string, keycloakToken string, realm string) (user *KeycloakUser, err error)
- func (s *SandboxController) RegisterSandboxUser(userName string) (compliantUsername string, err error)
- func (s *SandboxController) RegisterSandboxUserUserWithSignUp(userName string, userSignup *toolchainApi.UserSignup) (compliantUsername string, err error)
- func (s *SandboxController) UpdateUserSignup(userSignupName string, modifyUserSignup func(us *toolchainApi.UserSignup)) (*toolchainApi.UserSignup, error)
- type SandboxUserAuthInfo
Constants ¶
const ( DEFAULT_KEYCLOAK_INSTANCE_NAME = "keycloak" DEFAULT_KEYCLOAK_NAMESPACE = "dev-sso" )
const ( DEFAULT_KEYCLOAK_MASTER_REALM = "master" DEFAULT_KEYCLOAK_ADMIN_CLIENT_ID = "admin-cli" DEFAULT_KEYCLOAK_ADMIN_USERNAME = "admin" DEFAULT_KEYCLOAK_ADMIN_SECRET = "credential-dev-sso" SECRET_KEY = "ADMIN_PASSWORD" DEFAULT_TOOLCHAIN_INSTANCE_NAME = "api" DEFAULT_TOOLCHAIN_NAMESPACE = "toolchain-host-operator" DEFAULT_KEYCLOAK_TESTING_REALM = "redhat-external" DEFAULT_KEYCLOAK_TEST_CLIENT_ID = "cloud-services" )
Variables ¶
This section is empty.
Functions ¶
func GetUserSignupSpecs ¶
func GetUserSignupSpecs(username string) *toolchainApi.UserSignup
func GetUserSignupSpecsBanned ¶
func GetUserSignupSpecsBanned(username string) *toolchainApi.UserSignup
func GetUserSignupSpecsDeactivated ¶
func GetUserSignupSpecsDeactivated(username string) *toolchainApi.UserSignup
func NewHttpClient ¶
NewHttpClient creates http client wrapper with helper functions for rest models call
Types ¶
type HttpClient ¶
type KeycloakAuth ¶
type KeycloakAuth struct { // An access token is a token delivered by they keycloak server, and which allows an application to access to a resource AccessToken string `json:"access_token"` //refresh token is subject to SSO Session Idle timeout (30mn -default) and SSO Session Max lifespan (10hours-default) whereas offline token never expires RefreshToken string `json:"refresh_token"` }
type KeycloakUser ¶
type KeycloakUser struct { FirstName string `json:"firstName"` LastName string `json:"lastName"` Username string `json:"username"` Enabled string `json:"enabled"` Email string `json:"email"` Credentials []KeycloakUserCredentials `json:"credentials"` }
Values to create a valid user for testing purposes
type KeycloakUserCredentials ¶
type LoggingRoundTripper ¶
type LoggingRoundTripper struct {
Proxied http.RoundTripper
}
This type implements the http.RoundTripper interface
type SandboxController ¶
type SandboxController struct { // A Client is an HTTP client. Its zero value (DefaultClient) is a // usable client that uses DefaultTransport. HttpClient *http.Client // A valid keycloak url where to point all API REST calls KeycloakUrl string // Wrapper of valid kubernetes with admin access to the cluster KubeClient kubernetes.Interface // Wrapper of valid kubernetes with admin access to the cluster KubeRest crclient.Client }
func NewDevSandboxController ¶
func NewDevSandboxController(kube kubernetes.Interface, kubeRest crclient.Client) (*SandboxController, error)
NewKeyCloakApiController creates http client wrapper with helper functions for keycloak calls
func NewDevSandboxStageController ¶
func NewDevSandboxStageController() (*SandboxController, error)
same as NewKeyCloakApiController but for stage
func (*SandboxController) CheckUserCreated ¶
func (s *SandboxController) CheckUserCreated(userName string) (compliantUsername string, err error)
func (*SandboxController) CheckUserCreatedWithSignUp ¶
func (s *SandboxController) CheckUserCreatedWithSignUp(userName string, userSignup *toolchainApi.UserSignup) (compliantUsername string, err error)
func (*SandboxController) DeleteUserSignup ¶
func (s *SandboxController) DeleteUserSignup(userName string) (bool, error)
func (*SandboxController) GetKeycloakAdminSecret ¶
func (s *SandboxController) GetKeycloakAdminSecret() (adminPassword string, err error)
Add a valid description
func (*SandboxController) GetKeycloakToken ¶
func (k *SandboxController) GetKeycloakToken(clientID string, userName string, password string, realm string) (keycloakAuth *KeycloakAuth, err error)
GetKeycloakToken return a token for admins
func (*SandboxController) GetKeycloakTokenStage ¶
func (k *SandboxController) GetKeycloakTokenStage(userName, tokenURL, refreshToken string) (keycloakAuth *KeycloakAuth, err error)
Get Stage KeyCloak Token
func (*SandboxController) GetKubeconfigPathForSpecificUser ¶
func (s *SandboxController) GetKubeconfigPathForSpecificUser(isStage bool, toolchainApiUrl string, userName string, kubeconfigPath string, keycloakAuth *KeycloakAuth) (*SandboxUserAuthInfo, error)
func (*SandboxController) GetOpenshiftRouteHost ¶
func (s *SandboxController) GetOpenshiftRouteHost(namespace string, name string) (string, error)
func (*SandboxController) GetUserProvisionedNamespace ¶
func (s *SandboxController) GetUserProvisionedNamespace(userName string) (namespace string, err error)
func (*SandboxController) IsKeycloakRunning ¶
func (s *SandboxController) IsKeycloakRunning() error
Add a valid description
func (*SandboxController) KeycloakUserExists ¶
func (s *SandboxController) KeycloakUserExists(realm string, token string, username string) bool
func (*SandboxController) MakeRequestKeyCloak ¶
func (k *SandboxController) MakeRequestKeyCloak(req *http.Request, userName string) (keycloakAuth *KeycloakAuth, err error)
Make Request
func (*SandboxController) ReconcileUserCreation ¶
func (s *SandboxController) ReconcileUserCreation(userName string) (*SandboxUserAuthInfo, error)
ReconcileUserCreation create a user in sandbox and return a valid kubeconfig for user to be used for the tests
func (*SandboxController) ReconcileUserCreationStage ¶
func (s *SandboxController) ReconcileUserCreationStage(userName, toolchainApiUrl, keycloakUrl, offlineToken string) (*SandboxUserAuthInfo, error)
ReconcileUserCreation create a user in sandbox and return a valid kubeconfig for user to be used for the tests
func (*SandboxController) RegisterBannedSandboxUser ¶
func (s *SandboxController) RegisterBannedSandboxUser(userName string) (compliantUsername string, err error)
func (*SandboxController) RegisterDeactivatedSandboxUser ¶
func (s *SandboxController) RegisterDeactivatedSandboxUser(userName string) (compliantUsername string, err error)
func (*SandboxController) RegisterKeycloakUser ¶
func (k *SandboxController) RegisterKeycloakUser(userName string, keycloakToken string, realm string) (user *KeycloakUser, err error)
RegisterKeycloakUser create a username in keycloak service and return if succeed or not curl --location --request POST 'https://<keycloak-route>/auth/admin/realms/testrealm/users' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJyS2VyZnczU2tzV2hBUF9TeUJuMDRaRm5Pa09ITVFRRmpnOGhjaG12X3VVIn0.eyJleHAiOjE2NzQ3NTkyODksImlhdCI6MTY3NDc1OTIyOSwianRpIjoiY2ZjNzNjMjEtZDU5Mi00MmI4LTk4MWMtYjc5MjAxNzI3OTJhIiwiaXNzIjoiaHR0cHM6Ly9rZXljbG9hay1kZXYtc3NvLmFwcHMuY2x1c3Rlci05cm05ei45cm05ei5zYW5kYm94MTE3OS5vcGVudGxjLmNvbS9hdXRoL3JlYWxtcy9tYXN0ZXIiLCJzdWIiOiI4ODcxMmJjOS1kZDBiLTQxNTktOGE1Ny1mZTRjMDlmYzBhM2IiLCJ0eXAiOiJCZWFyZXIiLCJhenAiOiJhZG1pbi1jbGkiLCJzZXNzaW9uX3N0YXRlIjoiM2I3MDM5NmItMzk4Yy00MjQyLTljZDMtZGJlYjM0ZWVjYmE0IiwiYWNyIjoiMSIsInNjb3BlIjoicHJvZmlsZSBlbWFpbCIsInNpZCI6IjNiNzAzOTZiLTM5OGMtNDI0Mi05Y2QzLWRiZWIzNGVlY2JhNCIsImVtYWlsX3ZlcmlmaWVkIjpmYWxzZSwicHJlZmVycmVkX3VzZXJuYW1lIjoiYWRtaW4ifQ.GBHKQC0VZk4nEWVXDYC-Npk5Z503xlkDNbcrgd9nRTWcLZdD6HmgKnvGgoVYBssiSQyBYnAAqVQLGslbENjtohOlU4UxV0-Tsr2OpJUlKP0oMBVcna745UHAxU2JcVraVR4UkiryZbAOTJyUYKdhszqmfkGWPukTAo4lB2GO7HdfyU1UAwp8mzfLQ6WWV-LmeFjUUpwGOUed3Ztoa4DMBnVNFp7WHqoFyPO6xSTqq59ai__bJ8_8W7KfUTI6Rmfcno-6_9PtWFC8_bvs8bRBV7Xs8j4wn-7Y2-f9WTGC8EfUTacVGTf1ma-lBUEzWKodc7XH_5O18Huko3eS3RMDTA' \
--data-raw "{ "firstName":"user1", "lastName":"user1", "username":"user1", "enabled":"true", "email":"user1@test.com", "credentials":[ { "type":"password", "value":"user1", "temporary":"false" } ] }"
func (*SandboxController) RegisterSandboxUser ¶
func (s *SandboxController) RegisterSandboxUser(userName string) (compliantUsername string, err error)
func (*SandboxController) RegisterSandboxUserUserWithSignUp ¶
func (s *SandboxController) RegisterSandboxUserUserWithSignUp(userName string, userSignup *toolchainApi.UserSignup) (compliantUsername string, err error)
func (*SandboxController) UpdateUserSignup ¶
func (s *SandboxController) UpdateUserSignup(userSignupName string, modifyUserSignup func(us *toolchainApi.UserSignup)) (*toolchainApi.UserSignup, error)
type SandboxUserAuthInfo ¶
type SandboxUserAuthInfo struct { // Add a description about user UserName string // Returns the username namespace provisioned by toolchain UserNamespace string // Add a description about kubeconfigpath KubeconfigPath string // Url of user api to access kubernetes host ProxyUrl string // User token used as bearer to authenticate against kubernetes host UserToken string }
Return specs to authenticate with toolchain proxy