[#168] session: Implement binary/JSON encoders/decoders on TokenLifetime

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-11-13 16:43:54 +03:00 committed by Alex Vanin
parent 86351a8f90
commit 20bf21e5e4
4 changed files with 45 additions and 4 deletions

View file

@ -18,3 +18,15 @@ func TestChecksumJSON(t *testing.T) {
require.Equal(t, ctx, ctx2)
}
func TestTokenLifetimeJSON(t *testing.T) {
l := generateLifetime(1, 2, 3)
data, err := l.MarshalJSON()
require.NoError(t, err)
l2 := new(session.TokenLifetime)
require.NoError(t, l2.UnmarshalJSON(data))
require.Equal(t, l, l2)
}