testlib

package
v1.3.3-0...-f31c912 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2024 License: AGPL-3.0 Imports: 42 Imported by: 0

Documentation

Index

Constants

View Source
const MaxTimeDiff = 2 * time.Millisecond

MaxTimeDiff is used when writing tests comparing times. Timestamps suffer from being serialized/deserialized with different precisions, the final value might be a bit different from the initial one. If the difference is less than MaxTimeDiff, we consider the values equal.

Variables

This section is empty.

Functions

func AccessListCreationTest

func AccessListCreationTest(t *testing.T, clt *client.Client)

func AccessListDeletionDriftTest

func AccessListDeletionDriftTest(t *testing.T, clt *client.Client)

func AccessListMutateExistingTest

func AccessListMutateExistingTest(t *testing.T, clt *client.Client)

AccessListMutateExistingTest checks that the operator propagates the expiry from the existing access list to the new one it will upsert.

func AccessListUpdateTest

func AccessListUpdateTest(t *testing.T, clt *client.Client)

func CompareOptions

func CompareOptions(customOpts ...cmp.Option) []cmp.Option

CompareOptions builds comparison options by returning a slice of both default comparison options and optional custom ones for the test/resource.

func FastEventually

func FastEventually(t *testing.T, condition func() bool)

func FastEventuallyWithT

func FastEventuallyWithT(t *testing.T, condition func(collectT *assert.CollectT))

func LoginRuleCreationTest

func LoginRuleCreationTest(t *testing.T, clt *client.Client)

func LoginRuleDeletionDriftTest

func LoginRuleDeletionDriftTest(t *testing.T, clt *client.Client)

func LoginRuleUpdateTest

func LoginRuleUpdateTest(t *testing.T, clt *client.Client)

func StepByStep

func StepByStep(setup *TestSetup)

func ValidRandomResourceName

func ValidRandomResourceName(prefix string) string

Types

type ResourceTestingPrimitives

type ResourceTestingPrimitives[T resources.TeleportResource, K resources.TeleportKubernetesResource[T]] interface {
	Init(setup *TestSetup)
	SetupTeleportFixtures(context.Context) error
	// Interacting with the Teleport Resource
	CreateTeleportResource(context.Context, string) error
	GetTeleportResource(context.Context, string) (T, error)
	DeleteTeleportResource(context.Context, string) error
	// Interacting with the Kubernetes Resource
	CreateKubernetesResource(context.Context, string) error
	DeleteKubernetesResource(context.Context, string) error
	GetKubernetesResource(context.Context, string) (K, error)
	ModifyKubernetesResource(context.Context, string) error
	// Comparing both
	CompareTeleportAndKubernetesResource(T, K) (bool, string)
}

type TestOption

type TestOption func(*TestSetup)

func WithTeleportClient

func WithTeleportClient(clt *client.Client) TestOption

type TestSetup

type TestSetup struct {
	TeleportClient *client.Client
	K8sClient      kclient.Client
	K8sRestConfig  *rest.Config
	Namespace      *core.Namespace
	Operator       manager.Manager
	OperatorCancel context.CancelFunc
	OperatorName   string
	// contains filtered or unexported fields
}

func SetupTestEnv

func SetupTestEnv(t *testing.T, opts ...TestOption) *TestSetup

SetupTestEnv creates a Kubernetes server, a teleport server and starts the operator

func (*TestSetup) StartKubernetesOperator

func (s *TestSetup) StartKubernetesOperator(t *testing.T)

StartKubernetesOperator creates and start a new operator

func (*TestSetup) StopKubernetesOperator

func (s *TestSetup) StopKubernetesOperator()

Jump to

Keyboard shortcuts

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