diff --git a/internal/grpc/services/gateway/usershareprovider.go b/internal/grpc/services/gateway/usershareprovider.go index b6950d9c659..625971071b3 100644 --- a/internal/grpc/services/gateway/usershareprovider.go +++ b/internal/grpc/services/gateway/usershareprovider.go @@ -20,7 +20,6 @@ package gateway import ( "context" - "fmt" "path" rtrace "github.com/cs3org/reva/pkg/trace" @@ -378,85 +377,6 @@ func (s *svc) removeReference(ctx context.Context, resourceID *provider.Resource return status.NewOK(ctx) } -func (s *svc) createReference(ctx context.Context, resourceID *provider.ResourceId) *rpc.Status { - ref := &provider.Reference{ - ResourceId: resourceID, - } - log := appctx.GetLogger(ctx) - - // get the metadata about the share - c, err := s.find(ctx, ref) - if err != nil { - if _, ok := err.(errtypes.IsNotFound); ok { - return status.NewNotFound(ctx, "storage provider not found") - } - return status.NewInternal(ctx, err, "error finding storage provider") - } - - statReq := &provider.StatRequest{ - Ref: ref, - } - - statRes, err := c.Stat(ctx, statReq) - if err != nil { - return status.NewInternal(ctx, err, "gateway: error calling Stat for the share resource id: "+resourceID.String()) - } - - if statRes.Status.Code != rpc.Code_CODE_OK { - err := status.NewErrorFromCode(statRes.Status.GetCode(), "gateway") - log.Err(err).Msg("gateway: Stat failed on the share resource id: " + resourceID.String()) - return status.NewInternal(ctx, err, "error updating received share") - } - - homeRes, err := s.GetHome(ctx, &provider.GetHomeRequest{}) - if err != nil { - err := errors.Wrap(err, "gateway: error calling GetHome") - return status.NewInternal(ctx, err, "error updating received share") - } - - // reference path is the home path + some name - // CreateReferene(cs3://home/MyShares/x) - // that can end up in the storage provider like: - // /eos/user/.shadow/g/gonzalhu/MyShares/x - // A reference can point to any place, for that reason the namespace starts with cs3:// - // For example, a reference can point also to a dropbox resource: - // CreateReference(dropbox://x/y/z) - // It is the responsibility of the gateway to resolve these references and merge the response back - // from the main request. - // TODO(labkode): the name of the share should be the filename it points to by default. - refPath := path.Join(homeRes.Path, s.c.ShareFolder, path.Base(statRes.Info.Path)) - log.Info().Msg("mount path will be:" + refPath) - - createRefReq := &provider.CreateReferenceRequest{ - Ref: &provider.Reference{Path: refPath}, - // cs3 is the Scheme and %s/%s is the Opaque parts of a net.URL. - TargetUri: fmt.Sprintf("cs3:%s/%s", resourceID.GetStorageId(), resourceID.GetOpaqueId()), - } - - c, err = s.findByPath(ctx, homeRes.Path) - if err != nil { - if _, ok := err.(errtypes.IsNotFound); ok { - return status.NewNotFound(ctx, "storage provider not found") - } - return status.NewInternal(ctx, err, "error finding storage provider") - } - - createRefRes, err := c.CreateReference(ctx, createRefReq) - if err != nil { - log.Err(err).Msg("gateway: error calling GetHome") - return &rpc.Status{ - Code: rpc.Code_CODE_INTERNAL, - } - } - - if createRefRes.Status.Code != rpc.Code_CODE_OK { - err := status.NewErrorFromCode(createRefRes.Status.GetCode(), "gateway") - return status.NewInternal(ctx, err, "error updating received share") - } - - return status.NewOK(ctx) -} - func (s *svc) denyGrant(ctx context.Context, id *provider.ResourceId, g *provider.Grantee) (*rpc.Status, error) { ref := &provider.Reference{ ResourceId: id, diff --git a/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/pending_test.go b/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/pending_test.go index 01a322e259a..cd38f75f6ed 100644 --- a/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/pending_test.go +++ b/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/pending_test.go @@ -53,16 +53,6 @@ var _ = Describe("The ocs API", func() { }) Describe("AcceptReceivedShare", func() { - type responseShare struct { - ID string `xml:"id"` - } - type listSharesData struct { - Shares []responseShare `xml:"element"` - } - type listSharesResponse struct { - Data listSharesData `xml:"data"` - } - var ( resID = &provider.ResourceId{ StorageId: "share1-storageid", diff --git a/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go b/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go index f7ce22c5cd4..f95b4bfea43 100644 --- a/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go +++ b/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go @@ -280,7 +280,6 @@ func (h *Handler) CreateShare(w http.ResponseWriter, r *http.Request) { response.WriteOCSError(w, r, response.MetaServerError.StatusCode, "machine authentication failed", nil) return } - //granteeCtx = revactx.ContextSetToken(granteeCtx, authRes.Token) granteeCtx = metadata.AppendToOutgoingContext(granteeCtx, revactx.TokenHeader, authRes.Token) lrs, ocsResponse := getSharesList(granteeCtx, client) @@ -370,12 +369,11 @@ func (h *Handler) extractPermissions(w http.ResponseWriter, r *http.Request, ri Message: err.Error(), Error: err, } - } else { - return nil, nil, &ocsError{ - Code: response.MetaBadRequest.StatusCode, - Message: err.Error(), - Error: err, - } + } + return nil, nil, &ocsError{ + Code: response.MetaBadRequest.StatusCode, + Message: err.Error(), + Error: err, } } role = conversions.RoleFromOCSPermissions(perm) diff --git a/pkg/share/manager/json/json.go b/pkg/share/manager/json/json.go index 27f94e2985a..9347fa613b0 100644 --- a/pkg/share/manager/json/json.go +++ b/pkg/share/manager/json/json.go @@ -403,10 +403,7 @@ func (m *mgr) ListReceivedShares(ctx context.Context, filters []*collaboration.F // to the same resource. Leave the more explicit and hide the more explicit. In this case we hide the group shares // and return the user share to the user. filtered := make([]*collaboration.ReceivedShare, 0) - - for _, s := range rss { - filtered = append(filtered, s) - } + filtered = append(filtered, rss...) for i := range rss { for j := range rss { diff --git a/pkg/share/manager/sql/sql_test.go b/pkg/share/manager/sql/sql_test.go index 5837d847dfb..24d20ede454 100644 --- a/pkg/share/manager/sql/sql_test.go +++ b/pkg/share/manager/sql/sql_test.go @@ -299,6 +299,7 @@ var _ = Describe("SQL manager", func() { 31, // permissions, 0, // accepted ) + Expect(err).ToNot(HaveOccurred()) shares, err := mgr.ListReceivedShares(ctx, []*collaboration.Filter{}) Expect(err).ToNot(HaveOccurred()) @@ -436,6 +437,7 @@ var _ = Describe("SQL manager", func() { 31, // permissions, 0, // accepted ) + Expect(err).ToNot(HaveOccurred()) parentRef := &collaboration.ShareReference{Spec: &collaboration.ShareReference_Id{ Id: &collaboration.ShareId{ OpaqueId: strconv.Itoa(parentID), diff --git a/pkg/user/manager/ldap/ldap.go b/pkg/user/manager/ldap/ldap.go index e87670dfe1b..4f72e018964 100644 --- a/pkg/user/manager/ldap/ldap.go +++ b/pkg/user/manager/ldap/ldap.go @@ -149,7 +149,7 @@ func (m *manager) GetUser(ctx context.Context, uid *userpb.UserId) (*userpb.User } defer l.Close() - userEntry, err := m.getLDAPUserById(ctx, l, uid) + userEntry, err := m.getLDAPUserByID(ctx, l, uid) if err != nil { return nil, err } @@ -350,11 +350,14 @@ func (m *manager) GetUserGroups(ctx context.Context, uid *userpb.UserId) ([]stri } defer l.Close() - userEntry, err := m.getLDAPUserById(ctx, l, uid) + userEntry, err := m.getLDAPUserByID(ctx, l, uid) + if err != nil { + return []string{}, err + } return m.getLDAPUserGroups(ctx, l, userEntry) } -func (m *manager) getLDAPUserById(ctx context.Context, conn *ldap.Conn, uid *userpb.UserId) (*ldap.Entry, error) { +func (m *manager) getLDAPUserByID(ctx context.Context, conn *ldap.Conn, uid *userpb.UserId) (*ldap.Entry, error) { log := appctx.GetLogger(ctx) // Search for the given clientID, use a sizeLimit of 1 to be able // to error out early when the userid is not unique