forked from TrueCloudLab/frostfs-api-go
session: support the expiration of private tokens
All sessions in NeoFS has limited in epochs lifetime. There is a need to limit the lifetime of private session tokens. This commmit: * extends PrivateToken interface with Expired method; * defines EpochLifetimeStore interface with RemoveExpired method and embeds it to PrivateTokenStore interface; * adds epoch value parameter to private token constructor.
This commit is contained in:
parent
8cbdb9183f
commit
4fa7360cd1
5 changed files with 116 additions and 4 deletions
|
@ -10,7 +10,7 @@ import (
|
|||
|
||||
func TestPrivateToken(t *testing.T) {
|
||||
// create new private token
|
||||
pToken, err := NewPrivateToken()
|
||||
pToken, err := NewPrivateToken(0)
|
||||
require.NoError(t, err)
|
||||
|
||||
// generate data to sign
|
||||
|
@ -31,3 +31,20 @@ func TestPrivateToken(t *testing.T) {
|
|||
),
|
||||
)
|
||||
}
|
||||
|
||||
func TestPToken_Expired(t *testing.T) {
|
||||
e := uint64(10)
|
||||
|
||||
var token PrivateToken = &pToken{
|
||||
validUntil: e,
|
||||
}
|
||||
|
||||
// must not be expired in the epoch before last
|
||||
require.False(t, token.Expired(e-1))
|
||||
|
||||
// must not be expired in the last epoch
|
||||
require.False(t, token.Expired(e))
|
||||
|
||||
// must be expired in the epoch after last
|
||||
require.True(t, token.Expired(e+1))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue