testutil

package
v2.12.2 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2025 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Overview

Package testutil needs to be documented.

TODO: document

Index

Constants

View Source
const DefaultTransformImage = "ubuntu:20.04"
View Source
const DexMockConnectorEmail = `[email protected]`

DexMockConnectorEmail is the identity returned for all requests to the mock Dex connector (see https://github.com/dexidp/dex/blob/c113df2730052e20881dd68561289f8ae121300b/connector/mock/connectortest.go#L21) Kilgore Trout is a recurring character of Kurt Vonnegut's

View Source
const (
	// RootToken is the hard-coded admin token used on all activated test clusters
	RootToken = "iamroot"
)

Variables

This section is empty.

Functions

func ActivateAuthClient

func ActivateAuthClient(tb testing.TB, c *client.APIClient, port ...string)

ActivateAuthClient activates the auth service in the test cluster, if it isn't already enabled

func AuthenticateClient

func AuthenticateClient(tb testing.TB, c *client.APIClient, subject string) *client.APIClient

AuthenticateClient creates a new authenticated pach client, without re-activating.

func AuthenticatedPachClient

func AuthenticatedPachClient(tb testing.TB, c *client.APIClient, subject string, port ...string) *client.APIClient

func BuildBindings

func BuildBindings(s ...string) *auth.RoleBinding

func BuildClusterBindings

func BuildClusterBindings(s ...string) *auth.RoleBinding

func CleanupEphemeralDB added in v2.10.0

func CleanupEphemeralDB(ctx context.Context, db *pachsql.DB, dbName string) error

CleanupEphemeralDB cleans up a database.

func CommitCnt

func CommitCnt(t *testing.T, c *client.APIClient, repo *pfs.Repo) int

CommitCnt uses 'c' to get the number of commits made to the repo 'repo'

func ConfigureOIDCProvider

func ConfigureOIDCProvider(t *testing.T, c *client.APIClient, unitTest bool) error

ConfigureOIDCProvider configures the identity service and the auth service to use a mock connector.

func CreateEphemeralDB

func CreateEphemeralDB(t testing.TB, db *pachsql.DB, dbName string)

CreateEphemeralDB creates a new database using db with a lifetime scoped to the test t.

func CreateEphemeralDBNontest added in v2.10.0

func CreateEphemeralDBNontest(ctx context.Context, db *pachsql.DB, dbName string) error

CreateEphemeralDBNontest creates a new database outside of a test.

func DebugFiles

func DebugFiles(t testing.TB, projectName, repoName string) (map[string]*globlib.Glob, []string)

func DeletePipelineRC

func DeletePipelineRC(t testing.TB, pipeline, namespace string)

DeletePipelineRC deletes the RC belonging to the pipeline 'pipeline'. This can be used to test PPS's robustness

func DexHost

func DexHost(c *client.APIClient) string

DexHost returns the address to access the identity server during tests

func DoOAuthExchange

func DoOAuthExchange(t testing.TB, pachClient, enterpriseClient *client.APIClient, loginURL string)

DoOAuthExchange does the OAuth dance to log in to the mock provider, given a login URL

func DoOAuthExchangeOnce added in v2.8.0

func DoOAuthExchangeOnce(t testing.TB, pachClient, enterpriseClient *client.APIClient, loginURL string) error

func GenerateEphemeralDBName

func GenerateEphemeralDBName() string

GenerateEphemeralDBName generates a random name suitable for use as a Postgres identifier

func GetKubeClient

func GetKubeClient(t testing.TB) *kube.Clientset

GetKubeClient connects to the Kubernetes API server either from inside the cluster or from a test binary running on a machine with kubectl (it will connect to the same cluster as kubectl)

func GetOIDCTokenForTrustedApp

func GetOIDCTokenForTrustedApp(t testing.TB, testClient *client.APIClient, unitTest bool) string

func GetProjectRoleBinding

func GetProjectRoleBinding(ctx context.Context, t *testing.T, c *client.APIClient, project string) *auth.RoleBinding

func GetRepoRoleBinding

func GetRepoRoleBinding(ctx context.Context, t *testing.T, c *client.APIClient, projectName, repoName string) *auth.RoleBinding

func Group

func Group(group string) string

func Listen added in v2.8.0

func Listen(t testing.TB) net.Listener

Listen creates a new net.Listener on localhost and ensures the listener is closed when the test exits

func LogHttpResponse

func LogHttpResponse(t testing.TB, response *http.Response, msg string)

func NewLoggingHTTPClient added in v2.7.0

func NewLoggingHTTPClient(t testing.TB) *http.Client

func OIDCOIDCConfig

func OIDCOIDCConfig(host, issuerPort, redirectPort string, local bool) *auth.OIDCConfig

OIDCOIDCConfig is an auth config which can be used to connect to the identity service in tests

func OpenDB

func OpenDB(t testing.TB, opts ...dbutil.Option) *pachsql.DB

OpenDB connects to a database using opts and returns it. The database will be closed at the end of the test.

func OpenDBURL

func OpenDBURL(t testing.TB, u pachsql.URL, password string) *pachsql.DB

OpenDBURL connects to a database using u and returns it. The database will be closed at the end of the test.

func PipelineNames

func PipelineNames(t *testing.T, c *client.APIClient, project string) []string

PipelineNames returns the names of all pipelines that 'c' gets from ListPipeline in the specified project.

func Pl

func Pl(projectName, pipelineName string) string

func RandomRobot

func RandomRobot(t *testing.T, c *client.APIClient, name string) (string, *client.APIClient)

func RepoInfoToName

func RepoInfoToName(repoInfo interface{}) interface{}

func RewriteRedirect

func RewriteRedirect(t testing.TB, resp *http.Response, host string) string

RewriteRedirect rewrites the Location header to point to the returned path at `host`

func RewriteURL

func RewriteURL(t testing.TB, urlStr, host string) string

RewriteURL rewrites the host and scheme in urlStr

func Robot

func Robot(robot string) string

func TSProtoOrDie

func TSProtoOrDie(t testing.TB, ts time.Time) *timestamppb.Timestamp

func UnauthenticatedPachClient

func UnauthenticatedPachClient(tb testing.TB, c *client.APIClient) *client.APIClient

UnauthenticatedPachClient returns a copy of the testing pach client with no auth token.

func User

func User(email string) string

Types

This section is empty.

Directories

Path Synopsis
Package random enables the caller to seed package rand based on the current time.
Package random enables the caller to seed package rand based on the current time.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳