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 ¶
- Variables
- type Fake
- func (f *Fake) Accept(idToken string, token authn.Token)
- func (f *Fake) AddUser(user authn.User)
- func (f *Fake) FailRemoveUser()
- func (f *Fake) FailUsers()
- func (f *Fake) FailVerify()
- func (f *Fake) Refuse(idToken string, class authn.Class, uid string)
- func (f *Fake) RemoveUser(_ context.Context, uid string) error
- func (f *Fake) Removed() []string
- func (f *Fake) Users(context.Context) iter.Seq2[authn.User, error]
- func (f *Fake) Verify(_ context.Context, idToken string) (authn.Token, error)
Constants ¶
This section is empty.
Variables ¶
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) 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 ¶
Refuse makes Verify refuse idToken by class. The UID goes with the classes Revoked and NoUser, as the adapter's does.
func (*Fake) RemoveUser ¶
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.