clerktest

package
v2.0.2-beta.5 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package clerktest provides utilities for testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateJWT

func GenerateJWT(t *testing.T, claims any, kid string) (string, crypto.PublicKey)

GenerateJWT creates a JSON web token with the provided claims and key ID.

Types

type RoundTripper

type RoundTripper struct {
	T *testing.T
	// Status is the response Status code.
	Status int
	// Out is the response body.
	Out json.RawMessage
	// Set this field to assert on the request method.
	Method string
	// Set this field to assert that the request path matches.
	Path string
	// Set this field to assert that the request URL querystring matches.
	Query *url.Values
	// Set this field to assert that the request body matches.
	In json.RawMessage
}

RoundTripper can be used as a mock Transport for http.Clients. Set the RoundTripper's fields accordingly to determine the response or perform assertions on the http.Request properties.

func (*RoundTripper) RoundTrip

func (rt *RoundTripper) RoundTrip(r *http.Request) (*http.Response, error)

RoundTrip returns an http.Response based on the RoundTripper's fields. It will also perform assertions on the http.Request.

Jump to

Keyboard shortcuts

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