testauth

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package testauth implements a simple JWKS file server and token signer for use in test packages when jwt validation is required.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClaimOption

type ClaimOption func(*jwt.Claims)

ClaimOption is a claim option definition.

func Audience

func Audience(v ...string) ClaimOption

Audience lets you specify an audience claim option.

func Expiry

func Expiry(v *jwt.NumericDate) ClaimOption

Expiry lets you specify an expiry claim option.

func NotBefore

func NotBefore(v *jwt.NumericDate) ClaimOption

NotBefore lets you specify a not before claim option.

func Subject

func Subject(v string) ClaimOption

Subject lets you specify a subject claim option.

type Server

type Server struct {
	Issuer string
	// contains filtered or unexported fields
}

Server handles serving JSON Web Key Set and signing tokens.

func NewServer

func NewServer(t *testing.T) *Server

NewServer creates a new Server and starts it.

func NewUnstartedServer

func NewUnstartedServer(t *testing.T) *Server

NewUnstartedServer creates a new Server without starting it.

func (*Server) SignSubject

func (s *Server) SignSubject(subject string, options ...ClaimOption) string

SignSubject returns a new token string with the provided subject. Additional claims may be provided as options. Any errors produced will result in the test passed when initializing Server to fail.

func (*Server) Start

func (s *Server) Start()

Start starts an unstarted server.

func (*Server) Stop

func (s *Server) Stop()

Stop shuts down the auth server.

func (*Server) TSignSubject

func (s *Server) TSignSubject(t *testing.T, subject string, options ...ClaimOption) string

TSignSubject returns a new token string with the provided subject. Additional claims may be provided as options. Any errors produced will result in the passed test argument failing.

Jump to

Keyboard shortcuts

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