oauthtest

package
v0.56.12 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2026 License: MIT Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package oauthtest is a test double for an OAuth token endpoint whose refresh tokens are single-use and rotate, like the real vendors': a refresh token works exactly once, and replaying it is rejected with 400 invalid_grant. It counts refreshes so tests can assert that concurrent resolvers (goroutines or separate processes) spend a login exactly once.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	*httptest.Server
	// contains filtered or unexported fields
}

Server is a rotating-refresh-token endpoint.

func New

func New(initialRefresh string, delay time.Duration, access func(n int) string) *Server

New starts a server that accepts initialRefresh once. delay stalls each successful exchange (widening a race window); access mints the access token for the n-th refresh (1-based), nil meaning "access-<n>".

func (*Server) Refreshes

func (s *Server) Refreshes() int

Refreshes is the number of successful refresh exchanges.

func (*Server) Rejected

func (s *Server) Rejected() int

Rejected is the number of refused (replayed or unknown) refresh tokens.

Jump to

Keyboard shortcuts

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