[#525] event/container: Parse binary session token from Put notification
The 4th item of `Put` container notification event is a byte array of serialized session token. Parse session token in `ParsePut` function. Provide `Put.SessionToken` method. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
98cc685a9b
commit
0f91b78df1
2 changed files with 27 additions and 1 deletions
|
@ -13,6 +13,7 @@ func TestParsePut(t *testing.T) {
|
|||
containerData = []byte("containerData")
|
||||
signature = []byte("signature")
|
||||
publicKey = []byte("pubkey")
|
||||
token = []byte("token")
|
||||
)
|
||||
|
||||
t.Run("wrong number of parameters", func(t *testing.T) {
|
||||
|
@ -52,12 +53,23 @@ func TestParsePut(t *testing.T) {
|
|||
require.Error(t, err)
|
||||
})
|
||||
|
||||
t.Run("wrong session token parameter", func(t *testing.T) {
|
||||
_, err := ParsePut([]stackitem.Item{
|
||||
stackitem.NewByteArray(containerData),
|
||||
stackitem.NewByteArray(signature),
|
||||
stackitem.NewByteArray(publicKey),
|
||||
stackitem.NewMap(),
|
||||
})
|
||||
|
||||
require.Error(t, err)
|
||||
})
|
||||
|
||||
t.Run("correct behavior", func(t *testing.T) {
|
||||
ev, err := ParsePut([]stackitem.Item{
|
||||
stackitem.NewByteArray(containerData),
|
||||
stackitem.NewByteArray(signature),
|
||||
stackitem.NewByteArray(publicKey),
|
||||
stackitem.NewMap(),
|
||||
stackitem.NewByteArray(token),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
|
@ -65,6 +77,7 @@ func TestParsePut(t *testing.T) {
|
|||
rawContainer: containerData,
|
||||
signature: signature,
|
||||
publicKey: publicKey,
|
||||
token: token,
|
||||
}, ev)
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue