Documentation ¶
Index ¶
- Constants
- func APIUserToKubermaticUser(user apiv1.User) *kubermaticv1.User
- func BuildSeeds() provider.SeedsGetter
- func CheckStatusCode(wantStatusCode int, recorder *httptest.ResponseRecorder, t *testing.T)
- func CompareVersions(t *testing.T, versions, expected []*apiv1.MasterVersion)
- func CompareWithResult(t *testing.T, res *httptest.ResponseRecorder, response string)
- func CreateTestEndpoint(user apiv1.User, kubeObjects, kubermaticObjects []runtime.Object, ...) (http.Handler, error)
- func DefaultCreationTimestamp() time.Time
- func GenAPIUser(name, email string) *apiv1.User
- func GenBinding(projectID, email, group string) *kubermaticv1.UserProjectBinding
- func GenBlacklistTokenSecret(name string, tokens []byte) *corev1.Secret
- func GenCluster(id string, name string, projectID string, creationTime time.Time, ...) *kubermaticv1.Cluster
- func GenDefaultAPIUser() *apiv1.User
- func GenDefaultAdminAPIUser() *apiv1.User
- func GenDefaultCluster() *kubermaticv1.Cluster
- func GenDefaultExpiry() (apiv1.Time, error)
- func GenDefaultKubermaticObjects(objs ...runtime.Object) []runtime.Object
- func GenDefaultOwnerBinding() *kubermaticv1.UserProjectBinding
- func GenDefaultPreset() *kubermaticv1.Preset
- func GenDefaultProject() *kubermaticv1.Project
- func GenDefaultSaToken(projectID, saID, name, id string) *corev1.Secret
- func GenDefaultSettings() *kubermaticv1.KubermaticSetting
- func GenDefaultUser() *kubermaticv1.User
- func GenDefaultVersions() []*version.Version
- func GenInactiveServiceAccount(id, name, group, projectName string) *kubermaticv1.User
- func GenProject(name, phase string, creationTime time.Time, oRef ...metav1.OwnerReference) *kubermaticv1.Project
- func GenServiceAccount(id, name, group, projectName string) *kubermaticv1.User
- func GenTestAddon(name string, variables *runtime.RawExtension, cluster *kubermaticv1.Cluster, ...) *kubermaticv1.Addon
- func GenTestEvent(eventName, eventType, eventReason, eventMessage, kind, uid string) *corev1.Event
- func GenTestMachine(name, rawProviderSpec string, labels map[string]string, ...) *clusterv1alpha1.Machine
- func GenTestMachineDeployment(name, rawProviderSpec string, selector map[string]string, dynamicConfig bool) *clusterv1alpha1.MachineDeployment
- func GenTestSeed() *kubermaticv1.Seed
- func GenUser(id, name, email string) *kubermaticv1.User
- func GenerateTestKubeconfig(clusterID, token string) string
- func GetUser(email, id, name string) apiv1.User
- type ClientsSets
- type FakePrivilegedProjectProvider
- func (f *FakePrivilegedProjectProvider) DeleteUnsecured(projectInternalName string) error
- func (f *FakePrivilegedProjectProvider) GetUnsecured(projectInternalName string, options *provider.ProjectGetOptions) (*kubermaticapiv1.Project, error)
- func (f *FakePrivilegedProjectProvider) UpdateUnsecured(project *kubermaticapiv1.Project) (*kubermaticapiv1.Project, error)
- type FakeProjectProvider
- func (f *FakeProjectProvider) Delete(userInfo *provider.UserInfo, projectInternalName string) error
- func (f *FakeProjectProvider) Get(userInfo *provider.UserInfo, projectInternalName string, ...) (*kubermaticapiv1.Project, error)
- func (f *FakeProjectProvider) List(options *provider.ProjectListOptions) ([]*kubermaticapiv1.Project, error)
- func (f *FakeProjectProvider) New(user *kubermaticapiv1.User, name string, labels map[string]string) (*kubermaticapiv1.Project, error)
- func (f *FakeProjectProvider) Update(userInfo *provider.UserInfo, newProject *kubermaticapiv1.Project) (*kubermaticapiv1.Project, error)
- type IssuerVerifier
- func (o *IssuerVerifier) AuthCodeURL(state string, offlineAsScope bool, scopes ...string) string
- func (o *IssuerVerifier) Exchange(ctx context.Context, code string) (auth.OIDCToken, error)
- func (o *IssuerVerifier) Extract(_ *http.Request) (string, error)
- func (o *IssuerVerifier) Verify(ctx context.Context, token string) (auth.TokenClaims, error)
- type NewAddonSliceWrapper
- type NewClusterV1SliceWrapper
- type NewRoleNameSliceWrapper
- type NewSSHKeyV1SliceWrapper
- type NewServiceAccountTokenV1SliceWrapper
- type NewServiceAccountV1SliceWrapper
- type NewUserV1SliceWrapper
- type NodeV1SliceWrapper
- type OicdProvider
- type ProjectV1SliceWrapper
Constants ¶
const ( // AuthorizationCode represents a shared secret used by IssuerVerifier // TODO: consider injecting it into IssuerVerifier AuthorizationCode = "fakeCode" // IDToken represents a shared fake token IDToken = "fakeTokenId" IDViewerToken = "fakeViewerTokenId" // IssuerURL holds test issuer URL IssuerURL = "url://dex" // IssuerClientID holds test issuer client ID IssuerClientID = "kubermatic" // IssuerClientSecret holds test issuer client secret IssuerClientSecret = "secret" )
const ( NoExistingFakeProject = "NoExistingFakeProject" NoExistingFakeProjectID = "NoExistingFakeProject-ID" ForbiddenFakeProject = "ForbiddenFakeProject" ForbiddenFakeProjectID = "ForbiddenFakeProject-ID" ExistingFakeProject = "ExistingFakeProject" ExistingFakeProjectID = "ExistingFakeProject-ID" ImpersonatedClientErrorMsg = "forbidden" )
const ( // UserID holds a test user ID UserID = "1233" // UserID2 holds a test user ID UserID2 = "1523" // UserName holds a test user name UserName = "user1" // UserName2 holds a test user name UserName2 = "user2" // UserEmail holds a test user email UserEmail = "john@acme.com" // UserEmail2 holds a test user email UserEmail2 = "bob@example.com" // ClusterID holds the test cluster ID ClusterID = "AbcClusterID" // DefaultClusterID holds the test default cluster ID DefaultClusterID = "defClusterID" // DefaultClusterName holds the test default cluster name DefaultClusterName = "defClusterName" // ProjectName holds the test project ID ProjectName = "my-first-project-ID" // TestDatacenter holds datacenter name TestSeedDatacenter = "us-central1" // TestServiceAccountHashKey authenticates the service account's token value using HMAC TestServiceAccountHashKey = "eyJhbGciOiJIUzI1NeyJhbGciOiJIUzI1N" // TestFakeToken signed JWT token with fake data TestFakeToken = "" /* 193-byte string literal not displayed */ // TestOSdomain OpenStack domain TestOSdomain = "OSdomain" // TestOSuserPass OpenStack user password TestOSuserPass = "OSpass" // TestOSuserName OpenStack user name TestOSuserName = "OSuser" // TestFakeCredential Fake provider credential name TestFakeCredential = "fake" // RequiredEmailDomain required domain for predefined credentials RequiredEmailDomain = "acme.com" )
Variables ¶
This section is empty.
Functions ¶
func APIUserToKubermaticUser ¶
func APIUserToKubermaticUser(user apiv1.User) *kubermaticv1.User
APIUserToKubermaticUser simply converts apiv1.User to kubermaticv1.User type
func BuildSeeds ¶
func BuildSeeds() provider.SeedsGetter
func CheckStatusCode ¶
func CheckStatusCode(wantStatusCode int, recorder *httptest.ResponseRecorder, t *testing.T)
func CompareVersions ¶
func CompareVersions(t *testing.T, versions, expected []*apiv1.MasterVersion)
func CompareWithResult ¶
func CompareWithResult(t *testing.T, res *httptest.ResponseRecorder, response string)
CompareWithResult a convenience function for comparing http.Body content with response
func CreateTestEndpoint ¶
func CreateTestEndpoint(user apiv1.User, kubeObjects, kubermaticObjects []runtime.Object, versions []*version.Version, updates []*version.Update, routingFunc newRoutingFunc) (http.Handler, error)
CreateTestEndpoint does exactly the same as CreateTestEndpointAndGetClients except it omits ClientsSets when returning
func DefaultCreationTimestamp ¶
DefaultCreationTimestamp returns default test timestamp
func GenBinding ¶
func GenBinding(projectID, email, group string) *kubermaticv1.UserProjectBinding
GenBinding generates a binding
func GenBlacklistTokenSecret ¶
func GenCluster ¶
func GenCluster(id string, name string, projectID string, creationTime time.Time, modifiers ...func(*kubermaticv1.Cluster)) *kubermaticv1.Cluster
func GenDefaultAPIUser ¶
GenDefaultAPIUser generates a default API user
func GenDefaultAdminAPIUser ¶
GenDefaultAdminAPIUser generates a default admin API user
func GenDefaultCluster ¶
func GenDefaultCluster() *kubermaticv1.Cluster
func GenDefaultExpiry ¶
func GenDefaultKubermaticObjects ¶
GenDefaultKubermaticObjects generates default kubermatic object
func GenDefaultOwnerBinding ¶
func GenDefaultOwnerBinding() *kubermaticv1.UserProjectBinding
GenDefaultOwnerBinding generates default owner binding
func GenDefaultPreset ¶
func GenDefaultPreset() *kubermaticv1.Preset
func GenDefaultProject ¶
func GenDefaultProject() *kubermaticv1.Project
GenDefaultProject generates a default project
func GenDefaultSaToken ¶
func GenDefaultSettings ¶
func GenDefaultSettings() *kubermaticv1.KubermaticSetting
func GenDefaultUser ¶
func GenDefaultUser() *kubermaticv1.User
GenDefaultUser generates a default user
func GenDefaultVersions ¶
func GenInactiveServiceAccount ¶
func GenInactiveServiceAccount(id, name, group, projectName string) *kubermaticv1.User
GenInactiveServiceAccount generates a Service Account resource
func GenProject ¶
func GenProject(name, phase string, creationTime time.Time, oRef ...metav1.OwnerReference) *kubermaticv1.Project
GenProject generates new empty project
func GenServiceAccount ¶
func GenServiceAccount(id, name, group, projectName string) *kubermaticv1.User
func GenTestAddon ¶
func GenTestAddon(name string, variables *runtime.RawExtension, cluster *kubermaticv1.Cluster, creationTime time.Time) *kubermaticv1.Addon
func GenTestEvent ¶
func GenTestMachine ¶
func GenTestMachine(name, rawProviderSpec string, labels map[string]string, ownerRef []metav1.OwnerReference) *clusterv1alpha1.Machine
func GenTestMachineDeployment ¶
func GenTestMachineDeployment(name, rawProviderSpec string, selector map[string]string, dynamicConfig bool) *clusterv1alpha1.MachineDeployment
func GenTestSeed ¶
func GenTestSeed() *kubermaticv1.Seed
func GenUser ¶
func GenUser(id, name, email string) *kubermaticv1.User
GenUser generates a User resource note if the id is empty then it will be auto generated
func GenerateTestKubeconfig ¶
GenerateTestKubeconfig returns test kubeconfig yaml structure
Types ¶
type ClientsSets ¶
type ClientsSets struct { FakeKubermaticClient *kubermaticfakeclentset.Clientset FakeClient ctrlruntimeclient.Client // this client is used for unprivileged methods where impersonated client is used FakeKubernetesCoreClient kubernetesclientset.Interface TokenAuthenticator serviceaccount.TokenAuthenticator TokenGenerator serviceaccount.TokenGenerator }
ClientsSets a simple wrapper that holds fake client sets
func CreateTestEndpointAndGetClients ¶
func CreateTestEndpointAndGetClients(user apiv1.User, seedsGetter provider.SeedsGetter, kubeObjects, machineObjects, kubermaticObjects []runtime.Object, versions []*version.Version, updates []*version.Update, routingFunc newRoutingFunc) (http.Handler, *ClientsSets, error)
CreateTestEndpointAndGetClients is a convenience function that instantiates fake providers and sets up routes for the tests
type FakePrivilegedProjectProvider ¶
type FakePrivilegedProjectProvider struct { }
func NewFakePrivilegedProjectProvider ¶
func NewFakePrivilegedProjectProvider() *FakePrivilegedProjectProvider
func (*FakePrivilegedProjectProvider) DeleteUnsecured ¶
func (f *FakePrivilegedProjectProvider) DeleteUnsecured(projectInternalName string) error
DeleteUnsecured deletes any given project This function is unsafe in a sense that it uses privileged account to delete project with the given name
func (*FakePrivilegedProjectProvider) GetUnsecured ¶
func (f *FakePrivilegedProjectProvider) GetUnsecured(projectInternalName string, options *provider.ProjectGetOptions) (*kubermaticapiv1.Project, error)
GetUnsecured returns the project with the given name This function is unsafe in a sense that it uses privileged account to get project with the given name
func (*FakePrivilegedProjectProvider) UpdateUnsecured ¶
func (f *FakePrivilegedProjectProvider) UpdateUnsecured(project *kubermaticapiv1.Project) (*kubermaticapiv1.Project, error)
UpdateUnsecured update an existing project and returns it This function is unsafe in a sense that it uses privileged account to update project
type FakeProjectProvider ¶
type FakeProjectProvider struct { }
func NewFakeProjectProvider ¶
func NewFakeProjectProvider() *FakeProjectProvider
func (*FakeProjectProvider) Delete ¶
func (f *FakeProjectProvider) Delete(userInfo *provider.UserInfo, projectInternalName string) error
Delete deletes the given project as the given user
Note: Before deletion project's status.phase is set to ProjectTerminating
func (*FakeProjectProvider) Get ¶
func (f *FakeProjectProvider) Get(userInfo *provider.UserInfo, projectInternalName string, options *provider.ProjectGetOptions) (*kubermaticapiv1.Project, error)
Get returns the project with the given name
func (*FakeProjectProvider) List ¶
func (f *FakeProjectProvider) List(options *provider.ProjectListOptions) ([]*kubermaticapiv1.Project, error)
List gets a list of projects, by default it returns all resources. If you want to filter the result please set ProjectListOptions
Note that the list is taken from the cache
func (*FakeProjectProvider) New ¶
func (f *FakeProjectProvider) New(user *kubermaticapiv1.User, name string, labels map[string]string) (*kubermaticapiv1.Project, error)
func (*FakeProjectProvider) Update ¶
func (f *FakeProjectProvider) Update(userInfo *provider.UserInfo, newProject *kubermaticapiv1.Project) (*kubermaticapiv1.Project, error)
Update update an existing project and returns it
type IssuerVerifier ¶
type IssuerVerifier struct {
// contains filtered or unexported fields
}
IssuerVerifier is a test stub that mocks OIDC responses
func NewFakeOIDCClient ¶
func NewFakeOIDCClient(user apiv1.User) *IssuerVerifier
NewFakeOIDCClient returns fake OIDC issuer and verifier
func (*IssuerVerifier) AuthCodeURL ¶
func (o *IssuerVerifier) AuthCodeURL(state string, offlineAsScope bool, scopes ...string) string
AuthCodeURL returns a URL to OpenID provider's consent page
func (*IssuerVerifier) Extract ¶
func (o *IssuerVerifier) Extract(_ *http.Request) (string, error)
Extractor knows how to extract the ID token from the request
func (*IssuerVerifier) Verify ¶
func (o *IssuerVerifier) Verify(ctx context.Context, token string) (auth.TokenClaims, error)
Verify parses a raw ID Token, verifies it's been signed by the provider, preforms any additional checks depending on the Config, and returns the payload as TokenClaims.
type NewAddonSliceWrapper ¶
NewAddonSliceWrapper wraps []apiv1.Addon to provide convenient methods for tests
func (*NewAddonSliceWrapper) DecodeOrDie ¶
func (k *NewAddonSliceWrapper) DecodeOrDie(r io.Reader, t *testing.T) *NewAddonSliceWrapper
DecodeOrDie reads and decodes json data from the reader
func (NewAddonSliceWrapper) EqualOrDie ¶
func (k NewAddonSliceWrapper) EqualOrDie(expected NewAddonSliceWrapper, t *testing.T)
EqualOrDie compares whether expected collection is equal to the actual one
func (NewAddonSliceWrapper) Sort ¶
func (k NewAddonSliceWrapper) Sort()
Sort sorts the collection by CreationTimestamp
type NewClusterV1SliceWrapper ¶
NewClusterV1SliceWrapper wraps []apiv1.Cluster to provide convenient methods for tests
func (*NewClusterV1SliceWrapper) DecodeOrDie ¶
func (k *NewClusterV1SliceWrapper) DecodeOrDie(r io.Reader, t *testing.T) *NewClusterV1SliceWrapper
DecodeOrDie reads and decodes json data from the reader
func (NewClusterV1SliceWrapper) EqualOrDie ¶
func (k NewClusterV1SliceWrapper) EqualOrDie(expected NewClusterV1SliceWrapper, t *testing.T)
EqualOrDie compares whether expected collection is equal to the actual one
func (NewClusterV1SliceWrapper) Sort ¶
func (k NewClusterV1SliceWrapper) Sort()
Sort sorts the collection by CreationTimestamp
type NewRoleNameSliceWrapper ¶
NewRoleNameSliceWrapper wraps []apiv1.RoleName to provide convenient methods for tests
func (*NewRoleNameSliceWrapper) DecodeOrDie ¶
func (k *NewRoleNameSliceWrapper) DecodeOrDie(r io.Reader, t *testing.T) *NewRoleNameSliceWrapper
DecodeOrDie reads and decodes json data from the reader
func (NewRoleNameSliceWrapper) EqualOrDie ¶
func (k NewRoleNameSliceWrapper) EqualOrDie(expected NewRoleNameSliceWrapper, t *testing.T)
EqualOrDie compares whether expected collection is equal to the actual one
func (NewRoleNameSliceWrapper) Sort ¶
func (k NewRoleNameSliceWrapper) Sort()
Sort sorts the collection by CreationTimestamp
type NewSSHKeyV1SliceWrapper ¶
NewSSHKeyV1SliceWrapper wraps []apiv1.SSHKey to provide convenient methods for tests
func (*NewSSHKeyV1SliceWrapper) DecodeOrDie ¶
func (k *NewSSHKeyV1SliceWrapper) DecodeOrDie(r io.Reader, t *testing.T) *NewSSHKeyV1SliceWrapper
DecodeOrDie reads and decodes json data from the reader
func (NewSSHKeyV1SliceWrapper) EqualOrDie ¶
func (k NewSSHKeyV1SliceWrapper) EqualOrDie(expected NewSSHKeyV1SliceWrapper, t *testing.T)
EqualOrDie compares whether expected collection is equal to the actual one
func (NewSSHKeyV1SliceWrapper) Sort ¶
func (k NewSSHKeyV1SliceWrapper) Sort()
Sort sorts the collection by CreationTimestamp
type NewServiceAccountTokenV1SliceWrapper ¶
type NewServiceAccountTokenV1SliceWrapper []apiv1.PublicServiceAccountToken
NewServiceAccountTokenV1SliceWrapper wraps []apiv1.ServiceAccountToken to provide convenient methods for tests
func (*NewServiceAccountTokenV1SliceWrapper) DecodeOrDie ¶
func (k *NewServiceAccountTokenV1SliceWrapper) DecodeOrDie(r io.Reader, t *testing.T) *NewServiceAccountTokenV1SliceWrapper
DecodeOrDie reads and decodes json data from the reader
func (NewServiceAccountTokenV1SliceWrapper) EqualOrDie ¶
func (k NewServiceAccountTokenV1SliceWrapper) EqualOrDie(expected NewServiceAccountTokenV1SliceWrapper, t *testing.T)
EqualOrDie compares whether expected collection is equal to the actual one
func (NewServiceAccountTokenV1SliceWrapper) Sort ¶
func (k NewServiceAccountTokenV1SliceWrapper) Sort()
Sort sorts the collection by name
type NewServiceAccountV1SliceWrapper ¶
type NewServiceAccountV1SliceWrapper []apiv1.ServiceAccount
NewServiceAccountV1SliceWrapper wraps []apiv1.ServiceAccount to provide convenient methods for tests
func (*NewServiceAccountV1SliceWrapper) DecodeOrDie ¶
func (k *NewServiceAccountV1SliceWrapper) DecodeOrDie(r io.Reader, t *testing.T) *NewServiceAccountV1SliceWrapper
DecodeOrDie reads and decodes json data from the reader
func (NewServiceAccountV1SliceWrapper) EqualOrDie ¶
func (k NewServiceAccountV1SliceWrapper) EqualOrDie(expected NewServiceAccountV1SliceWrapper, t *testing.T)
EqualOrDie compares whether expected collection is equal to the actual one
func (NewServiceAccountV1SliceWrapper) Sort ¶
func (k NewServiceAccountV1SliceWrapper) Sort()
Sort sorts the collection by name
type NewUserV1SliceWrapper ¶
NewUserV1SliceWrapper wraps []apiv1.User to provide convenient methods for tests
func (*NewUserV1SliceWrapper) DecodeOrDie ¶
func (k *NewUserV1SliceWrapper) DecodeOrDie(r io.Reader, t *testing.T) *NewUserV1SliceWrapper
DecodeOrDie reads and decodes json data from the reader
func (NewUserV1SliceWrapper) EqualOrDie ¶
func (k NewUserV1SliceWrapper) EqualOrDie(expected NewUserV1SliceWrapper, t *testing.T)
EqualOrDie compares whether expected collection is equal to the actual one
func (NewUserV1SliceWrapper) Sort ¶
func (k NewUserV1SliceWrapper) Sort()
Sort sorts the collection by CreationTimestamp
type NodeV1SliceWrapper ¶
NodeV1SliceWrapper wraps []apiv1.Node to provide convenient methods for tests
func (*NodeV1SliceWrapper) DecodeOrDie ¶
func (k *NodeV1SliceWrapper) DecodeOrDie(r io.Reader, t *testing.T) *NodeV1SliceWrapper
DecodeOrDie reads and decodes json data from the reader
func (NodeV1SliceWrapper) EqualOrDie ¶
func (k NodeV1SliceWrapper) EqualOrDie(expected NodeV1SliceWrapper, t *testing.T)
EqualOrDie compares whether expected collection is equal to the actual one
func (NodeV1SliceWrapper) Sort ¶
func (k NodeV1SliceWrapper) Sort()
Sort sorts the collection by CreationTimestamp
type OicdProvider ¶
type OicdProvider struct {
// contains filtered or unexported fields
}
OicdProvider is a test stub that mocks *oidc.Provider
func (*OicdProvider) Endpoint ¶
func (p *OicdProvider) Endpoint() oauth2.Endpoint
Endpoint returns the OAuth2 auth and token endpoints for the given provider.
type ProjectV1SliceWrapper ¶
ProjectV1SliceWrapper wraps []apiv1.Project to provide convenient methods for tests
func (*ProjectV1SliceWrapper) DecodeOrDie ¶
func (k *ProjectV1SliceWrapper) DecodeOrDie(r io.Reader, t *testing.T) *ProjectV1SliceWrapper
DecodeOrDie reads and decodes json data from the reader
func (ProjectV1SliceWrapper) EqualOrDie ¶
func (k ProjectV1SliceWrapper) EqualOrDie(expected ProjectV1SliceWrapper, t *testing.T)
EqualOrDie compares whether expected collection is equal to the actual one
func (ProjectV1SliceWrapper) Sort ¶
func (k ProjectV1SliceWrapper) Sort()
Sort sorts the collection by CreationTimestamp