testing

package
v0.30.9 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2023 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssetAcmeDBFilePath added in v0.30.0

func AssetAcmeDBFilePath() string

AssetAcmeDBFilePath returns the path of the test contoso EDS database file.

func AssetDefaultConfigLocal

func AssetDefaultConfigLocal() config.Path

AssetDefaultConfigLocal returns the path of the default yaml config file that doesn't use an online bundle.

func AssetDefaultConfigOnline

func AssetDefaultConfigOnline() config.Path

AssetDefaultConfigOnline returns the path of the default yaml config file that uses an online bundle.

func AssetLocalBundle

func AssetLocalBundle() string

AssetLocalBundle returns the path of the default local bundle directory that contains test policies and data.

func AssetsDir

func AssetsDir() string

AssetsDir returns the directory containing test assets nolint: dogsled

func LogReadLine

func LogReadLine(reader *bufio.Reader, timeout time.Duration) (string, error)

LogReadLine reads and returns a single line from the given file. If a given timeout has passed, an error is returned.

func PortOpen

func PortOpen(listenAddress string) bool

PortOpen returns true if there's a socket listening on the specified listenAddress.

func PrettyPrintObject

func PrettyPrintObject(obj interface{}) string

PrettyPrintObject returns the JSON representation of any object; only useful for debugging.

Types

type DirectoryClient added in v0.30.0

type DirectoryClient struct {
	Model    dsm3.ModelClient
	Reader   dsr3.ReaderClient
	Writer   dsw3.WriterClient
	Importer dsi3.ImporterClient
	Exporter dse3.ExporterClient
}

type EngineHarness

type EngineHarness struct {
	Engine      *app.Topaz
	LogDebugger *LogDebugger
	// contains filtered or unexported fields
}

EngineHarness wraps an Aserto Runtime Engine so we can set it up easily and monitor its logs.

func SetupOffline

func SetupOffline(t *testing.T, configOverrides func(*config.Config)) *EngineHarness

SetupOffline sets up an engine that uses a runtime that loads offline bundles, from the assets directory.

func SetupOnline

func SetupOnline(t *testing.T, configOverrides func(*config.Config)) *EngineHarness

SetupOnline sets up an engine that uses a runtime that loads online bundles, from the online policy registry service.

func (*EngineHarness) Cleanup

func (h *EngineHarness) Cleanup()

Cleanup releases all resources the harness uses and shuts down servers and runtimes.

func (*EngineHarness) Context added in v0.0.8

func (h *EngineHarness) Context() context.Context

func (*EngineHarness) CreateClient

func (h *EngineHarness) CreateClient() *http.Client

CreateClient creates a new http client that can talk to the API.

func (*EngineHarness) CreateDirectoryClient added in v0.30.0

func (h *EngineHarness) CreateDirectoryClient(ctx context.Context) *DirectoryClient

func (*EngineHarness) CreateGRPCClient

func (h *EngineHarness) CreateGRPCClient() authz2.AuthorizerClient

func (*EngineHarness) Req

func (h *EngineHarness) Req(verb, path, tenantID, body string) (string, int)

type LogDebugger added in v0.0.7

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

func NewLogDebugger added in v0.0.7

func NewLogDebugger(t *testing.T, logName string) *LogDebugger

func (*LogDebugger) Contains added in v0.0.7

func (d *LogDebugger) Contains(message string) bool

func (*LogDebugger) Write added in v0.0.7

func (d *LogDebugger) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

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