enhancement: add sharedWithMe graph beta endpoint (#7633)

This commit is contained in:
Florian Schade
2023-11-08 20:02:58 +01:00
committed by GitHub
parent d928044073
commit 643158b67b
45 changed files with 6268 additions and 163 deletions
+5 -4
View File
@@ -15,6 +15,11 @@ import (
"github.com/cs3org/reva/v2/pkg/storagespace"
"github.com/go-chi/chi/v5"
"github.com/jellydator/ttlcache/v3"
"go-micro.dev/v4/client"
mevents "go-micro.dev/v4/events"
"go.opentelemetry.io/otel/trace"
"google.golang.org/protobuf/types/known/emptypb"
"github.com/owncloud/ocis/v2/ocis-pkg/keycloak"
"github.com/owncloud/ocis/v2/ocis-pkg/log"
ehsvc "github.com/owncloud/ocis/v2/protogen/gen/ocis/services/eventhistory/v0"
@@ -23,10 +28,6 @@ import (
"github.com/owncloud/ocis/v2/services/graph/pkg/config"
"github.com/owncloud/ocis/v2/services/graph/pkg/identity"
"github.com/owncloud/ocis/v2/services/graph/pkg/service/v0/errorcode"
"go-micro.dev/v4/client"
mevents "go-micro.dev/v4/events"
"go.opentelemetry.io/otel/trace"
"google.golang.org/protobuf/types/known/emptypb"
)
//go:generate make -C ../../.. generate
+7 -5
View File
@@ -16,6 +16,8 @@ import (
"github.com/go-chi/chi/v5/middleware"
ldapv3 "github.com/go-ldap/ldap/v3"
"github.com/jellydator/ttlcache/v3"
microstore "go-micro.dev/v4/store"
ocisldap "github.com/owncloud/ocis/v2/ocis-pkg/ldap"
"github.com/owncloud/ocis/v2/ocis-pkg/registry"
"github.com/owncloud/ocis/v2/ocis-pkg/roles"
@@ -24,7 +26,6 @@ import (
"github.com/owncloud/ocis/v2/services/graph/pkg/identity"
"github.com/owncloud/ocis/v2/services/graph/pkg/identity/ldap"
graphm "github.com/owncloud/ocis/v2/services/graph/pkg/middleware"
microstore "go-micro.dev/v4/store"
)
const (
@@ -95,11 +96,13 @@ type Service interface {
GetDrives(w http.ResponseWriter, r *http.Request)
GetSingleDrive(w http.ResponseWriter, r *http.Request)
GetAllDrives(w http.ResponseWriter, r *http.Request)
GetSharedByMe(w http.ResponseWriter, r *http.Request)
CreateDrive(w http.ResponseWriter, r *http.Request)
UpdateDrive(w http.ResponseWriter, r *http.Request)
DeleteDrive(w http.ResponseWriter, r *http.Request)
GetSharedByMe(w http.ResponseWriter, r *http.Request)
ListSharedWithMe(w http.ResponseWriter, r *http.Request)
GetRootDriveChildren(w http.ResponseWriter, r *http.Request)
GetDriveItem(w http.ResponseWriter, r *http.Request)
GetDriveItemChildren(w http.ResponseWriter, r *http.Request)
@@ -190,6 +193,7 @@ func NewService(opts ...Option) (Graph, error) {
r.Use(middleware.StripSlashes)
r.Route("/v1beta1", func(r chi.Router) {
r.Get("/me/drive/sharedByMe", svc.GetSharedByMe)
r.Get("/me/drive/sharedWithMe", svc.ListSharedWithMe)
r.Route("/roleManagement/permissions/roleDefinitions", func(r chi.Router) {
r.Get("/", svc.GetRoleDefinitions)
r.Get("/{roleID}", svc.GetRoleDefinition)
@@ -208,9 +212,7 @@ func NewService(opts ...Option) (Graph, error) {
r.Route("/me", func(r chi.Router) {
r.Get("/", svc.GetMe)
r.Get("/drive", svc.GetUserDrive)
r.Route("/drives", func(r chi.Router) {
r.Get("/", svc.GetDrives)
})
r.Get("/drives", svc.GetDrives)
r.Get("/drive/root/children", svc.GetRootDriveChildren)
r.Post("/changePassword", svc.ChangeOwnPassword)
})
@@ -0,0 +1,226 @@
package svc
import (
"context"
"net/http"
"strings"
rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
collaboration "github.com/cs3org/go-cs3apis/cs3/sharing/collaboration/v1beta1"
storageprovider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
"github.com/cs3org/reva/v2/pkg/storagespace"
"github.com/go-chi/render"
libregraph "github.com/owncloud/libre-graph-api-go"
"github.com/owncloud/ocis/v2/services/graph/pkg/identity"
"github.com/owncloud/ocis/v2/services/graph/pkg/service/v0/errorcode"
)
// ListSharedWithMe lists the files shared with the current user.
func (g Graph) ListSharedWithMe(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
driveItems, err := g.listSharedWithMe(ctx)
if err != nil {
g.logger.Error().Err(err).Msg("listSharedWithMe failed")
errorcode.RenderError(w, r, err)
return
}
render.Status(r, http.StatusOK)
render.JSON(w, r, &ListResponse{Value: driveItems})
}
func (g Graph) listSharedWithMe(ctx context.Context) ([]libregraph.DriveItem, error) {
gatewayClient, err := g.gatewaySelector.Next()
if err != nil {
g.logger.Error().Err(err).Msg("could not select next gateway client")
return nil, err
}
listReceivedSharesResponse, err := gatewayClient.ListReceivedShares(ctx, &collaboration.ListReceivedSharesRequest{})
if err != nil {
g.logger.Error().Err(err).Msg("listing shares failed")
return nil, errorcode.New(errorcode.GeneralException, err.Error())
}
switch listReceivedSharesResponse.Status.Code {
case rpc.Code_CODE_NOT_FOUND:
return nil, identity.ErrNotFound
}
var driveItems []libregraph.DriveItem
for _, receivedShare := range listReceivedSharesResponse.GetShares() {
share := receivedShare.GetShare()
if share == nil {
g.logger.Error().Interface("ListReceivedShares", listReceivedSharesResponse).Msg("unexpected empty ReceivedShare.Share")
continue
}
driveItem := &libregraph.DriveItem{}
statResponse, err := gatewayClient.Stat(ctx, &storageprovider.StatRequest{Ref: &storageprovider.Reference{ResourceId: share.GetResourceId()}})
if err != nil {
g.logger.Error().Err(err).Msg("could not stat")
continue
}
if statResponse.GetStatus().GetCode() != rpc.Code_CODE_OK {
g.logger.Error().Err(err).Msg("invalid stat response")
continue
}
resourceInfo := statResponse.GetInfo()
var driveOwner *libregraph.Identity
if userID := statResponse.GetInfo().GetOwner(); userID != nil {
if user, err := g.identityCache.GetUser(ctx, userID.GetOpaqueId()); err != nil {
g.logger.Error().Err(err).Msg("could not get user")
continue
} else {
driveOwner = &libregraph.Identity{
DisplayName: user.GetDisplayName(),
Id: libregraph.PtrString(user.GetId()),
}
}
}
var shareCreator *libregraph.Identity
if userID := share.GetCreator(); userID != nil {
if user, err := g.identityCache.GetUser(ctx, userID.GetOpaqueId()); err != nil {
g.logger.Error().Err(err).Msg("could not get user")
continue
} else {
shareCreator = &libregraph.Identity{
DisplayName: user.GetDisplayName(),
Id: libregraph.PtrString(user.GetId()),
}
}
}
if cTime := share.GetCtime(); cTime != nil {
driveItem.CreatedDateTime = libregraph.PtrTime(cs3TimestampToTime(cTime))
}
driveItem.ETag = libregraph.PtrString(strings.Trim(statResponse.GetInfo().GetEtag(), "\""))
if id := share.GetId().GetOpaqueId(); id != "" {
driveItem.Id = libregraph.PtrString(id)
}
if mTime := share.GetMtime(); mTime != nil {
driveItem.LastModifiedDateTime = libregraph.PtrTime(cs3TimestampToTime(mTime))
}
if name := resourceInfo.GetName(); name != "" {
driveItem.Name = libregraph.PtrString(name)
}
{
addParentReference := false
parentReference := &libregraph.ItemReference{}
if id := share.GetId().GetOpaqueId(); id != "" {
parentReference.DriveId = libregraph.PtrString(id)
addParentReference = true
}
if addParentReference {
driveItem.ParentReference = parentReference
}
}
{
remoteItem := &libregraph.RemoteItem{}
if id := resourceInfo.GetId(); id != nil {
remoteItem.Id = libregraph.PtrString(storagespace.FormatResourceID(*id))
}
if mTime := resourceInfo.GetMtime(); mTime != nil {
remoteItem.LastModifiedDateTime = libregraph.PtrTime(cs3TimestampToTime(mTime))
}
if name := resourceInfo.GetName(); name != "" {
remoteItem.Name = libregraph.PtrString(name)
}
// fixMe:
// - negative permission could distort the size, am i right?
remoteItem.Size = libregraph.PtrInt64(int64(resourceInfo.GetSize()))
remoteItem.CreatedBy = &libregraph.IdentitySet{
User: driveOwner,
}
{
addFileSystemInfo := false
fileSystemInfo := &libregraph.FileSystemInfo{}
if cTime := share.GetCtime(); cTime != nil {
// fixMe:
// - ms uses the root resource ctime for that,
// the stat response does not contain any information about this, use share instead?
fileSystemInfo.CreatedDateTime = libregraph.PtrTime(cs3TimestampToTime(cTime))
addFileSystemInfo = true
}
if mTime := resourceInfo.GetMtime(); mTime != nil {
fileSystemInfo.LastModifiedDateTime = libregraph.PtrTime(cs3TimestampToTime(mTime))
addFileSystemInfo = true
}
if addFileSystemInfo {
remoteItem.FileSystemInfo = fileSystemInfo
}
}
switch resourceInfo.GetType() {
case storageprovider.ResourceType_RESOURCE_TYPE_CONTAINER:
remoteItem.Folder = &libregraph.Folder{}
case storageprovider.ResourceType_RESOURCE_TYPE_FILE:
openGraphFile := &libregraph.OpenGraphFile{}
if mimeType := resourceInfo.GetMimeType(); mimeType != "" {
openGraphFile.MimeType = libregraph.PtrString(mimeType)
}
remoteItem.File = openGraphFile
case storageprovider.ResourceType_RESOURCE_TYPE_INVALID:
g.logger.Error().Msg("invalid resource type")
continue
}
{
addShared := false
shared := &libregraph.Shared{
Owner: &libregraph.IdentitySet{
User: shareCreator,
},
SharedBy: &libregraph.IdentitySet{
User: shareCreator,
},
}
if cTime := share.GetCtime(); cTime != nil {
shared.SharedDateTime = libregraph.PtrTime(cs3TimestampToTime(cTime))
addShared = true
}
if shareCreator != nil {
shared.Owner.User = shareCreator
shared.SharedBy.User = shareCreator
addShared = true
}
if addShared {
remoteItem.Shared = shared
}
}
driveItem.RemoteItem = remoteItem
}
driveItems = append(driveItems, *driveItem)
}
return driveItems, nil
}
@@ -0,0 +1,370 @@
package svc_test
import (
"context"
"net/http"
"net/http/httptest"
"time"
gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1"
userv1beta1 "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
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"
"github.com/cs3org/reva/v2/pkg/rgrpc/status"
"github.com/cs3org/reva/v2/pkg/rgrpc/todo/pool"
"github.com/cs3org/reva/v2/pkg/storagespace"
"github.com/cs3org/reva/v2/pkg/utils"
cs3mocks "github.com/cs3org/reva/v2/tests/cs3mocks/mocks"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/stretchr/testify/mock"
"github.com/tidwall/gjson"
"google.golang.org/grpc"
"github.com/owncloud/ocis/v2/ocis-pkg/shared"
"github.com/owncloud/ocis/v2/services/graph/pkg/config"
"github.com/owncloud/ocis/v2/services/graph/pkg/config/defaults"
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/service/v0/errorcode"
)
var _ = Describe("SharedWithMe", func() {
var (
svc service.Service
cfg *config.Config
gatewayClient *cs3mocks.GatewayAPIClient
gatewaySelector pool.Selectable[gateway.GatewayAPIClient]
identityBackend *identitymocks.Backend
ctx context.Context
tape *httptest.ResponseRecorder
)
BeforeEach(func() {
pool.RemoveSelector("GatewaySelector" + "com.owncloud.api.gateway")
gatewayClient = &cs3mocks.GatewayAPIClient{}
gatewaySelector = pool.GetSelector[gateway.GatewayAPIClient](
"GatewaySelector",
"com.owncloud.api.gateway",
func(cc *grpc.ClientConn) gateway.GatewayAPIClient {
return gatewayClient
},
)
identityBackend = &identitymocks.Backend{}
tape = httptest.NewRecorder()
ctx = context.Background()
cfg = defaults.FullDefaultConfig()
cfg.Identity.LDAP.CACert = "" // skip the startup checks, we don't use LDAP at all in this tests
cfg.TokenManager.JWTSecret = "loremipsum"
cfg.Commons = &shared.Commons{}
cfg.GRPCClientTLS = &shared.GRPCClientTLS{}
svc, _ = service.NewService(
service.Config(cfg),
service.WithGatewaySelector(gatewaySelector),
service.WithIdentityBackend(identityBackend),
)
})
Describe("ListSharedWithMe", func() {
var (
listReceivedSharesResponse *collaborationv1beta1.ListReceivedSharesResponse
statResponse *providerv1beta1.StatResponse
getUserResponse *userv1beta1.GetUserResponse
)
toResourceID := func(in string) *providerv1beta1.ResourceId {
out, err := storagespace.ParseID(in)
Expect(err).To(BeNil())
return &out
}
BeforeEach(func() {
getUserResponse = &userv1beta1.GetUserResponse{
Status: status.NewOK(ctx),
User: &userv1beta1.User{
Id: &userv1beta1.UserId{
OpaqueId: "2699b42d-c6ca-4ce1-90de-89dedfb3022c",
},
DisplayName: "John Romero",
},
}
gatewayClient.On("GetUser", mock.Anything, mock.Anything).Return(getUserResponse, nil)
listReceivedSharesResponse = &collaborationv1beta1.ListReceivedSharesResponse{
Status: status.NewOK(ctx),
Shares: []*collaborationv1beta1.ReceivedShare{
{Share: &collaborationv1beta1.Share{ResourceId: toResourceID("1$2!3")}},
},
}
gatewayClient.On("ListReceivedShares", mock.Anything, mock.Anything).Return(listReceivedSharesResponse, nil)
statResponse = &providerv1beta1.StatResponse{
Status: status.NewOK(ctx),
Info: &providerv1beta1.ResourceInfo{
Type: providerv1beta1.ResourceType_RESOURCE_TYPE_CONTAINER,
},
}
gatewayClient.On("Stat", mock.Anything, mock.Anything).Return(func(_ context.Context, r *providerv1beta1.StatRequest, _ ...grpc.CallOption) (*providerv1beta1.StatResponse, error) {
for _, share := range listReceivedSharesResponse.Shares {
if share.Share.ResourceId != r.Ref.ResourceId {
continue
}
if statResponse.Info.Id == nil {
statResponse.Info.Id = share.Share.ResourceId
}
return statResponse, nil
}
return nil, nil
})
})
It("fails if no received shares were found", func() {
listReceivedSharesResponse.Status = status.NewNotFound(ctx, "msg")
svc.ListSharedWithMe(
tape,
httptest.NewRequest(http.MethodGet, "/graph/v1beta1/me/drive/sharedWithMe", nil),
)
Expect(tape.Code, errorcode.ItemNotFound)
})
It("ignores hidden received shares by default", func() {
listReceivedSharesResponse.Shares = append(listReceivedSharesResponse.Shares, &collaborationv1beta1.ReceivedShare{
Hidden: true,
})
svc.ListSharedWithMe(
tape,
httptest.NewRequest(http.MethodGet, "/graph/v1beta1/me/drive/sharedWithMe", nil),
)
jsonData := gjson.Get(tape.Body.String(), "value")
Expect(len(listReceivedSharesResponse.Shares)).To(Equal(2))
Expect(jsonData.Get("#").Num).To(Equal(float64(1)))
})
It("includes hidden shares if explicitly stated", func() {
listReceivedSharesResponse.Shares = append(listReceivedSharesResponse.Shares, &collaborationv1beta1.ReceivedShare{
Hidden: true,
Share: &collaborationv1beta1.Share{
ResourceId: toResourceID("7$8!9"),
},
})
svc.ListSharedWithMe(
tape,
httptest.NewRequest(http.MethodGet, "/graph/v1beta1/me/drive/sharedWithMe?show-hidden=true", nil),
)
jsonData := gjson.Get(tape.Body.String(), "value")
Expect(len(listReceivedSharesResponse.Shares)).To(Equal(2))
Expect(jsonData.Get("#").Num).To(Equal(float64(2)))
})
It("populates the driveItem properties", func() {
share := listReceivedSharesResponse.Shares[0].Share
share.Id = &collaborationv1beta1.ShareId{OpaqueId: "1:2:3"}
share.Ctime = &typesv1beta1.Timestamp{Seconds: 4000}
share.Mtime = &typesv1beta1.Timestamp{Seconds: 40000}
etag := "5ffb8e4bec7026050af7fde9482b289a"
resourceInfo := statResponse.Info
resourceInfo.Name = "some folder"
resourceInfo.Etag = "\"" + etag + "\""
svc.ListSharedWithMe(
tape,
httptest.NewRequest(http.MethodGet, "/graph/v1beta1/me/drive/sharedWithMe", nil),
)
jsonData := gjson.Get(tape.Body.String(), "value.0")
Expect(jsonData.Get("createdDateTime").String()).To(Equal(utils.TSToTime(share.Ctime).Format(time.RFC3339Nano)))
Expect(jsonData.Get("eTag").String()).To(Equal(etag))
Expect(jsonData.Get("id").String()).To(Equal(share.Id.OpaqueId))
Expect(jsonData.Get("lastModifiedDateTime").String()).To(Equal(utils.TSToTime(share.Mtime).Format(time.RFC3339Nano)))
Expect(jsonData.Get("name").String()).To(Equal(resourceInfo.Name))
})
It("populates the driveItem parentReference properties", func() {
share := listReceivedSharesResponse.Shares[0].Share
share.Id = &collaborationv1beta1.ShareId{OpaqueId: "1:2:3"}
svc.ListSharedWithMe(
tape,
httptest.NewRequest(http.MethodGet, "/graph/v1beta1/me/drive/sharedWithMe", nil),
)
jsonData := gjson.Get(tape.Body.String(), "value.0.parentReference")
Expect(jsonData.Get("driveId").String()).To(Equal(share.Id.OpaqueId))
})
It("populates the driveItem remoteItem properties", func() {
share := listReceivedSharesResponse.Shares[0].Share
resourceInfo := statResponse.Info
resourceInfo.Name = "some folder"
resourceInfo.Mtime = &typesv1beta1.Timestamp{Seconds: 40000}
resourceInfo.Size = 500
svc.ListSharedWithMe(
tape,
httptest.NewRequest(http.MethodGet, "/graph/v1beta1/me/drive/sharedWithMe", nil),
)
jsonData := gjson.Get(tape.Body.String(), "value.0.remoteItem")
Expect(jsonData.Get("id").String()).To(Equal(storagespace.FormatResourceID(*share.ResourceId)))
Expect(jsonData.Get("lastModifiedDateTime").String()).To(Equal(utils.TSToTime(resourceInfo.Mtime).Format(time.RFC3339Nano)))
Expect(jsonData.Get("name").String()).To(Equal(resourceInfo.Name))
Expect(jsonData.Get("size").Num).To(Equal(float64(resourceInfo.Size)))
})
It("populates the driveItem.remoteItem.createdBy properties", func() {
driveOwner := getUserResponse.User
resourceInfo := statResponse.Info
resourceInfo.Owner = driveOwner.Id
svc.ListSharedWithMe(
tape,
httptest.NewRequest(http.MethodGet, "/graph/v1beta1/me/drive/sharedWithMe", nil),
)
jsonData := gjson.Get(tape.Body.String(), "value.0.remoteItem.createdBy")
Expect(jsonData.Get("user.displayName").String()).To(Equal(driveOwner.DisplayName))
Expect(jsonData.Get("user.id").String()).To(Equal(driveOwner.Id.OpaqueId))
})
It("populates the driveItem.remoteItem.fileSystemInfo properties", func() {
share := listReceivedSharesResponse.Shares[0].Share
share.Ctime = &typesv1beta1.Timestamp{Seconds: 400}
resourceInfo := statResponse.Info
resourceInfo.Mtime = &typesv1beta1.Timestamp{Seconds: 4000}
svc.ListSharedWithMe(
tape,
httptest.NewRequest(http.MethodGet, "/graph/v1beta1/me/drive/sharedWithMe", nil),
)
jsonData := gjson.Get(tape.Body.String(), "value.0.remoteItem.fileSystemInfo")
Expect(jsonData.Get("createdDateTime").String()).To(Equal(utils.TSToTime(share.Ctime).Format(time.RFC3339Nano)))
Expect(jsonData.Get("lastModifiedDateTime").String()).To(Equal(utils.TSToTime(resourceInfo.Mtime).Format(time.RFC3339Nano)))
})
It("populates the driveItem.remoteItem.folder properties", func() {
svc.ListSharedWithMe(
tape,
httptest.NewRequest(http.MethodGet, "/graph/v1beta1/me/drive/sharedWithMe", nil),
)
jsonData := gjson.Get(tape.Body.String(), "value.0.remoteItem")
Expect(jsonData.Get("file").Exists()).To(BeFalse())
Expect(jsonData.Get("folder.childCount").Num).To(Equal(float64(0)))
})
It("populates the driveItem.remoteItem.file properties", func() {
resourceInfo := statResponse.Info
resourceInfo.Type = providerv1beta1.ResourceType_RESOURCE_TYPE_FILE
resourceInfo.MimeType = "application/pdf"
svc.ListSharedWithMe(
tape,
httptest.NewRequest(http.MethodGet, "/graph/v1beta1/me/drive/sharedWithMe", nil),
)
jsonData := gjson.Get(tape.Body.String(), "value.0.remoteItem")
Expect(jsonData.Get("folder").Exists()).To(BeFalse())
Expect(jsonData.Get("file.mimeType").String()).To(Equal(resourceInfo.MimeType))
})
It("populates the driveItem.remoteItem.folder properties", func() {
resourceInfo := statResponse.Info
resourceInfo.Type = providerv1beta1.ResourceType_RESOURCE_TYPE_CONTAINER
svc.ListSharedWithMe(
tape,
httptest.NewRequest(http.MethodGet, "/graph/v1beta1/me/drive/sharedWithMe", nil),
)
jsonData := gjson.Get(tape.Body.String(), "value.0.remoteItem")
Expect(jsonData.Get("folder").Exists()).To(BeTrue())
})
It("populates the driveItem.remoteItem.shared properties", func() {
share := listReceivedSharesResponse.Shares[0].Share
share.Ctime = &typesv1beta1.Timestamp{Seconds: 4000}
svc.ListSharedWithMe(
tape,
httptest.NewRequest(http.MethodGet, "/graph/v1beta1/me/drive/sharedWithMe", nil),
)
jsonData := gjson.Get(tape.Body.String(), "value.0.remoteItem.shared")
Expect(jsonData.Get("sharedDateTime").String()).To(Equal(utils.TSToTime(share.Ctime).Format(time.RFC3339Nano)))
})
It("populates the driveItem.remoteItem.shared.owner properties", func() {
shareCreator := getUserResponse.User
share := listReceivedSharesResponse.Shares[0].Share
share.Creator = shareCreator.Id
svc.ListSharedWithMe(
tape,
httptest.NewRequest(http.MethodGet, "/graph/v1beta1/me/drive/sharedWithMe", nil),
)
jsonData := gjson.Get(tape.Body.String(), "value.0.remoteItem.shared.owner")
Expect(jsonData.Get("user.displayName").String()).To(Equal(shareCreator.DisplayName))
Expect(jsonData.Get("user.id").String()).To(Equal(shareCreator.Id.OpaqueId))
})
It("populates the driveItem.remoteItem.shared.sharedBy properties", func() {
shareCreator := getUserResponse.User
share := listReceivedSharesResponse.Shares[0].Share
share.Creator = shareCreator.Id
svc.ListSharedWithMe(
tape,
httptest.NewRequest(http.MethodGet, "/graph/v1beta1/me/drive/sharedWithMe", nil),
)
jsonData := gjson.Get(tape.Body.String(), "value.0.remoteItem.shared.sharedBy")
Expect(jsonData.Get("user.displayName").String()).To(Equal(shareCreator.DisplayName))
Expect(jsonData.Get("user.id").String()).To(Equal(shareCreator.Id.OpaqueId))
})
})
})