test_utils

package
v0.0.0-...-e150be1 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2025 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateJWK

func GenerateJWK() (jwk.Key, jwk.Set, string, error)

GenerateJWK generates a JWK private key and a corresponding JWKS public key, and the string representation of the public key

func GenerateJWKS

func GenerateJWKS() (string, error)

func GetUniqueAvailablePorts

func GetUniqueAvailablePorts(count int) ([]int, error)

getUniqueAvailablePorts returns `count` unique, available ports. **WARNING**: There is a small race condition between getting the list of available ports and actually binding to them in whatever service uses these values. Be warned they may (but are hopefully unlikely to) disappear before you can use them!

func InitClient

func InitClient(t *testing.T, initCfg map[string]any)

Initialize the client for a unit test

Will set the configuration to a temporary directory (to avoid pulling in global configuration) and set some arbitrary viper configurations

func MockFederationRoot

func MockFederationRoot(t *testing.T, fInfo *pelican_url.FederationDiscovery, kSet *jwk.Set)

Create a mock federation root that can respond to requests for metadata and federation keys

func MockIssuer

func MockIssuer(t *testing.T, kSet *jwk.Set) string

Create a mock issuer that responds to request for /.well-known/openid-configuration and /.well-known/issuer.jwks

func RegistryMockup

func RegistryMockup(t *testing.T, prefix string) *httptest.Server

For these tests, we only need to lookup key locations. Create a dummy registry that only returns the jwks_uri location for the given key. Once a server is instantiated, it will only return locations for the provided prefix. To change prefixes, create a new registry mockup.

func TestContext

func TestContext(ictx context.Context, t *testing.T) (ctx context.Context, cancel context.CancelFunc, egrp *errgroup.Group)

func WriteBigBuffer

func WriteBigBuffer(t *testing.T, fp io.WriteCloser, sizeMB int) (size int)

Writes a file at least the specified size in MB

Types

This section is empty.

Jump to

Keyboard shortcuts

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