test

package
v0.0.0-...-c29da01 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: MPL-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const AuthMethod = "consul-k8s-auth-method"
View Source
const ServiceAccountJWTToken = `` /* 1044-byte string literal not displayed */

Variables

This section is empty.

Functions

func CmpProtoIgnoreOrder

func CmpProtoIgnoreOrder() []cmp.Option

CmpProtoIgnoreOrder returns a slice of cmp.Option useful for comparing proto messages independent of the order of their repeated fields.

func GenerateServerCerts

func GenerateServerCerts(t *testing.T) (string, string, string)

GenerateServerCerts generates Consul CA and a server certificate and saves them to temp files. It returns file names in this order: CA certificate, server certificate, and server key.

func MockConnMgrForIPAndPort

func MockConnMgrForIPAndPort(t *testing.T, ip string, port int, enableGRPCConn bool) *consul.MockServerConnectionManager

func ResourceHasPersisted

func ResourceHasPersisted(t *testing.T, ctx context.Context, client pbresource.ResourceServiceClient, id *pbresource.ID)

ResourceHasPersisted checks that a recently written resource exists in the Consul state store with a valid version. This must be true before a resource is overwritten or deleted.

func ServiceAccountGetResponse

func ServiceAccountGetResponse(name, ns string) string

func SetupK8sAuthMethod

func SetupK8sAuthMethod(t *testing.T, consulClient *api.Client, serviceName, k8sServiceNS string)

SetupK8sAuthMethod create a k8s auth method and a binding rule in Consul for the given k8s service and namespace.

func SetupK8sAuthMethodV2

func SetupK8sAuthMethodV2(t *testing.T, consulClient *api.Client, serviceName, k8sServiceNS string)

SetupK8sAuthMethodV2 create a k8s auth method and a binding rule in Consul for the given k8s service and namespace.

func SetupK8sAuthMethodWithNamespaces

func SetupK8sAuthMethodWithNamespaces(t *testing.T, consulClient *api.Client, serviceName, k8sServiceNS, consulNS string, mirrorNS bool, nsPrefix string, useV2 bool)

SetupK8sAuthMethodWithNamespaces creates a k8s auth method and binding rule in Consul for the k8s service name and namespace. It sets up the auth method and the binding rule so that it works with consul namespaces.

func SetupK8sComponentAuthMethod

func SetupK8sComponentAuthMethod(t *testing.T, consulClient *api.Client, serviceAccountName, k8sComponentNS string)

SetupK8sComponentAuthMethod creates a k8s auth method, sample "acl:write" ACL policy, Role and BindingRule that allows a client using serviceAccount's JWT token to call "consul login".

func TokenReviewsResponse

func TokenReviewsResponse(name, ns string) string

Types

type TestServerClient

type TestServerClient struct {
	TestServer     *testutil.TestServer
	APIClient      *api.Client
	Cfg            *consul.Config
	Watcher        consul.ServerConnectionManager
	ResourceClient pbresource.ResourceServiceClient
}

func TestServerWithMockConnMgrWatcher

func TestServerWithMockConnMgrWatcher(t *testing.T, callback testutil.ServerConfigCallback) *TestServerClient

Jump to

Keyboard shortcuts

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