satellite/metainfo: fix usage of types from internalpb
After moving SatStreamID and SatSegmentID from common I missed changing some methods in metainfo endpoint. This change is a fix for that. Change-Id: I34e121fce47371ee4cfd92cce03809520b68859f
This commit is contained in:
parent
77c4f99fa0
commit
0205f0d807
@ -727,21 +727,11 @@ func (endpoint *Endpoint) CommitObject(ctx context.Context, req *pb.ObjectCommit
|
||||
func (endpoint *Endpoint) commitObject(ctx context.Context, req *pb.ObjectCommitRequest, pointer *pb.Pointer) (resp *pb.ObjectCommitResponse, err error) {
|
||||
defer mon.Task()(&ctx)(&err)
|
||||
|
||||
streamID := &pb.SatStreamID{}
|
||||
err = pb.Unmarshal(req.StreamId, streamID)
|
||||
if err != nil {
|
||||
return nil, rpcstatus.Error(rpcstatus.Internal, err.Error())
|
||||
}
|
||||
|
||||
err = signing.VerifyStreamID(ctx, endpoint.satellite, streamID)
|
||||
streamID, err := endpoint.unmarshalSatStreamID(ctx, req.StreamId)
|
||||
if err != nil {
|
||||
return nil, rpcstatus.Error(rpcstatus.InvalidArgument, err.Error())
|
||||
}
|
||||
|
||||
if streamID.CreationDate.Before(time.Now().Add(-satIDExpiration)) {
|
||||
return nil, rpcstatus.Error(rpcstatus.InvalidArgument, "stream ID expired")
|
||||
}
|
||||
|
||||
keyInfo, err := endpoint.validateAuth(ctx, req.Header, macaroon.Action{
|
||||
Op: macaroon.ActionWrite,
|
||||
Bucket: streamID.Bucket,
|
||||
@ -1718,10 +1708,10 @@ func (endpoint *Endpoint) unmarshalSatStreamID(ctx context.Context, streamID sto
|
||||
return satStreamID, nil
|
||||
}
|
||||
|
||||
func (endpoint *Endpoint) unmarshalSatSegmentID(ctx context.Context, segmentID storj.SegmentID) (_ *pb.SatSegmentID, err error) {
|
||||
func (endpoint *Endpoint) unmarshalSatSegmentID(ctx context.Context, segmentID storj.SegmentID) (_ *internalpb.SegmentID, err error) {
|
||||
defer mon.Task()(&ctx)(&err)
|
||||
|
||||
satSegmentID := &pb.SatSegmentID{}
|
||||
satSegmentID := &internalpb.SegmentID{}
|
||||
err = pb.Unmarshal(segmentID, satSegmentID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -1730,7 +1720,7 @@ func (endpoint *Endpoint) unmarshalSatSegmentID(ctx context.Context, segmentID s
|
||||
return nil, errs.New("stream ID missing")
|
||||
}
|
||||
|
||||
err = signing.VerifySegmentID(ctx, endpoint.satellite, satSegmentID)
|
||||
err = VerifySegmentID(ctx, endpoint.satellite, satSegmentID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ import (
|
||||
"storj.io/common/testrand"
|
||||
"storj.io/storj/private/testplanet"
|
||||
"storj.io/storj/satellite"
|
||||
"storj.io/storj/satellite/internalpb"
|
||||
satMetainfo "storj.io/storj/satellite/metainfo"
|
||||
"storj.io/storj/satellite/metainfo/metabase"
|
||||
"storj.io/uplink"
|
||||
@ -166,10 +167,10 @@ func TestRevokeMacaroon(t *testing.T) {
|
||||
assert.True(t, errs2.IsRPC(err, rpcstatus.PermissionDenied))
|
||||
|
||||
signer := signing.SignerFromFullIdentity(planet.Satellites[0].Identity)
|
||||
satStreamID := &pb.SatStreamID{
|
||||
satStreamID := &internalpb.StreamID{
|
||||
CreationDate: time.Now(),
|
||||
}
|
||||
signedStreamID, err := signing.SignStreamID(ctx, signer, satStreamID)
|
||||
signedStreamID, err := satMetainfo.SignStreamID(ctx, signer, satStreamID)
|
||||
require.NoError(t, err)
|
||||
|
||||
encodedStreamID, err := pb.Marshal(signedStreamID)
|
||||
@ -189,7 +190,7 @@ func TestRevokeMacaroon(t *testing.T) {
|
||||
|
||||
// these methods needs SegmentID
|
||||
|
||||
signedSegmentID, err := signing.SignSegmentID(ctx, signer, &pb.SatSegmentID{
|
||||
signedSegmentID, err := satMetainfo.SignSegmentID(ctx, signer, &internalpb.SegmentID{
|
||||
StreamId: satStreamID,
|
||||
CreationDate: time.Now(),
|
||||
})
|
||||
@ -253,10 +254,10 @@ func TestInvalidAPIKey(t *testing.T) {
|
||||
// these methods needs StreamID to do authentication
|
||||
|
||||
signer := signing.SignerFromFullIdentity(planet.Satellites[0].Identity)
|
||||
satStreamID := &pb.SatStreamID{
|
||||
satStreamID := &internalpb.StreamID{
|
||||
CreationDate: time.Now(),
|
||||
}
|
||||
signedStreamID, err := signing.SignStreamID(ctx, signer, satStreamID)
|
||||
signedStreamID, err := satMetainfo.SignStreamID(ctx, signer, satStreamID)
|
||||
require.NoError(t, err)
|
||||
|
||||
encodedStreamID, err := pb.Marshal(signedStreamID)
|
||||
@ -279,7 +280,7 @@ func TestInvalidAPIKey(t *testing.T) {
|
||||
|
||||
// these methods needs SegmentID
|
||||
|
||||
signedSegmentID, err := signing.SignSegmentID(ctx, signer, &pb.SatSegmentID{
|
||||
signedSegmentID, err := satMetainfo.SignSegmentID(ctx, signer, &internalpb.SegmentID{
|
||||
StreamId: satStreamID,
|
||||
CreationDate: time.Now(),
|
||||
})
|
||||
@ -940,7 +941,7 @@ func TestIDs(t *testing.T) {
|
||||
satellitePeer := signing.SignerFromFullIdentity(planet.Satellites[0].Identity)
|
||||
|
||||
{ // streamID expired
|
||||
signedStreamID, err := signing.SignStreamID(ctx, satellitePeer, &pb.SatStreamID{
|
||||
signedStreamID, err := satMetainfo.SignStreamID(ctx, satellitePeer, &internalpb.StreamID{
|
||||
CreationDate: time.Now().Add(-36 * time.Hour),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
@ -958,7 +959,7 @@ func TestIDs(t *testing.T) {
|
||||
}
|
||||
|
||||
{ // segment id missing stream id
|
||||
signedSegmentID, err := signing.SignSegmentID(ctx, satellitePeer, &pb.SatSegmentID{
|
||||
signedSegmentID, err := satMetainfo.SignSegmentID(ctx, satellitePeer, &internalpb.SegmentID{
|
||||
CreationDate: time.Now().Add(-1 * time.Hour),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
@ -976,9 +977,9 @@ func TestIDs(t *testing.T) {
|
||||
}
|
||||
|
||||
{ // segmentID expired
|
||||
signedSegmentID, err := signing.SignSegmentID(ctx, satellitePeer, &pb.SatSegmentID{
|
||||
signedSegmentID, err := satMetainfo.SignSegmentID(ctx, satellitePeer, &internalpb.SegmentID{
|
||||
CreationDate: time.Now().Add(-36 * time.Hour),
|
||||
StreamId: &pb.SatStreamID{
|
||||
StreamId: &internalpb.StreamID{
|
||||
CreationDate: time.Now(),
|
||||
},
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user