Documentation
¶
Index ¶
- func FileOwner(t *testing.T, path string) (uid, gid uint32)
- func GenerateJWK() (jwk.Key, jwk.Set, string, error)
- func GenerateJWKS() (string, error)
- func GetTmpStoragePrefixDir(t *testing.T) string
- func GetUniqueAvailablePorts(count int) ([]int, error)
- func InitClient(t *testing.T, initCfg map[param.Param]any)
- func MockFederationRoot(t *testing.T, fInfo *pelican_url.FederationDiscovery, kSet *jwk.Set)
- func MockIssuer(t *testing.T, kSet *jwk.Set) string
- func RegistryMockup(t *testing.T, prefix string) *httptest.Server
- func SetupGlobalTestLogging() func()
- func SetupTestLogging(t *testing.T) func()
- func SkipUnlessPrivileged(t *testing.T)
- func SkipUnlessTestUsers(t *testing.T, usernames ...string)
- func TestContext(ictx context.Context, t *testing.T) (ctx context.Context, cancel context.CancelFunc, egrp *errgroup.Group)
- func WriteBigBuffer(t *testing.T, fp io.WriteCloser, sizeMB int) (size int)
- type TestLogHook
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateJWK ¶
GenerateJWK generates a JWK private key and a corresponding JWKS public key, and the string representation of the public key
func GenerateJWKS ¶
func GetTmpStoragePrefixDir ¶
Helper function for other tests who call server_utils.GetOriginExports() internally. This function gets a temp dir for export StoragePrefixes, whose existence is validated by server_utils.GetOriginExports(). The directory is created with 0777 permissions so the XRootD daemon user (which is "others" relative to the test process owner) has the read, write, and execute permissions needed for all origin capabilities.
func GetUniqueAvailablePorts ¶
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 ¶
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 param configurations. The initCfg map uses typed param constants as keys; each value is set via the param's typed Set method where possible (StringParam, BoolParam, etc.), falling back to param.Set for OpaqueParam or unknown types. Panics from type mismatches are caught and reported as test failures.
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 ¶
Create a mock issuer that responds to request for /.well-known/openid-configuration and /.well-known/issuer.jwks
func RegistryMockup ¶
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 SetupGlobalTestLogging ¶
func SetupGlobalTestLogging() func()
SetupGlobalTestLogging silences logrus output for an entire package's tests (for use in TestMain). It preserves existing logger settings and restores them when the returned cleanup is called.
func SetupTestLogging ¶
SetupTestLogging configures logrus to write to the test's log buffer. This should be called at the beginning of tests to ensure clean output. Returns a cleanup function that should be called with defer.
func SkipUnlessPrivileged ¶
SkipUnlessPrivileged skips the test if the process lacks CAP_SETUID or CAP_SETGID in its effective capability set.
func SkipUnlessTestUsers ¶
SkipUnlessTestUsers skips the test if any of the given usernames cannot be resolved via the system user database.
func TestContext ¶
func WriteBigBuffer ¶
Writes a file at least the specified size in MB
Types ¶
type TestLogHook ¶
type TestLogHook struct {
// contains filtered or unexported fields
}
TestLogHook forwards log entries to the test log buffer so they appear under the test's output (visible with -v or on failure) and never hit stdout/stderr directly.
func NewTestLogHook ¶
func NewTestLogHook(t *testing.T) *TestLogHook
NewTestLogHook creates a new TestLogHook that writes to testing.T's log buffer
func (*TestLogHook) Fire ¶
func (hook *TestLogHook) Fire(entry *logrus.Entry) error
Fire is called on every log entry
func (*TestLogHook) Levels ¶
func (hook *TestLogHook) Levels() []logrus.Level
Levels defines which log levels this hook applies to