object: add unit test of HeadRequest.ReadSignedData method

This commit is contained in:
Leonard Lyubich 2020-05-18 12:47:13 +03:00
parent d391421e5e
commit 2c571718d0
2 changed files with 31 additions and 0 deletions

View file

@ -187,3 +187,29 @@ func TestSignVerifyRequests(t *testing.T) {
} }
} }
} }
func TestHeadRequest_ReadSignedData(t *testing.T) {
t.Run("full headers", func(t *testing.T) {
req := new(HeadRequest)
// allocate buffer for reading
buf := make([]byte, req.SignedDataSize())
buf[0] = 2
// set FullHeaders option
req.SetFullHeaders(true)
_, err := req.ReadSignedData(buf)
require.NoError(t, err)
require.Equal(t, byte(1), buf[0])
// unset FullHeaders option
req.SetFullHeaders(false)
_, err = req.ReadSignedData(buf)
require.NoError(t, err)
require.Equal(t, byte(0), buf[0])
})
}

View file

@ -386,3 +386,8 @@ func Stringify(dst io.Writer, obj *Object) error {
return nil return nil
} }
// SetFullHeaders is a FullHeaders field setter.
func (m *HeadRequest) SetFullHeaders(v bool) {
m.FullHeaders = v
}