luci: Index | Files

package testsecrets

import ""

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


Package Files


func Use Uses

func Use(c context.Context) context.Context

Use installs default testing store into the context.

type Store Uses

type Store struct {

    Secrets        map[string]secrets.Secret // current map of all secrets
    NoAutogenerate bool                      // if true, GetSecret will NOT generate 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) GetSecret Uses

func (t *Store) GetSecret(k string) (secrets.Secret, error)

GetSecret is a part of Store interface.

Package testsecrets imports 4 packages (graph) and is imported by 6 packages. Updated 2020-11-26. Refresh now. Tools for package owners.