Skip to content

Commit

Permalink
graph/sharewithme: add unit test for 'remoteitem.permissions' property
Browse files Browse the repository at this point in the history
  • Loading branch information
rhafer committed Jan 16, 2024
1 parent 2c16188 commit 3cc485a
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions services/graph/pkg/service/v0/sharedwithme_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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() {
Expand Down Expand Up @@ -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}
Expand Down

0 comments on commit 3cc485a

Please sign in to comment.