testingutils

package
v0.0.0-...-8540621 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const TestOrgID string = "6ba7b810-9dad-11d1-80b4-00c04fd430c8"

TestOrgID is a test org valid UUID

View Source
const TestUserID string = "7ba7b810-9dad-11d1-80b4-00c04fd430c8"

TestUserID is a test user valid UUID

Variables

This section is empty.

Functions

func GenerateTestClaims

func GenerateTestClaims(t *testing.T) *jwtpb.JWTClaims

GenerateTestClaims generates valid test user claims valid for 60 minutes

func GenerateTestClaimsWithDuration

func GenerateTestClaimsWithDuration(t *testing.T, duration time.Duration, email string) *jwtpb.JWTClaims

GenerateTestClaimsWithDuration generates valid test user claims for a specified duration.

func GenerateTestClaimsWithEmail

func GenerateTestClaimsWithEmail(t *testing.T, email string) *jwtpb.JWTClaims

GenerateTestClaimsWithEmail generates valid test user claims for the given email.

func GenerateTestJWTToken

func GenerateTestJWTToken(t *testing.T, signingKey string) string

GenerateTestJWTToken generates valid tokens for testing.

func GenerateTestJWTTokenWithDuration

func GenerateTestJWTTokenWithDuration(t *testing.T, signingKey string, timeout time.Duration) string

GenerateTestJWTTokenWithDuration generates valid tokens for testing with the specified duration.

func GenerateTestServiceClaims

func GenerateTestServiceClaims(t *testing.T, service string) *jwtpb.JWTClaims

GenerateTestServiceClaims generates valid test service claims for a specified duration.

func MustStartTestNATS

func MustStartTestNATS(t *testing.T) (*nats.Conn, func())

MustStartTestNATS starts up a NATS server at an open port.

func NewMockGCSClient

func NewMockGCSClient(buckets map[string]*MockGCSBucket) stiface.Client

NewMockGCSClient creates a new mock client for GCS.

func SetupEtcd

func SetupEtcd() (*clientv3.Client, func(), error)

SetupEtcd starts up an embedded etcd server on some free ports.

func SignPBClaims

func SignPBClaims(t *testing.T, claims *jwtpb.JWTClaims, signingKey string) string

SignPBClaims signs our protobuf claims after converting to json.

Types

type MockContext

type MockContext struct{}

MockContext provides a mock context for testing.

func (MockContext) Deadline

func (ctx MockContext) Deadline() (time.Time, bool)

Deadline returns the deadline for the mock context.

func (MockContext) Done

func (ctx MockContext) Done() <-chan struct{}

Done returns the done channel for the mock context.

func (MockContext) Err

func (ctx MockContext) Err() error

Err returns the error for the mock context.

func (MockContext) Value

func (ctx MockContext) Value(key interface{}) interface{}

Value returns the value for the mock context.

type MockGCSBucket

type MockGCSBucket struct {
	// contains filtered or unexported fields
}

MockGCSBucket is a mock of a GCS storage bucket.

func NewMockGCSBucket

func NewMockGCSBucket(objects map[string]*MockGCSObject, attrs *storage.BucketAttrs) *MockGCSBucket

NewMockGCSBucket creates a new mock bucket for GCS.

type MockGCSBucketHandle

type MockGCSBucketHandle struct {
	stiface.BucketHandle
	// contains filtered or unexported fields
}

MockGCSBucketHandle is a mock of GCS storage client's BucketHandle.

func (MockGCSBucketHandle) Object

Object returns object handle from the given path.

type MockGCSClient

type MockGCSClient struct {
	stiface.Client
	// contains filtered or unexported fields
}

MockGCSClient is a mock of GCS's storage client.

func (*MockGCSClient) Bucket

func (c *MockGCSClient) Bucket(name string) stiface.BucketHandle

Bucket gets a mock gcs bucket.

type MockGCSObject

type MockGCSObject struct {
	// contains filtered or unexported fields
}

MockGCSObject is a mock of a GCS object, storing contents and attrs.

func NewMockGCSObject

func NewMockGCSObject(contents []byte, attrs *storage.ObjectAttrs) *MockGCSObject

NewMockGCSObject creates a new mock GCS object.

type MockGCSObjectHandle

type MockGCSObjectHandle struct {
	stiface.ObjectHandle
	// contains filtered or unexported fields
}

MockGCSObjectHandle is a mock of GCS storage client's ObjectHandle.

func (MockGCSObjectHandle) Attrs

Attrs returns a new Mocked attrs object.

func (MockGCSObjectHandle) NewReader

NewReader returns a new Reader for the object.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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