diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e7736d6..a3f3c8ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,22 @@ # Changelog This is the changelog for NeoFS Proto +## [0.2.3] - 2019-11-28 + +### Removed +- service: SignRequest / VerifyRequest and accompanying code +- proto: Signature field from requests +- object: bytefmt package not used anymore + +### Changed +- service: rename EpochRequest to EpochHeader and merge with MetaHeader +- service: get status error even if it is wrapped + +### Added +- service: RequestVerificationHeader's method to validate owner +- service: test coverage for CheckOwner +- service: test coverage for wrapped status errors + ## [0.2.2] - 2019-11-22 ### Changed @@ -33,3 +49,4 @@ Initial public release [0.2.0]: https://github.com/nspcc-dev/neofs-proto/compare/v0.1.0...v0.2.0 [0.2.1]: https://github.com/nspcc-dev/neofs-proto/compare/v0.2.0...v0.2.1 [0.2.2]: https://github.com/nspcc-dev/neofs-proto/compare/v0.2.1...v0.2.2 +[0.2.3]: https://github.com/nspcc-dev/neofs-proto/compare/v0.2.2...v0.2.3 diff --git a/accounting/withdraw.go b/accounting/withdraw.go index 0a8cf901..11c56081 100644 --- a/accounting/withdraw.go +++ b/accounting/withdraw.go @@ -11,12 +11,6 @@ type ( MessageID = refs.MessageID ) -// SetSignature sets signature to PutRequest to satisfy SignedRequest interface. -func (m *PutRequest) SetSignature(v []byte) { m.Signature = v } - -// SetSignature sets signature to DeleteRequest to satisfy SignedRequest interface. -func (m *DeleteRequest) SetSignature(v []byte) { m.Signature = v } - // PrepareData prepares bytes representation of PutRequest to satisfy SignedRequest interface. func (m *PutRequest) PrepareData() ([]byte, error) { var offset int diff --git a/accounting/withdraw.pb.go b/accounting/withdraw.pb.go index a2116c01..d80b01cf 100644 --- a/accounting/withdraw.pb.go +++ b/accounting/withdraw.pb.go @@ -191,8 +191,6 @@ type PutRequest struct { Height uint64 `protobuf:"varint,3,opt,name=Height,proto3" json:"Height,omitempty"` // MessageID is a nonce for uniq request (UUIDv4) MessageID MessageID `protobuf:"bytes,4,opt,name=MessageID,proto3,customtype=MessageID" json:"MessageID"` - // Signature is a signature of the sent request - Signature []byte `protobuf:"bytes,5,opt,name=Signature,proto3" json:"Signature,omitempty"` // RequestMetaHeader contains information about request meta headers (should be embedded into message) service.RequestMetaHeader `protobuf:"bytes,98,opt,name=Meta,proto3,embedded=Meta" json:"Meta"` // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) @@ -245,13 +243,6 @@ func (m *PutRequest) GetHeight() uint64 { return 0 } -func (m *PutRequest) GetSignature() []byte { - if m != nil { - return m.Signature - } - return nil -} - type PutResponse struct { // ID is cheque identifier ID ChequeID `protobuf:"bytes,1,opt,name=ID,proto3,customtype=ChequeID" json:"ID"` @@ -381,8 +372,6 @@ type DeleteRequest struct { OwnerID OwnerID `protobuf:"bytes,2,opt,name=OwnerID,proto3,customtype=OwnerID" json:"OwnerID"` // MessageID is a nonce for uniq request (UUIDv4) MessageID MessageID `protobuf:"bytes,3,opt,name=MessageID,proto3,customtype=MessageID" json:"MessageID"` - // Signature is a signature of the sent request - Signature []byte `protobuf:"bytes,4,opt,name=Signature,proto3" json:"Signature,omitempty"` // RequestMetaHeader contains information about request meta headers (should be embedded into message) service.RequestMetaHeader `protobuf:"bytes,98,opt,name=Meta,proto3,embedded=Meta" json:"Meta"` // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) @@ -421,13 +410,6 @@ func (m *DeleteRequest) XXX_DiscardUnknown() { var xxx_messageInfo_DeleteRequest proto.InternalMessageInfo -func (m *DeleteRequest) GetSignature() []byte { - if m != nil { - return m.Signature - } - return nil -} - // DeleteResponse is empty type DeleteResponse struct { XXX_NoUnkeyedLiteral struct{} `json:"-"` @@ -479,46 +461,45 @@ func init() { func init() { proto.RegisterFile("accounting/withdraw.proto", fileDescriptor_b3a38a4dc2575267) } var fileDescriptor_b3a38a4dc2575267 = []byte{ - // 615 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00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, 0xdd, 0xf1, 0xb4, 0x41, - 0x4e, 0xa7, 0x0d, 0xf2, 0x79, 0xda, 0x20, 0xdf, 0xa6, 0x0d, 0xf2, 0xfe, 0x7b, 0x63, 0xe1, 0xed, - 0x83, 0xca, 0x7f, 0x2b, 0x4c, 0x06, 0x9e, 0xb7, 0xd5, 0xc5, 0xa1, 0x19, 0x62, 0x74, 0x94, 0x6c, - 0xe5, 0x7f, 0xad, 0xf2, 0xc4, 0x4e, 0x8d, 0x47, 0x1e, 0xfd, 0x0c, 0x00, 0x00, 0xff, 0xff, 0xd3, - 0x26, 0xc1, 0xc6, 0x55, 0x07, 0x00, 0x00, + // 600 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x55, 0xc1, 0x6e, 0xd3, 0x4c, + 0x10, 0xee, 0xda, 0x69, 0xda, 0x7f, 0xd2, 0x1f, 0xca, 0x0a, 0x8a, 0xeb, 0x43, 0x1a, 0xf9, 0x80, + 0x82, 0x20, 0xb6, 0x54, 0xa4, 0x08, 0xc4, 0x01, 0x35, 0x58, 0x6a, 0x2d, 0x51, 0x11, 0xf9, 0x00, + 0x12, 0x37, 0xc7, 0x99, 0x38, 0x96, 0x12, 0x3b, 0xd8, 0xeb, 0x44, 0x7d, 0x08, 0xee, 0x3c, 0x03, + 0x17, 0xae, 0x3c, 0x42, 0x8f, 0x3d, 0x02, 0x87, 0x08, 0x85, 0x77, 0xe0, 0x8c, 0xbc, 0x5e, 0xd7, + 0x4e, 0x53, 0x89, 0x0a, 0x81, 0x2a, 0x4e, 0xd9, 0x9d, 0x6f, 0x66, 0x77, 0xe6, 0xfb, 0xbe, 0x8d, + 0x61, 0xd7, 0x71, 0xdd, 0x30, 0x09, 0x98, 0x1f, 0x78, 0xc6, 0xcc, 0x67, 0xc3, 0x7e, 0xe4, 0xcc, + 0xf4, 0x49, 0x14, 0xb2, 0x90, 0x42, 0x01, 0xa9,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xf9, 0x10, 0x19, 0xdd, 0x29, 0xd3, 0x59, 0xfc, 0x51, 0xa9, 0x77, 0x57, 0xe2, + 0x42, 0x8e, 0x36, 0xc8, 0xdd, 0xe4, 0x42, 0x5d, 0xf1, 0x8e, 0x97, 0xeb, 0xca, 0x9e, 0x7d, 0x02, + 0x95, 0x54, 0x56, 0xba, 0x94, 0x50, 0xb2, 0xa8, 0xaa, 0xac, 0x02, 0xa2, 0xf4, 0x19, 0x54, 0xb3, + 0x49, 0xe8, 0x6e, 0x39, 0x67, 0x49, 0x6c, 0x55, 0xbd, 0x0c, 0xca, 0x0e, 0xe8, 0x1c, 0x9c, 0x2e, + 0xea, 0xe4, 0x6c, 0x51, 0x27, 0x9f, 0x17, 0x75, 0xf2, 0x6d, 0x51, 0x27, 0xef, 0xbf, 0xd7, 0xd7, + 0xde, 0x3c, 0x28, 0x7d, 0x7b, 0x82, 0x78, 0xe2, 0xba, 0xad, 0x3e, 0x4e, 0x8d, 0x00, 0xc3, 0x41, + 0xdc, 0xca, 0xbe, 0x3c, 0xc5, 0x89, 0xbd, 0x2a, 0x8f, 0x3c, 0xfa, 0x19, 0x00, 0x00, 0xff, 0xff, + 0x39, 0x77, 0x4b, 0x08, 0x19, 0x07, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -946,13 +927,6 @@ func (m *PutRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x6 i-- dAtA[i] = 0x92 - if len(m.Signature) > 0 { - i -= len(m.Signature) - copy(dAtA[i:], m.Signature) - i = encodeVarintWithdraw(dAtA, i, uint64(len(m.Signature))) - i-- - dAtA[i] = 0x2a - } { size := m.MessageID.Size() i -= size @@ -1180,13 +1154,6 @@ func (m *DeleteRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x6 i-- dAtA[i] = 0x92 - if len(m.Signature) > 0 { - i -= len(m.Signature) - copy(dAtA[i:], m.Signature) - i = encodeVarintWithdraw(dAtA, i, uint64(len(m.Signature))) - i-- - dAtA[i] = 0x22 - } { size := m.MessageID.Size() i -= size @@ -1338,10 +1305,6 @@ func (m *PutRequest) Size() (n int) { } l = m.MessageID.Size() n += 1 + l + sovWithdraw(uint64(l)) - l = len(m.Signature) - if l > 0 { - n += 1 + l + sovWithdraw(uint64(l)) - } l = m.RequestMetaHeader.Size() n += 2 + l + sovWithdraw(uint64(l)) l = m.RequestVerificationHeader.Size() @@ -1414,10 +1377,6 @@ func (m *DeleteRequest) Size() (n int) { n += 1 + l + sovWithdraw(uint64(l)) l = m.MessageID.Size() n += 1 + l + sovWithdraw(uint64(l)) - l = len(m.Signature) - if l > 0 { - n += 1 + l + sovWithdraw(uint64(l)) - } l = m.RequestMetaHeader.Size() n += 2 + l + sovWithdraw(uint64(l)) l = m.RequestVerificationHeader.Size() @@ -2081,40 +2040,6 @@ func (m *PutRequest) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Signature", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowWithdraw - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthWithdraw - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthWithdraw - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Signature = append(m.Signature[:0], dAtA[iNdEx:postIndex]...) - if m.Signature == nil { - m.Signature = []byte{} - } - iNdEx = postIndex case 98: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field RequestMetaHeader", wireType) @@ -2662,40 +2587,6 @@ func (m *DeleteRequest) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Signature", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowWithdraw - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthWithdraw - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthWithdraw - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Signature = append(m.Signature[:0], dAtA[iNdEx:postIndex]...) - if m.Signature == nil { - m.Signature = []byte{} - } - iNdEx = postIndex case 98: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field RequestMetaHeader", wireType) diff --git a/accounting/withdraw.proto b/accounting/withdraw.proto index bb950ba4..a44e47a8 100644 --- a/accounting/withdraw.proto +++ b/accounting/withdraw.proto @@ -59,8 +59,6 @@ message PutRequest { uint64 Height = 3; // MessageID is a nonce for uniq request (UUIDv4) bytes MessageID = 4 [(gogoproto.customtype) = "MessageID", (gogoproto.nullable) = false]; - // Signature is a signature of the sent request - bytes Signature = 5; // RequestMetaHeader contains information about request meta headers (should be embedded into message) service.RequestMetaHeader Meta = 98 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) @@ -92,8 +90,6 @@ message DeleteRequest { bytes OwnerID = 2 [(gogoproto.customtype) = "OwnerID", (gogoproto.nullable) = false]; // MessageID is a nonce for uniq request (UUIDv4) bytes MessageID = 3 [(gogoproto.customtype) = "MessageID", (gogoproto.nullable) = false]; - // Signature is a signature of the sent request - bytes Signature = 4; // RequestMetaHeader contains information about request meta headers (should be embedded into message) service.RequestMetaHeader Meta = 98 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) diff --git a/container/service.go b/container/service.go index 4d3747e5..24727ee7 100644 --- a/container/service.go +++ b/container/service.go @@ -25,12 +25,6 @@ const ( ErrNotFound = internal.Error("could not find container") ) -// SetSignature sets signature to PutRequest to satisfy SignedRequest interface. -func (m *PutRequest) SetSignature(v []byte) { m.Signature = v } - -// SetSignature sets signature to DeleteRequest to satisfy SignedRequest interface. -func (m *DeleteRequest) SetSignature(v []byte) { m.Signature = v } - // PrepareData prepares bytes representation of PutRequest to satisfy SignedRequest interface. func (m *PutRequest) PrepareData() ([]byte, error) { var ( diff --git a/container/service.pb.go b/container/service.pb.go index 8b98cfa5..d9febc0e 100644 --- a/container/service.pb.go +++ b/container/service.pb.go @@ -38,8 +38,6 @@ type PutRequest struct { OwnerID OwnerID `protobuf:"bytes,3,opt,name=OwnerID,proto3,customtype=OwnerID" json:"OwnerID"` // Rules define storage policy for the object inside the container. Rules netmap.PlacementRule `protobuf:"bytes,4,opt,name=rules,proto3" json:"rules"` - // Signature of the user (owner id) - Signature []byte `protobuf:"bytes,5,opt,name=Signature,proto3" json:"Signature,omitempty"` // RequestMetaHeader contains information about request meta headers (should be embedded into message) service.RequestMetaHeader `protobuf:"bytes,98,opt,name=Meta,proto3,embedded=Meta" json:"Meta"` // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) @@ -92,13 +90,6 @@ func (m *PutRequest) GetRules() netmap.PlacementRule { return netmap.PlacementRule{} } -func (m *PutRequest) GetSignature() []byte { - if m != nil { - return m.Signature - } - return nil -} - type PutResponse struct { // CID (container id) is a SHA256 hash of the container structure CID CID `protobuf:"bytes,1,opt,name=CID,proto3,customtype=CID" json:"CID"` @@ -139,8 +130,6 @@ var xxx_messageInfo_PutResponse proto.InternalMessageInfo type DeleteRequest struct { // CID (container id) is a SHA256 hash of the container structure CID CID `protobuf:"bytes,1,opt,name=CID,proto3,customtype=CID" json:"CID"` - // Signature of the container owner - Signature []byte `protobuf:"bytes,2,opt,name=Signature,proto3" json:"Signature,omitempty"` // RequestMetaHeader contains information about request meta headers (should be embedded into message) service.RequestMetaHeader `protobuf:"bytes,98,opt,name=Meta,proto3,embedded=Meta" json:"Meta"` // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) @@ -179,13 +168,6 @@ func (m *DeleteRequest) XXX_DiscardUnknown() { var xxx_messageInfo_DeleteRequest proto.InternalMessageInfo -func (m *DeleteRequest) GetSignature() []byte { - if m != nil { - return m.Signature - } - return nil -} - // DeleteResponse is empty because delete operation is asynchronous and done // via consensus in inner ring nodes type DeleteResponse struct { @@ -400,44 +382,43 @@ func init() { func init() { proto.RegisterFile("container/service.proto", fileDescriptor_e1fa9d7ab2e7ae06) } var fileDescriptor_e1fa9d7ab2e7ae06 = []byte{ - // 586 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x54, 0xcd, 0x6e, 0xd3, 0x4c, - 0x14, 0xed, 0x34, 0x69, 0xda, 0x5c, 0xf7, 0xfb, 0x80, 0x51, 0x43, 0x8d, 0x05, 0x49, 0xe4, 0x55, - 0x40, 0xc4, 0x16, 0xa1, 0x12, 0x6c, 0x90, 0x20, 0x89, 0x54, 0x2a, 0x51, 0x11, 0xb9, 0x12, 0x0b, - 0x76, 0x8e, 0x7b, 0x13, 0x2c, 0x25, 0xb6, 0xf1, 0x8c, 0x83, 0xf2, 0x26, 0xbc, 0x03, 0x2f, 0xc0, - 0x23, 0x74, 0xc1, 0xa2, 0x1b, 0x24, 0xc4, 0x22, 0x42, 0x61, 0xcd, 0x3b, 0x20, 0x8f, 0xc7, 0x3f, - 0x49, 0xcb, 0xcf, 0xae, 0x6c, 0x2c, 0xcf, 0x39, 0xf7, 0x9e, 0x99, 0x73, 0xef, 0xdc, 0x81, 0x7d, - 0xc7, 0xf7, 0xb8, 0xed, 0x7a, 0x18, 0x9a, 0x0c, 0xc3, 0x99, 0xeb, 0xa0, 0x11, 0x84, 0x3e, 0xf7, - 0x69, 0x35, 0x23, 0x34, 0x2a, 0x19, 0x73, 0x8a, 0xdc, 0x4e, 0x68, 0x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xc9, 0x1f, 0x17, 0xed, 0xe6, 0x3a, 0x2c, 0x37, 0x78, 0x02, 0x95, - 0xe4, 0xba, 0x50, 0xb5, 0x10, 0xb1, 0x32, 0x0f, 0xda, 0xad, 0x4b, 0x18, 0x99, 0x7e, 0x00, 0xa5, - 0x43, 0x5c, 0xdd, 0x34, 0xbf, 0x6a, 0x2b, 0x9b, 0x16, 0x9b, 0xfa, 0x08, 0xca, 0xb1, 0x4b, 0x5a, - 0xe4, 0x0b, 0x0d, 0xd3, 0xf6, 0x2f, 0xe0, 0x49, 0x62, 0xf7, 0xe9, 0xd9, 0xb2, 0x4e, 0xce, 0x97, - 0x75, 0xf2, 0x65, 0x59, 0x27, 0xdf, 0x96, 0x75, 0xf2, 0xfe, 0x7b, 0x7d, 0xe3, 0xf5, 0xaf, 0x9e, - 0x68, 0x7f, 0xc4, 0xda, 0xc9, 0xa3, 0x9b, 0xc9, 0x0d, 0x2b, 0x02, 0x78, 0xf8, 0x33, 0x00, 0x00, - 0xff, 0xff, 0xd2, 0x95, 0x12, 0x0c, 0x3c, 0x06, 0x00, 0x00, + // 562 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x54, 0xcd, 0x6e, 0xd3, 0x4c, + 0x14, 0xed, 0x34, 0xf9, 0xd2, 0xe6, 0xba, 0x1f, 0x3f, 0xa3, 0x86, 0x1a, 0x4b, 0x24, 0x91, 0x57, + 0x01, 0x11, 0x5b, 0x84, 0x4a, 0xb0, 0x41, 0x82, 0x24, 0x52, 0xa9, 0x44, 0x45, 0x64, 0x24, 0x16, + 0xec, 0x1c, 0xf7, 0x26, 0x58, 0x72, 0x6c, 0xe3, 0x19, 0x07, 0xe5, 0x4d, 0x78, 0x07, 0x24, 0xb6, + 0xf0, 0x08, 0x5d, 0x76, 0x89, 0x58, 0x44, 0x28, 0xac, 0x79, 0x07, 0xe4, 0xf1, 0xf8, 0x27, 0x69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x59, 0xbd, 0x9f, 0x04, + 0x76, 0x5e, 0xa5, 0xc7, 0xd0, 0x43, 0xa8, 0x8c, 0x62, 0x4e, 0x1b, 0xa5, 0xee, 0x14, 0x0f, 0x84, + 0x76, 0x6b, 0x13, 0x96, 0x07, 0x3c, 0x81, 0x5a, 0x3a, 0x2e, 0x54, 0x2d, 0x45, 0xac, 0x4d, 0xbc, + 0x76, 0xfb, 0x12, 0x46, 0xca, 0x0f, 0xa1, 0x72, 0x84, 0xeb, 0x87, 0x16, 0xa3, 0xb6, 0x76, 0x68, + 0xf9, 0x52, 0x1f, 0x41, 0x35, 0x71, 0x49, 0xcb, 0x7c, 0xe9, 0xc2, 0xb4, 0x83, 0x0b, 0x78, 0x2a, + 0xec, 0x3f, 0x3d, 0x5b, 0x35, 0xc9, 0xf9, 0xaa, 0x49, 0xbe, 0xae, 0x9a, 0xe4, 0xfb, 0xaa, 0x49, + 0x3e, 0xfc, 0x68, 0x6e, 0xbd, 0xf9, 0xdd, 0x33, 0x1b, 0x4c, 0x58, 0x37, 0x7d, 0x38, 0xf3, 0x74, + 0xe3, 0x9a, 0x00, 0x1e, 0xfe, 0x0a, 0x00, 0x00, 0xff, 0xff, 0x36, 0x72, 0xbd, 0x89, 0x00, 0x06, + 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -690,13 +671,6 @@ func (m *PutRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x6 i-- dAtA[i] = 0x92 - if len(m.Signature) > 0 { - i -= len(m.Signature) - copy(dAtA[i:], m.Signature) - i = encodeVarintService(dAtA, i, uint64(len(m.Signature))) - i-- - dAtA[i] = 0x2a - } { size, err := m.Rules.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -820,13 +794,6 @@ func (m *DeleteRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x6 i-- dAtA[i] = 0x92 - if len(m.Signature) > 0 { - i -= len(m.Signature) - copy(dAtA[i:], m.Signature) - i = encodeVarintService(dAtA, i, uint64(len(m.Signature))) - i-- - dAtA[i] = 0x12 - } { size := m.CID.Size() i -= size @@ -1095,10 +1062,6 @@ func (m *PutRequest) Size() (n int) { n += 1 + l + sovService(uint64(l)) l = m.Rules.Size() n += 1 + l + sovService(uint64(l)) - l = len(m.Signature) - if l > 0 { - n += 1 + l + sovService(uint64(l)) - } l = m.RequestMetaHeader.Size() n += 2 + l + sovService(uint64(l)) l = m.RequestVerificationHeader.Size() @@ -1131,10 +1094,6 @@ func (m *DeleteRequest) Size() (n int) { _ = l l = m.CID.Size() n += 1 + l + sovService(uint64(l)) - l = len(m.Signature) - if l > 0 { - n += 1 + l + sovService(uint64(l)) - } l = m.RequestMetaHeader.Size() n += 2 + l + sovService(uint64(l)) l = m.RequestVerificationHeader.Size() @@ -1380,40 +1339,6 @@ func (m *PutRequest) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Signature", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Signature = append(m.Signature[:0], dAtA[iNdEx:postIndex]...) - if m.Signature == nil { - m.Signature = []byte{} - } - iNdEx = postIndex case 98: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field RequestMetaHeader", wireType) @@ -1654,40 +1579,6 @@ func (m *DeleteRequest) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Signature", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowService - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthService - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthService - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Signature = append(m.Signature[:0], dAtA[iNdEx:postIndex]...) - if m.Signature == nil { - m.Signature = []byte{} - } - iNdEx = postIndex case 98: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field RequestMetaHeader", wireType) diff --git a/container/service.proto b/container/service.proto index d4d50cae..8a3f56c0 100644 --- a/container/service.proto +++ b/container/service.proto @@ -41,9 +41,6 @@ message PutRequest { // Rules define storage policy for the object inside the container. netmap.PlacementRule rules = 4 [(gogoproto.nullable) = false]; - // Signature of the user (owner id) - bytes Signature = 5; - // RequestMetaHeader contains information about request meta headers (should be embedded into message) service.RequestMetaHeader Meta = 98 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) @@ -59,9 +56,6 @@ message DeleteRequest { // CID (container id) is a SHA256 hash of the container structure bytes CID = 1 [(gogoproto.customtype) = "CID", (gogoproto.nullable) = false]; - // Signature of the container owner - bytes Signature = 2; - // RequestMetaHeader contains information about request meta headers (should be embedded into message) service.RequestMetaHeader Meta = 98 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; // RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) diff --git a/docs/accounting.md b/docs/accounting.md index 268a1872..bcae1366 100644 --- a/docs/accounting.md +++ b/docs/accounting.md @@ -362,7 +362,6 @@ Delete allows user to remove unused cheque | ID | [bytes](#bytes) | | ID is cheque identifier | | OwnerID | [bytes](#bytes) | | OwnerID is a wallet address | | MessageID | [bytes](#bytes) | | MessageID is a nonce for uniq request (UUIDv4) | -| Signature | [bytes](#bytes) | | Signature is a signature of the sent request | | Meta | [service.RequestMetaHeader](#service.RequestMetaHeader) | | RequestMetaHeader contains information about request meta headers (should be embedded into message) | | Verify | [service.RequestVerificationHeader](#service.RequestVerificationHeader) | | RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) | @@ -450,7 +449,6 @@ DeleteResponse is empty | Amount | [decimal.Decimal](#decimal.Decimal) | | Amount of funds | | Height | [uint64](#uint64) | | Height is the neo blockchain height until the cheque is valid | | MessageID | [bytes](#bytes) | | MessageID is a nonce for uniq request (UUIDv4) | -| Signature | [bytes](#bytes) | | Signature is a signature of the sent request | | Meta | [service.RequestMetaHeader](#service.RequestMetaHeader) | | RequestMetaHeader contains information about request meta headers (should be embedded into message) | | Verify | [service.RequestVerificationHeader](#service.RequestVerificationHeader) | | RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) | diff --git a/docs/container.md b/docs/container.md index bc559ce2..ef2ba19a 100644 --- a/docs/container.md +++ b/docs/container.md @@ -92,7 +92,6 @@ List returns all user's containers | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | | CID | [bytes](#bytes) | | CID (container id) is a SHA256 hash of the container structure | -| Signature | [bytes](#bytes) | | Signature of the container owner | | Meta | [service.RequestMetaHeader](#service.RequestMetaHeader) | | RequestMetaHeader contains information about request meta headers (should be embedded into message) | | Verify | [service.RequestVerificationHeader](#service.RequestVerificationHeader) | | RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) | @@ -165,7 +164,6 @@ via consensus in inner ring nodes | Capacity | [uint64](#uint64) | | Capacity defines amount of data that can be stored in the container (doesn't used for now). | | OwnerID | [bytes](#bytes) | | OwnerID is a wallet address | | rules | [netmap.PlacementRule](#netmap.PlacementRule) | | Rules define storage policy for the object inside the container. | -| Signature | [bytes](#bytes) | | Signature of the user (owner id) | | Meta | [service.RequestMetaHeader](#service.RequestMetaHeader) | | RequestMetaHeader contains information about request meta headers (should be embedded into message) | | Verify | [service.RequestVerificationHeader](#service.RequestVerificationHeader) | | RequestVerificationHeader is a set of signatures of every NeoFS Node that processed request (should be embedded into message) | diff --git a/go.mod b/go.mod index 06fb5c07..dc07a30b 100644 --- a/go.mod +++ b/go.mod @@ -3,16 +3,13 @@ module github.com/nspcc-dev/neofs-proto go 1.13 require ( - code.cloudfoundry.org/bytefmt v0.0.0-20190819182555-854d396b647c github.com/gogo/protobuf v1.3.1 github.com/golang/protobuf v1.3.2 github.com/google/uuid v1.1.1 - github.com/mr-tron/base58 v1.1.2 + github.com/mr-tron/base58 v1.1.3 github.com/nspcc-dev/neofs-crypto v0.2.2 github.com/nspcc-dev/netmap v1.6.1 github.com/nspcc-dev/tzhash v1.3.0 - github.com/onsi/ginkgo v1.10.2 // indirect - github.com/onsi/gomega v1.7.0 // indirect github.com/pkg/errors v0.8.1 github.com/prometheus/client_golang v1.2.1 github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4 diff --git a/go.sum b/go.sum index f06a4990..13842ce9 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,4 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -code.cloudfoundry.org/bytefmt v0.0.0-20190819182555-854d396b647c h1:2RuXx1+tSNWRjxhY0Bx52kjV2odJQ0a6MTbfTPhGAkg= -code.cloudfoundry.org/bytefmt v0.0.0-20190819182555-854d396b647c/go.mod h1:wN/zk7mhREp/oviagqUXY3EwuHhWyOvAdsn5Y4CzOrc= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/abiosoft/ishell v2.0.0+incompatible/go.mod h1:HQR9AqF2R3P4XXpMpI0NAzgHf/aS6+zVXRj14cVk9qg= github.com/abiosoft/readline v0.0.0-20180607040430-155bce2042db/go.mod h1:rB3B4rKii8V21ydCbIzH5hZiCQE7f5E9SzUb/ZZx530= @@ -25,8 +23,6 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/flynn-archive/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:rZfgFAXFS/z/lEd6LJmf9HVZ1LkgYiHx5pHhV5DR16M= -github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= -github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= @@ -49,8 +45,6 @@ github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= -github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= @@ -68,6 +62,8 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lN github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/mr-tron/base58 v1.1.2 h1:ZEw4I2EgPKDJ2iEw0cNmLB3ROrEmkOtXIkaG7wZg+78= github.com/mr-tron/base58 v1.1.2/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= +github.com/mr-tron/base58 v1.1.3 h1:v+sk57XuaCKGXpWtVBX8YJzO7hMGx4Aajh4TQbdEFdc= +github.com/mr-tron/base58 v1.1.3/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/nspcc-dev/hrw v1.0.8 h1:vwRuJXZXgkMvf473vFzeWGCfY1WBVeSHAEHvR4u3/Cg= github.com/nspcc-dev/hrw v1.0.8/go.mod h1:l/W2vx83vMQo6aStyx2AuZrJ+07lGv2JQGlVkPG06MU= @@ -79,11 +75,6 @@ github.com/nspcc-dev/rfc6979 v0.1.0 h1:Lwg7esRRoyK1Up/IN1vAef1EmvrBeMHeeEkek2fAJ github.com/nspcc-dev/rfc6979 v0.1.0/go.mod h1:exhIh1PdpDC5vQmyEsGvc4YDM/lyQp/452QxGq/UEso= github.com/nspcc-dev/tzhash v1.3.0 h1:n6FTHsfPYbMi5Jmo6SwGVVRQD8i2w1P2ScCaW6rz69Q= github.com/nspcc-dev/tzhash v1.3.0/go.mod h1:Lc4DersKS8MNIrunTmsAzANO56qnG+LZ4GOE/WYGVzU= -github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.10.2 h1:uqH7bpe+ERSiDa34FDOF7RikN6RzXgduUF8yarlZp94= -github.com/onsi/ginkgo v1.10.2/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/gomega v1.7.0 h1:XPnZz8VVBHjVsy1vzJmRwIcSwiUO+JFfrv/xGiigmME= -github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -119,7 +110,6 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 h1:ObdrDkeb4kJdCP557AjRjq69pTHfNouLtWZG7j9rPN8= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 h1:0GoQqolDA55aaLxZyTzK/Y2ePZzZTUrRacwib7cNsYQ= @@ -127,12 +117,10 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190613194153-d28f0bde5980 h1:dfGZHvZk057jK2MCeWus/TowKpJ8y4AmooUzdBSR9GU= golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181228144115-9a3f9b0469bb/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -155,10 +143,6 @@ gopkg.in/abiosoft/ishell.v2 v2.0.0/go.mod h1:sFp+cGtH6o4s1FtpVPTMcHq2yue+c4DGOVo gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= -gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/object/utils.go b/object/utils.go index c0fb6248..fab7fcc8 100644 --- a/object/utils.go +++ b/object/utils.go @@ -2,12 +2,43 @@ package object import ( "io" + "strconv" - "code.cloudfoundry.org/bytefmt" "github.com/nspcc-dev/neofs-proto/session" "github.com/pkg/errors" ) +// ByteSize used to format bytes +type ByteSize uint64 + +// String represents ByteSize in string format +func (b ByteSize) String() string { + var ( + dec int64 + unit string + num = int64(b) + ) + + switch { + case num > UnitsTB: + unit = "TB" + dec = UnitsTB + case num > UnitsGB: + unit = "GB" + dec = UnitsGB + case num > UnitsMB: + unit = "MB" + dec = UnitsMB + case num > UnitsKB: + unit = "KB" + dec = UnitsKB + case num > UnitsB: + dec = 1 + } + + return strconv.FormatFloat(float64(num)/float64(dec), 'g', 6, 64) + unit +} + // MakePutRequestHeader combines object and session token value // into header of object put request. func MakePutRequestHeader(obj *Object, token *session.Token) *PutRequest { @@ -26,7 +57,7 @@ func MakePutRequestChunk(chunk []byte) *PutRequest { } func errMaxSizeExceeded(size uint64) error { - return errors.Errorf("object payload size exceed: %s", bytefmt.ByteSize(size)) + return errors.Errorf("object payload size exceed: %s", ByteSize(size).String()) } // ReceiveGetResponse receives object by chunks from the protobuf stream diff --git a/object/utils_test.go b/object/utils_test.go new file mode 100644 index 00000000..a3f0162b --- /dev/null +++ b/object/utils_test.go @@ -0,0 +1,48 @@ +package object + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestByteSize_String(t *testing.T) { + var cases = []struct { + name string + expect string + actual ByteSize + }{ + { + name: "101 bytes", + expect: "101", + actual: ByteSize(101), + }, + { + name: "112.84KB", + expect: "112.84KB", + actual: ByteSize(115548), + }, + { + name: "80.44MB", + expect: "80.44MB", + actual: ByteSize(84347453), + }, + { + name: "905.144GB", + expect: "905.144GB", + actual: ByteSize(971891061884), + }, + { + name: "1.857TB", + expect: "1.857TB", + actual: ByteSize(2041793092780), + }, + } + + for i := range cases { + tt := cases[i] + t.Run(tt.name, func(t *testing.T) { + require.Equal(t, tt.expect, tt.actual.String()) + }) + } +} diff --git a/service/epoch.go b/service/epoch.go deleted file mode 100644 index 2fd43817..00000000 --- a/service/epoch.go +++ /dev/null @@ -1,7 +0,0 @@ -package service - -// EpochRequest interface gives possibility to get or set epoch in RPC Requests. -type EpochRequest interface { - GetEpoch() uint64 - SetEpoch(v uint64) -} diff --git a/service/meta.go b/service/meta.go index abffdadd..8730386c 100644 --- a/service/meta.go +++ b/service/meta.go @@ -2,6 +2,7 @@ package service import ( "github.com/nspcc-dev/neofs-proto/internal" + "github.com/pkg/errors" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) @@ -19,14 +20,19 @@ type ( GetTTL() uint32 SetTTL(uint32) - // EpochRequest gives possibility to get or set epoch in RPC Requests. - GetEpoch() uint64 - SetEpoch(uint64) + // EpochHeader gives possibility to get or set epoch in RPC Requests. + EpochHeader // VersionHeader allows get or set version of protocol request VersionHeader } + // EpochHeader interface gives possibility to get or set epoch in RPC Requests. + EpochHeader interface { + GetEpoch() uint64 + SetEpoch(v uint64) + } + // VersionHeader allows get or set version of protocol request VersionHeader interface { GetVersion() uint32 @@ -101,7 +107,7 @@ func ProcessRequestTTL(req MetaHeader, cond ...TTLCondition) error { // check specific condition: if err := cond[i](ttl); err != nil { - if st, ok := status.FromError(err); ok { + if st, ok := status.FromError(errors.Cause(err)); ok { return st.Err() } diff --git a/service/meta_test.go b/service/meta_test.go index 496ea519..e208dfe1 100644 --- a/service/meta_test.go +++ b/service/meta_test.go @@ -3,6 +3,7 @@ package service import ( "testing" + "github.com/pkg/errors" "github.com/stretchr/testify/require" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -54,6 +55,18 @@ func TestMetaRequest(t *testing.T) { RequestMetaHeader: RequestMetaHeader{TTL: SingleForwardingTTL}, handler: func(_ uint32) error { return status.Error(codes.NotFound, "not found") }, }, + { + msg: "not found", + code: codes.NotFound, + name: "custom wrapped status error", + RequestMetaHeader: RequestMetaHeader{TTL: SingleForwardingTTL}, + handler: func(_ uint32) error { + err := status.Error(codes.NotFound, "not found") + err = errors.Wrap(err, "some error context") + err = errors.Wrap(err, "another error context") + return err + }, + }, } for i := range tests { diff --git a/service/sign.go b/service/sign.go deleted file mode 100644 index d8db94e8..00000000 --- a/service/sign.go +++ /dev/null @@ -1,47 +0,0 @@ -package service - -import ( - "crypto/ecdsa" - - crypto "github.com/nspcc-dev/neofs-crypto" - "github.com/nspcc-dev/neofs-proto/internal" - "github.com/pkg/errors" -) - -// ErrWrongSignature should be raised when wrong signature is passed into VerifyRequest. -const ErrWrongSignature = internal.Error("wrong signature") - -// SignedRequest interface allows sign and verify requests. -type SignedRequest interface { - PrepareData() ([]byte, error) - GetSignature() []byte - SetSignature([]byte) -} - -// SignRequest with passed private key. -func SignRequest(r SignedRequest, key *ecdsa.PrivateKey) error { - var signature []byte - if data, err := r.PrepareData(); err != nil { - return err - } else if signature, err = crypto.Sign(key, data); err != nil { - return errors.Wrap(err, "could not sign data") - } - - r.SetSignature(signature) - - return nil -} - -// VerifyRequest by passed public keys. -func VerifyRequest(r SignedRequest, keys ...*ecdsa.PublicKey) bool { - data, err := r.PrepareData() - if err != nil { - return false - } - for i := range keys { - if err := crypto.Verify(keys[i], data, r.GetSignature()); err == nil { - return true - } - } - return false -} diff --git a/service/verify.go b/service/verify.go index a6ac3a51..48e2871d 100644 --- a/service/verify.go +++ b/service/verify.go @@ -6,6 +6,7 @@ import ( "github.com/gogo/protobuf/proto" crypto "github.com/nspcc-dev/neofs-crypto" "github.com/nspcc-dev/neofs-proto/internal" + "github.com/nspcc-dev/neofs-proto/refs" "github.com/pkg/errors" ) @@ -35,6 +36,9 @@ const ( // ErrCannotFindOwner is raised when signatures empty in GetOwner. ErrCannotFindOwner = internal.Error("cannot find owner public key") + + // ErrWrongOwner is raised when passed OwnerID not equal to present PublicKey + ErrWrongOwner = internal.Error("wrong owner") ) // SetSignatures replaces signatures stored in RequestVerificationHeader. @@ -62,6 +66,18 @@ func (m *RequestVerificationHeader) SetOwner(pub *ecdsa.PublicKey, sign []byte) } } +// CheckOwner validates, that passed OwnerID is equal to present PublicKey of owner. +func (m *RequestVerificationHeader) CheckOwner(owner refs.OwnerID) error { + if key, err := m.GetOwner(); err != nil { + return err + } else if user, err := refs.NewOwnerID(key); err != nil { + return err + } else if !user.Equal(owner) { + return ErrWrongOwner + } + return nil +} + // GetOwner tries to get owner (client) public key from signatures. // If signatures contains not empty Origin, we should try to validate, // that session key was signed by owner (client), otherwise return error. diff --git a/service/verify_test.go b/service/verify_test.go index 1403c678..237e3623 100644 --- a/service/verify_test.go +++ b/service/verify_test.go @@ -9,6 +9,7 @@ import ( "github.com/gogo/protobuf/proto" crypto "github.com/nspcc-dev/neofs-crypto" "github.com/nspcc-dev/neofs-crypto/test" + "github.com/nspcc-dev/neofs-proto/refs" "github.com/pkg/errors" "github.com/stretchr/testify/require" ) @@ -78,6 +79,12 @@ func TestMaintainableRequest(t *testing.T) { } } + { // Validate owner + user, err := refs.NewOwnerID(&owner.PublicKey) + require.NoError(t, err) + require.NoError(t, req.CheckOwner(user)) + } + { // Good case: require.NoError(t, VerifyRequestHeader(req))