diff --git a/service/token.go b/service/token.go index f431427b..78fccfac 100644 --- a/service/token.go +++ b/service/token.go @@ -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 } diff --git a/session/request.go b/session/request.go new file mode 100644 index 00000000..4a92c424 --- /dev/null +++ b/session/request.go @@ -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 +} diff --git a/session/request_test.go b/session/request_test.go new file mode 100644 index 00000000..06c62fd2 --- /dev/null +++ b/session/request_test.go @@ -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()) + }) +} diff --git a/session/response.go b/session/response.go new file mode 100644 index 00000000..3426d7c2 --- /dev/null +++ b/session/response.go @@ -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 +} diff --git a/session/response_test.go b/session/response_test.go new file mode 100644 index 00000000..0e1de0ba --- /dev/null +++ b/session/response_test.go @@ -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()) + }) +} diff --git a/session/service.go b/session/service.go deleted file mode 100644 index ab876163..00000000 --- a/session/service.go +++ /dev/null @@ -1 +0,0 @@ -package session