decodertest

package
v0.0.0-...-a49cb6e Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AuthHeaderKey for the test
	AuthHeaderKey = "Authorization"
	// TokenValidatedHeaderKey for the test
	TokenValidatedHeaderKey = "jwt-token-validated"
	// AuthHeaderRequired for the test
	AuthHeaderRequired = false
)

Variables

View Source
var (
	// Cache to be reused between all tests
	Cache, _ = ristretto.NewCache(&ristretto.Config{
		NumCounters: 1e7,
		MaxCost:     1 << 30,
		BufferItems: 64,
		Metrics:     true,
	})
)

Functions

func Ctx

func Ctx() context.Context

Ctx creates a new test config with a logger

func HandleByPanic

func HandleByPanic(err error)

HandleByPanic handles a non nil error by panicing

func Report

func Report(t *testing.T, condition bool, message string, args ...interface{})

Report the error message to testing if the condition is met

Types

type TestConfig

type TestConfig struct {
	// JwksURL is where the JWKS is hosted
	JwksURL string
	// contains filtered or unexported fields
}

TestConfig holds most config used for tests also starts a JWKS server

func NewTest

func NewTest() *TestConfig

NewTest creates a new test config

func (*TestConfig) CachedServer

func (tc *TestConfig) CachedServer(claimMappings map[string]string) *decoder.Server

CachedServer creates a cached server

func (*TestConfig) NewExpiredToken

func (tc *TestConfig) NewExpiredToken(claims map[string]interface{}) []byte

NewExpiredToken generates a signed but expired token with the given claims

func (*TestConfig) NewInvalidToken

func (tc *TestConfig) NewInvalidToken(claims map[string]interface{}) []byte

NewInvalidToken generates a token signed with a key that does not exist in the JWKS

func (*TestConfig) NewValidToken

func (tc *TestConfig) NewValidToken(claims map[string]interface{}) []byte

NewValidToken generates a signed valid token with the given claims

func (*TestConfig) UncachedServer

func (tc *TestConfig) UncachedServer(claimMappings map[string]string) *decoder.Server

UncachedServer creates an uncached server

Jump to

Keyboard shortcuts

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