[#298] pkg/session: Implement methods to work with Token lifetime

Implement `Exp`/`SetExp`/`Nbf`/`SetNbf`/`Iat`/`SetIat` methods on `Token`
type which provide access to the message fields of the same name.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-06-04 16:17:47 +03:00 committed by Leonard Lyubich
parent 7968c4994a
commit 779a61c97d
2 changed files with 87 additions and 0 deletions

View file

@ -132,3 +132,33 @@ func TestGetContainerContext(t *testing.T) {
require.Nil(t, session.GetContainerContext(tok))
}
}
func TestToken_Exp(t *testing.T) {
tok := session.NewToken()
const exp = 11
tok.SetExp(exp)
require.EqualValues(t, exp, tok.Exp())
}
func TestToken_Nbf(t *testing.T) {
tok := session.NewToken()
const nbf = 22
tok.SetNbf(nbf)
require.EqualValues(t, nbf, tok.Nbf())
}
func TestToken_Iat(t *testing.T) {
tok := session.NewToken()
const iat = 33
tok.SetIat(iat)
require.EqualValues(t, iat, tok.Iat())
}