Documentation ¶
Index ¶
- func AssertEquals[T comparable](t *testing.T, got T, expected T)
- func AssertNoError(t *testing.T, err error)
- func AssertNotNil[T comparable](t *testing.T, value T)
- func GetNextPort(t *testing.T, purpose string) int
- func RandomString(length int) string
- type KerberosHelper
- type KubernetesTestConfiguration
- type OIDCServerInstance
- type RegistryHelper
- type S3Helper
- type SSHHelper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertEquals ¶
func AssertEquals[T comparable](t *testing.T, got T, expected T)
func AssertNoError ¶
func AssertNotNil ¶
func AssertNotNil[T comparable](t *testing.T, value T)
func GetNextPort ¶
GetNextPort returns the next free port a test service can bind to.
func RandomString ¶
Types ¶
type KerberosHelper ¶
type KerberosHelper interface { // Realm returns the Kerberos realm to authenticate with. Realm() string // KDCHost returns the IP address of the KDC service. KDCHost() string // KDCPort returns the port number the KDC service is running on. KDCPort() int // AdminUsername returns a Kerberos username which has admin privileges. AdminUsername() string // AdminPassword returns the password for the admin username from AdminUsername. AdminPassword() string // Get service keytab Keytab() []byte }
KerberosHelper is a helper which contains the information about the running Kerberos test service. The individual functions can be used to obtain kerberos parameters.
func Kerberos ¶
func Kerberos(t *testing.T) KerberosHelper
Kerberos starts a new test Kerberos instance. This Kerberos instance is available on the host system. The realm can be obtained from the returned helper object and will be accessible via public DNS. However, to decrease the need to rely on DNS working for your tests you should set up the KDC address explicitly, for example:
var krbConfigTemplate = `[libdefaults] dns_lookup_realm = false dns_lookup_kdc = false [realms] %s = { kdc = %s:%d } [domain_realm]` func TestMe(t *testing.T) { krb := test.Kerberos(t) krbConfig := fmt.Sprintf( krbConfigTemplate, krb.Realm(), krb.KDCHost(), krb.KDCPort(), ) // Do more Kerberos stuff }
type KubernetesTestConfiguration ¶
type KubernetesTestConfiguration struct { // Host contains the IP, IP and port, or URL to connect to. Host string // ServerName contains the host name against which the servers certificate should be validated. ServerName string // CACert contains the clusters CA certificate in PEM format. CACert string // UserCert contains the users certificate in PEM format. UserCert string // UserKey contains the users private key in PEM format. UserKey string }
KubernetesTestConfiguration holds the credentials to the Kubernetes cluster that can be used for testing.
func Kubernetes ¶
func Kubernetes(t *testing.T) KubernetesTestConfiguration
Kubernetes launches a Kubernetes-in-Docker cluster for testing purposes. The returned string is the path to the kubeconfig file. This function MAY block until enough resources become available to run the Kubernetes cluster. This function MAY return a shared Kubernetes cluster.
type OIDCServerInstance ¶
type OIDCServerInstance interface { BaseURL() string AuthorizationEndpoint() string TokenEndpoint() string UserinfoEndpoint() string ClientID() string ClientSecret() string }
func OIDCServer ¶
func OIDCServer( t *testing.T, redirectURI *url.URL, ) OIDCServerInstance
type RegistryHelper ¶
type S3Helper ¶
type S3Helper interface { // URL returns the endpoint for the S3 connection. URL() string // AccessKey returns the access key ID that can be used to access the S3 service. AccessKey() string // SecretKey returns the secret access key that can be used to access the S3 service. SecretKey() string // Region returns the S3 region string to use. Region() string // PathStyle returns true if path-style access should be used. PathStyle() bool }
S3Helper gives access to an S3-compatible object storage.
type SSHHelper ¶
type SSHHelper interface { // Host returns the IP address of the running SSH service. Host() string // Port returns the port number of the running SSH service. Port() int // FingerprintSHA256 returns the SHA 256 fingerprint of the server. FingerprintSHA256() string // HostKey returns the private SSH host key. HostKey() []byte // Username returns the SSH username to use for connecting. Username() string // Password returns the SSH password to use for connecting. Password() string // HostKeyAlgorithms returns a list of usable host key algorithms. HostKeyAlgorithms() []string }
SSHHelper contains the details about a running SSH service.