forked from TrueCloudLab/frostfs-api-go
[#168] object: Implement binary/JSON encoders/decoders on HeaderWithSig
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
b8f86f1a60
commit
9cdd14841a
4 changed files with 66 additions and 5 deletions
|
@ -352,6 +352,20 @@ func TestGetRangeHashResponseBody_StableMarshal(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestHeaderWithSignature_StableMarshal(t *testing.T) {
|
||||
from := generateHeaderWithSignature()
|
||||
|
||||
t.Run("non empty", func(t *testing.T) {
|
||||
wire, err := from.StableMarshal(nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
to := new(object.HeaderWithSignature)
|
||||
require.NoError(t, to.Unmarshal(wire))
|
||||
|
||||
require.Equal(t, from, to)
|
||||
})
|
||||
}
|
||||
|
||||
func generateOwner(id string) *refs.OwnerID {
|
||||
owner := new(refs.OwnerID)
|
||||
owner.SetValue([]byte(id))
|
||||
|
@ -582,12 +596,8 @@ func generateHeadResponseBody(flag bool) *object.HeadResponseBody {
|
|||
short.SetShortHeader(generateShortHeader("short id"))
|
||||
part = short
|
||||
} else {
|
||||
hdrWithSig := new(object.HeaderWithSignature)
|
||||
hdrWithSig.SetHeader(generateHeader(30))
|
||||
hdrWithSig.SetSignature(generateSignature("sig", "key"))
|
||||
|
||||
full := new(object.GetHeaderPartFull)
|
||||
full.SetHeaderWithSignature(hdrWithSig)
|
||||
full.SetHeaderWithSignature(generateHeaderWithSignature())
|
||||
part = full
|
||||
}
|
||||
|
||||
|
@ -596,6 +606,14 @@ func generateHeadResponseBody(flag bool) *object.HeadResponseBody {
|
|||
return req
|
||||
}
|
||||
|
||||
func generateHeaderWithSignature() *object.HeaderWithSignature {
|
||||
hdrWithSig := new(object.HeaderWithSignature)
|
||||
hdrWithSig.SetHeader(generateHeader(30))
|
||||
hdrWithSig.SetSignature(generateSignature("sig", "key"))
|
||||
|
||||
return hdrWithSig
|
||||
}
|
||||
|
||||
func generateFilter(k, v string) *object.SearchFilter {
|
||||
f := new(object.SearchFilter)
|
||||
f.SetKey(k)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue