null

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package null implements a testing shim for testing the token system and some higher level components. It is a prime candidate to be replaced with a mocked version of the interface, since unlike some other shims it is used exclusively for testing.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ValidToken is a valid token for entity1 which has
	// GLOBAL_ROOT capability.
	ValidToken = "{\"EntityID\":\"valid\",\"Capabilities\":[\"GLOBAL_ROOT\"]}"

	// ValidEmptyToken is a valid token, but contains no
	// capabilities.
	ValidEmptyToken = "{\"EntityID\":\"valid\",\"Capabilities\":[]}"

	// InvalidToken is a token which will always return a in
	// ErrTokenInvalid error.
	InvalidToken = "invalid"
)

Functions

func NewKeyProvider added in v0.6.1

func NewKeyProvider() keyprovider.KeyProvider

Types

type NullKeyProvider added in v0.6.1

type NullKeyProvider struct{}

The KeyProvider provided here provides no keys, as they are not used in the null token service. This interface is provided exclusively to satisfy the initialization requirements.

func (NullKeyProvider) Provide added in v0.6.1

func (nk NullKeyProvider) Provide(_, _ string) ([]byte, error)

type Service

type Service struct{}

Service binds the methods of the null token implementation.

func New

func New(_ hclog.Logger, _ keyprovider.KeyProvider) *Service

New returns a new token service

func (*Service) Generate

func (s *Service) Generate(claims token.Claims, config token.Config) (string, error)

Generate generates a token with some quirks. If the claims passed in requests an EntityID of "invalid-token" then an invalid token will be issued. If the ID is "token-issue-error" then an InternalError will be returned. For all other values a valid token will be returned.

func (*Service) Validate

func (s *Service) Validate(t string) (token.Claims, error)

Validate checks a token that's been provided. The token is simply deserialized, there is no validation performed. Do not use this in production, it is provided as a testing aid only.

Jump to

Keyboard shortcuts

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