adminauthtest

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package adminauthtest is the contract suite every adminauth.Store must pass, plus a failing store for error-path tests.

Why

The in-memory store and the three SQL backends have to behave identically, or an authorization decision would depend on which database a deployment chose. RunSuite is what proves that, the same way storagetest, ddmtest, deptest, and acmetest do for their own interfaces.

The cases that matter most are the ones a naive implementation gets wrong: a revoked principal must not be findable by an empty digest, a rotated token must stop working the moment the new one is issued, and the policy version must move on every write so a cached compilation notices.

References

  • Decision record: docs/research/decisions/0034-admin-api-and-authorization.md
  • Plan of record: docs/research/implementation_plan.md (phase 8)
  • Sibling suites: storage/storagetest, ddm/ddmtest, acme/acmetest

Index

Constants

This section is empty.

Variables

View Source
var ErrFailing = errors.New("adminauthtest: injected failure")

ErrFailing is what a Failing store returns from the selected method.

Functions

func RunSuite

func RunSuite(t *testing.T, newStore NewStore)

RunSuite runs every contract case against newStore.

Types

type Failing

type Failing struct {
	adminauth.Store
	Fail string
}

Failing wraps a Store and makes one named method fail, so a caller's error path is reachable without a broken database. Fail is the method name, for example "Principal" or "Policies"; an empty Fail passes everything through.

func (*Failing) CountRoot

func (f *Failing) CountRoot(ctx context.Context) (int, error)

CountRoot implements adminauth.Store.

func (*Failing) CreatePrincipal

func (f *Failing) CreatePrincipal(ctx context.Context, p adminauth.Principal, digest string, now time.Time) (adminauth.Principal, error)

CreatePrincipal implements adminauth.Store.

func (*Failing) DeletePolicy

func (f *Failing) DeletePolicy(ctx context.Context, name string) error

DeletePolicy implements adminauth.Store.

func (*Failing) DeletePrincipal

func (f *Failing) DeletePrincipal(ctx context.Context, name string) error

DeletePrincipal implements adminauth.Store.

func (*Failing) GetPolicy

func (f *Failing) GetPolicy(ctx context.Context, name string) (adminauth.Policy, error)

GetPolicy implements adminauth.Store.

func (*Failing) Policies

func (f *Failing) Policies(ctx context.Context) ([]adminauth.Policy, error)

Policies implements adminauth.Store.

func (*Failing) PolicyVersion

func (f *Failing) PolicyVersion(ctx context.Context) (int64, error)

PolicyVersion implements adminauth.Store.

func (*Failing) Principal

func (f *Failing) Principal(ctx context.Context, name string) (adminauth.Principal, error)

Principal implements adminauth.Store.

func (*Failing) PrincipalByDigest

func (f *Failing) PrincipalByDigest(ctx context.Context, digest string) (adminauth.Principal, error)

PrincipalByDigest implements adminauth.Store.

func (*Failing) Principals

Principals implements adminauth.Store.

func (*Failing) PutPolicy

func (f *Failing) PutPolicy(ctx context.Context, p adminauth.Policy, now time.Time) (adminauth.Policy, error)

PutPolicy implements adminauth.Store.

func (*Failing) RevokeToken

func (f *Failing) RevokeToken(ctx context.Context, name string, now time.Time) error

RevokeToken implements adminauth.Store.

func (*Failing) SetToken

func (f *Failing) SetToken(ctx context.Context, name, digest, tokenID string, expires, now time.Time) (adminauth.Principal, error)

SetToken implements adminauth.Store.

func (*Failing) UpdatePrincipal

func (f *Failing) UpdatePrincipal(ctx context.Context, name string, roles []string, root bool, now time.Time) (adminauth.Principal, error)

UpdatePrincipal implements adminauth.Store.

type NewStore

type NewStore func(t *testing.T) adminauth.Store

NewStore builds an empty store for one subtest.

Jump to

Keyboard shortcuts

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