Documentation
¶
Overview ¶
Package mock contains basic mocks and test doubles.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Clock ¶
type Clock struct {
// contains filtered or unexported fields
}
Clock is a deterministic clock for unit tests. It starts at the Unix epoch and only advances when Clock.StepBy() is called.
func (*Clock) AddListener ¶
AddListener registers a callback that will be called whenever the clock is advanced. It will also be called once immediately.
type Enforcer ¶
type Enforcer struct {
// contains filtered or unexported fields
}
Enforcer implements the gopherpolicy.Enforcer interface. During enforcement, all accesses are allowed by default. More restrictive policies can be configured with Forbid() and Allow(). Request attributes cannot be checked.
type Validator ¶
type Validator[E gopherpolicy.Enforcer] struct { Enforcer E Auth map[string]string }
Validator implements the gopherpolicy.Validator and gopherpolicy.Enforcer interfaces.
During validation, the X-Auth-Token header on the request is not inspected at all. Instead, auth success is always assumed and a token is built from the Auth parameters provided during New(), using the mock itself as Enforcer.
During enforcement, all accesses are allowed by default. More restrictive policies can be configured with Forbid() and Allow().
func NewValidator ¶
func NewValidator[E gopherpolicy.Enforcer](enforcer E, auth map[string]string) *Validator[E]
NewValidator initializes a new Validator. The provided auth variables will be mirrored into all gopherpolicy.Token instances returned by this Validator.
func (*Validator[E]) CheckToken ¶
func (v *Validator[E]) CheckToken(r *http.Request) *gopherpolicy.Token
CheckToken implements the gopherpolicy.Validator interface.