forked from TrueCloudLab/frostfs-api-go
session: implement getters and setters on messages
This commit is contained in:
parent
d8cc00b54c
commit
1932658a7d
6 changed files with 87 additions and 5 deletions
|
@ -75,22 +75,22 @@ func (m *Token_Info) SetAddress(addr Address) {
|
|||
}
|
||||
|
||||
// CreationEpoch is a Created field getter.
|
||||
func (m Token_Info) CreationEpoch() uint64 {
|
||||
func (m TokenLifetime) CreationEpoch() uint64 {
|
||||
return m.Created
|
||||
}
|
||||
|
||||
// SetCreationEpoch is a Created field setter.
|
||||
func (m *Token_Info) SetCreationEpoch(e uint64) {
|
||||
func (m *TokenLifetime) SetCreationEpoch(e uint64) {
|
||||
m.Created = e
|
||||
}
|
||||
|
||||
// ExpirationEpoch is a ValidUntil field getter.
|
||||
func (m Token_Info) ExpirationEpoch() uint64 {
|
||||
func (m TokenLifetime) ExpirationEpoch() uint64 {
|
||||
return m.ValidUntil
|
||||
}
|
||||
|
||||
// SetExpirationEpoch is a ValidUntil field setter.
|
||||
func (m *Token_Info) SetExpirationEpoch(e uint64) {
|
||||
func (m *TokenLifetime) SetExpirationEpoch(e uint64) {
|
||||
m.ValidUntil = e
|
||||
}
|
||||
|
||||
|
|
11
session/request.go
Normal file
11
session/request.go
Normal file
|
@ -0,0 +1,11 @@
|
|||
package session
|
||||
|
||||
// GetOwnerID is an OwnerID field getter.
|
||||
func (m CreateRequest) GetOwnerID() OwnerID {
|
||||
return m.OwnerID
|
||||
}
|
||||
|
||||
// SetOwnerID is an OwnerID field setter.
|
||||
func (m *CreateRequest) SetOwnerID(id OwnerID) {
|
||||
m.OwnerID = id
|
||||
}
|
29
session/request_test.go
Normal file
29
session/request_test.go
Normal file
|
@ -0,0 +1,29 @@
|
|||
package session
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestCreateRequestGettersSetters(t *testing.T) {
|
||||
t.Run("owner ID", func(t *testing.T) {
|
||||
id := OwnerID{1, 2, 3}
|
||||
m := new(CreateRequest)
|
||||
|
||||
m.SetOwnerID(id)
|
||||
|
||||
require.Equal(t, id, m.GetOwnerID())
|
||||
})
|
||||
|
||||
t.Run("lifetime", func(t *testing.T) {
|
||||
e1, e2 := uint64(3), uint64(4)
|
||||
m := new(CreateRequest)
|
||||
|
||||
m.SetCreationEpoch(e1)
|
||||
m.SetExpirationEpoch(e2)
|
||||
|
||||
require.Equal(t, e1, m.CreationEpoch())
|
||||
require.Equal(t, e2, m.ExpirationEpoch())
|
||||
})
|
||||
}
|
16
session/response.go
Normal file
16
session/response.go
Normal file
|
@ -0,0 +1,16 @@
|
|||
package session
|
||||
|
||||
// GetID is an ID field getter.
|
||||
func (m CreateResponse) GetID() TokenID {
|
||||
return m.ID
|
||||
}
|
||||
|
||||
// SetID is an ID field setter.
|
||||
func (m *CreateResponse) SetID(id TokenID) {
|
||||
m.ID = id
|
||||
}
|
||||
|
||||
// SetSessionKey is a SessionKey field setter.
|
||||
func (m *CreateResponse) SetSessionKey(key []byte) {
|
||||
m.SessionKey = key
|
||||
}
|
27
session/response_test.go
Normal file
27
session/response_test.go
Normal file
|
@ -0,0 +1,27 @@
|
|||
package session
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestCreateResponseGettersSetters(t *testing.T) {
|
||||
t.Run("id", func(t *testing.T) {
|
||||
id := TokenID{1, 2, 3}
|
||||
m := new(CreateResponse)
|
||||
|
||||
m.SetID(id)
|
||||
|
||||
require.Equal(t, id, m.GetID())
|
||||
})
|
||||
|
||||
t.Run("session key", func(t *testing.T) {
|
||||
key := []byte{1, 2, 3}
|
||||
m := new(CreateResponse)
|
||||
|
||||
m.SetSessionKey(key)
|
||||
|
||||
require.Equal(t, key, m.GetSessionKey())
|
||||
})
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
package session
|
Loading…
Reference in a new issue