testutils

package
v1.21.6 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2024 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const Secret = "0123456789101112"

Variables

This section is empty.

Functions

func ExpectMessage

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

func ExpectVersionAndReleaseHold

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

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

func SendMessage

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

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

Types

type Buffer

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

func (*Buffer) String

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

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

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

func (l Logger) GetLogs() string

type MockRoundTripper

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

func NewMockRoundTripper

func NewMockRoundTripper(rt http.RoundTripper) *MockRoundTripper

func (*MockRoundTripper) RoundTrip

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

type RoundTripperFunc

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

func NewRoundTripperFunc

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

func (*RoundTripperFunc) RoundTrip

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