spiretest

package
v1.8.9 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: Apache-2.0 Imports: 25 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EC256Key, _ = pemutil.ParseSigner([]byte(`-----BEGIN PRIVATE KEY-----
MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgcyW+Ne33t4e7HVxn
5aWdL02CcurRNixGgu1vVqQzq3+hRANCAASSQSfkTYd3+u8JEMJUw2Pd143QAOKP
24lWY34SXQInPaja544bc67U0dG0YCNozyAtZxIHFjV+t2HGThM8qNYg
-----END PRIVATE KEY-----
`))
	DefaultKey = EC256Key
)

Functions

func AssertErrorContains

func AssertErrorContains(tb testing.TB, err error, contains string) bool

func AssertErrorPrefix added in v1.0.0

func AssertErrorPrefix(tb testing.TB, err error, prefix string) bool

func AssertGRPCStatus

func AssertGRPCStatus(tb testing.TB, err error, code codes.Code, message string) bool

func AssertGRPCStatusContains

func AssertGRPCStatusContains(tb testing.TB, err error, code codes.Code, contains string, msgAndArgs ...any) bool

func AssertGRPCStatusHasPrefix added in v1.0.0

func AssertGRPCStatusHasPrefix(tb testing.TB, err error, code codes.Code, prefix string) bool

func AssertHasPrefix added in v1.2.1

func AssertHasPrefix(tb testing.TB, msg string, prefix string) bool

func AssertLastLogs added in v0.12.2

func AssertLastLogs(t *testing.T, entries []*logrus.Entry, expected []LogEntry)

func AssertLogs added in v0.10.1

func AssertLogs(t *testing.T, entries []*logrus.Entry, expected []LogEntry)

func AssertLogsAnyOrder added in v0.11.0

func AssertLogsAnyOrder(t *testing.T, entries []*logrus.Entry, expected []LogEntry)

func AssertLogsContainEntries added in v1.1.0

func AssertLogsContainEntries(t *testing.T, entries []*logrus.Entry, expectedEntries []LogEntry)

func AssertProtoEqual

func AssertProtoEqual(tb testing.TB, expected, actual proto.Message, msgAndArgs ...any) bool

func AssertProtoListEqual

func AssertProtoListEqual(tb testing.TB, expected, actual any) bool

func CreateCertificate

func CreateCertificate(tb testing.TB, tmpl, parent *x509.Certificate, pub, priv any) *x509.Certificate

func FileNotFound added in v1.2.0

func FileNotFound() string

func NewAPIServer added in v0.10.1

func NewAPIServer(tb testing.TB, registerFn func(s *grpc.Server), contextFn func(ctx context.Context) context.Context) (*grpc.ClientConn, func())

func NewAPIServerWithMiddleware added in v1.0.1

func NewAPIServerWithMiddleware(tb testing.TB, registerFn func(s *grpc.Server), server *grpc.Server) (*grpc.ClientConn, func())

func PathNotFound added in v1.2.0

func PathNotFound() string

func RequireErrorContains

func RequireErrorContains(tb testing.TB, err error, contains string)

func RequireErrorPrefix added in v1.0.0

func RequireErrorPrefix(tb testing.TB, err error, prefix string)

func RequireGRPCStatus

func RequireGRPCStatus(tb testing.TB, err error, code codes.Code, message string)

func RequireGRPCStatusContains

func RequireGRPCStatusContains(tb testing.TB, err error, code codes.Code, contains string, msgAndArgs ...any)

func RequireGRPCStatusHasPrefix added in v1.0.0

func RequireGRPCStatusHasPrefix(tb testing.TB, err error, code codes.Code, prefix string)

func RequireProtoEqual

func RequireProtoEqual(tb testing.TB, expected, actual proto.Message, msgAndArgs ...any)

func RequireProtoListEqual

func RequireProtoListEqual(tb testing.TB, expected, actual any)

func Run

func Run(t *testing.T, s suite.TestingSuite)

func SelfSignCertificate

func SelfSignCertificate(tb testing.TB, tmpl *x509.Certificate) (*x509.Certificate, crypto.Signer)

func SelfSignCertificateWithKey

func SelfSignCertificateWithKey(tb testing.TB, tmpl *x509.Certificate, key crypto.Signer) *x509.Certificate

func ServeGRPCServerOnListener added in v0.12.0

func ServeGRPCServerOnListener(t *testing.T, server *grpc.Server, listener net.Listener)

func ServeGRPCServerOnTempUDSSocket added in v1.2.2

func ServeGRPCServerOnTempUDSSocket(t *testing.T, server *grpc.Server) net.Addr

func ServeGRPCServerOnUDSSocket added in v1.2.2

func ServeGRPCServerOnUDSSocket(t *testing.T, server *grpc.Server, socketPath string) net.Addr

func SocketFileNotFound added in v1.2.0

func SocketFileNotFound() string

func StartGRPCServer added in v1.3.0

func StartGRPCServer(t *testing.T, registerFn func(s *grpc.Server)) net.Addr

func StartGRPCUDSSocketServer added in v1.2.2

func StartGRPCUDSSocketServer(t *testing.T, socketPath string, registerFn func(s *grpc.Server)) net.Addr

func StartWorkloadAPI added in v1.3.0

func StartWorkloadAPI(t *testing.T, server workload.SpiffeWorkloadAPIServer) net.Addr

func StartWorkloadAPIOnUDSSocket added in v1.2.2

func StartWorkloadAPIOnUDSSocket(t *testing.T, socketPath string, server workload.SpiffeWorkloadAPIServer) net.Addr

func TempDir added in v0.11.0

func TempDir(tb testing.TB) string

TempDir creates a temporary directory that is cleaned up when the test finishes. TODO: remove when go1.15 is out, which introduces a new method on *testing.T for this purpose.

Types

type LogEntry added in v0.10.1

type LogEntry struct {
	Level   logrus.Level
	Message string
	Data    logrus.Fields
}

type Suite

type Suite struct {
	suite.Suite
}

func (*Suite) AssertErrorContains

func (s *Suite) AssertErrorContains(err error, contains string) bool

func (*Suite) AssertGRPCStatus

func (s *Suite) AssertGRPCStatus(err error, code codes.Code, message string) bool

func (*Suite) AssertGRPCStatusContains

func (s *Suite) AssertGRPCStatusContains(err error, code codes.Code, contains string) bool

func (*Suite) AssertProtoEqual

func (s *Suite) AssertProtoEqual(expected, actual proto.Message, msgAndArgs ...any) bool

func (*Suite) AssertProtoListEqual

func (s *Suite) AssertProtoListEqual(expected, actual any) bool

func (*Suite) Cleanup added in v0.11.0

func (s *Suite) Cleanup(cleanup func())

func (*Suite) RequireErrorContains

func (s *Suite) RequireErrorContains(err error, contains string)

func (*Suite) RequireGRPCStatus

func (s *Suite) RequireGRPCStatus(err error, code codes.Code, message string)

func (*Suite) RequireGRPCStatusContains

func (s *Suite) RequireGRPCStatusContains(err error, code codes.Code, contains string)

func (*Suite) RequireProtoEqual

func (s *Suite) RequireProtoEqual(expected, actual proto.Message)

func (*Suite) RequireProtoListEqual

func (s *Suite) RequireProtoListEqual(expected, actual any)

func (*Suite) TempDir

func (s *Suite) TempDir() string

Jump to

Keyboard shortcuts

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