diff --git a/service/verify.go b/service/verify.go index ade13efd..182685d5 100644 --- a/service/verify.go +++ b/service/verify.go @@ -27,6 +27,12 @@ type ( SetOwner(*ecdsa.PublicKey, []byte) GetLastPeer() (*ecdsa.PublicKey, error) } + + // TokenHeader is an interface of the container of a Token pointer value + TokenHeader interface { + GetToken() *Token + SetToken(*Token) + } ) const ( @@ -97,6 +103,11 @@ func (m *RequestVerificationHeader) GetLastPeer() (*ecdsa.PublicKey, error) { } } +// SetToken is a Token field setter. +func (m *RequestVerificationHeader) SetToken(token *Token) { + m.Token = token +} + func newSignature(key *ecdsa.PrivateKey, data []byte) (*RequestVerificationHeader_Signature, error) { sign, err := crypto.Sign(key, data) if err != nil { diff --git a/service/verify_test.go b/service/verify_test.go index ce333aa0..c192f0f3 100644 --- a/service/verify_test.go +++ b/service/verify_test.go @@ -188,3 +188,17 @@ func TestVerifyAndSignRequestHeaderWithoutCloning(t *testing.T) { require.Contains(t, buf.String(), "proto: don't know how to copy") } + +func TestRequestVerificationHeader_SetToken(t *testing.T) { + id, err := refs.NewUUID() + require.NoError(t, err) + + token := new(Token) + token.ID = id + + h := new(RequestVerificationHeader) + + h.SetToken(token) + + require.Equal(t, token, h.GetToken()) +}