testutils

package
v1.21.2 Latest Latest
Warning

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

Go to latest
Published: May 19, 2024 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const Secret = "0123456789101112"

Variables

This section is empty.

Functions

func ExpectMessage added in v1.16.0

func ExpectMessage(tb testing.TB, conn net.Conn, reader *bufio.Reader, expectMessage string) bool

func ExpectVersionAndReleaseHold added in v1.16.0

func ExpectVersionAndReleaseHold(tb testing.TB, conn net.Conn, reader *bufio.Reader) bool

func ReadLine

func ReadLine(tb testing.TB, conn net.Conn, reader *bufio.Reader) string

func SendAndExpectMessage added in v1.16.0

func SendAndExpectMessage(tb testing.TB, conn net.Conn, reader *bufio.Reader, sendMessage string, expectMessage string) bool

func SendMessage added in v1.16.0

func SendMessage(tb testing.TB, conn net.Conn, sendMessage string, args ...any) bool

func SetupResourceServer

func SetupResourceServer(tb testing.TB, clientListener net.Listener) (*httptest.Server, *url.URL, config.OAuth2Client, error)

func WaitUntilListening added in v1.21.0

func WaitUntilListening(tb testing.TB, listener net.Listener) error

Types

type Buffer added in v1.15.0

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

func (*Buffer) String added in v1.15.0

func (s *Buffer) String() string

String returns the contents of the unread portion of the buffer as a string. If the Buffer is a nil pointer, it returns "<nil>".

func (*Buffer) Write added in v1.15.0

func (s *Buffer) Write(p []byte) (int, error)

Write appends the contents of p to the buffer, growing the buffer as needed. It returns the number of bytes written.

type Logger

type Logger struct {
	*slog.Logger
	*Buffer
}

func NewTestLogger

func NewTestLogger() *Logger

func SetupMockEnvironment added in v1.13.0

func SetupMockEnvironment(ctx context.Context, tb testing.TB, conf config.Config) (config.Config, *openvpn.Client, net.Listener, *oauth2.Provider,
	*httptest.Server, *http.Client, *Logger, func(),
)

SetupMockEnvironment setups an OpenVPN and IDP mock

func (Logger) GetLogs added in v1.15.0

func (l Logger) GetLogs() string

type MockRoundTripper added in v1.18.0

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

func NewMockRoundTripper added in v1.18.0

func NewMockRoundTripper(rt http.RoundTripper) *MockRoundTripper

func (*MockRoundTripper) RoundTrip added in v1.18.0

func (f *MockRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

type RoundTripperFunc added in v1.18.0

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

func NewRoundTripperFunc added in v1.18.0

func NewRoundTripperFunc(fn func(req *http.Request) (*http.Response, error)) *RoundTripperFunc

func (*RoundTripperFunc) RoundTrip added in v1.18.0

func (f *RoundTripperFunc) RoundTrip(req *http.Request) (*http.Response, error)

Jump to

Keyboard shortcuts

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