testsecrets

package
v0.0.0-...-51f9457 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package testsecrets provides a dumb in-memory secret store to use in unit tests. Use secrets.Use(c, &testsecrets.Store{...}) to inject it into the context.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

type Store struct {
	sync.Mutex

	Secrets   map[string]secrets.Secret // current map of all secrets
	SecretLen int                       // length of generated secret, 8 bytes default
	Rand      *rand.Rand                // used to generate missing secrets
}

Store implements secrets.Store in the simplest way possible using memory as a backend and very dumb deterministic "randomness" source for secret key autogeneration. Useful in unit tests. Can be modified directly (use lock if doing it concurrently). NEVER use it outside of tests.

func (*Store) AddRotationHandler

func (t *Store) AddRotationHandler(ctx context.Context, name string, cb secrets.RotationHandler) error

AddRotationHandler is a part of Store interface.

func (*Store) RandomSecret

func (t *Store) RandomSecret(ctx context.Context, k string) (secrets.Secret, error)

RandomSecret is a part of Store interface.

func (*Store) StoredSecret

func (t *Store) StoredSecret(ctx context.Context, k string) (secrets.Secret, error)

StoredSecret is a part of Store interface.

Jump to

Keyboard shortcuts

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