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

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

View file

@ -30,3 +30,15 @@ func TestTokenLifetimeJSON(t *testing.T) {
require.Equal(t, l, l2)
}
func TestSessionTokenBodyJSON(t *testing.T) {
b := generateSessionTokenBody("id")
data, err := b.MarshalJSON()
require.NoError(t, err)
b2 := new(session.SessionTokenBody)
require.NoError(t, b2.UnmarshalJSON(data))
require.Equal(t, b, b2)
}