testutils

package
v1.6.18 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InsertTestClient added in v1.2.0

func InsertTestClient(t *testing.T, clientID string, redirectURIs []string)

InsertTestClient inserts a minimal active OAuth2 client row for tests. redirectURIs is the list of allowed redirect URIs for the client.

func InsertTestConfidentialClient added in v1.6.6

func InsertTestConfidentialClient(t *testing.T, clientID, clientSecret string)

InsertTestConfidentialClient inserts a confidential OAuth2 client with a known plaintext secret for testing endpoints that require client auth. The secret is bcrypt-hashed before storage, matching production behavior.

func InsertTestGroup added in v1.6.4

func InsertTestGroup(t *testing.T, groupID, name string)

InsertTestGroup inserts a minimal group row for tests.

func InsertTestGroupMembership added in v1.6.4

func InsertTestGroupMembership(t *testing.T, userID, groupID string)

InsertTestGroupMembership inserts a user_groups row for tests.

func InsertTestUser added in v1.0.8

func InsertTestUser(t *testing.T, userID string)

InsertTestUser inserts a minimal valid user row so that foreign-key constraints on user_id are satisfied in tests that don't exercise the user package directly.

func MockApiRequestWithAuth

func MockApiRequestWithAuth(t *testing.T, body, method, url string, handler RouteHandler, token string) *httptest.ResponseRecorder

func MockFormRequest

func MockFormRequest(t *testing.T, formData map[string]string, method, uri string, handler RouteHandler) *httptest.ResponseRecorder

func MockFormRequestWithBasicAuth added in v1.6.6

func MockFormRequestWithBasicAuth(t *testing.T, formData map[string]string, method, uri string, handler RouteHandler, clientID, clientSecret string) *httptest.ResponseRecorder

MockFormRequestWithBasicAuth is like MockFormRequest but adds HTTP Basic auth.

func MockJSONRequest

func MockJSONRequest(t *testing.T, body, method, url string, handler RouteHandler) []byte

func SetAuthorizeSig added in v1.6.8

func SetAuthorizeSig(v url.Values)

SetAuthorizeSig computes and sets the authorize_sig field on url.Values from the OAuth authorize parameters. Works for both form data and query params.

func SignedURL added in v1.6.8

func SignedURL(rawURL string) string

SignedURL appends an authorize_sig query param computed from the existing query params in the URL. Useful for passkey begin endpoints.

func WithConfigOverride

func WithConfigOverride(t *testing.T, override func())

func WithTestDB

func WithTestDB(t *testing.T)

Types

type RouteHandler

type RouteHandler func(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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