authntest

package
v0.1.46 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package authntest is a fake of authn.Port for the tests of the code that holds it: a token is whatever the test says it is, and the users are the test's own.

Index

Constants

This section is empty.

Variables

View Source
var ErrFailed = errors.New("authntest: the call failed, as the test asked")

ErrFailed is the error of a call the test asked to fail.

Functions

This section is empty.

Types

type Fake

type Fake struct {
	// contains filtered or unexported fields
}

Fake is a sign-in service the test sets up. Its zero value refuses every token as Invalid and has no users. It is safe for concurrent use.

func (*Fake) Accept

func (f *Fake) Accept(idToken string, token authn.Token)

Accept makes Verify accept idToken as token.

func (*Fake) AddUser

func (f *Fake) AddUser(user authn.User)

AddUser adds a user to the list Users gives.

func (*Fake) FailRemoveUser

func (f *Fake) FailRemoveUser()

FailRemoveUser makes every later RemoveUser fail with ErrFailed, the user kept.

func (*Fake) FailUsers

func (f *Fake) FailUsers()

FailUsers makes every later list of Users end at once with ErrFailed.

func (*Fake) FailVerify

func (f *Fake) FailVerify()

FailVerify makes every later Verify refuse its token as authn.Failed.

func (*Fake) Refuse

func (f *Fake) Refuse(idToken string, class authn.Class, uid string)

Refuse makes Verify refuse idToken by class. The UID goes with the classes Revoked and NoUser, as the adapter's does.

func (*Fake) RemoveUser

func (f *Fake) RemoveUser(_ context.Context, uid string) error

RemoveUser records the call and takes the user out of the list: a user who is not there is no error, as with the adapter.

func (*Fake) Removed

func (f *Fake) Removed() []string

Removed is the UIDs RemoveUser was called with, in order.

func (*Fake) Users

func (f *Fake) Users(context.Context) iter.Seq2[authn.User, error]

Users lists the users as they are when the list starts.

func (*Fake) Verify

func (f *Fake) Verify(_ context.Context, idToken string) (authn.Token, error)

Verify answers as the test set the token up.

Jump to

Keyboard shortcuts

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