spiretest

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 18, 2023 License: Apache-2.0 Imports: 25 Imported by: 0

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

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 ...interface{}) bool

func AssertGRPCStatusHasPrefix

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

func AssertHasPrefix

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

func AssertLastLogs

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

func AssertLogs

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

func AssertLogsAnyOrder

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

func AssertLogsContainEntries

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

func AssertProtoEqual

func AssertProtoEqual(tb testing.TB, expected, actual proto.Message, msgAndArgs ...interface{}) bool

func AssertProtoListEqual

func AssertProtoListEqual(tb testing.TB, expected, actual interface{}) bool

func CreateCertificate

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

func FileNotFound

func FileNotFound() string

func NewAPIServer

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

func NewAPIServerWithMiddleware

func NewAPIServerWithMiddleware(t *testing.T, registerFn func(s *grpc.Server), server *grpc.Server) (*grpc.ClientConn, func())

func PathNotFound

func PathNotFound() string

func RequireErrorContains

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

func RequireErrorPrefix

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 ...interface{})

func RequireGRPCStatusHasPrefix

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

func RequireProtoEqual

func RequireProtoEqual(tb testing.TB, expected, actual proto.Message, msgAndArgs ...interface{})

func RequireProtoListEqual

func RequireProtoListEqual(tb testing.TB, expected, actual interface{})

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

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

func ServeGRPCServerOnTempUDSSocket

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

func ServeGRPCServerOnUDSSocket

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

func SocketFileNotFound

func SocketFileNotFound() string

func StartGRPCServer

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

func StartGRPCUDSSocketServer

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

func StartWorkloadAPI

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

func StartWorkloadAPIOnUDSSocket

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

func TempDir

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

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 ...interface{}) bool

func (*Suite) AssertProtoListEqual

func (s *Suite) AssertProtoListEqual(expected, actual interface{}) bool

func (*Suite) Cleanup

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 interface{})

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