expected v0.1.1 Expected.Store behaviour View Source
Specification for login stores.
To automatically generate tests for a new store, you can use
Expected.Store.Test
.
Link to this section Summary
Callbacks
Cleans all the logins that have not been used for more than max_age
Deletes a login from the store given its username
and serial
Gets the login for the given username
and serial
from the store
Initialises the store
Lists the logins present in the store for the given username
Puts a login in the store
Link to this section Callbacks
clean_old_logins(max_age :: integer(), opts :: term()) :: [Expected.Login.t()]
Cleans all the logins that have not been used for more than max_age
.
This callback must compare with the :last_login
field, not :created_at
.
Deletes a login from the store given its username
and serial
.
get(username :: String.t(), serial :: String.t(), opts :: term()) :: {:ok, Expected.Login.t()} | {:error, :no_login}
Gets the login for the given username
and serial
from the store.
Initialises the store.
The value returned from this callback is passed as the last argument to
list_user_logins/2
, get/3
, put/2
and delete/3
.
list_user_logins(username :: String.t(), opts :: term()) :: [Expected.Login.t()]
Lists the logins present in the store for the given username
.
put(login :: Expected.Login.t(), opts :: term()) :: :ok
Puts a login in the store.
This callback must:
- create a new entry if there is none for the
username
andserial
, - replace the entry if there is already one for the
username
andserial
.
In other words, the couple {username, serial}
must be unique.