From 3cc485a0fc5767961bc53a0b302ad274ba7e32f4 Mon Sep 17 00:00:00 2001 From: Ralf Haferkamp Date: Tue, 16 Jan 2024 12:31:58 +0100 Subject: [PATCH] graph/sharewithme: add unit test for 'remoteitem.permissions' property --- .../graph/pkg/service/v0/sharedwithme_test.go | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/services/graph/pkg/service/v0/sharedwithme_test.go b/services/graph/pkg/service/v0/sharedwithme_test.go index 48eb01ccfa..00df68ac1e 100644 --- a/services/graph/pkg/service/v0/sharedwithme_test.go +++ b/services/graph/pkg/service/v0/sharedwithme_test.go @@ -11,6 +11,7 @@ import ( collaborationv1beta1 "github.com/cs3org/go-cs3apis/cs3/sharing/collaboration/v1beta1" providerv1beta1 "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" typesv1beta1 "github.com/cs3org/go-cs3apis/cs3/types/v1beta1" + roleconversions "github.com/cs3org/reva/v2/pkg/conversions" "github.com/cs3org/reva/v2/pkg/rgrpc/status" "github.com/cs3org/reva/v2/pkg/rgrpc/todo/pool" "github.com/cs3org/reva/v2/pkg/storagespace" @@ -28,6 +29,7 @@ import ( "github.com/owncloud/ocis/v2/services/graph/pkg/errorcode" identitymocks "github.com/owncloud/ocis/v2/services/graph/pkg/identity/mocks" service "github.com/owncloud/ocis/v2/services/graph/pkg/service/v0" + "github.com/owncloud/ocis/v2/services/graph/pkg/unifiedrole" ) var _ = Describe("SharedWithMe", func() { @@ -326,6 +328,24 @@ var _ = Describe("SharedWithMe", func() { Expect(jsonData.Get("file.mimeType").String()).To(Equal(resourceInfo.MimeType)) }) + It("populates the driveItem.remoteItem.permissions properties", func() { + resourceInfo := statResponse.Info + resourceInfo.PermissionSet = roleconversions.NewViewerRole(true).CS3ResourcePermissions() + + svc.ListSharedWithMe( + tape, + httptest.NewRequest(http.MethodGet, "/graph/v1beta1/me/drive/sharedWithMe", nil), + ) + + jsonData := gjson.Get(tape.Body.String(), "value.0.remoteItem.permissions.0") + + Expect(jsonData.Get("roles.0").String()).To(Equal(unifiedrole.UnifiedRoleViewerID)) + Expect(jsonData.Get("@ui\\.hidden").Exists()).To(BeTrue()) + Expect(jsonData.Get("@ui\\.hidden").Bool()).To(BeFalse()) + Expect(jsonData.Get("@client\\.synchronize").Exists()).To(BeTrue()) + Expect(jsonData.Get("@client\\.synchronize").Bool()).To(BeTrue()) + }) + It("populates the driveItem.remoteItem.shared properties", func() { share := listReceivedSharesResponse.Shares[0].Share share.Ctime = &typesv1beta1.Timestamp{Seconds: 4000}