From 6515de1a903988b797fe2bc10e7b40fbdd60cbb3 Mon Sep 17 00:00:00 2001 From: Christian Richter Date: Mon, 22 Jan 2024 15:37:13 +0100 Subject: [PATCH 1/6] bump reva Signed-off-by: Christian Richter --- go.mod | 2 +- go.sum | 6 +- .../sharesstorageprovider.go | 1 + .../usershareprovider/usershareprovider.go | 10 +- .../http/services/owncloud/ocdav/ocdav.go | 2 - .../owncloud/ocdav/propfind/propfind.go | 10 +- .../handlers/apps/sharing/shares/pending.go | 214 +++++++++--------- .../handlers/apps/sharing/shares/shares.go | 38 +--- .../ocs/handlers/apps/sharing/shares/user.go | 12 +- .../cs3org/reva/v2/pkg/conversions/main.go | 4 +- .../rhttp/datatx/utils/download/download.go | 5 +- .../pkg/storage/utils/decomposedfs/grants.go | 10 - .../utils/decomposedfs/options/options.go | 6 +- .../cs3org/reva/v2/pkg/store/store.go | 4 +- vendor/modules.txt | 2 +- 15 files changed, 150 insertions(+), 176 deletions(-) diff --git a/go.mod b/go.mod index 2f9566aa0dc..3e345cc0b8c 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/coreos/go-oidc v2.2.1+incompatible github.com/coreos/go-oidc/v3 v3.9.0 github.com/cs3org/go-cs3apis v0.0.0-20231023073225-7748710e0781 - github.com/cs3org/reva/v2 v2.18.1-0.20240115094008-bde86a38bd77 + github.com/cs3org/reva/v2 v2.18.1-0.20240122171534-e8fc07f2395a github.com/dhowden/tag v0.0.0-20230630033851-978a0926ee25 github.com/disintegration/imaging v1.6.2 github.com/dutchcoders/go-clamd v0.0.0-20170520113014-b970184f4d9e diff --git a/go.sum b/go.sum index 816a6ecb7b9..c9ca0d89b20 100644 --- a/go.sum +++ b/go.sum @@ -1018,8 +1018,10 @@ github.com/crewjam/saml v0.4.14 h1:g9FBNx62osKusnFzs3QTN5L9CVA/Egfgm+stJShzw/c= github.com/crewjam/saml v0.4.14/go.mod h1:UVSZCf18jJkk6GpWNVqcyQJMD5HsRugBPf4I1nl2mME= github.com/cs3org/go-cs3apis v0.0.0-20231023073225-7748710e0781 h1:BUdwkIlf8IS2FasrrPg8gGPHQPOrQ18MS1Oew2tmGtY= github.com/cs3org/go-cs3apis v0.0.0-20231023073225-7748710e0781/go.mod h1:UXha4TguuB52H14EMoSsCqDj7k8a/t7g4gVP+bgY5LY= -github.com/cs3org/reva/v2 v2.18.1-0.20240115094008-bde86a38bd77 h1:wDi6MOBGdd9zyqDSwhm2FBYqkiEVgDUevpMBKQ6zSf4= -github.com/cs3org/reva/v2 v2.18.1-0.20240115094008-bde86a38bd77/go.mod h1:plMbmaHczZbP+1rtV56YCYs5lkmpdRNpj0KZb9BWLus= +github.com/cs3org/reva/v2 v2.18.1-0.20240122154113-d79f163775db h1:0nc89DfeCGRr98Z/NZor9fRyQ0pGxq0iQnnUsWFhnek= +github.com/cs3org/reva/v2 v2.18.1-0.20240122154113-d79f163775db/go.mod h1:plMbmaHczZbP+1rtV56YCYs5lkmpdRNpj0KZb9BWLus= +github.com/cs3org/reva/v2 v2.18.1-0.20240122171534-e8fc07f2395a h1:2FLa9HFgDlvXTAdDjqcHsb8Ky2eTBXIIR/ukZeemMKI= +github.com/cs3org/reva/v2 v2.18.1-0.20240122171534-e8fc07f2395a/go.mod h1:GCN3g6uYE0Nvd31dGlhaGGyUviUfbG2NkecPRv5oSc4= github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4= github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= diff --git a/vendor/github.com/cs3org/reva/v2/internal/grpc/services/sharesstorageprovider/sharesstorageprovider.go b/vendor/github.com/cs3org/reva/v2/internal/grpc/services/sharesstorageprovider/sharesstorageprovider.go index 012ee4bcef4..432bcb15cec 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/grpc/services/sharesstorageprovider/sharesstorageprovider.go +++ b/vendor/github.com/cs3org/reva/v2/internal/grpc/services/sharesstorageprovider/sharesstorageprovider.go @@ -859,6 +859,7 @@ func (s *service) ListContainer(ctx context.Context, req *provider.ListContainer OpaqueId: share.Share.Id.OpaqueId, } info.Path = filepath.Base(share.MountPoint.Path) + info.Name = info.Path infos = append(infos, info) } diff --git a/vendor/github.com/cs3org/reva/v2/internal/grpc/services/usershareprovider/usershareprovider.go b/vendor/github.com/cs3org/reva/v2/internal/grpc/services/usershareprovider/usershareprovider.go index 6efc53a59a5..0710d007864 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/grpc/services/usershareprovider/usershareprovider.go +++ b/vendor/github.com/cs3org/reva/v2/internal/grpc/services/usershareprovider/usershareprovider.go @@ -198,7 +198,7 @@ func (s *service) CreateShare(ctx context.Context, req *collaboration.CreateShar Status: status.NewPermissionDenied(ctx, nil, "no permission to add grants on shared resource"), }, err } - // check if the requested share creation has sufficient permissions to do so. + // check if the share creator has sufficient permissions to do so. if shareCreationAllowed := conversions.SufficientCS3Permissions( sRes.GetInfo().GetPermissionSet(), req.GetGrant().GetPermissions().GetPermissions(), @@ -207,6 +207,14 @@ func (s *service) CreateShare(ctx context.Context, req *collaboration.CreateShar Status: status.NewPermissionDenied(ctx, nil, "insufficient permissions to create that kind of share"), }, nil } + // check if the requested permission are plausible for the Resource + if sRes.GetInfo().GetType() == provider.ResourceType_RESOURCE_TYPE_FILE { + if newPermissions := req.GetGrant().GetPermissions().GetPermissions(); newPermissions.GetCreateContainer() || newPermissions.GetMove() || newPermissions.GetDelete() { + return &collaboration.CreateShareResponse{ + Status: status.NewInvalid(ctx, "cannot set the requested permissions on that type of resource"), + }, nil + } + } if !s.isPathAllowed(req.GetResourceInfo().GetPath()) { return &collaboration.CreateShareResponse{ diff --git a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/ocdav.go b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/ocdav.go index 0eabd525e1f..509a6ea633f 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/ocdav.go +++ b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/ocdav.go @@ -286,8 +286,6 @@ func (s *svc) ApplyLayout(ctx context.Context, ns string, useLoggedInUserNS bool func addAccessHeaders(w http.ResponseWriter, r *http.Request) { headers := w.Header() - // the webdav api is accessible from anywhere - headers.Set("Access-Control-Allow-Origin", "*") // all resources served via the DAV endpoint should have the strictest possible as default headers.Set("Content-Security-Policy", "default-src 'none';") // disable sniffing the content type for IE diff --git a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/propfind/propfind.go b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/propfind/propfind.go index f9271fbbe91..fc5764738e9 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/propfind/propfind.go +++ b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/propfind/propfind.go @@ -486,12 +486,16 @@ func (p *Handler) propfindResponse(ctx context.Context, w http.ResponseWriter, r w.Header().Set(net.HeaderDav, "1, 3, extended-mkcol") w.Header().Set(net.HeaderContentType, "application/xml; charset=utf-8") if sendTusHeaders { - w.Header().Add(net.HeaderAccessControlExposeHeaders, strings.Join([]string{net.HeaderTusResumable, net.HeaderTusVersion, net.HeaderTusExtension}, ", ")) + w.Header().Add(net.HeaderAccessControlExposeHeaders, net.HeaderTusResumable) + w.Header().Add(net.HeaderAccessControlExposeHeaders, net.HeaderTusVersion) + w.Header().Add(net.HeaderAccessControlExposeHeaders, net.HeaderTusExtension) + w.Header().Set(net.HeaderAccessControlExposeHeaders, strings.Join(w.Header().Values(net.HeaderAccessControlExposeHeaders), ", ")) w.Header().Set(net.HeaderTusResumable, "1.0.0") w.Header().Set(net.HeaderTusVersion, "1.0.0") - w.Header().Set(net.HeaderTusExtension, "creation,creation-with-upload,checksum,expiration") + w.Header().Set(net.HeaderTusExtension, "creation, creation-with-upload, checksum, expiration") } - w.Header().Set(net.HeaderVary, net.HeaderPrefer) + w.Header().Add(net.HeaderVary, net.HeaderPrefer) + w.Header().Set(net.HeaderVary, strings.Join(w.Header().Values(net.HeaderVary), ", ")) if returnMinimal { w.Header().Set(net.HeaderPreferenceApplied, "return=minimal") } diff --git a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/pending.go b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/pending.go index b53d18021bb..ca6c28df5d9 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/pending.go +++ b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/pending.go @@ -36,6 +36,7 @@ import ( "github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/response" "github.com/cs3org/reva/v2/pkg/appctx" "github.com/cs3org/reva/v2/pkg/conversions" + "github.com/cs3org/reva/v2/pkg/errtypes" "github.com/cs3org/reva/v2/pkg/utils" "github.com/go-chi/chi/v5" "github.com/pkg/errors" @@ -63,62 +64,110 @@ func (h *Handler) AcceptReceivedShare(w http.ResponseWriter, r *http.Request) { return } - rs, ocsResponse := getReceivedShareFromID(ctx, client, shareID) + receivedShare, ocsResponse := getReceivedShareFromID(ctx, client, shareID) if ocsResponse != nil { response.WriteOCSResponse(w, r, *ocsResponse, nil) return } - sharedResource, ocsResponse := getSharedResource(ctx, client, rs.Share.Share.ResourceId) + sharedResource, ocsResponse := getSharedResource(ctx, client, receivedShare.Share.ResourceId) if ocsResponse != nil { response.WriteOCSResponse(w, r, *ocsResponse, nil) return } - lrs, ocsResponse := getSharesList(ctx, client) - if ocsResponse != nil { - response.WriteOCSResponse(w, r, *ocsResponse, nil) + mount, unmountedShares, err := GetMountpointAndUnmountedShares(ctx, client, sharedResource.Info) + if err != nil { + response.WriteOCSError(w, r, response.MetaServerError.StatusCode, "could not determine mountpoint", err) + return + } + + // first update the requested share + receivedShare.State = collaboration.ShareState_SHARE_STATE_ACCEPTED + // we need to add a path to the share + receivedShare.MountPoint = &provider.Reference{ + Path: mount, + } + + updateMask := &fieldmaskpb.FieldMask{Paths: []string{"state", "mount_point"}} + data, meta, err := h.updateReceivedShare(r.Context(), receivedShare, updateMask) + if err != nil { + // we log an error for affected shares, for the actual share we return an error + response.WriteOCSData(w, r, meta, data, err) return } + response.WriteOCSSuccess(w, r, []*conversions.ShareData{data}) + + // then update other unmounted shares to the same resource + for _, rs := range unmountedShares { + if rs.GetShare().GetId().GetOpaqueId() == shareID { + // we already updated this one + continue + } + + rs.State = collaboration.ShareState_SHARE_STATE_ACCEPTED + // set the same mountpoint as for the requested received share + rs.MountPoint = &provider.Reference{ + Path: mount, + } + + _, _, err := h.updateReceivedShare(r.Context(), rs, updateMask) + if err != nil { + // we log an error for affected shares, the actual share was successful + appctx.GetLogger(ctx).Error().Err(err).Str("received_share", shareID).Str("affected_share", rs.GetShare().GetId().GetOpaqueId()).Msg("could not update affected received share") + } + } +} + +// GetMountpointAndUnmountedShares returns a new or existing mountpoint for the given info and produces a list of unmounted received shares for the same resource +func GetMountpointAndUnmountedShares(ctx context.Context, gwc gateway.GatewayAPIClient, info *provider.ResourceInfo) (string, []*collaboration.ReceivedShare, error) { + unmountedShares := []*collaboration.ReceivedShare{} + receivedShares, err := listReceivedShares(ctx, gwc) + if err != nil { + return "", unmountedShares, err + } // we need to sort the received shares by mount point in order to make things easier to evaluate. - base := path.Base(sharedResource.GetInfo().GetPath()) - mount := base - var mountedShares []*collaboration.ReceivedShare - sharesToAccept := map[string]bool{shareID: true} - for _, s := range lrs.Shares { - if utils.ResourceIDEqual(s.Share.ResourceId, rs.Share.Share.GetResourceId()) { + mount := filepath.Clean(info.Name) + existingMountpoint := "" + mountedShares := make([]*collaboration.ReceivedShare, 0, len(receivedShares)) + for _, s := range receivedShares { + if utils.ResourceIDEqual(s.Share.ResourceId, info.GetId()) { if s.State == collaboration.ShareState_SHARE_STATE_ACCEPTED { - mount = s.MountPoint.Path + // a share to the resource already exists and is mounted, remember the mount point + _, err := utils.GetResourceByID(ctx, s.Share.ResourceId, gwc) + if err == nil { + existingMountpoint = s.MountPoint.Path + } } else { - sharesToAccept[s.Share.Id.OpaqueId] = true - } - } else { - if s.State == collaboration.ShareState_SHARE_STATE_ACCEPTED { - s.Hidden = h.getReceivedShareHideFlagFromShareID(r.Context(), shareID) - mountedShares = append(mountedShares, s) + // a share to the resource already exists but is not mounted, collect the unmounted share + unmountedShares = append(unmountedShares, s) } } + + if s.State == collaboration.ShareState_SHARE_STATE_ACCEPTED { + mountedShares = append(mountedShares, s) + } } - compareMountPoint := func(i, j int) bool { + sort.Slice(mountedShares, func(i, j int) bool { return mountedShares[i].MountPoint.Path > mountedShares[j].MountPoint.Path + }) + + if existingMountpoint != "" { + // we want to reuse the same mountpoint for all unmounted shares to the same resource + return existingMountpoint, unmountedShares, nil } - sort.Slice(mountedShares, compareMountPoint) - // now we have a list of shares, we want to iterate over all of them and check for name collisions + // we have a list of shares, we want to iterate over all of them and check for name collisions for i, ms := range mountedShares { if ms.MountPoint.Path == mount { // does the shared resource still exist? - res, err := client.Stat(ctx, &provider.StatRequest{ - Ref: &provider.Reference{ - ResourceId: ms.Share.ResourceId, - }, - }) - if err == nil && res.Status.Code == rpc.Code_CODE_OK { + _, err := utils.GetResourceByID(ctx, ms.Share.ResourceId, gwc) + if err == nil { // The mount point really already exists, we need to insert a number into the filename - ext := filepath.Ext(base) - name := strings.TrimSuffix(base, ext) + ext := filepath.Ext(mount) + name := strings.TrimSuffix(mount, ext) // be smart about .tar.(gz|bz) files if strings.HasSuffix(name, ".tar") { name = strings.TrimSuffix(name, ".tar") @@ -130,26 +179,7 @@ func (h *Handler) AcceptReceivedShare(w http.ResponseWriter, r *http.Request) { // TODO we could delete shares here if the stat returns code NOT FOUND ... but listening for file deletes would be better } } - // we need to add a path to the share - receivedShare := &collaboration.ReceivedShare{ - Share: &collaboration.Share{ - Id: &collaboration.ShareId{OpaqueId: shareID}, - }, - State: collaboration.ShareState_SHARE_STATE_ACCEPTED, - Hidden: h.getReceivedShareHideFlagFromShareID(r.Context(), shareID), - MountPoint: &provider.Reference{ - Path: mount, - }, - } - updateMask := &fieldmaskpb.FieldMask{Paths: []string{"state", "hidden", "mount_point"}} - - for id := range sharesToAccept { - data := h.updateReceivedShare(w, r, receivedShare, updateMask) - // only render the data for the changed share - if id == shareID && data != nil { - response.WriteOCSSuccess(w, r, []*conversions.ShareData{data}) - } - } + return mount, unmountedShares, nil } // RejectReceivedShare handles DELETE Requests on /apps/files_sharing/api/v1/shares/{shareid} @@ -166,15 +196,15 @@ func (h *Handler) RejectReceivedShare(w http.ResponseWriter, r *http.Request) { Share: &collaboration.Share{ Id: &collaboration.ShareId{OpaqueId: shareID}, }, - State: collaboration.ShareState_SHARE_STATE_REJECTED, - Hidden: h.getReceivedShareHideFlagFromShareID(r.Context(), shareID), + State: collaboration.ShareState_SHARE_STATE_REJECTED, } - updateMask := &fieldmaskpb.FieldMask{Paths: []string{"state", "hidden"}} + updateMask := &fieldmaskpb.FieldMask{Paths: []string{"state"}} - data := h.updateReceivedShare(w, r, receivedShare, updateMask) - if data != nil { - response.WriteOCSSuccess(w, r, []*conversions.ShareData{data}) + data, meta, err := h.updateReceivedShare(r.Context(), receivedShare, updateMask) + if err != nil { + response.WriteOCSData(w, r, meta, nil, err) } + response.WriteOCSSuccess(w, r, []*conversions.ShareData{data}) } func (h *Handler) UpdateReceivedShare(w http.ResponseWriter, r *http.Request) { @@ -199,18 +229,17 @@ func (h *Handler) UpdateReceivedShare(w http.ResponseWriter, r *http.Request) { rs, _ := getReceivedShareFromID(r.Context(), client, shareID) if rs != nil && rs.Share != nil { - receivedShare.State = rs.Share.State + receivedShare.State = rs.State } - data := h.updateReceivedShare(w, r, receivedShare, updateMask) - if data != nil { - response.WriteOCSSuccess(w, r, []*conversions.ShareData{data}) + data, meta, err := h.updateReceivedShare(r.Context(), receivedShare, updateMask) + if err != nil { + response.WriteOCSData(w, r, meta, nil, err) } - // TODO: do we need error handling here? + response.WriteOCSSuccess(w, r, []*conversions.ShareData{data}) } -func (h *Handler) updateReceivedShare(w http.ResponseWriter, r *http.Request, receivedShare *collaboration.ReceivedShare, fieldMask *fieldmaskpb.FieldMask) *conversions.ShareData { - ctx := r.Context() +func (h *Handler) updateReceivedShare(ctx context.Context, receivedShare *collaboration.ReceivedShare, fieldMask *fieldmaskpb.FieldMask) (*conversions.ShareData, response.Meta, error) { logger := appctx.GetLogger(ctx) updateShareRequest := &collaboration.UpdateReceivedShareRequest{ @@ -220,23 +249,19 @@ func (h *Handler) updateReceivedShare(w http.ResponseWriter, r *http.Request, re client, err := h.getClient() if err != nil { - response.WriteOCSError(w, r, response.MetaServerError.StatusCode, "error getting grpc gateway client", err) - return nil + return nil, response.MetaServerError, errors.Wrap(err, "error getting grpc gateway client") } shareRes, err := client.UpdateReceivedShare(ctx, updateShareRequest) if err != nil { - response.WriteOCSError(w, r, response.MetaServerError.StatusCode, "grpc update received share request failed", err) - return nil + return nil, response.MetaServerError, errors.Wrap(err, "grpc update received share request failed") } if shareRes.Status.Code != rpc.Code_CODE_OK { if shareRes.Status.Code == rpc.Code_CODE_NOT_FOUND { - response.WriteOCSError(w, r, response.MetaNotFound.StatusCode, "not found", nil) - return nil + return nil, response.MetaNotFound, errors.New(shareRes.Status.Message) } - response.WriteOCSError(w, r, response.MetaServerError.StatusCode, "grpc update received share request failed", errors.Errorf("code: %d, message: %s", shareRes.Status.Code, shareRes.Status.Message)) - return nil + return nil, response.MetaServerError, errors.Errorf("grpc update received share request failed: code: %d, message: %s", shareRes.Status.Code, shareRes.Status.Message) } rs := shareRes.GetShare() @@ -244,27 +269,23 @@ func (h *Handler) updateReceivedShare(w http.ResponseWriter, r *http.Request, re info, status, err := h.getResourceInfoByID(ctx, client, rs.Share.ResourceId) if err != nil || status.Code != rpc.Code_CODE_OK { h.logProblems(logger, status, err, "could not stat, skipping") - response.WriteOCSError(w, r, response.MetaServerError.StatusCode, "grpc get resource info failed", errors.Errorf("code: %d, message: %s", status.Code, status.Message)) - return nil + return nil, response.MetaServerError, errors.Errorf("grpc get resource info failed: code: %d, message: %s", status.Code, status.Message) } - data, err := conversions.CS3Share2ShareData(r.Context(), rs.Share) - if err != nil { - logger.Debug().Interface("share", rs.Share).Interface("shareData", data).Err(err).Msg("could not CS3Share2ShareData, skipping") - } + data := conversions.CS3Share2ShareData(ctx, rs.Share) data.State = mapState(rs.GetState()) data.Hidden = rs.GetHidden() h.addFileInfo(ctx, data, info) - h.mapUserIds(r.Context(), client, data) + h.mapUserIds(ctx, client, data) if data.State == ocsStateAccepted { // Needed because received shares can be jailed in a folder in the users home data.Path = path.Join(h.sharePrefix, path.Base(info.Path)) } - return data + return data, response.MetaOK, nil } func (h *Handler) updateReceivedFederatedShare(w http.ResponseWriter, r *http.Request, shareID string, rejectShare bool) { @@ -337,21 +358,8 @@ func (h *Handler) updateReceivedFederatedShare(w http.ResponseWriter, r *http.Re response.WriteOCSSuccess(w, r, []*conversions.ShareData{data}) } -// getReceivedShareHideFlagFromShareId returns the hide flag of a received share based on its ID. -func (h *Handler) getReceivedShareHideFlagFromShareID(ctx context.Context, shareID string) bool { - client, err := h.getClient() - if err != nil { - return false - } - rs, _ := getReceivedShareFromID(ctx, client, shareID) - if rs != nil { - return rs.GetShare().GetHidden() - } - return false -} - // getReceivedShareFromID uses a client to the gateway to fetch a share based on its ID. -func getReceivedShareFromID(ctx context.Context, client gateway.GatewayAPIClient, shareID string) (*collaboration.GetReceivedShareResponse, *response.Response) { +func getReceivedShareFromID(ctx context.Context, client gateway.GatewayAPIClient, shareID string) (*collaboration.ReceivedShare, *response.Response) { s, err := client.GetReceivedShare(ctx, &collaboration.GetReceivedShareRequest{ Ref: &collaboration.ShareReference{ Spec: &collaboration.ShareReference_Id{ @@ -376,7 +384,7 @@ func getReceivedShareFromID(ctx context.Context, client gateway.GatewayAPIClient return nil, arbitraryOcsResponse(response.MetaBadRequest.StatusCode, e.Error()) } - return s, nil + return s.Share, nil } // getSharedResource attempts to get a shared resource from the storage from the resource reference. @@ -403,23 +411,17 @@ func getSharedResource(ctx context.Context, client gateway.GatewayAPIClient, res return res, nil } -// getSharedResource gets the list of all shares for the current user. -func getSharesList(ctx context.Context, client gateway.GatewayAPIClient) (*collaboration.ListReceivedSharesResponse, *response.Response) { - shares, err := client.ListReceivedShares(ctx, &collaboration.ListReceivedSharesRequest{}) +// listReceivedShares list all received shares for the current user. +func listReceivedShares(ctx context.Context, client gateway.GatewayAPIClient) ([]*collaboration.ReceivedShare, error) { + res, err := client.ListReceivedShares(ctx, &collaboration.ListReceivedSharesRequest{}) if err != nil { - e := errors.Wrap(err, "error getting shares list") - return nil, arbitraryOcsResponse(response.MetaNotFound.StatusCode, e.Error()) + return nil, errtypes.InternalError("grpc list received shares request failed") } - if shares.Status.Code != rpc.Code_CODE_OK { - if shares.Status.Code == rpc.Code_CODE_NOT_FOUND { - e := fmt.Errorf("not found") - return nil, arbitraryOcsResponse(response.MetaNotFound.StatusCode, e.Error()) - } - e := fmt.Errorf(shares.GetStatus().GetMessage()) - return nil, arbitraryOcsResponse(response.MetaServerError.StatusCode, e.Error()) + if err := errtypes.NewErrtypeFromStatus(res.Status); err != nil { + return nil, err } - return shares, nil + return res.Shares, nil } // arbitraryOcsResponse abstracts the boilerplate that is creating a response.Response struct. diff --git a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go index 303fc95d401..f75a30b3400 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go +++ b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go @@ -303,11 +303,7 @@ func (h *Handler) CreateShare(w http.ResponseWriter, r *http.Request) { return } - s, err := conversions.CS3Share2ShareData(ctx, share) - if err != nil { - response.WriteOCSError(w, r, response.MetaServerError.StatusCode, "error mapping share data", err) - return - } + s := conversions.CS3Share2ShareData(ctx, share) h.addFileInfo(ctx, s, statRes.Info) @@ -402,12 +398,12 @@ func (h *Handler) updateExistingShareMountpoints(ctx context.Context, shareType } granteeCtx = metadata.AppendToOutgoingContext(granteeCtx, ctxpkg.TokenHeader, authRes.Token) - lrs, ocsResponse := getSharesList(granteeCtx, client) - if ocsResponse != nil { - return ocsResponse.OCS.Meta.StatusCode, ocsResponse.OCS.Meta.Message, nil + receivedShares, err := listReceivedShares(granteeCtx, client) + if err != nil { + return response.MetaServerError.StatusCode, "could not list shares", nil } - for _, s := range lrs.Shares { + for _, s := range receivedShares { if s.GetShare().GetId() != share.Id && s.State == collaboration.ShareState_SHARE_STATE_ACCEPTED && utils.ResourceIDEqual(s.Share.ResourceId, info.GetId()) { updateRequest := &collaboration.UpdateReceivedShareRequest{ Share: &collaboration.ReceivedShare{ @@ -595,12 +591,8 @@ func (h *Handler) GetShare(w http.ResponseWriter, r *http.Request) { }) if err == nil && uRes.GetShare() != nil { resourceID = uRes.Share.Share.ResourceId - share, err = conversions.CS3Share2ShareData(ctx, uRes.Share.Share) + share = conversions.CS3Share2ShareData(ctx, uRes.Share.Share) share.Hidden = uRes.Share.Hidden - if err != nil { - response.WriteOCSError(w, r, response.MetaServerError.StatusCode, "error mapping share data", err) - return - } } } @@ -635,11 +627,7 @@ func (h *Handler) GetShare(w http.ResponseWriter, r *http.Request) { if err == nil && uRes.GetShare() != nil { resourceID = uRes.Share.ResourceId - share, err = conversions.CS3Share2ShareData(ctx, uRes.Share) - if err != nil { - response.WriteOCSError(w, r, response.MetaServerError.StatusCode, "error mapping share data", err) - return - } + share = conversions.CS3Share2ShareData(ctx, uRes.Share) } } @@ -874,11 +862,7 @@ func (h *Handler) updateShare(w http.ResponseWriter, r *http.Request, share *col h.statCache.RemoveStat(currentUser.Id, share.ResourceId) } - resultshare, err := conversions.CS3Share2ShareData(ctx, uRes.Share) - if err != nil { - response.WriteOCSError(w, r, response.MetaServerError.StatusCode, "error mapping share data", err) - return - } + resultshare := conversions.CS3Share2ShareData(ctx, uRes.Share) statReq := provider.StatRequest{Ref: &provider.Reference{ ResourceId: uRes.Share.ResourceId, @@ -1072,11 +1056,7 @@ func (h *Handler) listSharesWithMe(w http.ResponseWriter, r *http.Request) { } } - data, err := conversions.CS3Share2ShareData(r.Context(), rs.Share) - if err != nil { - sublog.Debug().Interface("share", rs.Share).Interface("shareData", data).Err(err).Msg("could not CS3Share2ShareData, skipping") - continue - } + data := conversions.CS3Share2ShareData(r.Context(), rs.Share) data.State = mapState(rs.GetState()) data.Hidden = rs.Hidden diff --git a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/user.go b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/user.go index 04498b22057..dd940741b2f 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/user.go +++ b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/user.go @@ -281,11 +281,7 @@ func (h *Handler) removeUserShare(w http.ResponseWriter, r *http.Request, share }, } - data, err := conversions.CS3Share2ShareData(ctx, share) - if err != nil { - response.WriteOCSError(w, r, response.MetaServerError.StatusCode, "deleting share failed", err) - return - } + data := conversions.CS3Share2ShareData(ctx, share) // A deleted share should not have an ID. data.ID = "" @@ -337,11 +333,7 @@ func (h *Handler) listUserShares(r *http.Request, filters []*collaboration.Filte // build OCS response payload for _, s := range lsUserSharesResponse.Shares { - data, err := conversions.CS3Share2ShareData(ctx, s) - if err != nil { - log.Debug().Interface("share", s).Interface("shareData", data).Err(err).Msg("could not CS3Share2ShareData, skipping") - continue - } + data := conversions.CS3Share2ShareData(ctx, s) info, status, err := h.getResourceInfoByID(ctx, client, s.ResourceId) if err != nil || status.Code != rpc.Code_CODE_OK { diff --git a/vendor/github.com/cs3org/reva/v2/pkg/conversions/main.go b/vendor/github.com/cs3org/reva/v2/pkg/conversions/main.go index 8ef5dc395ab..dbeaedd3722 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/conversions/main.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/conversions/main.go @@ -232,7 +232,7 @@ type MatchValueData struct { } // CS3Share2ShareData converts a cs3api user share into shareData data model -func CS3Share2ShareData(ctx context.Context, share *collaboration.Share) (*ShareData, error) { +func CS3Share2ShareData(ctx context.Context, share *collaboration.Share) *ShareData { sd := &ShareData{ // share.permissions are mapped below // Displaynames are added later @@ -269,7 +269,7 @@ func CS3Share2ShareData(ctx context.Context, share *collaboration.Share) (*Share sd.Expiration = expiration.Format(_iso8601) } - return sd, nil + return sd } // PublicShare2ShareData converts a cs3api public share into shareData data model diff --git a/vendor/github.com/cs3org/reva/v2/pkg/rhttp/datatx/utils/download/download.go b/vendor/github.com/cs3org/reva/v2/pkg/rhttp/datatx/utils/download/download.go index cf0c8632376..c15029bd2fd 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/rhttp/datatx/utils/download/download.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/rhttp/datatx/utils/download/download.go @@ -159,6 +159,8 @@ func GetOrHeadFile(w http.ResponseWriter, r *http.Request, fs storage.FS, spaceI w.Header().Set("Accept-Ranges", "bytes") } + w.Header().Set(net.HeaderContentType, strings.Join([]string{md.MimeType, "charset=UTF-8"}, "; ")) + if len(ranges) > 0 { sublog.Debug().Int64("start", ranges[0].Start).Int64("length", ranges[0].Length).Msg("range request") if s == nil { @@ -200,7 +202,7 @@ func GetOrHeadFile(w http.ResponseWriter, r *http.Request, fs storage.FS, spaceI defer pr.Close() // cause writing goroutine to fail and exit if CopyN doesn't finish. go func() { for _, ra := range ranges { - part, err := mw.CreatePart(ra.MimeHeader(md.MimeType, int64(md.Size))) + part, err := mw.CreatePart(ra.MimeHeader(md.MimeType+"; charset=UTF-8", int64(md.Size))) if err != nil { _ = pw.CloseWithError(err) // CloseWithError always returns nil return @@ -224,7 +226,6 @@ func GetOrHeadFile(w http.ResponseWriter, r *http.Request, fs storage.FS, spaceI w.Header().Set(net.HeaderContentLength, strconv.FormatInt(sendSize, 10)) } - w.Header().Set(net.HeaderContentType, md.MimeType) w.Header().Set(net.HeaderContentDisposistion, net.ContentDispositionAttachment(path.Base(md.Path))) w.Header().Set(net.HeaderETag, md.Etag) w.Header().Set(net.HeaderOCFileID, storagespace.FormatResourceID(*md.Id)) diff --git a/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/grants.go b/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/grants.go index ed3f7ca113f..9dda19fa634 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/grants.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/grants.go @@ -197,11 +197,6 @@ func (fs *Decomposedfs) RemoveGrant(ctx context.Context, ref *provider.Reference } } - // check lock - if err := grantNode.CheckLock(ctx); err != nil { - return err - } - if err := grantNode.DeleteGrant(ctx, g, false); err != nil { return err } @@ -308,11 +303,6 @@ func (fs *Decomposedfs) loadGrant(ctx context.Context, ref *provider.Reference, } func (fs *Decomposedfs) storeGrant(ctx context.Context, n *node.Node, g *provider.Grant) error { - // check lock - if err := n.CheckLock(ctx); err != nil { - return err - } - var spaceType string spaceGrant := ctx.Value(utils.SpaceGrant) // this is not a grant on a space root we are just adding a share diff --git a/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/options/options.go b/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/options/options.go index 6e081fdcea4..f58edff6a2f 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/options/options.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/options/options.go @@ -91,11 +91,7 @@ type AsyncPropagatorOptions struct { // EventOptions are the configurable options for events type EventOptions struct { - NatsAddress string `mapstructure:"natsaddress"` - NatsClusterID string `mapstructure:"natsclusterid"` - TLSInsecure bool `mapstructure:"tlsinsecure"` - TLSRootCACertificate string `mapstructure:"tlsrootcacertificate"` - NumConsumers int `mapstructure:"numconsumers"` + NumConsumers int `mapstructure:"numconsumers"` } // TokenOptions are the configurable option for tokens diff --git a/vendor/github.com/cs3org/reva/v2/pkg/store/store.go b/vendor/github.com/cs3org/reva/v2/pkg/store/store.go index f26edff2e2d..0038d00580b 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/store/store.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/store/store.go @@ -151,8 +151,8 @@ func Create(opts ...microstore.Option) microstore.Store { } return natsjskv.NewStore( append(opts, - natsjs.NatsOptions(natsOptions), // always pass in properly initialized default nats options - natsjs.DefaultTTL(ttl))..., + natsjskv.NatsOptions(natsOptions), // always pass in properly initialized default nats options + natsjskv.DefaultTTL(ttl))..., ) case TypeMemory, "mem", "": // allow existing short form and use as default return microstore.NewMemoryStore(opts...) diff --git a/vendor/modules.txt b/vendor/modules.txt index 552be2a0b2d..1e48fa46ea5 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -362,7 +362,7 @@ github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1 github.com/cs3org/go-cs3apis/cs3/storage/registry/v1beta1 github.com/cs3org/go-cs3apis/cs3/tx/v1beta1 github.com/cs3org/go-cs3apis/cs3/types/v1beta1 -# github.com/cs3org/reva/v2 v2.18.1-0.20240115094008-bde86a38bd77 +# github.com/cs3org/reva/v2 v2.18.1-0.20240122171534-e8fc07f2395a ## explicit; go 1.21 github.com/cs3org/reva/v2/cmd/revad/internal/grace github.com/cs3org/reva/v2/cmd/revad/runtime From c2f0ac41df375116c76c5bbec9803ecbf02c5605 Mon Sep 17 00:00:00 2001 From: Michael Barz Date: Mon, 22 Jan 2024 21:37:28 +0100 Subject: [PATCH 2/6] tests: fix test expectation --- changelog/unreleased/bump-reva.md | 1 + .../expected-failures-localAPI-on-OCIS-storage.md | 12 ++++++++---- .../features/apiSharingNg/deletePermissions.feature | 8 -------- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/changelog/unreleased/bump-reva.md b/changelog/unreleased/bump-reva.md index 81e2d51d5ea..b08ffe6c430 100644 --- a/changelog/unreleased/bump-reva.md +++ b/changelog/unreleased/bump-reva.md @@ -2,4 +2,5 @@ Enhancement: Update reva to latest edge version We update reva to the latest edge version to get the latest fixes and features. +https://github.com/owncloud/ocis/pull/8264 https://github.com/owncloud/ocis/pull/8100 diff --git a/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md b/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md index 523a252c84e..acd221bf22e 100644 --- a/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md +++ b/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md @@ -270,10 +270,10 @@ The expected failures in this file are from features in the owncloud/ocis repo. - [apiSharingNg/linkShare.feature:453](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg/linkShare.feature#L453) - [apiSharingNg/linkShare.feature:455](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg/linkShare.feature#L455) - [apiSharingNg/linkShare.feature:456](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg/linkShare.feature#L456) -- [apiSharingNg/deletePermissions.feature:146](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg/deletePermissions.feature#L146) -- [apiSharingNg/deletePermissions.feature:163](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg/deletePermissions.feature#L163) -- [apiSharingNg/deletePermissions.feature:184](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg/deletePermissions.feature#L184) -- [apiSharingNg/deletePermissions.feature:203](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg/deletePermissions.feature#L203) +- [apiSharingNg/deletePermissions.feature:138](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg/deletePermissions.feature#L138) +- [apiSharingNg/deletePermissions.feature:155](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg/deletePermissions.feature#L155) +- [apiSharingNg/deletePermissions.feature:176](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg/deletePermissions.feature#L176) +- [apiSharingNg/deletePermissions.feature:195](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSharingNg/deletePermissions.feature#L195) ### [sharee (editor role) MOVE a file by file-id into same shared folder returns 403](https://github.com/owncloud/ocis/issues/7617) @@ -359,5 +359,9 @@ The expected failures in this file are from features in the owncloud/ocis repo. - [apiSpacesDavOperation/moveByFileId.feature:464](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpacesDavOperation/moveByFileId.feature#L464) - [apiSpacesDavOperation/moveByFileId.feature:465](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpacesDavOperation/moveByFileId.feature#L465) +### [CORS headers are only set when origin is sent by the client](https://github.com/owncloud/ocis/issues/5195) + +- [apiContract/copy.feature:16](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiContract/copy.feature#L16) + - Note: always have an empty line at the end of this file. The bash script that processes this file requires that the last line has a newline on the end. diff --git a/tests/acceptance/features/apiSharingNg/deletePermissions.feature b/tests/acceptance/features/apiSharingNg/deletePermissions.feature index 83199829663..83053a67184 100644 --- a/tests/acceptance/features/apiSharingNg/deletePermissions.feature +++ b/tests/acceptance/features/apiSharingNg/deletePermissions.feature @@ -27,8 +27,6 @@ Feature: Remove access to a drive item | permissionsRole | resource-type | path | | Viewer | file | textfile.txt | | File Editor | file | textfile.txt | - | Co Owner | file | textfile.txt | - | Manager | file | textfile.txt | | Viewer | folder | FolderToShare | | Editor | folder | FolderToShare | | Co Owner | folder | FolderToShare | @@ -56,8 +54,6 @@ Feature: Remove access to a drive item | permissionsRole | resource-type | path | | Viewer | file | textfile.txt | | File Editor | file | textfile.txt | - | Co Owner | file | textfile.txt | - | Manager | file | textfile.txt | | Viewer | folder | FolderToShare | | Editor | folder | FolderToShare | | Co Owner | folder | FolderToShare | @@ -86,8 +82,6 @@ Feature: Remove access to a drive item | permissionsRole | resource-type | path | | Viewer | file | textfile.txt | | File Editor | file | textfile.txt | - | Co Owner | file | textfile.txt | - | Manager | file | textfile.txt | | Viewer | folder | FolderToShare | | Editor | folder | FolderToShare | | Co Owner | folder | FolderToShare | @@ -118,8 +112,6 @@ Feature: Remove access to a drive item | permissionsRole | resource-type | path | | Viewer | file | textfile.txt | | File Editor | file | textfile.txt | - | Co Owner | file | textfile.txt | - | Manager | file | textfile.txt | | Viewer | folder | FolderToShare | | Editor | folder | FolderToShare | | Co Owner | folder | FolderToShare | From 9cb81073c1fd61dd959f02de68c391a81d4e376d Mon Sep 17 00:00:00 2001 From: Saw-jan Date: Tue, 23 Jan 2024 12:18:19 +0545 Subject: [PATCH 3/6] fix test expectations --- .../apiSharingNg/shareInvitations.feature | 30 ++++--------------- 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/tests/acceptance/features/apiSharingNg/shareInvitations.feature b/tests/acceptance/features/apiSharingNg/shareInvitations.feature index 331668114f6..931e0160e86 100644 --- a/tests/acceptance/features/apiSharingNg/shareInvitations.feature +++ b/tests/acceptance/features/apiSharingNg/shareInvitations.feature @@ -89,8 +89,6 @@ Feature: Send a sharing invitations | permissions-role | resource-type | path | | Viewer | file | /textfile1.txt | | File Editor | file | /textfile1.txt | - | Co Owner | file | /textfile1.txt | - | Manager | file | /textfile1.txt | | Viewer | folder | FolderToShare | | Editor | folder | FolderToShare | | Co Owner | folder | FolderToShare | @@ -181,8 +179,6 @@ Feature: Send a sharing invitations | permissions-role | resource-type | path | | Viewer | file | /textfile1.txt | | File Editor | file | /textfile1.txt | - | Co Owner | file | /textfile1.txt | - | Manager | file | /textfile1.txt | | Viewer | folder | FolderToShare | | Editor | folder | FolderToShare | | Co Owner | folder | FolderToShare | @@ -265,7 +261,7 @@ Feature: Send a sharing invitations Examples: | permissionsAction | | permissions/create | - | children/create | + # | children/create | | upload/create | | path/read | | quota/read | @@ -275,11 +271,11 @@ Feature: Send a sharing invitations | versions/read | | deleted/read | | basic/read | - | path/update | + # | path/update | | versions/update | | deleted/update | | permissions/update | - | standard/delete | + # | standard/delete | | permissions/delete | | deleted/delete | | permissions/deny | @@ -461,7 +457,7 @@ Feature: Send a sharing invitations Examples: | permissionsAction | | permissions/create | - | children/create | + # | children/create | | upload/create | | path/read | | quota/read | @@ -471,11 +467,11 @@ Feature: Send a sharing invitations | versions/read | | deleted/read | | basic/read | - | path/update | + # | path/update | | versions/update | | deleted/update | | permissions/update | - | standard/delete | + # | standard/delete | | permissions/delete | | deleted/delete | | permissions/deny | @@ -667,8 +663,6 @@ Feature: Send a sharing invitations | permissions-role | resource-type | path | | Viewer | file | /textfile1.txt | | File Editor | file | /textfile1.txt | - | Co Owner | file | /textfile1.txt | - | Manager | file | /textfile1.txt | | Viewer | folder | FolderToShare | | Editor | folder | FolderToShare | | Co Owner | folder | FolderToShare | @@ -767,8 +761,6 @@ Feature: Send a sharing invitations | permissions-role | resource-type | path | | Viewer | file | /textfile1.txt | | File Editor | file | /textfile1.txt | - | Co Owner | file | /textfile1.txt | - | Manager | file | /textfile1.txt | | Viewer | folder | FolderToShare | | Editor | folder | FolderToShare | | Co Owner | folder | FolderToShare | @@ -854,8 +846,6 @@ Feature: Send a sharing invitations | permissions-role | resource-type | path | | Viewer | file | /textfile1.txt | | File Editor | file | /textfile1.txt | - | Co Owner | file | /textfile1.txt | - | Manager | file | /textfile1.txt | | Viewer | folder | FolderToShare | | Editor | folder | FolderToShare | | Co Owner | folder | FolderToShare | @@ -917,8 +907,6 @@ Feature: Send a sharing invitations | permissions-role | resource-type | path | | Viewer | file | /textfile1.txt | | File Editor | file | /textfile1.txt | - | Co Owner | file | /textfile1.txt | - | Manager | file | /textfile1.txt | | Viewer | folder | FolderToShare | | Editor | folder | FolderToShare | | Co Owner | folder | FolderToShare | @@ -972,8 +960,6 @@ Feature: Send a sharing invitations | permissions-role | resource-type | path | | Viewer | file | /textfile1.txt | | File Editor | file | /textfile1.txt | - | Co Owner | file | /textfile1.txt | - | Manager | file | /textfile1.txt | | Viewer | folder | FolderToShare | | Editor | folder | FolderToShare | | Co Owner | folder | FolderToShare | @@ -1039,8 +1025,6 @@ Feature: Send a sharing invitations | permissions-role | resource-type | path | | Viewer | file | /textfile1.txt | | File Editor | file | /textfile1.txt | - | Co Owner | file | /textfile1.txt | - | Manager | file | /textfile1.txt | | Viewer | folder | FolderToShare | | Editor | folder | FolderToShare | | Co Owner | folder | FolderToShare | @@ -1104,8 +1088,6 @@ Feature: Send a sharing invitations | permissions-role | resource-type | path | | Viewer | file | /textfile1.txt | | File Editor | file | /textfile1.txt | - | Co Owner | file | /textfile1.txt | - | Manager | file | /textfile1.txt | | Viewer | folder | FolderToShare | | Editor | folder | FolderToShare | | Co Owner | folder | FolderToShare | From ca2b5744a1ab93d9a96e981e5cd8914841a0de64 Mon Sep 17 00:00:00 2001 From: Saw-jan Date: Tue, 23 Jan 2024 12:19:31 +0545 Subject: [PATCH 4/6] fix test expectations --- .../features/apiSharingNg/shareInvitations.feature | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/acceptance/features/apiSharingNg/shareInvitations.feature b/tests/acceptance/features/apiSharingNg/shareInvitations.feature index 931e0160e86..8737dd2a6f2 100644 --- a/tests/acceptance/features/apiSharingNg/shareInvitations.feature +++ b/tests/acceptance/features/apiSharingNg/shareInvitations.feature @@ -261,7 +261,6 @@ Feature: Send a sharing invitations Examples: | permissionsAction | | permissions/create | - # | children/create | | upload/create | | path/read | | quota/read | @@ -271,11 +270,9 @@ Feature: Send a sharing invitations | versions/read | | deleted/read | | basic/read | - # | path/update | | versions/update | | deleted/update | | permissions/update | - # | standard/delete | | permissions/delete | | deleted/delete | | permissions/deny | @@ -457,7 +454,6 @@ Feature: Send a sharing invitations Examples: | permissionsAction | | permissions/create | - # | children/create | | upload/create | | path/read | | quota/read | @@ -467,11 +463,9 @@ Feature: Send a sharing invitations | versions/read | | deleted/read | | basic/read | - # | path/update | | versions/update | | deleted/update | | permissions/update | - # | standard/delete | | permissions/delete | | deleted/delete | | permissions/deny | From e1101940dcb211d6a720a8f0933cc7feaccece83 Mon Sep 17 00:00:00 2001 From: Saw-jan Date: Tue, 23 Jan 2024 12:40:13 +0545 Subject: [PATCH 5/6] fix cors tests --- ...xpected-failures-localAPI-on-OCIS-storage.md | 4 ---- .../features/apiContract/copy.feature | 4 +++- .../features/bootstrap/SpacesContext.php | 17 ++++++++++++++++- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md b/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md index acd221bf22e..d9b6da351ea 100644 --- a/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md +++ b/tests/acceptance/expected-failures-localAPI-on-OCIS-storage.md @@ -359,9 +359,5 @@ The expected failures in this file are from features in the owncloud/ocis repo. - [apiSpacesDavOperation/moveByFileId.feature:464](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpacesDavOperation/moveByFileId.feature#L464) - [apiSpacesDavOperation/moveByFileId.feature:465](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpacesDavOperation/moveByFileId.feature#L465) -### [CORS headers are only set when origin is sent by the client](https://github.com/owncloud/ocis/issues/5195) - -- [apiContract/copy.feature:16](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiContract/copy.feature#L16) - - Note: always have an empty line at the end of this file. The bash script that processes this file requires that the last line has a newline on the end. diff --git a/tests/acceptance/features/apiContract/copy.feature b/tests/acceptance/features/apiContract/copy.feature index 5bf61391e8d..08a1fc195ad 100644 --- a/tests/acceptance/features/apiContract/copy.feature +++ b/tests/acceptance/features/apiContract/copy.feature @@ -16,7 +16,9 @@ Feature: Copy test Scenario: check the COPY response headers Given user "Alice" has uploaded a file inside space "new-space" with content "some content" to "testfile.txt" And user "Alice" has created a folder "new" in space "new-space" - When user "Alice" copies file "testfile.txt" from space "new-space" to "/new/testfile.txt" inside space "new-space" using the WebDAV API + When user "Alice" copies file "testfile.txt" from space "new-space" to "/new/testfile.txt" inside space "new-space" with following headers using the WebDAV API + | header | value | + | Origin | %base_url% | Then the HTTP status code should be "201" And the following headers should match these regular expressions | Oc-Fileid | /^[a-f0-9!\$\-]{110}$/ | diff --git a/tests/acceptance/features/bootstrap/SpacesContext.php b/tests/acceptance/features/bootstrap/SpacesContext.php index f4672f18780..acc293c0808 100644 --- a/tests/acceptance/features/bootstrap/SpacesContext.php +++ b/tests/acceptance/features/bootstrap/SpacesContext.php @@ -1807,12 +1807,15 @@ public function moveFilesAndFoldersRequest(string $user, string $fullUrl, array /** * @When /^user "([^"]*)" copies (?:file|folder) "([^"]*)" from space "([^"]*)" to "([^"]*)" inside space "([^"]*)" using the WebDAV API$/ + * @When /^user "([^"]*)" copies (?:file|folder) "([^"]*)" from space "([^"]*)" to "([^"]*)" inside space "([^"]*)"(?: with following headers) using the WebDAV API$/ * * @param string $user * @param string $fileSource * @param string $fromSpaceName * @param string $fileDestination * @param string $toSpaceName + * @param string $toSpaceName + * @param TableNode|null $table * * @return void * @throws GuzzleException @@ -1822,10 +1825,22 @@ public function userCopiesFileFromAndToSpaceBetweenSpaces( string $fileSource, string $fromSpaceName, string $fileDestination, - string $toSpaceName + string $toSpaceName, + TableNode $table = null ):void { $space = $this->getSpaceByName($user, $fromSpaceName); $headers['Destination'] = $this->destinationHeaderValueWithSpaceName($user, $fileDestination, $toSpaceName); + + if ($table !== null) { + $this->featureContext->verifyTableNodeColumns( + $table, + ['header', 'value'] + ); + foreach ($table as $row) { + $headers[$row['header']] = $this->featureContext->substituteInLineCodes($row['value']); + } + } + $fullUrl = $space["root"]["webDavUrl"] . '/' . ltrim($fileSource, "/"); $this->featureContext->setResponse($this->copyFilesAndFoldersRequest($user, $fullUrl, $headers)); } From a7ab682f172bd1a4ac0499ba46e853a839c64e72 Mon Sep 17 00:00:00 2001 From: Saw-jan Date: Tue, 23 Jan 2024 12:42:47 +0545 Subject: [PATCH 6/6] fix php code --- tests/acceptance/features/bootstrap/SpacesContext.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/acceptance/features/bootstrap/SpacesContext.php b/tests/acceptance/features/bootstrap/SpacesContext.php index acc293c0808..1fd4615bab4 100644 --- a/tests/acceptance/features/bootstrap/SpacesContext.php +++ b/tests/acceptance/features/bootstrap/SpacesContext.php @@ -1814,7 +1814,6 @@ public function moveFilesAndFoldersRequest(string $user, string $fullUrl, array * @param string $fromSpaceName * @param string $fileDestination * @param string $toSpaceName - * @param string $toSpaceName * @param TableNode|null $table * * @return void