testkit

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2020 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package testkit provides constants, functions, and types which provide common necessities for the tests in multple sub-commands.

Index

Constants

View Source
const (
	// Prefix is prepended to most reusable data values to clarify their origin
	// when viewing them in error messages.
	Prefix = "kubeauth-testkit"

	ClusterName         = Prefix + "-explicit-cluster"
	ClusterRoleBindName = Prefix + "cluster-role-bind"
	ClusterRoleName     = Prefix + "cluster-role"
	ConfigFilename      = Prefix + "-kubeconfig"
	ContextName         = Prefix + "-explicit-context"
	GroupName           = Prefix + "-group"
	Namespace           = Prefix + "-explicit-namespace"
	ServiceAccountName  = Prefix + "-test-sa"

	CurrentClusterName = Prefix + "-current-cluster"
	CurrentContextName = Prefix + "-current-context"
	CurrentNamespace   = Prefix + "-current-namespace"
	Username           = Prefix + "-username"

	AllNamspacesEnabled  = true
	AllNamspacesDisabled = false
	Exists               = true
	NotExists            = false

	RoleBindName              = Prefix + "role-bind"
	RoleName                  = Prefix + "role"
	SecretNameSuffix          = "-token-1abcd"
	Server                    = Prefix + "-server"
	ServiceAccountSubjectName = Prefix + "-test-sa-subject"
	TokenSuffix               = "-token-1abcd"
)

Variables

This section is empty.

Functions

func Ctx

func Ctx() context.Context

Ctx returns a common-case value for expected call parameters.

func NewConfigFile

func NewConfigFile(filename, context, cluster, namespace string) *cage_k8s_config.File

NewConfigFile returns a minimal File object which supports two modes: creation of a file which only has "current" values because the test case will use values of flags like --context, or creation of a file which contains both the "current" values and an additional context matching the input context/namespace value.

func NewNamespace

func NewNamespace(name string) *core.Namespace

NewNamespace returns a namespace object with common-case fields initialized.

Types

type HandlerKit

type HandlerKit struct {
	*mock_handler.HandlerKit

	ApiClientset     *mock_core.Clientset
	ConfigClient     *mock_config.MockClient
	IdentityRegistry *mock_identity.Registry

	// ClusterName is the expected effective value after flag/default processing is complete.
	ClusterName string

	// ContextName is the expected effective value after flag/default processing is complete.
	ContextName string

	// Namespace is the expected effective value after flag/default processing is complete.
	Namespace string
}

HandlerKit provides an embeddable starting point for sub-commands' own HandlerKit implementations to build on, providing setup for common mocks via NewHandlerKit.

func NewHandlerKit

func NewHandlerKit(t *testing.T) *HandlerKit

NewHandlerKit returns a kit with mocks required by multiple sub-commands in order to reduce their boilerplate.

type QueryResultset

type QueryResultset struct {
	CoreGroup           *cage_k8s_identity.IdentityList
	CoreUser            *cage_k8s_identity.IdentityList
	RoleSubject         *cage_k8s_identity.IdentityList
	ClusterRoleSubject  *cage_k8s_identity.IdentityList
	ServiceAccountUser  *cage_k8s_identity.IdentityList
	ServiceAccountGroup *cage_k8s_identity.IdentityList
	ConfigUser          *cage_k8s_identity.IdentityList
}

func NewQueryResultset

func NewQueryResultset() QueryResultset

Jump to

Keyboard shortcuts

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