forked from TrueCloudLab/frostfs-node
[#943] service/object: Check session token expiration
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
508a28fdc0
commit
2fbdcbdee1
4 changed files with 36 additions and 7 deletions
|
@ -19,7 +19,7 @@ func TestNewKeyStorage(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
|
||||
tokenStor := tokenStorage.New()
|
||||
stor := util.NewKeyStorage(&nodeKey.PrivateKey, tokenStor)
|
||||
stor := util.NewKeyStorage(&nodeKey.PrivateKey, tokenStor, mockedNetworkState{42})
|
||||
|
||||
t.Run("node key", func(t *testing.T) {
|
||||
key, err := stor.GetKey(nil)
|
||||
|
@ -43,6 +43,12 @@ func TestNewKeyStorage(t *testing.T) {
|
|||
require.Equal(t, pubKey.X, key.PublicKey.X)
|
||||
require.Equal(t, pubKey.Y, key.PublicKey.Y)
|
||||
})
|
||||
|
||||
t.Run("expired token", func(t *testing.T) {
|
||||
tok := createToken(t, tokenStor, 30)
|
||||
_, err := stor.GetKey(tok)
|
||||
require.Error(t, err)
|
||||
})
|
||||
}
|
||||
|
||||
func generateToken(t *testing.T) *session.Token {
|
||||
|
@ -74,3 +80,11 @@ func createToken(t *testing.T, store *tokenStorage.TokenStore, exp uint64) *sess
|
|||
|
||||
return tok
|
||||
}
|
||||
|
||||
type mockedNetworkState struct {
|
||||
value uint64
|
||||
}
|
||||
|
||||
func (m mockedNetworkState) CurrentEpoch() uint64 {
|
||||
return m.value
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue