Fix fallout of reva bump

reva tries to avoid copying proto messages now. This changed some calls
to take pointers now (mainly e.g. FormatResourceId())
This commit is contained in:
Ralf Haferkamp
2024-07-11 15:21:56 +02:00
parent a33dd51581
commit ff6674f97b
40 changed files with 283 additions and 234 deletions

View File

@@ -64,7 +64,7 @@ func WithResource(ref *provider.Reference, addSpace bool) ActivityOption {
}
vars["resource"] = Resource{
ID: storagespace.FormatResourceID(*info.GetId()),
ID: storagespace.FormatResourceID(info.GetId()),
Name: info.GetName(),
}
@@ -111,7 +111,7 @@ func WithTrashedResource(ref *provider.Reference, rid *provider.ResourceId) Acti
if item.GetKey() == rid.GetOpaqueId() {
vars["resource"] = Resource{
ID: storagespace.FormatResourceID(*rid),
ID: storagespace.FormatResourceID(rid),
Name: filepath.Base(item.GetRef().GetPath()),
}

View File

@@ -158,7 +158,7 @@ func (a *ActivitylogService) AddActivityTrashed(resourceID *provider.ResourceId,
}
// store activity on trashed item
if err := a.storeActivity(storagespace.FormatResourceID(*resourceID), eventID, 0, timestamp); err != nil {
if err := a.storeActivity(storagespace.FormatResourceID(resourceID), eventID, 0, timestamp); err != nil {
return fmt.Errorf("could not store activity: %w", err)
}
@@ -183,7 +183,7 @@ func (a *ActivitylogService) AddSpaceActivity(spaceID *provider.StorageSpaceId,
return fmt.Errorf("could not parse space id: %w", err)
}
rid.OpaqueId = rid.GetSpaceId()
return a.storeActivity(storagespace.FormatResourceID(rid), eventID, 0, timestamp)
return a.storeActivity(storagespace.FormatResourceID(&rid), eventID, 0, timestamp)
}
@@ -218,7 +218,7 @@ func (a *ActivitylogService) RemoveActivities(rid *provider.ResourceId, toDelete
}
return a.store.Write(&microstore.Record{
Key: storagespace.FormatResourceID(*rid),
Key: storagespace.FormatResourceID(rid),
Value: b,
})
}
@@ -232,11 +232,11 @@ func (a *ActivitylogService) RemoveResource(rid *provider.ResourceId) error {
a.lock.Lock()
defer a.lock.Unlock()
return a.store.Delete(storagespace.FormatResourceID(*rid))
return a.store.Delete(storagespace.FormatResourceID(rid))
}
func (a *ActivitylogService) activities(rid *provider.ResourceId) ([]RawActivity, error) {
resourceID := storagespace.FormatResourceID(*rid)
resourceID := storagespace.FormatResourceID(rid)
records, err := a.store.Read(resourceID)
if err != nil && err != microstore.ErrNotFound {
@@ -269,7 +269,7 @@ func (a *ActivitylogService) addActivity(initRef *provider.Reference, eventID st
return fmt.Errorf("could not get resource info: %w", err)
}
if err := a.storeActivity(storagespace.FormatResourceID(*info.GetId()), eventID, depth, timestamp); err != nil {
if err := a.storeActivity(storagespace.FormatResourceID(info.GetId()), eventID, depth, timestamp); err != nil {
return fmt.Errorf("could not store activity: %w", err)
}

View File

@@ -108,7 +108,7 @@ var testCases = []struct {
require.Equal(t, "", ev.ItemType) // not implemented atm
require.Equal(t, "", ev.ExpirationDate) // no expiration for shares
require.Equal(t, false, ev.SharePass)
require.Equal(t, "get_quota:true stat:true ", ev.Permissions)
require.Equal(t, "get_quota:true stat:true", ev.Permissions)
require.Equal(t, "group", ev.ShareType)
require.Equal(t, "beshared-groupid", ev.ShareWith)
require.Equal(t, "sharing-userid", ev.ShareOwner)
@@ -142,7 +142,7 @@ var testCases = []struct {
require.Equal(t, "", ev.ItemType) // not implemented atm
require.Equal(t, "2001-09-20T15:33:20Z", ev.ExpirationDate)
require.Equal(t, true, ev.SharePass)
require.Equal(t, "stat:true ", ev.Permissions)
require.Equal(t, "stat:true", ev.Permissions)
require.Equal(t, "link", ev.ShareType)
require.Equal(t, "", ev.ShareWith) // not filled on links
require.Equal(t, "sharing-userid", ev.ShareOwner)

View File

@@ -196,8 +196,8 @@ func processFileEvent(ctx context.Context, ref *provider.Reference, gwc gateway.
}
data := FileEvent{
ParentItemID: storagespace.FormatResourceID(*info.GetParentId()),
ItemID: storagespace.FormatResourceID(*info.GetId()),
ParentItemID: storagespace.FormatResourceID(info.GetParentId()),
ItemID: storagespace.FormatResourceID(info.GetId()),
SpaceID: storagespace.FormatStorageID(info.GetSpace().GetRoot().GetStorageId(), info.GetSpace().GetRoot().GetSpaceId()),
InitiatorID: initiatorid,
Etag: info.GetEtag(),
@@ -233,7 +233,7 @@ func processItemTrashedEvent(ctx context.Context, ref *provider.Reference, gwc g
if item.GetKey() == itemID.GetOpaqueId() {
data := FileEvent{
ItemID: storagespace.FormatResourceID(*itemID),
ItemID: storagespace.FormatResourceID(itemID),
// TODO: check with web if parentID is needed
// ParentItemID: storagespace.FormatResourceID(*item.GetRef().GetResourceId()),
SpaceID: storagespace.FormatStorageID(itemID.GetStorageId(), itemID.GetSpaceId()),

View File

@@ -25,7 +25,7 @@ func (_m *DriveItemPermissionsProvider) EXPECT() *DriveItemPermissionsProvider_E
}
// CreateLink provides a mock function with given fields: ctx, driveItemID, createLink
func (_m *DriveItemPermissionsProvider) CreateLink(ctx context.Context, driveItemID providerv1beta1.ResourceId, createLink libregraph.DriveItemCreateLink) (libregraph.Permission, error) {
func (_m *DriveItemPermissionsProvider) CreateLink(ctx context.Context, driveItemID *providerv1beta1.ResourceId, createLink libregraph.DriveItemCreateLink) (libregraph.Permission, error) {
ret := _m.Called(ctx, driveItemID, createLink)
if len(ret) == 0 {
@@ -34,16 +34,16 @@ func (_m *DriveItemPermissionsProvider) CreateLink(ctx context.Context, driveIte
var r0 libregraph.Permission
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, providerv1beta1.ResourceId, libregraph.DriveItemCreateLink) (libregraph.Permission, error)); ok {
if rf, ok := ret.Get(0).(func(context.Context, *providerv1beta1.ResourceId, libregraph.DriveItemCreateLink) (libregraph.Permission, error)); ok {
return rf(ctx, driveItemID, createLink)
}
if rf, ok := ret.Get(0).(func(context.Context, providerv1beta1.ResourceId, libregraph.DriveItemCreateLink) libregraph.Permission); ok {
if rf, ok := ret.Get(0).(func(context.Context, *providerv1beta1.ResourceId, libregraph.DriveItemCreateLink) libregraph.Permission); ok {
r0 = rf(ctx, driveItemID, createLink)
} else {
r0 = ret.Get(0).(libregraph.Permission)
}
if rf, ok := ret.Get(1).(func(context.Context, providerv1beta1.ResourceId, libregraph.DriveItemCreateLink) error); ok {
if rf, ok := ret.Get(1).(func(context.Context, *providerv1beta1.ResourceId, libregraph.DriveItemCreateLink) error); ok {
r1 = rf(ctx, driveItemID, createLink)
} else {
r1 = ret.Error(1)
@@ -59,15 +59,15 @@ type DriveItemPermissionsProvider_CreateLink_Call struct {
// CreateLink is a helper method to define mock.On call
// - ctx context.Context
// - driveItemID providerv1beta1.ResourceId
// - driveItemID *providerv1beta1.ResourceId
// - createLink libregraph.DriveItemCreateLink
func (_e *DriveItemPermissionsProvider_Expecter) CreateLink(ctx interface{}, driveItemID interface{}, createLink interface{}) *DriveItemPermissionsProvider_CreateLink_Call {
return &DriveItemPermissionsProvider_CreateLink_Call{Call: _e.mock.On("CreateLink", ctx, driveItemID, createLink)}
}
func (_c *DriveItemPermissionsProvider_CreateLink_Call) Run(run func(ctx context.Context, driveItemID providerv1beta1.ResourceId, createLink libregraph.DriveItemCreateLink)) *DriveItemPermissionsProvider_CreateLink_Call {
func (_c *DriveItemPermissionsProvider_CreateLink_Call) Run(run func(ctx context.Context, driveItemID *providerv1beta1.ResourceId, createLink libregraph.DriveItemCreateLink)) *DriveItemPermissionsProvider_CreateLink_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(providerv1beta1.ResourceId), args[2].(libregraph.DriveItemCreateLink))
run(args[0].(context.Context), args[1].(*providerv1beta1.ResourceId), args[2].(libregraph.DriveItemCreateLink))
})
return _c
}
@@ -77,13 +77,13 @@ func (_c *DriveItemPermissionsProvider_CreateLink_Call) Return(_a0 libregraph.Pe
return _c
}
func (_c *DriveItemPermissionsProvider_CreateLink_Call) RunAndReturn(run func(context.Context, providerv1beta1.ResourceId, libregraph.DriveItemCreateLink) (libregraph.Permission, error)) *DriveItemPermissionsProvider_CreateLink_Call {
func (_c *DriveItemPermissionsProvider_CreateLink_Call) RunAndReturn(run func(context.Context, *providerv1beta1.ResourceId, libregraph.DriveItemCreateLink) (libregraph.Permission, error)) *DriveItemPermissionsProvider_CreateLink_Call {
_c.Call.Return(run)
return _c
}
// CreateSpaceRootLink provides a mock function with given fields: ctx, driveID, createLink
func (_m *DriveItemPermissionsProvider) CreateSpaceRootLink(ctx context.Context, driveID providerv1beta1.ResourceId, createLink libregraph.DriveItemCreateLink) (libregraph.Permission, error) {
func (_m *DriveItemPermissionsProvider) CreateSpaceRootLink(ctx context.Context, driveID *providerv1beta1.ResourceId, createLink libregraph.DriveItemCreateLink) (libregraph.Permission, error) {
ret := _m.Called(ctx, driveID, createLink)
if len(ret) == 0 {
@@ -92,16 +92,16 @@ func (_m *DriveItemPermissionsProvider) CreateSpaceRootLink(ctx context.Context,
var r0 libregraph.Permission
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, providerv1beta1.ResourceId, libregraph.DriveItemCreateLink) (libregraph.Permission, error)); ok {
if rf, ok := ret.Get(0).(func(context.Context, *providerv1beta1.ResourceId, libregraph.DriveItemCreateLink) (libregraph.Permission, error)); ok {
return rf(ctx, driveID, createLink)
}
if rf, ok := ret.Get(0).(func(context.Context, providerv1beta1.ResourceId, libregraph.DriveItemCreateLink) libregraph.Permission); ok {
if rf, ok := ret.Get(0).(func(context.Context, *providerv1beta1.ResourceId, libregraph.DriveItemCreateLink) libregraph.Permission); ok {
r0 = rf(ctx, driveID, createLink)
} else {
r0 = ret.Get(0).(libregraph.Permission)
}
if rf, ok := ret.Get(1).(func(context.Context, providerv1beta1.ResourceId, libregraph.DriveItemCreateLink) error); ok {
if rf, ok := ret.Get(1).(func(context.Context, *providerv1beta1.ResourceId, libregraph.DriveItemCreateLink) error); ok {
r1 = rf(ctx, driveID, createLink)
} else {
r1 = ret.Error(1)
@@ -117,15 +117,15 @@ type DriveItemPermissionsProvider_CreateSpaceRootLink_Call struct {
// CreateSpaceRootLink is a helper method to define mock.On call
// - ctx context.Context
// - driveID providerv1beta1.ResourceId
// - driveID *providerv1beta1.ResourceId
// - createLink libregraph.DriveItemCreateLink
func (_e *DriveItemPermissionsProvider_Expecter) CreateSpaceRootLink(ctx interface{}, driveID interface{}, createLink interface{}) *DriveItemPermissionsProvider_CreateSpaceRootLink_Call {
return &DriveItemPermissionsProvider_CreateSpaceRootLink_Call{Call: _e.mock.On("CreateSpaceRootLink", ctx, driveID, createLink)}
}
func (_c *DriveItemPermissionsProvider_CreateSpaceRootLink_Call) Run(run func(ctx context.Context, driveID providerv1beta1.ResourceId, createLink libregraph.DriveItemCreateLink)) *DriveItemPermissionsProvider_CreateSpaceRootLink_Call {
func (_c *DriveItemPermissionsProvider_CreateSpaceRootLink_Call) Run(run func(ctx context.Context, driveID *providerv1beta1.ResourceId, createLink libregraph.DriveItemCreateLink)) *DriveItemPermissionsProvider_CreateSpaceRootLink_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(providerv1beta1.ResourceId), args[2].(libregraph.DriveItemCreateLink))
run(args[0].(context.Context), args[1].(*providerv1beta1.ResourceId), args[2].(libregraph.DriveItemCreateLink))
})
return _c
}
@@ -135,13 +135,13 @@ func (_c *DriveItemPermissionsProvider_CreateSpaceRootLink_Call) Return(_a0 libr
return _c
}
func (_c *DriveItemPermissionsProvider_CreateSpaceRootLink_Call) RunAndReturn(run func(context.Context, providerv1beta1.ResourceId, libregraph.DriveItemCreateLink) (libregraph.Permission, error)) *DriveItemPermissionsProvider_CreateSpaceRootLink_Call {
func (_c *DriveItemPermissionsProvider_CreateSpaceRootLink_Call) RunAndReturn(run func(context.Context, *providerv1beta1.ResourceId, libregraph.DriveItemCreateLink) (libregraph.Permission, error)) *DriveItemPermissionsProvider_CreateSpaceRootLink_Call {
_c.Call.Return(run)
return _c
}
// DeletePermission provides a mock function with given fields: ctx, itemID, permissionID
func (_m *DriveItemPermissionsProvider) DeletePermission(ctx context.Context, itemID providerv1beta1.ResourceId, permissionID string) error {
func (_m *DriveItemPermissionsProvider) DeletePermission(ctx context.Context, itemID *providerv1beta1.ResourceId, permissionID string) error {
ret := _m.Called(ctx, itemID, permissionID)
if len(ret) == 0 {
@@ -149,7 +149,7 @@ func (_m *DriveItemPermissionsProvider) DeletePermission(ctx context.Context, it
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, providerv1beta1.ResourceId, string) error); ok {
if rf, ok := ret.Get(0).(func(context.Context, *providerv1beta1.ResourceId, string) error); ok {
r0 = rf(ctx, itemID, permissionID)
} else {
r0 = ret.Error(0)
@@ -165,15 +165,15 @@ type DriveItemPermissionsProvider_DeletePermission_Call struct {
// DeletePermission is a helper method to define mock.On call
// - ctx context.Context
// - itemID providerv1beta1.ResourceId
// - itemID *providerv1beta1.ResourceId
// - permissionID string
func (_e *DriveItemPermissionsProvider_Expecter) DeletePermission(ctx interface{}, itemID interface{}, permissionID interface{}) *DriveItemPermissionsProvider_DeletePermission_Call {
return &DriveItemPermissionsProvider_DeletePermission_Call{Call: _e.mock.On("DeletePermission", ctx, itemID, permissionID)}
}
func (_c *DriveItemPermissionsProvider_DeletePermission_Call) Run(run func(ctx context.Context, itemID providerv1beta1.ResourceId, permissionID string)) *DriveItemPermissionsProvider_DeletePermission_Call {
func (_c *DriveItemPermissionsProvider_DeletePermission_Call) Run(run func(ctx context.Context, itemID *providerv1beta1.ResourceId, permissionID string)) *DriveItemPermissionsProvider_DeletePermission_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(providerv1beta1.ResourceId), args[2].(string))
run(args[0].(context.Context), args[1].(*providerv1beta1.ResourceId), args[2].(string))
})
return _c
}
@@ -183,13 +183,13 @@ func (_c *DriveItemPermissionsProvider_DeletePermission_Call) Return(_a0 error)
return _c
}
func (_c *DriveItemPermissionsProvider_DeletePermission_Call) RunAndReturn(run func(context.Context, providerv1beta1.ResourceId, string) error) *DriveItemPermissionsProvider_DeletePermission_Call {
func (_c *DriveItemPermissionsProvider_DeletePermission_Call) RunAndReturn(run func(context.Context, *providerv1beta1.ResourceId, string) error) *DriveItemPermissionsProvider_DeletePermission_Call {
_c.Call.Return(run)
return _c
}
// DeleteSpaceRootPermission provides a mock function with given fields: ctx, driveID, permissionID
func (_m *DriveItemPermissionsProvider) DeleteSpaceRootPermission(ctx context.Context, driveID providerv1beta1.ResourceId, permissionID string) error {
func (_m *DriveItemPermissionsProvider) DeleteSpaceRootPermission(ctx context.Context, driveID *providerv1beta1.ResourceId, permissionID string) error {
ret := _m.Called(ctx, driveID, permissionID)
if len(ret) == 0 {
@@ -197,7 +197,7 @@ func (_m *DriveItemPermissionsProvider) DeleteSpaceRootPermission(ctx context.Co
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, providerv1beta1.ResourceId, string) error); ok {
if rf, ok := ret.Get(0).(func(context.Context, *providerv1beta1.ResourceId, string) error); ok {
r0 = rf(ctx, driveID, permissionID)
} else {
r0 = ret.Error(0)
@@ -213,15 +213,15 @@ type DriveItemPermissionsProvider_DeleteSpaceRootPermission_Call struct {
// DeleteSpaceRootPermission is a helper method to define mock.On call
// - ctx context.Context
// - driveID providerv1beta1.ResourceId
// - driveID *providerv1beta1.ResourceId
// - permissionID string
func (_e *DriveItemPermissionsProvider_Expecter) DeleteSpaceRootPermission(ctx interface{}, driveID interface{}, permissionID interface{}) *DriveItemPermissionsProvider_DeleteSpaceRootPermission_Call {
return &DriveItemPermissionsProvider_DeleteSpaceRootPermission_Call{Call: _e.mock.On("DeleteSpaceRootPermission", ctx, driveID, permissionID)}
}
func (_c *DriveItemPermissionsProvider_DeleteSpaceRootPermission_Call) Run(run func(ctx context.Context, driveID providerv1beta1.ResourceId, permissionID string)) *DriveItemPermissionsProvider_DeleteSpaceRootPermission_Call {
func (_c *DriveItemPermissionsProvider_DeleteSpaceRootPermission_Call) Run(run func(ctx context.Context, driveID *providerv1beta1.ResourceId, permissionID string)) *DriveItemPermissionsProvider_DeleteSpaceRootPermission_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(providerv1beta1.ResourceId), args[2].(string))
run(args[0].(context.Context), args[1].(*providerv1beta1.ResourceId), args[2].(string))
})
return _c
}
@@ -231,13 +231,13 @@ func (_c *DriveItemPermissionsProvider_DeleteSpaceRootPermission_Call) Return(_a
return _c
}
func (_c *DriveItemPermissionsProvider_DeleteSpaceRootPermission_Call) RunAndReturn(run func(context.Context, providerv1beta1.ResourceId, string) error) *DriveItemPermissionsProvider_DeleteSpaceRootPermission_Call {
func (_c *DriveItemPermissionsProvider_DeleteSpaceRootPermission_Call) RunAndReturn(run func(context.Context, *providerv1beta1.ResourceId, string) error) *DriveItemPermissionsProvider_DeleteSpaceRootPermission_Call {
_c.Call.Return(run)
return _c
}
// Invite provides a mock function with given fields: ctx, resourceId, invite
func (_m *DriveItemPermissionsProvider) Invite(ctx context.Context, resourceId providerv1beta1.ResourceId, invite libregraph.DriveItemInvite) (libregraph.Permission, error) {
func (_m *DriveItemPermissionsProvider) Invite(ctx context.Context, resourceId *providerv1beta1.ResourceId, invite libregraph.DriveItemInvite) (libregraph.Permission, error) {
ret := _m.Called(ctx, resourceId, invite)
if len(ret) == 0 {
@@ -246,16 +246,16 @@ func (_m *DriveItemPermissionsProvider) Invite(ctx context.Context, resourceId p
var r0 libregraph.Permission
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, providerv1beta1.ResourceId, libregraph.DriveItemInvite) (libregraph.Permission, error)); ok {
if rf, ok := ret.Get(0).(func(context.Context, *providerv1beta1.ResourceId, libregraph.DriveItemInvite) (libregraph.Permission, error)); ok {
return rf(ctx, resourceId, invite)
}
if rf, ok := ret.Get(0).(func(context.Context, providerv1beta1.ResourceId, libregraph.DriveItemInvite) libregraph.Permission); ok {
if rf, ok := ret.Get(0).(func(context.Context, *providerv1beta1.ResourceId, libregraph.DriveItemInvite) libregraph.Permission); ok {
r0 = rf(ctx, resourceId, invite)
} else {
r0 = ret.Get(0).(libregraph.Permission)
}
if rf, ok := ret.Get(1).(func(context.Context, providerv1beta1.ResourceId, libregraph.DriveItemInvite) error); ok {
if rf, ok := ret.Get(1).(func(context.Context, *providerv1beta1.ResourceId, libregraph.DriveItemInvite) error); ok {
r1 = rf(ctx, resourceId, invite)
} else {
r1 = ret.Error(1)
@@ -271,15 +271,15 @@ type DriveItemPermissionsProvider_Invite_Call struct {
// Invite is a helper method to define mock.On call
// - ctx context.Context
// - resourceId providerv1beta1.ResourceId
// - resourceId *providerv1beta1.ResourceId
// - invite libregraph.DriveItemInvite
func (_e *DriveItemPermissionsProvider_Expecter) Invite(ctx interface{}, resourceId interface{}, invite interface{}) *DriveItemPermissionsProvider_Invite_Call {
return &DriveItemPermissionsProvider_Invite_Call{Call: _e.mock.On("Invite", ctx, resourceId, invite)}
}
func (_c *DriveItemPermissionsProvider_Invite_Call) Run(run func(ctx context.Context, resourceId providerv1beta1.ResourceId, invite libregraph.DriveItemInvite)) *DriveItemPermissionsProvider_Invite_Call {
func (_c *DriveItemPermissionsProvider_Invite_Call) Run(run func(ctx context.Context, resourceId *providerv1beta1.ResourceId, invite libregraph.DriveItemInvite)) *DriveItemPermissionsProvider_Invite_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(providerv1beta1.ResourceId), args[2].(libregraph.DriveItemInvite))
run(args[0].(context.Context), args[1].(*providerv1beta1.ResourceId), args[2].(libregraph.DriveItemInvite))
})
return _c
}
@@ -289,7 +289,7 @@ func (_c *DriveItemPermissionsProvider_Invite_Call) Return(_a0 libregraph.Permis
return _c
}
func (_c *DriveItemPermissionsProvider_Invite_Call) RunAndReturn(run func(context.Context, providerv1beta1.ResourceId, libregraph.DriveItemInvite) (libregraph.Permission, error)) *DriveItemPermissionsProvider_Invite_Call {
func (_c *DriveItemPermissionsProvider_Invite_Call) RunAndReturn(run func(context.Context, *providerv1beta1.ResourceId, libregraph.DriveItemInvite) (libregraph.Permission, error)) *DriveItemPermissionsProvider_Invite_Call {
_c.Call.Return(run)
return _c
}
@@ -352,7 +352,7 @@ func (_c *DriveItemPermissionsProvider_ListPermissions_Call) RunAndReturn(run fu
}
// ListSpaceRootPermissions provides a mock function with given fields: ctx, driveID
func (_m *DriveItemPermissionsProvider) ListSpaceRootPermissions(ctx context.Context, driveID providerv1beta1.ResourceId) (libregraph.CollectionOfPermissionsWithAllowedValues, error) {
func (_m *DriveItemPermissionsProvider) ListSpaceRootPermissions(ctx context.Context, driveID *providerv1beta1.ResourceId) (libregraph.CollectionOfPermissionsWithAllowedValues, error) {
ret := _m.Called(ctx, driveID)
if len(ret) == 0 {
@@ -361,16 +361,16 @@ func (_m *DriveItemPermissionsProvider) ListSpaceRootPermissions(ctx context.Con
var r0 libregraph.CollectionOfPermissionsWithAllowedValues
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, providerv1beta1.ResourceId) (libregraph.CollectionOfPermissionsWithAllowedValues, error)); ok {
if rf, ok := ret.Get(0).(func(context.Context, *providerv1beta1.ResourceId) (libregraph.CollectionOfPermissionsWithAllowedValues, error)); ok {
return rf(ctx, driveID)
}
if rf, ok := ret.Get(0).(func(context.Context, providerv1beta1.ResourceId) libregraph.CollectionOfPermissionsWithAllowedValues); ok {
if rf, ok := ret.Get(0).(func(context.Context, *providerv1beta1.ResourceId) libregraph.CollectionOfPermissionsWithAllowedValues); ok {
r0 = rf(ctx, driveID)
} else {
r0 = ret.Get(0).(libregraph.CollectionOfPermissionsWithAllowedValues)
}
if rf, ok := ret.Get(1).(func(context.Context, providerv1beta1.ResourceId) error); ok {
if rf, ok := ret.Get(1).(func(context.Context, *providerv1beta1.ResourceId) error); ok {
r1 = rf(ctx, driveID)
} else {
r1 = ret.Error(1)
@@ -386,14 +386,14 @@ type DriveItemPermissionsProvider_ListSpaceRootPermissions_Call struct {
// ListSpaceRootPermissions is a helper method to define mock.On call
// - ctx context.Context
// - driveID providerv1beta1.ResourceId
// - driveID *providerv1beta1.ResourceId
func (_e *DriveItemPermissionsProvider_Expecter) ListSpaceRootPermissions(ctx interface{}, driveID interface{}) *DriveItemPermissionsProvider_ListSpaceRootPermissions_Call {
return &DriveItemPermissionsProvider_ListSpaceRootPermissions_Call{Call: _e.mock.On("ListSpaceRootPermissions", ctx, driveID)}
}
func (_c *DriveItemPermissionsProvider_ListSpaceRootPermissions_Call) Run(run func(ctx context.Context, driveID providerv1beta1.ResourceId)) *DriveItemPermissionsProvider_ListSpaceRootPermissions_Call {
func (_c *DriveItemPermissionsProvider_ListSpaceRootPermissions_Call) Run(run func(ctx context.Context, driveID *providerv1beta1.ResourceId)) *DriveItemPermissionsProvider_ListSpaceRootPermissions_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(providerv1beta1.ResourceId))
run(args[0].(context.Context), args[1].(*providerv1beta1.ResourceId))
})
return _c
}
@@ -403,13 +403,13 @@ func (_c *DriveItemPermissionsProvider_ListSpaceRootPermissions_Call) Return(_a0
return _c
}
func (_c *DriveItemPermissionsProvider_ListSpaceRootPermissions_Call) RunAndReturn(run func(context.Context, providerv1beta1.ResourceId) (libregraph.CollectionOfPermissionsWithAllowedValues, error)) *DriveItemPermissionsProvider_ListSpaceRootPermissions_Call {
func (_c *DriveItemPermissionsProvider_ListSpaceRootPermissions_Call) RunAndReturn(run func(context.Context, *providerv1beta1.ResourceId) (libregraph.CollectionOfPermissionsWithAllowedValues, error)) *DriveItemPermissionsProvider_ListSpaceRootPermissions_Call {
_c.Call.Return(run)
return _c
}
// SetPublicLinkPassword provides a mock function with given fields: ctx, driveItemID, permissionID, password
func (_m *DriveItemPermissionsProvider) SetPublicLinkPassword(ctx context.Context, driveItemID providerv1beta1.ResourceId, permissionID string, password string) (libregraph.Permission, error) {
func (_m *DriveItemPermissionsProvider) SetPublicLinkPassword(ctx context.Context, driveItemID *providerv1beta1.ResourceId, permissionID string, password string) (libregraph.Permission, error) {
ret := _m.Called(ctx, driveItemID, permissionID, password)
if len(ret) == 0 {
@@ -418,16 +418,16 @@ func (_m *DriveItemPermissionsProvider) SetPublicLinkPassword(ctx context.Contex
var r0 libregraph.Permission
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, providerv1beta1.ResourceId, string, string) (libregraph.Permission, error)); ok {
if rf, ok := ret.Get(0).(func(context.Context, *providerv1beta1.ResourceId, string, string) (libregraph.Permission, error)); ok {
return rf(ctx, driveItemID, permissionID, password)
}
if rf, ok := ret.Get(0).(func(context.Context, providerv1beta1.ResourceId, string, string) libregraph.Permission); ok {
if rf, ok := ret.Get(0).(func(context.Context, *providerv1beta1.ResourceId, string, string) libregraph.Permission); ok {
r0 = rf(ctx, driveItemID, permissionID, password)
} else {
r0 = ret.Get(0).(libregraph.Permission)
}
if rf, ok := ret.Get(1).(func(context.Context, providerv1beta1.ResourceId, string, string) error); ok {
if rf, ok := ret.Get(1).(func(context.Context, *providerv1beta1.ResourceId, string, string) error); ok {
r1 = rf(ctx, driveItemID, permissionID, password)
} else {
r1 = ret.Error(1)
@@ -443,16 +443,16 @@ type DriveItemPermissionsProvider_SetPublicLinkPassword_Call struct {
// SetPublicLinkPassword is a helper method to define mock.On call
// - ctx context.Context
// - driveItemID providerv1beta1.ResourceId
// - driveItemID *providerv1beta1.ResourceId
// - permissionID string
// - password string
func (_e *DriveItemPermissionsProvider_Expecter) SetPublicLinkPassword(ctx interface{}, driveItemID interface{}, permissionID interface{}, password interface{}) *DriveItemPermissionsProvider_SetPublicLinkPassword_Call {
return &DriveItemPermissionsProvider_SetPublicLinkPassword_Call{Call: _e.mock.On("SetPublicLinkPassword", ctx, driveItemID, permissionID, password)}
}
func (_c *DriveItemPermissionsProvider_SetPublicLinkPassword_Call) Run(run func(ctx context.Context, driveItemID providerv1beta1.ResourceId, permissionID string, password string)) *DriveItemPermissionsProvider_SetPublicLinkPassword_Call {
func (_c *DriveItemPermissionsProvider_SetPublicLinkPassword_Call) Run(run func(ctx context.Context, driveItemID *providerv1beta1.ResourceId, permissionID string, password string)) *DriveItemPermissionsProvider_SetPublicLinkPassword_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(providerv1beta1.ResourceId), args[2].(string), args[3].(string))
run(args[0].(context.Context), args[1].(*providerv1beta1.ResourceId), args[2].(string), args[3].(string))
})
return _c
}
@@ -462,13 +462,13 @@ func (_c *DriveItemPermissionsProvider_SetPublicLinkPassword_Call) Return(_a0 li
return _c
}
func (_c *DriveItemPermissionsProvider_SetPublicLinkPassword_Call) RunAndReturn(run func(context.Context, providerv1beta1.ResourceId, string, string) (libregraph.Permission, error)) *DriveItemPermissionsProvider_SetPublicLinkPassword_Call {
func (_c *DriveItemPermissionsProvider_SetPublicLinkPassword_Call) RunAndReturn(run func(context.Context, *providerv1beta1.ResourceId, string, string) (libregraph.Permission, error)) *DriveItemPermissionsProvider_SetPublicLinkPassword_Call {
_c.Call.Return(run)
return _c
}
// SetPublicLinkPasswordOnSpaceRoot provides a mock function with given fields: ctx, driveID, permissionID, password
func (_m *DriveItemPermissionsProvider) SetPublicLinkPasswordOnSpaceRoot(ctx context.Context, driveID providerv1beta1.ResourceId, permissionID string, password string) (libregraph.Permission, error) {
func (_m *DriveItemPermissionsProvider) SetPublicLinkPasswordOnSpaceRoot(ctx context.Context, driveID *providerv1beta1.ResourceId, permissionID string, password string) (libregraph.Permission, error) {
ret := _m.Called(ctx, driveID, permissionID, password)
if len(ret) == 0 {
@@ -477,16 +477,16 @@ func (_m *DriveItemPermissionsProvider) SetPublicLinkPasswordOnSpaceRoot(ctx con
var r0 libregraph.Permission
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, providerv1beta1.ResourceId, string, string) (libregraph.Permission, error)); ok {
if rf, ok := ret.Get(0).(func(context.Context, *providerv1beta1.ResourceId, string, string) (libregraph.Permission, error)); ok {
return rf(ctx, driveID, permissionID, password)
}
if rf, ok := ret.Get(0).(func(context.Context, providerv1beta1.ResourceId, string, string) libregraph.Permission); ok {
if rf, ok := ret.Get(0).(func(context.Context, *providerv1beta1.ResourceId, string, string) libregraph.Permission); ok {
r0 = rf(ctx, driveID, permissionID, password)
} else {
r0 = ret.Get(0).(libregraph.Permission)
}
if rf, ok := ret.Get(1).(func(context.Context, providerv1beta1.ResourceId, string, string) error); ok {
if rf, ok := ret.Get(1).(func(context.Context, *providerv1beta1.ResourceId, string, string) error); ok {
r1 = rf(ctx, driveID, permissionID, password)
} else {
r1 = ret.Error(1)
@@ -502,16 +502,16 @@ type DriveItemPermissionsProvider_SetPublicLinkPasswordOnSpaceRoot_Call struct {
// SetPublicLinkPasswordOnSpaceRoot is a helper method to define mock.On call
// - ctx context.Context
// - driveID providerv1beta1.ResourceId
// - driveID *providerv1beta1.ResourceId
// - permissionID string
// - password string
func (_e *DriveItemPermissionsProvider_Expecter) SetPublicLinkPasswordOnSpaceRoot(ctx interface{}, driveID interface{}, permissionID interface{}, password interface{}) *DriveItemPermissionsProvider_SetPublicLinkPasswordOnSpaceRoot_Call {
return &DriveItemPermissionsProvider_SetPublicLinkPasswordOnSpaceRoot_Call{Call: _e.mock.On("SetPublicLinkPasswordOnSpaceRoot", ctx, driveID, permissionID, password)}
}
func (_c *DriveItemPermissionsProvider_SetPublicLinkPasswordOnSpaceRoot_Call) Run(run func(ctx context.Context, driveID providerv1beta1.ResourceId, permissionID string, password string)) *DriveItemPermissionsProvider_SetPublicLinkPasswordOnSpaceRoot_Call {
func (_c *DriveItemPermissionsProvider_SetPublicLinkPasswordOnSpaceRoot_Call) Run(run func(ctx context.Context, driveID *providerv1beta1.ResourceId, permissionID string, password string)) *DriveItemPermissionsProvider_SetPublicLinkPasswordOnSpaceRoot_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(providerv1beta1.ResourceId), args[2].(string), args[3].(string))
run(args[0].(context.Context), args[1].(*providerv1beta1.ResourceId), args[2].(string), args[3].(string))
})
return _c
}
@@ -521,13 +521,13 @@ func (_c *DriveItemPermissionsProvider_SetPublicLinkPasswordOnSpaceRoot_Call) Re
return _c
}
func (_c *DriveItemPermissionsProvider_SetPublicLinkPasswordOnSpaceRoot_Call) RunAndReturn(run func(context.Context, providerv1beta1.ResourceId, string, string) (libregraph.Permission, error)) *DriveItemPermissionsProvider_SetPublicLinkPasswordOnSpaceRoot_Call {
func (_c *DriveItemPermissionsProvider_SetPublicLinkPasswordOnSpaceRoot_Call) RunAndReturn(run func(context.Context, *providerv1beta1.ResourceId, string, string) (libregraph.Permission, error)) *DriveItemPermissionsProvider_SetPublicLinkPasswordOnSpaceRoot_Call {
_c.Call.Return(run)
return _c
}
// SpaceRootInvite provides a mock function with given fields: ctx, driveID, invite
func (_m *DriveItemPermissionsProvider) SpaceRootInvite(ctx context.Context, driveID providerv1beta1.ResourceId, invite libregraph.DriveItemInvite) (libregraph.Permission, error) {
func (_m *DriveItemPermissionsProvider) SpaceRootInvite(ctx context.Context, driveID *providerv1beta1.ResourceId, invite libregraph.DriveItemInvite) (libregraph.Permission, error) {
ret := _m.Called(ctx, driveID, invite)
if len(ret) == 0 {
@@ -536,16 +536,16 @@ func (_m *DriveItemPermissionsProvider) SpaceRootInvite(ctx context.Context, dri
var r0 libregraph.Permission
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, providerv1beta1.ResourceId, libregraph.DriveItemInvite) (libregraph.Permission, error)); ok {
if rf, ok := ret.Get(0).(func(context.Context, *providerv1beta1.ResourceId, libregraph.DriveItemInvite) (libregraph.Permission, error)); ok {
return rf(ctx, driveID, invite)
}
if rf, ok := ret.Get(0).(func(context.Context, providerv1beta1.ResourceId, libregraph.DriveItemInvite) libregraph.Permission); ok {
if rf, ok := ret.Get(0).(func(context.Context, *providerv1beta1.ResourceId, libregraph.DriveItemInvite) libregraph.Permission); ok {
r0 = rf(ctx, driveID, invite)
} else {
r0 = ret.Get(0).(libregraph.Permission)
}
if rf, ok := ret.Get(1).(func(context.Context, providerv1beta1.ResourceId, libregraph.DriveItemInvite) error); ok {
if rf, ok := ret.Get(1).(func(context.Context, *providerv1beta1.ResourceId, libregraph.DriveItemInvite) error); ok {
r1 = rf(ctx, driveID, invite)
} else {
r1 = ret.Error(1)
@@ -561,15 +561,15 @@ type DriveItemPermissionsProvider_SpaceRootInvite_Call struct {
// SpaceRootInvite is a helper method to define mock.On call
// - ctx context.Context
// - driveID providerv1beta1.ResourceId
// - driveID *providerv1beta1.ResourceId
// - invite libregraph.DriveItemInvite
func (_e *DriveItemPermissionsProvider_Expecter) SpaceRootInvite(ctx interface{}, driveID interface{}, invite interface{}) *DriveItemPermissionsProvider_SpaceRootInvite_Call {
return &DriveItemPermissionsProvider_SpaceRootInvite_Call{Call: _e.mock.On("SpaceRootInvite", ctx, driveID, invite)}
}
func (_c *DriveItemPermissionsProvider_SpaceRootInvite_Call) Run(run func(ctx context.Context, driveID providerv1beta1.ResourceId, invite libregraph.DriveItemInvite)) *DriveItemPermissionsProvider_SpaceRootInvite_Call {
func (_c *DriveItemPermissionsProvider_SpaceRootInvite_Call) Run(run func(ctx context.Context, driveID *providerv1beta1.ResourceId, invite libregraph.DriveItemInvite)) *DriveItemPermissionsProvider_SpaceRootInvite_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(providerv1beta1.ResourceId), args[2].(libregraph.DriveItemInvite))
run(args[0].(context.Context), args[1].(*providerv1beta1.ResourceId), args[2].(libregraph.DriveItemInvite))
})
return _c
}
@@ -579,13 +579,13 @@ func (_c *DriveItemPermissionsProvider_SpaceRootInvite_Call) Return(_a0 libregra
return _c
}
func (_c *DriveItemPermissionsProvider_SpaceRootInvite_Call) RunAndReturn(run func(context.Context, providerv1beta1.ResourceId, libregraph.DriveItemInvite) (libregraph.Permission, error)) *DriveItemPermissionsProvider_SpaceRootInvite_Call {
func (_c *DriveItemPermissionsProvider_SpaceRootInvite_Call) RunAndReturn(run func(context.Context, *providerv1beta1.ResourceId, libregraph.DriveItemInvite) (libregraph.Permission, error)) *DriveItemPermissionsProvider_SpaceRootInvite_Call {
_c.Call.Return(run)
return _c
}
// UpdatePermission provides a mock function with given fields: ctx, itemID, permissionID, newPermission
func (_m *DriveItemPermissionsProvider) UpdatePermission(ctx context.Context, itemID providerv1beta1.ResourceId, permissionID string, newPermission libregraph.Permission) (libregraph.Permission, error) {
func (_m *DriveItemPermissionsProvider) UpdatePermission(ctx context.Context, itemID *providerv1beta1.ResourceId, permissionID string, newPermission libregraph.Permission) (libregraph.Permission, error) {
ret := _m.Called(ctx, itemID, permissionID, newPermission)
if len(ret) == 0 {
@@ -594,16 +594,16 @@ func (_m *DriveItemPermissionsProvider) UpdatePermission(ctx context.Context, it
var r0 libregraph.Permission
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, providerv1beta1.ResourceId, string, libregraph.Permission) (libregraph.Permission, error)); ok {
if rf, ok := ret.Get(0).(func(context.Context, *providerv1beta1.ResourceId, string, libregraph.Permission) (libregraph.Permission, error)); ok {
return rf(ctx, itemID, permissionID, newPermission)
}
if rf, ok := ret.Get(0).(func(context.Context, providerv1beta1.ResourceId, string, libregraph.Permission) libregraph.Permission); ok {
if rf, ok := ret.Get(0).(func(context.Context, *providerv1beta1.ResourceId, string, libregraph.Permission) libregraph.Permission); ok {
r0 = rf(ctx, itemID, permissionID, newPermission)
} else {
r0 = ret.Get(0).(libregraph.Permission)
}
if rf, ok := ret.Get(1).(func(context.Context, providerv1beta1.ResourceId, string, libregraph.Permission) error); ok {
if rf, ok := ret.Get(1).(func(context.Context, *providerv1beta1.ResourceId, string, libregraph.Permission) error); ok {
r1 = rf(ctx, itemID, permissionID, newPermission)
} else {
r1 = ret.Error(1)
@@ -619,16 +619,16 @@ type DriveItemPermissionsProvider_UpdatePermission_Call struct {
// UpdatePermission is a helper method to define mock.On call
// - ctx context.Context
// - itemID providerv1beta1.ResourceId
// - itemID *providerv1beta1.ResourceId
// - permissionID string
// - newPermission libregraph.Permission
func (_e *DriveItemPermissionsProvider_Expecter) UpdatePermission(ctx interface{}, itemID interface{}, permissionID interface{}, newPermission interface{}) *DriveItemPermissionsProvider_UpdatePermission_Call {
return &DriveItemPermissionsProvider_UpdatePermission_Call{Call: _e.mock.On("UpdatePermission", ctx, itemID, permissionID, newPermission)}
}
func (_c *DriveItemPermissionsProvider_UpdatePermission_Call) Run(run func(ctx context.Context, itemID providerv1beta1.ResourceId, permissionID string, newPermission libregraph.Permission)) *DriveItemPermissionsProvider_UpdatePermission_Call {
func (_c *DriveItemPermissionsProvider_UpdatePermission_Call) Run(run func(ctx context.Context, itemID *providerv1beta1.ResourceId, permissionID string, newPermission libregraph.Permission)) *DriveItemPermissionsProvider_UpdatePermission_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(providerv1beta1.ResourceId), args[2].(string), args[3].(libregraph.Permission))
run(args[0].(context.Context), args[1].(*providerv1beta1.ResourceId), args[2].(string), args[3].(libregraph.Permission))
})
return _c
}
@@ -638,13 +638,13 @@ func (_c *DriveItemPermissionsProvider_UpdatePermission_Call) Return(_a0 libregr
return _c
}
func (_c *DriveItemPermissionsProvider_UpdatePermission_Call) RunAndReturn(run func(context.Context, providerv1beta1.ResourceId, string, libregraph.Permission) (libregraph.Permission, error)) *DriveItemPermissionsProvider_UpdatePermission_Call {
func (_c *DriveItemPermissionsProvider_UpdatePermission_Call) RunAndReturn(run func(context.Context, *providerv1beta1.ResourceId, string, libregraph.Permission) (libregraph.Permission, error)) *DriveItemPermissionsProvider_UpdatePermission_Call {
_c.Call.Return(run)
return _c
}
// UpdateSpaceRootPermission provides a mock function with given fields: ctx, driveID, permissionID, newPermission
func (_m *DriveItemPermissionsProvider) UpdateSpaceRootPermission(ctx context.Context, driveID providerv1beta1.ResourceId, permissionID string, newPermission libregraph.Permission) (libregraph.Permission, error) {
func (_m *DriveItemPermissionsProvider) UpdateSpaceRootPermission(ctx context.Context, driveID *providerv1beta1.ResourceId, permissionID string, newPermission libregraph.Permission) (libregraph.Permission, error) {
ret := _m.Called(ctx, driveID, permissionID, newPermission)
if len(ret) == 0 {
@@ -653,16 +653,16 @@ func (_m *DriveItemPermissionsProvider) UpdateSpaceRootPermission(ctx context.Co
var r0 libregraph.Permission
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, providerv1beta1.ResourceId, string, libregraph.Permission) (libregraph.Permission, error)); ok {
if rf, ok := ret.Get(0).(func(context.Context, *providerv1beta1.ResourceId, string, libregraph.Permission) (libregraph.Permission, error)); ok {
return rf(ctx, driveID, permissionID, newPermission)
}
if rf, ok := ret.Get(0).(func(context.Context, providerv1beta1.ResourceId, string, libregraph.Permission) libregraph.Permission); ok {
if rf, ok := ret.Get(0).(func(context.Context, *providerv1beta1.ResourceId, string, libregraph.Permission) libregraph.Permission); ok {
r0 = rf(ctx, driveID, permissionID, newPermission)
} else {
r0 = ret.Get(0).(libregraph.Permission)
}
if rf, ok := ret.Get(1).(func(context.Context, providerv1beta1.ResourceId, string, libregraph.Permission) error); ok {
if rf, ok := ret.Get(1).(func(context.Context, *providerv1beta1.ResourceId, string, libregraph.Permission) error); ok {
r1 = rf(ctx, driveID, permissionID, newPermission)
} else {
r1 = ret.Error(1)
@@ -678,16 +678,16 @@ type DriveItemPermissionsProvider_UpdateSpaceRootPermission_Call struct {
// UpdateSpaceRootPermission is a helper method to define mock.On call
// - ctx context.Context
// - driveID providerv1beta1.ResourceId
// - driveID *providerv1beta1.ResourceId
// - permissionID string
// - newPermission libregraph.Permission
func (_e *DriveItemPermissionsProvider_Expecter) UpdateSpaceRootPermission(ctx interface{}, driveID interface{}, permissionID interface{}, newPermission interface{}) *DriveItemPermissionsProvider_UpdateSpaceRootPermission_Call {
return &DriveItemPermissionsProvider_UpdateSpaceRootPermission_Call{Call: _e.mock.On("UpdateSpaceRootPermission", ctx, driveID, permissionID, newPermission)}
}
func (_c *DriveItemPermissionsProvider_UpdateSpaceRootPermission_Call) Run(run func(ctx context.Context, driveID providerv1beta1.ResourceId, permissionID string, newPermission libregraph.Permission)) *DriveItemPermissionsProvider_UpdateSpaceRootPermission_Call {
func (_c *DriveItemPermissionsProvider_UpdateSpaceRootPermission_Call) Run(run func(ctx context.Context, driveID *providerv1beta1.ResourceId, permissionID string, newPermission libregraph.Permission)) *DriveItemPermissionsProvider_UpdateSpaceRootPermission_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(providerv1beta1.ResourceId), args[2].(string), args[3].(libregraph.Permission))
run(args[0].(context.Context), args[1].(*providerv1beta1.ResourceId), args[2].(string), args[3].(libregraph.Permission))
})
return _c
}
@@ -697,7 +697,7 @@ func (_c *DriveItemPermissionsProvider_UpdateSpaceRootPermission_Call) Return(_a
return _c
}
func (_c *DriveItemPermissionsProvider_UpdateSpaceRootPermission_Call) RunAndReturn(run func(context.Context, providerv1beta1.ResourceId, string, libregraph.Permission) (libregraph.Permission, error)) *DriveItemPermissionsProvider_UpdateSpaceRootPermission_Call {
func (_c *DriveItemPermissionsProvider_UpdateSpaceRootPermission_Call) RunAndReturn(run func(context.Context, *providerv1beta1.ResourceId, string, libregraph.Permission) (libregraph.Permission, error)) *DriveItemPermissionsProvider_UpdateSpaceRootPermission_Call {
_c.Call.Return(run)
return _c
}

View File

@@ -41,18 +41,18 @@ const (
// DriveItemPermissionsProvider contains the methods related to handling permissions on drive items
type DriveItemPermissionsProvider interface {
Invite(ctx context.Context, resourceId storageprovider.ResourceId, invite libregraph.DriveItemInvite) (libregraph.Permission, error)
SpaceRootInvite(ctx context.Context, driveID storageprovider.ResourceId, invite libregraph.DriveItemInvite) (libregraph.Permission, error)
Invite(ctx context.Context, resourceId *storageprovider.ResourceId, invite libregraph.DriveItemInvite) (libregraph.Permission, error)
SpaceRootInvite(ctx context.Context, driveID *storageprovider.ResourceId, invite libregraph.DriveItemInvite) (libregraph.Permission, error)
ListPermissions(ctx context.Context, itemID storageprovider.ResourceId) (libregraph.CollectionOfPermissionsWithAllowedValues, error)
ListSpaceRootPermissions(ctx context.Context, driveID storageprovider.ResourceId) (libregraph.CollectionOfPermissionsWithAllowedValues, error)
DeletePermission(ctx context.Context, itemID storageprovider.ResourceId, permissionID string) error
DeleteSpaceRootPermission(ctx context.Context, driveID storageprovider.ResourceId, permissionID string) error
UpdatePermission(ctx context.Context, itemID storageprovider.ResourceId, permissionID string, newPermission libregraph.Permission) (libregraph.Permission, error)
UpdateSpaceRootPermission(ctx context.Context, driveID storageprovider.ResourceId, permissionID string, newPermission libregraph.Permission) (libregraph.Permission, error)
CreateLink(ctx context.Context, driveItemID storageprovider.ResourceId, createLink libregraph.DriveItemCreateLink) (libregraph.Permission, error)
CreateSpaceRootLink(ctx context.Context, driveID storageprovider.ResourceId, createLink libregraph.DriveItemCreateLink) (libregraph.Permission, error)
SetPublicLinkPassword(ctx context.Context, driveItemID storageprovider.ResourceId, permissionID string, password string) (libregraph.Permission, error)
SetPublicLinkPasswordOnSpaceRoot(ctx context.Context, driveID storageprovider.ResourceId, permissionID string, password string) (libregraph.Permission, error)
ListSpaceRootPermissions(ctx context.Context, driveID *storageprovider.ResourceId) (libregraph.CollectionOfPermissionsWithAllowedValues, error)
DeletePermission(ctx context.Context, itemID *storageprovider.ResourceId, permissionID string) error
DeleteSpaceRootPermission(ctx context.Context, driveID *storageprovider.ResourceId, permissionID string) error
UpdatePermission(ctx context.Context, itemID *storageprovider.ResourceId, permissionID string, newPermission libregraph.Permission) (libregraph.Permission, error)
UpdateSpaceRootPermission(ctx context.Context, driveID *storageprovider.ResourceId, permissionID string, newPermission libregraph.Permission) (libregraph.Permission, error)
CreateLink(ctx context.Context, driveItemID *storageprovider.ResourceId, createLink libregraph.DriveItemCreateLink) (libregraph.Permission, error)
CreateSpaceRootLink(ctx context.Context, driveID *storageprovider.ResourceId, createLink libregraph.DriveItemCreateLink) (libregraph.Permission, error)
SetPublicLinkPassword(ctx context.Context, driveItemID *storageprovider.ResourceId, permissionID string, password string) (libregraph.Permission, error)
SetPublicLinkPasswordOnSpaceRoot(ctx context.Context, driveID *storageprovider.ResourceId, permissionID string, password string) (libregraph.Permission, error)
}
// DriveItemPermissionsService contains the production business logic for everything that relates to permissions on drive items.
@@ -82,13 +82,13 @@ func NewDriveItemPermissionsService(logger log.Logger, gatewaySelector pool.Sele
}
// Invite invites a user to a drive item.
func (s DriveItemPermissionsService) Invite(ctx context.Context, resourceId storageprovider.ResourceId, invite libregraph.DriveItemInvite) (libregraph.Permission, error) {
func (s DriveItemPermissionsService) Invite(ctx context.Context, resourceId *storageprovider.ResourceId, invite libregraph.DriveItemInvite) (libregraph.Permission, error) {
gatewayClient, err := s.gatewaySelector.Next()
if err != nil {
return libregraph.Permission{}, err
}
statResponse, err := gatewayClient.Stat(ctx, &storageprovider.StatRequest{Ref: &storageprovider.Reference{ResourceId: &resourceId}})
statResponse, err := gatewayClient.Stat(ctx, &storageprovider.StatRequest{Ref: &storageprovider.Reference{ResourceId: resourceId}})
if err := errorcode.FromStat(statResponse, err); err != nil {
s.logger.Warn().Err(err).Interface("stat.res", statResponse).Msg("stat failed")
return libregraph.Permission{}, err
@@ -284,7 +284,7 @@ func createShareRequestToFederatedUser(user libregraph.User, resourceId *storage
}
// SpaceRootInvite handles invitation request on project spaces
func (s DriveItemPermissionsService) SpaceRootInvite(ctx context.Context, driveID storageprovider.ResourceId, invite libregraph.DriveItemInvite) (libregraph.Permission, error) {
func (s DriveItemPermissionsService) SpaceRootInvite(ctx context.Context, driveID *storageprovider.ResourceId, invite libregraph.DriveItemInvite) (libregraph.Permission, error) {
gatewayClient, err := s.gatewaySelector.Next()
if err != nil {
return libregraph.Permission{}, err
@@ -300,7 +300,7 @@ func (s DriveItemPermissionsService) SpaceRootInvite(ctx context.Context, driveI
}
rootResourceID := space.GetRoot()
return s.Invite(ctx, *rootResourceID, invite)
return s.Invite(ctx, rootResourceID, invite)
}
// ListPermissions lists the permissions of a driveItem
@@ -374,7 +374,7 @@ func (s DriveItemPermissionsService) ListPermissions(ctx context.Context, itemID
}
// ListSpaceRootPermissions handles ListPermissions request on project spaces
func (s DriveItemPermissionsService) ListSpaceRootPermissions(ctx context.Context, driveID storageprovider.ResourceId) (libregraph.CollectionOfPermissionsWithAllowedValues, error) {
func (s DriveItemPermissionsService) ListSpaceRootPermissions(ctx context.Context, driveID *storageprovider.ResourceId) (libregraph.CollectionOfPermissionsWithAllowedValues, error) {
collectionOfPermissions := libregraph.CollectionOfPermissionsWithAllowedValues{}
gatewayClient, err := s.gatewaySelector.Next()
if err != nil {
@@ -396,7 +396,7 @@ func (s DriveItemPermissionsService) ListSpaceRootPermissions(ctx context.Contex
}
// DeletePermission deletes a permission from a drive item
func (s DriveItemPermissionsService) DeletePermission(ctx context.Context, itemID storageprovider.ResourceId, permissionID string) error {
func (s DriveItemPermissionsService) DeletePermission(ctx context.Context, itemID *storageprovider.ResourceId, permissionID string) error {
var permissionType permissionType
sharedResourceID, err := s.getLinkPermissionResourceID(ctx, permissionID)
@@ -406,9 +406,9 @@ func (s DriveItemPermissionsService) DeletePermission(ctx context.Context, itemI
permissionType = Public
// If the item id is referring to a space root and this is not a public share
// we have to deal with space permissions
case IsSpaceRoot(&itemID):
case IsSpaceRoot(itemID):
permissionType = Space
sharedResourceID = &itemID
sharedResourceID = itemID
err = nil
// If this is neither a public share nor a space permission, check if this is a
// user share
@@ -430,7 +430,7 @@ func (s DriveItemPermissionsService) DeletePermission(ctx context.Context, itemI
// The resourceID of the shared resource need to match the item ID from the Request Path
// otherwise this is an invalid Request.
if !utils.ResourceIDEqual(sharedResourceID, &itemID) {
if !utils.ResourceIDEqual(sharedResourceID, itemID) {
s.logger.Debug().Msg("resourceID of shared does not match itemID")
return errorcode.New(errorcode.InvalidRequest, "permissionID and itemID do not match")
}
@@ -449,7 +449,7 @@ func (s DriveItemPermissionsService) DeletePermission(ctx context.Context, itemI
}
// DeleteSpaceRootPermission deletes a permission on the root item of a project space
func (s DriveItemPermissionsService) DeleteSpaceRootPermission(ctx context.Context, driveID storageprovider.ResourceId, permissionID string) error {
func (s DriveItemPermissionsService) DeleteSpaceRootPermission(ctx context.Context, driveID *storageprovider.ResourceId, permissionID string) error {
gatewayClient, err := s.gatewaySelector.Next()
if err != nil {
return err
@@ -465,26 +465,26 @@ func (s DriveItemPermissionsService) DeleteSpaceRootPermission(ctx context.Conte
}
rootResourceID := space.GetRoot()
return s.DeletePermission(ctx, *rootResourceID, permissionID)
return s.DeletePermission(ctx, rootResourceID, permissionID)
}
// UpdatePermission updates a permission on a drive item
func (s DriveItemPermissionsService) UpdatePermission(ctx context.Context, itemID storageprovider.ResourceId, permissionID string, newPermission libregraph.Permission) (libregraph.Permission, error) {
oldPermission, sharedResourceID, err := s.getPermissionByID(ctx, permissionID, &itemID)
func (s DriveItemPermissionsService) UpdatePermission(ctx context.Context, itemID *storageprovider.ResourceId, permissionID string, newPermission libregraph.Permission) (libregraph.Permission, error) {
oldPermission, sharedResourceID, err := s.getPermissionByID(ctx, permissionID, itemID)
if err != nil {
return libregraph.Permission{}, err
}
// The resourceID of the shared resource need to match the item ID from the Request Path
// otherwise this is an invalid Request.
if !utils.ResourceIDEqual(sharedResourceID, &itemID) {
if !utils.ResourceIDEqual(sharedResourceID, itemID) {
s.logger.Debug().Msg("resourceID of shared does not match itemID")
return libregraph.Permission{}, errorcode.New(errorcode.InvalidRequest, "permissionID and itemID do not match")
}
// This is a public link
if _, ok := oldPermission.GetLinkOk(); ok {
updatedPermission, err := s.updatePublicLinkPermission(ctx, permissionID, &itemID, &newPermission)
updatedPermission, err := s.updatePublicLinkPermission(ctx, permissionID, itemID, &newPermission)
if err != nil {
return libregraph.Permission{}, err
}
@@ -500,7 +500,7 @@ func (s DriveItemPermissionsService) UpdatePermission(ctx context.Context, itemI
}
// UpdateSpaceRootPermission updates a permission on the root item of a project space
func (s DriveItemPermissionsService) UpdateSpaceRootPermission(ctx context.Context, driveID storageprovider.ResourceId, permissionID string, newPermission libregraph.Permission) (libregraph.Permission, error) {
func (s DriveItemPermissionsService) UpdateSpaceRootPermission(ctx context.Context, driveID *storageprovider.ResourceId, permissionID string, newPermission libregraph.Permission) (libregraph.Permission, error) {
gatewayClient, err := s.gatewaySelector.Next()
if err != nil {
return libregraph.Permission{}, err
@@ -516,7 +516,7 @@ func (s DriveItemPermissionsService) UpdateSpaceRootPermission(ctx context.Conte
}
rootResourceID := space.GetRoot()
return s.UpdatePermission(ctx, *rootResourceID, permissionID, newPermission)
return s.UpdatePermission(ctx, rootResourceID, permissionID, newPermission)
}
// DriveItemPermissionsService is the api that registers the http endpoints which expose needed operation to the graph api.
@@ -557,7 +557,7 @@ func (api DriveItemPermissionsApi) Invite(w http.ResponseWriter, r *http.Request
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, err.Error())
return
}
permission, err := api.driveItemPermissionsService.Invite(ctx, itemID, *driveItemInvite)
permission, err := api.driveItemPermissionsService.Invite(ctx, &itemID, *driveItemInvite)
if err != nil {
errorcode.RenderError(w, r, err)
@@ -590,7 +590,7 @@ func (api DriveItemPermissionsApi) SpaceRootInvite(w http.ResponseWriter, r *htt
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, err.Error())
return
}
permission, err := api.driveItemPermissionsService.SpaceRootInvite(ctx, driveID, *driveItemInvite)
permission, err := api.driveItemPermissionsService.SpaceRootInvite(ctx, &driveID, *driveItemInvite)
if err != nil {
errorcode.RenderError(w, r, err)
@@ -632,7 +632,7 @@ func (api DriveItemPermissionsApi) ListSpaceRootPermissions(w http.ResponseWrite
}
ctx := r.Context()
permissions, err := api.driveItemPermissionsService.ListSpaceRootPermissions(ctx, driveID)
permissions, err := api.driveItemPermissionsService.ListSpaceRootPermissions(ctx, &driveID)
if err != nil {
errorcode.RenderError(w, r, err)
@@ -660,7 +660,7 @@ func (api DriveItemPermissionsApi) DeletePermission(w http.ResponseWriter, r *ht
}
ctx := r.Context()
err = api.driveItemPermissionsService.DeletePermission(ctx, itemID, permissionID)
err = api.driveItemPermissionsService.DeletePermission(ctx, &itemID, permissionID)
if err != nil {
errorcode.RenderError(w, r, err)
return
@@ -687,7 +687,7 @@ func (api DriveItemPermissionsApi) DeleteSpaceRootPermission(w http.ResponseWrit
}
ctx := r.Context()
err = api.driveItemPermissionsService.DeleteSpaceRootPermission(ctx, driveID, permissionID)
err = api.driveItemPermissionsService.DeleteSpaceRootPermission(ctx, &driveID, permissionID)
if err != nil {
errorcode.RenderError(w, r, err)
return
@@ -727,7 +727,7 @@ func (api DriveItemPermissionsApi) UpdatePermission(w http.ResponseWriter, r *ht
return
}
updatedPermission, err := api.driveItemPermissionsService.UpdatePermission(ctx, itemID, permissionID, permission)
updatedPermission, err := api.driveItemPermissionsService.UpdatePermission(ctx, &itemID, permissionID, permission)
if err != nil {
errorcode.RenderError(w, r, err)
return
@@ -766,7 +766,7 @@ func (api DriveItemPermissionsApi) UpdateSpaceRootPermission(w http.ResponseWrit
return
}
updatedPermission, err := api.driveItemPermissionsService.UpdateSpaceRootPermission(ctx, driveID, permissionID, permission)
updatedPermission, err := api.driveItemPermissionsService.UpdateSpaceRootPermission(ctx, &driveID, permissionID, permission)
if err != nil {
errorcode.RenderError(w, r, err)
return

View File

@@ -20,7 +20,7 @@ import (
"github.com/owncloud/ocis/v2/services/graph/pkg/linktype"
)
func (s DriveItemPermissionsService) CreateLink(ctx context.Context, driveItemID storageprovider.ResourceId, createLink libregraph.DriveItemCreateLink) (libregraph.Permission, error) {
func (s DriveItemPermissionsService) CreateLink(ctx context.Context, driveItemID *storageprovider.ResourceId, createLink libregraph.DriveItemCreateLink) (libregraph.Permission, error) {
gatewayClient, err := s.gatewaySelector.Next()
if err != nil {
s.logger.Error().Err(err).Msg("could not select next gateway client")
@@ -31,7 +31,7 @@ func (s DriveItemPermissionsService) CreateLink(ctx context.Context, driveItemID
ctx,
&storageprovider.StatRequest{
Ref: &storageprovider.Reference{
ResourceId: &driveItemID,
ResourceId: driveItemID,
Path: ".",
},
})
@@ -93,7 +93,7 @@ func (s DriveItemPermissionsService) CreateLink(ctx context.Context, driveItemID
return *perm, nil
}
func (s DriveItemPermissionsService) CreateSpaceRootLink(ctx context.Context, driveID storageprovider.ResourceId, createLink libregraph.DriveItemCreateLink) (libregraph.Permission, error) {
func (s DriveItemPermissionsService) CreateSpaceRootLink(ctx context.Context, driveID *storageprovider.ResourceId, createLink libregraph.DriveItemCreateLink) (libregraph.Permission, error) {
gatewayClient, err := s.gatewaySelector.Next()
if err != nil {
return libregraph.Permission{}, err
@@ -108,10 +108,10 @@ func (s DriveItemPermissionsService) CreateSpaceRootLink(ctx context.Context, dr
}
rootResourceID := space.GetRoot()
return s.CreateLink(ctx, *rootResourceID, createLink)
return s.CreateLink(ctx, rootResourceID, createLink)
}
func (s DriveItemPermissionsService) SetPublicLinkPassword(ctx context.Context, driveItemId storageprovider.ResourceId, permissionID string, password string) (libregraph.Permission, error) {
func (s DriveItemPermissionsService) SetPublicLinkPassword(ctx context.Context, driveItemId *storageprovider.ResourceId, permissionID string, password string) (libregraph.Permission, error) {
publicShare, err := s.getCS3PublicShareByID(ctx, permissionID)
if err != nil {
return libregraph.Permission{}, err
@@ -119,7 +119,7 @@ func (s DriveItemPermissionsService) SetPublicLinkPassword(ctx context.Context,
// The resourceID of the shared resource need to match the item ID from the Request Path
// otherwise this is an invalid Request.
if !utils.ResourceIDEqual(publicShare.GetResourceId(), &driveItemId) {
if !utils.ResourceIDEqual(publicShare.GetResourceId(), driveItemId) {
s.logger.Debug().Msg("resourceID of shared does not match itemID")
return libregraph.Permission{}, errorcode.New(errorcode.InvalidRequest, "permissionID and itemID do not match")
}
@@ -131,7 +131,7 @@ func (s DriveItemPermissionsService) SetPublicLinkPassword(ctx context.Context,
return *permission, nil
}
func (s DriveItemPermissionsService) SetPublicLinkPasswordOnSpaceRoot(ctx context.Context, driveID storageprovider.ResourceId, permissionID string, password string) (libregraph.Permission, error) {
func (s DriveItemPermissionsService) SetPublicLinkPasswordOnSpaceRoot(ctx context.Context, driveID *storageprovider.ResourceId, permissionID string, password string) (libregraph.Permission, error) {
gatewayClient, err := s.gatewaySelector.Next()
if err != nil {
return libregraph.Permission{}, err
@@ -145,7 +145,7 @@ func (s DriveItemPermissionsService) SetPublicLinkPasswordOnSpaceRoot(ctx contex
return libregraph.Permission{}, errorcode.New(errorcode.InvalidRequest, "unsupported space type")
}
rootResourceID := space.GetRoot()
return s.SetPublicLinkPassword(ctx, *rootResourceID, permissionID, password)
return s.SetPublicLinkPassword(ctx, rootResourceID, permissionID, password)
}
// CreateLink creates a public link on the cs3 api
@@ -166,7 +166,7 @@ func (api DriveItemPermissionsApi) CreateLink(w http.ResponseWriter, r *http.Req
return
}
perm, err := api.driveItemPermissionsService.CreateLink(r.Context(), driveItemID, createLink)
perm, err := api.driveItemPermissionsService.CreateLink(r.Context(), &driveItemID, createLink)
if err != nil {
errorcode.RenderError(w, r, err)
return
@@ -195,7 +195,7 @@ func (api DriveItemPermissionsApi) CreateSpaceRootLink(w http.ResponseWriter, r
return
}
perm, err := api.driveItemPermissionsService.CreateSpaceRootLink(r.Context(), driveID, createLink)
perm, err := api.driveItemPermissionsService.CreateSpaceRootLink(r.Context(), &driveID, createLink)
if err != nil {
errorcode.RenderError(w, r, err)
return
@@ -228,7 +228,7 @@ func (api DriveItemPermissionsApi) SetLinkPassword(w http.ResponseWriter, r *htt
return
}
newPermission, err := api.driveItemPermissionsService.SetPublicLinkPassword(ctx, itemID, permissionID, password.GetPassword())
newPermission, err := api.driveItemPermissionsService.SetPublicLinkPassword(ctx, &itemID, permissionID, password.GetPassword())
if err != nil {
errorcode.RenderError(w, r, err)
return
@@ -262,7 +262,7 @@ func (api DriveItemPermissionsApi) SetSpaceRootLinkPassword(w http.ResponseWrite
}
ctx := r.Context()
newPermission, err := api.driveItemPermissionsService.SetPublicLinkPasswordOnSpaceRoot(ctx, driveID, permissionID, password.GetPassword())
newPermission, err := api.driveItemPermissionsService.SetPublicLinkPasswordOnSpaceRoot(ctx, &driveID, permissionID, password.GetPassword())
if err != nil {
errorcode.RenderError(w, r, err)
return

View File

@@ -29,7 +29,7 @@ import (
var _ = Describe("createLinkTests", func() {
var (
svc service.DriveItemPermissionsService
driveItemId provider.ResourceId
driveItemId *provider.ResourceId
ctx context.Context
gatewayClient *cs3mocks.GatewayAPIClient
gatewaySelector *mocks.Selectable[gateway.GatewayAPIClient]
@@ -56,7 +56,7 @@ var _ = Describe("createLinkTests", func() {
cfg := defaults.FullDefaultConfig()
svc, err = service.NewDriveItemPermissionsService(logger, gatewaySelector, cache, cfg)
Expect(err).ToNot(HaveOccurred())
driveItemId = provider.ResourceId{
driveItemId = &provider.ResourceId{
StorageId: "1",
SpaceId: "2",
OpaqueId: "3",
@@ -225,7 +225,7 @@ var _ = Describe("createLinkTests", func() {
Id: &link.PublicShareId{
OpaqueId: "permissionid",
},
ResourceId: &driveItemId,
ResourceId: driveItemId,
Permissions: &link.PublicSharePermissions{
Permissions: linktype.NewViewLinkPermissionSet().GetPermissions(),
},

View File

@@ -56,7 +56,7 @@ var _ = Describe("DriveItemPermissionsService", func() {
},
}
statResponse *provider.StatResponse
driveItemId provider.ResourceId
driveItemId *provider.ResourceId
ctx context.Context
)
@@ -88,7 +88,7 @@ var _ = Describe("DriveItemPermissionsService", func() {
Status: status.NewOK(ctx),
}
driveItemId = provider.ResourceId{
driveItemId = &provider.ResourceId{
StorageId: "1",
SpaceId: "2",
OpaqueId: "3",
@@ -106,7 +106,7 @@ var _ = Describe("DriveItemPermissionsService", func() {
BeforeEach(func() {
gatewayClient.On("Stat", mock.Anything, mock.Anything).Return(statResponse, nil)
statResponse.Info = &provider.ResourceInfo{
Id: &driveItemId,
Id: driveItemId,
Type: provider.ResourceType_RESOURCE_TYPE_FILE,
}
@@ -258,12 +258,12 @@ var _ = Describe("DriveItemPermissionsService", func() {
var (
createShareResponse *collaboration.CreateShareResponse
driveItemInvite libregraph.DriveItemInvite
driveId provider.ResourceId
driveId *provider.ResourceId
getUserResponse *userpb.GetUserResponse
)
BeforeEach(func() {
driveId = provider.ResourceId{
driveId = &provider.ResourceId{
StorageId: "1",
SpaceId: "2",
}
@@ -423,11 +423,11 @@ var _ = Describe("DriveItemPermissionsService", func() {
})
Describe("ListSpaceRootPermissions", func() {
var (
driveId provider.ResourceId
driveId *provider.ResourceId
)
BeforeEach(func() {
driveId = provider.ResourceId{
driveId = &provider.ResourceId{
StorageId: "1",
SpaceId: "2",
}
@@ -489,7 +489,7 @@ var _ = Describe("DriveItemPermissionsService", func() {
gatewayClient.On("GetPublicShare", mock.Anything, mock.Anything).Return(&getPublicShareResponse, nil)
err := driveItemPermissionsService.DeletePermission(context.Background(),
*getShareResponse.Share.ResourceId,
getShareResponse.Share.ResourceId,
"permissionid",
)
Expect(err).To(MatchError(errorcode.New(errorcode.ItemNotFound, "failed to resolve resource id for shared resource")))
@@ -515,7 +515,7 @@ var _ = Describe("DriveItemPermissionsService", func() {
).Return(rmShareMockResponse, nil)
err := driveItemPermissionsService.DeletePermission(context.Background(),
*getShareResponse.Share.ResourceId,
getShareResponse.Share.ResourceId,
"permissionid",
)
Expect(err).ToNot(HaveOccurred())
@@ -545,7 +545,7 @@ var _ = Describe("DriveItemPermissionsService", func() {
)
err := driveItemPermissionsService.DeletePermission(context.Background(),
*getShareResponse.Share.ResourceId,
getShareResponse.Share.ResourceId,
"linkpermissionid",
)
Expect(err).ToNot(HaveOccurred())
@@ -564,7 +564,7 @@ var _ = Describe("DriveItemPermissionsService", func() {
})
err := driveItemPermissionsService.DeletePermission(context.Background(),
provider.ResourceId{
&provider.ResourceId{
StorageId: "1",
SpaceId: "2",
OpaqueId: "2",
@@ -597,7 +597,7 @@ var _ = Describe("DriveItemPermissionsService", func() {
ctx = context.WithValue(context.Background(), chi.RouteCtxKey, rctx)
err := driveItemPermissionsService.DeletePermission(context.Background(),
provider.ResourceId{
&provider.ResourceId{
StorageId: "1",
SpaceId: "2",
OpaqueId: "3",
@@ -625,7 +625,7 @@ var _ = Describe("DriveItemPermissionsService", func() {
Id: &collaboration.ShareId{
OpaqueId: "permissionid",
},
ResourceId: &driveItemId,
ResourceId: driveItemId,
Grantee: &provider.Grantee{
Type: provider.GranteeType_GRANTEE_TYPE_USER,
Id: &provider.Grantee_UserId{
@@ -659,7 +659,7 @@ var _ = Describe("DriveItemPermissionsService", func() {
Id: &link.PublicShareId{
OpaqueId: "permissionid",
},
ResourceId: &driveItemId,
ResourceId: driveItemId,
Permissions: &link.PublicSharePermissions{
Permissions: linktype.NewViewLinkPermissionSet().GetPermissions(),
},
@@ -669,7 +669,7 @@ var _ = Describe("DriveItemPermissionsService", func() {
statResponse = &provider.StatResponse{
Status: status.NewOK(ctx),
Info: &provider.ResourceInfo{
Id: &driveItemId,
Id: driveItemId,
Type: provider.ResourceType_RESOURCE_TYPE_CONTAINER,
},
}
@@ -739,7 +739,7 @@ var _ = Describe("DriveItemPermissionsService", func() {
})).Return(getPublicShareMockResponse, nil)
gatewayClient.On("Stat", mock.Anything, mock.MatchedBy(func(req *provider.StatRequest) bool {
return utils.ResourceIDEqual(req.GetRef().GetResourceId(), &driveItemId) && req.GetRef().GetPath() == "."
return utils.ResourceIDEqual(req.GetRef().GetResourceId(), driveItemId) && req.GetRef().GetPath() == "."
})).Return(statResponse, nil)
gatewayClient.On("UpdatePublicShare",
@@ -851,7 +851,7 @@ var _ = Describe("DriveItemPermissionsService", func() {
gatewayClient.On("GetUser", mock.Anything, mock.Anything).Return(getUserResponse, nil)
driveItemPermission.SetRoles([]string{unifiedrole.NewFileEditorUnifiedRole().GetId()})
spaceId := provider.ResourceId{
spaceId := &provider.ResourceId{
StorageId: "1",
SpaceId: "2",
OpaqueId: "2",
@@ -1072,7 +1072,7 @@ var _ = Describe("DriveItemPermissionsApi", func() {
onInvite := mockProvider.On("Invite", mock.Anything, mock.Anything, mock.Anything)
onInvite.Return(func(ctx context.Context, resourceID storageprovider.ResourceId, invite libregraph.DriveItemInvite) (libregraph.Permission, error) {
onInvite.Return(func(ctx context.Context, resourceID *storageprovider.ResourceId, invite libregraph.DriveItemInvite) (libregraph.Permission, error) {
return libregraph.Permission{}, errors.New("any")
}).Once()
@@ -1088,7 +1088,7 @@ var _ = Describe("DriveItemPermissionsApi", func() {
Expect(err).ToNot(HaveOccurred())
onInvite := mockProvider.On("Invite", mock.Anything, mock.Anything, mock.Anything)
onInvite.Return(func(ctx context.Context, resourceID storageprovider.ResourceId, invite libregraph.DriveItemInvite) (libregraph.Permission, error) {
onInvite.Return(func(ctx context.Context, resourceID *storageprovider.ResourceId, invite libregraph.DriveItemInvite) (libregraph.Permission, error) {
Expect(storagespace.FormatResourceID(resourceID)).To(Equal("1$2!3"))
return libregraph.Permission{}, nil
}).Once()
@@ -1109,7 +1109,7 @@ var _ = Describe("DriveItemPermissionsApi", func() {
Expect(err).ToNot(HaveOccurred())
onInvite := mockProvider.On("SpaceRootInvite", mock.Anything, mock.Anything, mock.Anything)
onInvite.Return(func(ctx context.Context, driveID storageprovider.ResourceId, invite libregraph.DriveItemInvite) (libregraph.Permission, error) {
onInvite.Return(func(ctx context.Context, driveID *storageprovider.ResourceId, invite libregraph.DriveItemInvite) (libregraph.Permission, error) {
Expect(storagespace.FormatResourceID(driveID)).To(Equal("1$2"))
return libregraph.Permission{}, nil
}).Once()
@@ -1146,7 +1146,7 @@ var _ = Describe("DriveItemPermissionsApi", func() {
mockProvider.On("ListPermissions", mock.Anything, mock.Anything, mock.Anything).
Return(func(ctx context.Context, itemid storageprovider.ResourceId) (libregraph.CollectionOfPermissionsWithAllowedValues, error) {
Expect(storagespace.FormatResourceID(itemid)).To(Equal("1$2!3"))
Expect(storagespace.FormatResourceID(&itemid)).To(Equal("1$2!3"))
return libregraph.CollectionOfPermissionsWithAllowedValues{}, nil
}).Once()

View File

@@ -55,7 +55,7 @@ var _ = Describe("Applications", func() {
gatewaySelector = pool.GetSelector[gateway.GatewayAPIClient](
"GatewaySelector",
"com.owncloud.api.gateway",
func(cc *grpc.ClientConn) gateway.GatewayAPIClient {
func(cc grpc.ClientConnInterface) gateway.GatewayAPIClient {
return gatewayClient
},
)

View File

@@ -65,7 +65,7 @@ var _ = Describe("AppRoleAssignments", func() {
gatewaySelector = pool.GetSelector[gateway.GatewayAPIClient](
"GatewaySelector",
"com.owncloud.api.gateway",
func(cc *grpc.ClientConn) gateway.GatewayAPIClient {
func(cc grpc.ClientConnInterface) gateway.GatewayAPIClient {
return gatewayClient
},
)

View File

@@ -308,7 +308,7 @@ func (g BaseGraphService) listPublicShares(ctx context.Context, filters []*link.
func (g BaseGraphService) cs3UserSharesToDriveItems(ctx context.Context, shares []*collaboration.Share, driveItems driveItemsByResourceID) (driveItemsByResourceID, error) {
for _, s := range shares {
g.logger.Debug().Interface("CS3 UserShare", s).Msg("Got Share")
resIDStr := storagespace.FormatResourceID(*s.ResourceId)
resIDStr := storagespace.FormatResourceID(s.ResourceId)
item, ok := driveItems[resIDStr]
if !ok {
itemptr, err := g.getDriveItem(ctx, storageprovider.Reference{ResourceId: s.ResourceId})
@@ -410,7 +410,7 @@ func (g BaseGraphService) cs3UserShareToPermission(ctx context.Context, share *c
func (g BaseGraphService) cs3PublicSharesToDriveItems(ctx context.Context, shares []*link.PublicShare, driveItems driveItemsByResourceID) (driveItemsByResourceID, error) {
for _, s := range shares {
g.logger.Debug().Interface("CS3 PublicShare", s).Msg("Got Share")
resIDStr := storagespace.FormatResourceID(*s.ResourceId)
resIDStr := storagespace.FormatResourceID(s.ResourceId)
item, ok := driveItems[resIDStr]
if !ok {
itemptr, err := g.getDriveItem(ctx, storageprovider.Reference{ResourceId: s.ResourceId})

View File

@@ -409,7 +409,7 @@ func (g Graph) getRemoteItem(ctx context.Context, root *storageprovider.Resource
if res.GetInfo().GetSpace().GetRoot() != nil {
webDavURL := *baseURL
relativePath := res.GetInfo().GetPath()
webDavURL.Path = path.Join(webDavURL.Path, storagespace.FormatResourceID(*res.GetInfo().GetSpace().GetRoot()), relativePath)
webDavURL.Path = path.Join(webDavURL.Path, storagespace.FormatResourceID(res.GetInfo().GetSpace().GetRoot()), relativePath)
item.WebDavUrl = libregraph.PtrString(webDavURL.String())
}
}
@@ -438,7 +438,7 @@ func cs3ResourceToDriveItem(logger *log.Logger, res *storageprovider.ResourceInf
*size = int64(res.GetSize()) // TODO lurking overflow: make size of libregraph drive item use uint64
driveItem := &libregraph.DriveItem{
Id: libregraph.PtrString(storagespace.FormatResourceID(*res.GetId())),
Id: libregraph.PtrString(storagespace.FormatResourceID(res.GetId())),
Size: size,
}
@@ -456,7 +456,7 @@ func cs3ResourceToDriveItem(logger *log.Logger, res *storageprovider.ResourceInf
parentRef := libregraph.NewItemReference()
parentRef.SetDriveType(res.GetSpace().GetSpaceType())
parentRef.SetDriveId(storagespace.FormatStorageID(res.GetParentId().GetStorageId(), res.GetParentId().GetSpaceId()))
parentRef.SetId(storagespace.FormatResourceID(*res.GetParentId()))
parentRef.SetId(storagespace.FormatResourceID(res.GetParentId()))
parentRef.SetName(path.Base(path.Dir(res.GetPath())))
parentRef.SetPath(path.Dir(res.GetPath()))
driveItem.ParentReference = parentRef
@@ -602,7 +602,7 @@ func cs3ResourceToRemoteItem(res *storageprovider.ResourceInfo) (*libregraph.Rem
*size = int64(res.GetSize()) // TODO lurking overflow: make size of libregraph drive item use uint64
remoteItem := &libregraph.RemoteItem{
Id: libregraph.PtrString(storagespace.FormatResourceID(*res.GetId())),
Id: libregraph.PtrString(storagespace.FormatResourceID(res.GetId())),
Size: size,
}
@@ -626,7 +626,7 @@ func cs3ResourceToRemoteItem(res *storageprovider.ResourceInfo) (*libregraph.Rem
remoteItem.Folder = &libregraph.Folder{}
}
if res.GetSpace() != nil && res.GetSpace().GetRoot() != nil {
remoteItem.RootId = libregraph.PtrString(storagespace.FormatResourceID(*res.GetSpace().GetRoot()))
remoteItem.RootId = libregraph.PtrString(storagespace.FormatResourceID(res.GetSpace().GetRoot()))
grantSpaceAlias := utils.ReadPlainFromOpaque(res.GetSpace().GetOpaque(), "spaceAlias")
if grantSpaceAlias != "" {
remoteItem.DriveAlias = libregraph.PtrString(grantSpaceAlias)

View File

@@ -66,7 +66,7 @@ var _ = Describe("Driveitems", func() {
gatewaySelector = pool.GetSelector[gateway.GatewayAPIClient](
"GatewaySelector",
"com.owncloud.api.gateway",
func(cc *grpc.ClientConn) gateway.GatewayAPIClient {
func(cc grpc.ClientConnInterface) gateway.GatewayAPIClient {
return gatewayClient
},
)

View File

@@ -23,6 +23,7 @@ import (
"github.com/pkg/errors"
merrors "go-micro.dev/v4/errors"
"golang.org/x/sync/errgroup"
"google.golang.org/protobuf/proto"
revactx "github.com/cs3org/reva/v2/pkg/ctx"
"github.com/cs3org/reva/v2/pkg/storagespace"
@@ -259,7 +260,7 @@ func (g Graph) GetSingleDrive(w http.ResponseWriter, r *http.Request) {
log.Debug().Msg("calling list storage spaces with id filter")
filters := []*storageprovider.ListStorageSpacesRequest_Filter{
listStorageSpacesIDFilter(storagespace.FormatResourceID(rid)),
listStorageSpacesIDFilter(storagespace.FormatResourceID(&rid)),
}
res, err := g.ListStorageSpacesWithFilters(ctx, filters, true)
switch {
@@ -492,7 +493,7 @@ func (g Graph) UpdateDrive(w http.ResponseWriter, r *http.Request) {
// the original storage space.
StorageSpace: &storageprovider.StorageSpace{
Id: &storageprovider.StorageSpaceId{
OpaqueId: storagespace.FormatResourceID(rid),
OpaqueId: storagespace.FormatResourceID(&rid),
},
Root: root,
},
@@ -743,7 +744,7 @@ func (g Graph) cs3StorageSpaceToDrive(ctx context.Context, baseURL *url.URL, spa
logger.Error().Msg("unable to parse space: space has no root")
return nil, errors.New("space has no root")
}
spaceRid := *space.Root
spaceRid := proto.Clone(space.Root).(*storageprovider.ResourceId)
if space.Root.GetSpaceId() == space.Root.GetOpaqueId() {
spaceRid.OpaqueId = ""
}
@@ -1047,11 +1048,11 @@ func (g Graph) DeleteDrive(w http.ResponseWriter, r *http.Request) {
dRes, err := gatewayClient.DeleteStorageSpace(r.Context(), &storageprovider.DeleteStorageSpaceRequest{
Opaque: opaque,
Id: &storageprovider.StorageSpaceId{
OpaqueId: storagespace.FormatResourceID(rid),
OpaqueId: storagespace.FormatResourceID(&rid),
},
})
if err != nil {
logger.Error().Err(err).Interface("id", rid).Msg("could not delete drive: transport error")
logger.Error().Err(err).Str("id", rid.String()).Msg("could not delete drive: transport error")
errorcode.GeneralException.Render(w, r, http.StatusInternalServerError, "transport error")
return
}

View File

@@ -58,7 +58,7 @@ var _ = Describe("EducationClass", func() {
gatewaySelector = pool.GetSelector[gateway.GatewayAPIClient](
"GatewaySelector",
"com.owncloud.api.gateway",
func(cc *grpc.ClientConn) gateway.GatewayAPIClient {
func(cc grpc.ClientConnInterface) gateway.GatewayAPIClient {
return gatewayClient
},
)

View File

@@ -59,7 +59,7 @@ var _ = Describe("Schools", func() {
gatewaySelector = pool.GetSelector[gateway.GatewayAPIClient](
"GatewaySelector",
"com.owncloud.api.gateway",
func(cc *grpc.ClientConn) gateway.GatewayAPIClient {
func(cc grpc.ClientConnInterface) gateway.GatewayAPIClient {
return gatewayClient
},
)

View File

@@ -63,7 +63,7 @@ var _ = Describe("EducationUsers", func() {
gatewaySelector = pool.GetSelector[gateway.GatewayAPIClient](
"GatewaySelector",
"com.owncloud.api.gateway",
func(cc *grpc.ClientConn) gateway.GatewayAPIClient {
func(cc grpc.ClientConnInterface) gateway.GatewayAPIClient {
return gatewayClient
},
)

View File

@@ -73,7 +73,7 @@ var _ = Describe("Graph", func() {
gatewaySelector = pool.GetSelector[gateway.GatewayAPIClient](
"GatewaySelector",
"com.owncloud.api.gateway",
func(cc *grpc.ClientConn) gateway.GatewayAPIClient {
func(cc grpc.ClientConnInterface) gateway.GatewayAPIClient {
return gatewayClient
},
)

View File

@@ -64,7 +64,7 @@ var _ = Describe("Groups", func() {
gatewaySelector = pool.GetSelector[gateway.GatewayAPIClient](
"GatewaySelector",
"com.owncloud.api.gateway",
func(cc *grpc.ClientConn) gateway.GatewayAPIClient {
func(cc grpc.ClientConnInterface) gateway.GatewayAPIClient {
return gatewayClient
},
)

View File

@@ -56,7 +56,7 @@ var _ = Describe("Users changing their own password", func() {
gatewaySelector = pool.GetSelector[gateway.GatewayAPIClient](
"GatewaySelector",
"com.owncloud.api.gateway",
func(cc *grpc.ClientConn) gateway.GatewayAPIClient {
func(cc grpc.ClientConnInterface) gateway.GatewayAPIClient {
return gatewayClient
},
)

View File

@@ -229,7 +229,7 @@ var _ = Describe("sharedbyme", func() {
gatewaySelector = pool.GetSelector[gateway.GatewayAPIClient](
"GatewaySelector",
"com.owncloud.api.gateway",
func(cc *grpc.ClientConn) gateway.GatewayAPIClient {
func(cc grpc.ClientConnInterface) gateway.GatewayAPIClient {
return gatewayClient
},
)
@@ -336,7 +336,7 @@ var _ = Describe("sharedbyme", func() {
Expect(len(res.Value)).To(Equal(1))
di := res.Value[0]
Expect(di.GetId()).To(Equal(storagespace.FormatResourceID(*userShare.GetResourceId())))
Expect(di.GetId()).To(Equal(storagespace.FormatResourceID(userShare.GetResourceId())))
perm := di.GetPermissions()
Expect(perm[0].GetId()).To(Equal(userShare.GetId().GetOpaqueId()))
@@ -380,7 +380,7 @@ var _ = Describe("sharedbyme", func() {
Expect(len(res.Value)).To(Equal(1))
di := res.Value[0]
Expect(di.GetId()).To(Equal(storagespace.FormatResourceID(*groupShare.GetResourceId())))
Expect(di.GetId()).To(Equal(storagespace.FormatResourceID(groupShare.GetResourceId())))
perm := di.GetPermissions()
Expect(perm[0].GetId()).To(Equal(userShare.GetId().GetOpaqueId()))
@@ -425,7 +425,7 @@ var _ = Describe("sharedbyme", func() {
Expect(len(res.Value)).To(Equal(1))
di := res.Value[0]
Expect(di.GetId()).To(Equal(storagespace.FormatResourceID(*groupShare.GetResourceId())))
Expect(di.GetId()).To(Equal(storagespace.FormatResourceID(groupShare.GetResourceId())))
// one permission per share
Expect(len(di.GetPermissions())).To(Equal(2))
@@ -456,7 +456,7 @@ var _ = Describe("sharedbyme", func() {
Expect(len(res.Value)).To(Equal(1))
di := res.Value[0]
Expect(di.GetId()).To(Equal(storagespace.FormatResourceID(*userShareWithExpiration.GetResourceId())))
Expect(di.GetId()).To(Equal(storagespace.FormatResourceID(userShareWithExpiration.GetResourceId())))
perm := di.GetPermissions()
Expect(perm[0].GetId()).To(Equal(userShareWithExpiration.GetId().GetOpaqueId()))
@@ -519,7 +519,7 @@ var _ = Describe("sharedbyme", func() {
Expect(len(res.Value)).To(Equal(1))
di := res.Value[0]
Expect(di.GetId()).To(Equal(storagespace.FormatResourceID(*publicShare.GetResourceId())))
Expect(di.GetId()).To(Equal(storagespace.FormatResourceID(publicShare.GetResourceId())))
perm := di.GetPermissions()
Expect(perm[0].GetId()).To(Equal(publicShare.GetId().GetOpaqueId()))

View File

@@ -52,7 +52,7 @@ var _ = Describe("SharedWithMe", func() {
gatewaySelector = pool.GetSelector[gateway.GatewayAPIClient](
"GatewaySelector",
"com.owncloud.api.gateway",
func(cc *grpc.ClientConn) gateway.GatewayAPIClient {
func(cc grpc.ClientConnInterface) gateway.GatewayAPIClient {
return gatewayClient
},
)
@@ -253,7 +253,7 @@ var _ = Describe("SharedWithMe", func() {
Expect(jsonData.Get("eTag").String()).To(Equal(resourceInfo.Etag))
Expect(jsonData.Get("id").String()).To(Equal(storagespace.FormatResourceID(
providerv1beta1.ResourceId{
&providerv1beta1.ResourceId{
StorageId: utils.ShareStorageProviderID,
SpaceId: utils.ShareStorageSpaceID,
OpaqueId: share.Id.OpaqueId,
@@ -299,7 +299,7 @@ var _ = Describe("SharedWithMe", func() {
jsonData := gjson.Get(tape.Body.String(), "value.0.remoteItem")
Expect(jsonData.Get("eTag").String()).To(Equal(resourceInfo.Etag))
Expect(jsonData.Get("id").String()).To(Equal(storagespace.FormatResourceID(*share.ResourceId)))
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)))

View File

@@ -89,7 +89,7 @@ func (g Graph) applyDefaultTemplate(ctx context.Context, gwc gateway.GatewayAPIC
resp, err := gwc.UpdateStorageSpace(ctx, &storageprovider.UpdateStorageSpaceRequest{
StorageSpace: &storageprovider.StorageSpace{
Id: &storageprovider.StorageSpaceId{
OpaqueId: storagespace.FormatResourceID(*root),
OpaqueId: storagespace.FormatResourceID(root),
},
Root: root,
Opaque: opaque,

View File

@@ -70,7 +70,7 @@ var _ = Describe("Users", func() {
gatewaySelector = pool.GetSelector[gateway.GatewayAPIClient](
"GatewaySelector",
"com.owncloud.api.gateway",
func(cc *grpc.ClientConn) gateway.GatewayAPIClient {
func(cc grpc.ClientConnInterface) gateway.GatewayAPIClient {
return gatewayClient
},
)

View File

@@ -156,7 +156,7 @@ func cs3ReceivedSharesToDriveItems(ctx context.Context,
continue
}
rIDStr := storagespace.FormatResourceID(*receivedShare.GetShare().GetResourceId())
rIDStr := storagespace.FormatResourceID(receivedShare.GetShare().GetResourceId())
receivedSharesByResourceID[rIDStr] = append(receivedSharesByResourceID[rIDStr], receivedShare)
}
@@ -203,7 +203,7 @@ func cs3ReceivedSharesToDriveItems(ctx context.Context,
remoteItem := driveItem.RemoteItem
{
if id := shareStat.GetInfo().GetId(); id != nil {
remoteItem.SetId(storagespace.FormatResourceID(*id))
remoteItem.SetId(storagespace.FormatResourceID(id))
}
if name := shareStat.GetInfo().GetName(); name != "" {
@@ -228,7 +228,7 @@ func cs3ReceivedSharesToDriveItems(ctx context.Context,
}
if root := shareStat.GetInfo().GetSpace().GetRoot(); root != nil {
parentReference.SetDriveId(storagespace.FormatResourceID(*root))
parentReference.SetDriveId(storagespace.FormatResourceID(root))
}
if !reflect.ValueOf(*parentReference).IsZero() {
remoteItem.ParentReference = parentReference
@@ -241,7 +241,7 @@ func cs3ReceivedSharesToDriveItems(ctx context.Context,
driveItem.ParentReference = libregraph.NewItemReference()
driveItem.ParentReference.SetDriveType(_spaceTypeVirtual)
driveItem.ParentReference.SetDriveId(storagespace.FormatStorageID(utils.ShareStorageProviderID, utils.ShareStorageSpaceID))
driveItem.ParentReference.SetId(storagespace.FormatResourceID(storageprovider.ResourceId{
driveItem.ParentReference.SetId(storagespace.FormatResourceID(&storageprovider.ResourceId{
StorageId: utils.ShareStorageProviderID,
OpaqueId: utils.ShareStorageSpaceID,
SpaceId: utils.ShareStorageSpaceID,
@@ -383,7 +383,7 @@ func fillDriveItemPropertiesFromReceivedShare(ctx context.Context, logger *log.L
// ID across all services this means we needed to make similar adjustments
// to the sharejail (usershareprovider, webdav). Which we can't currently do
// as some clients rely on the IDs used there having a special format.
driveItem.SetId(storagespace.FormatResourceID(storageprovider.ResourceId{
driveItem.SetId(storagespace.FormatResourceID(&storageprovider.ResourceId{
StorageId: utils.ShareStorageProviderID,
OpaqueId: oldestReceivedShare.GetShare().GetId().GetOpaqueId(),
SpaceId: utils.ShareStorageSpaceID,
@@ -537,7 +537,7 @@ func cs3ReceivedOCMSharesToDriveItems(ctx context.Context,
remoteItem := driveItem.RemoteItem
{
if id := shareStat.GetInfo().GetId(); id != nil {
remoteItem.SetId(storagespace.FormatResourceID(*id))
remoteItem.SetId(storagespace.FormatResourceID(id))
}
if name := shareStat.GetInfo().GetName(); name != "" {
@@ -562,7 +562,7 @@ func cs3ReceivedOCMSharesToDriveItems(ctx context.Context,
}
if root := shareStat.GetInfo().GetSpace().GetRoot(); root != nil {
parentReference.SetDriveId(storagespace.FormatResourceID(*root))
parentReference.SetDriveId(storagespace.FormatResourceID(root))
}
if !reflect.ValueOf(*parentReference).IsZero() {
remoteItem.ParentReference = parentReference
@@ -575,7 +575,7 @@ func cs3ReceivedOCMSharesToDriveItems(ctx context.Context,
driveItem.ParentReference = libregraph.NewItemReference()
driveItem.ParentReference.SetDriveType("virtual")
driveItem.ParentReference.SetDriveId(storagespace.FormatStorageID(utils.ShareStorageProviderID, utils.ShareStorageSpaceID))
driveItem.ParentReference.SetId(storagespace.FormatResourceID(storageprovider.ResourceId{
driveItem.ParentReference.SetId(storagespace.FormatResourceID(&storageprovider.ResourceId{
StorageId: utils.ShareStorageProviderID,
OpaqueId: utils.ShareStorageSpaceID,
SpaceId: utils.ShareStorageSpaceID,
@@ -721,7 +721,7 @@ func fillDriveItemPropertiesFromReceivedOCMShare(ctx context.Context, logger *lo
// ID across all services this means we needed to make similar adjustments
// to the sharejail (usershareprovider, webdav). Which we can't currently do
// as some clients rely on the IDs used there having a special format.
driveItem.SetId(storagespace.FormatResourceID(storageprovider.ResourceId{
driveItem.SetId(storagespace.FormatResourceID(&storageprovider.ResourceId{
StorageId: utils.OCMStorageProviderID,
SpaceId: utils.OCMStorageSpaceID,
OpaqueId: oldestReceivedShare.GetRemoteShareId(),

View File

@@ -57,7 +57,7 @@ var _ = Describe("Notifications", func() {
gatewaySelector = pool.GetSelector[gateway.GatewayAPIClient](
"GatewaySelector",
"com.owncloud.api.gateway",
func(cc *grpc.ClientConn) gateway.GatewayAPIClient {
func(cc grpc.ClientConnInterface) gateway.GatewayAPIClient {
return gatewayClient
},
)
@@ -250,7 +250,7 @@ var _ = Describe("Notifications X-Site Scripting", func() {
gatewaySelector = pool.GetSelector[gateway.GatewayAPIClient](
"GatewaySelector",
"com.owncloud.api.gateway",
func(cc *grpc.ClientConn) gateway.GatewayAPIClient {
func(cc grpc.ClientConnInterface) gateway.GatewayAPIClient {
return gatewayClient
},
)

View File

@@ -92,7 +92,7 @@ var _ = Describe("Authenticating requests", Label("Authentication"), func() {
RevaGatewaySelector: pool.GetSelector[gateway.GatewayAPIClient](
"GatewaySelector",
"com.owncloud.api.gateway",
func(cc *grpc.ClientConn) gateway.GatewayAPIClient {
func(cc grpc.ClientConnInterface) gateway.GatewayAPIClient {
return mockGatewayClient{
AuthenticateFunc: func(authType, clientID, clientSecret string) (string, rpcv1beta1.Code) {
if authType != "publicshares" {

View File

@@ -147,7 +147,7 @@ func prepare(q string) (http.Handler, *mocks.PoliciesProviderService, *cs3mocks.
gatewaySelector := pool.GetSelector[gateway.GatewayAPIClient](
"GatewaySelector",
"com.owncloud.api.gateway",
func(cc *grpc.ClientConn) gateway.GatewayAPIClient {
func(cc grpc.ClientConnInterface) gateway.GatewayAPIClient {
return gatewayClient
},
)

View File

@@ -23,7 +23,7 @@ var _ = Describe("Authenticating requests", Label("PublicShareAuthenticator"), f
RevaGatewaySelector: pool.GetSelector[gateway.GatewayAPIClient](
"GatewaySelector",
"com.owncloud.api.gateway",
func(cc *grpc.ClientConn) gateway.GatewayAPIClient {
func(cc grpc.ClientConnInterface) gateway.GatewayAPIClient {
return mockGatewayClient{
AuthenticateFunc: func(authType, clientID, clientSecret string) (string, rpcv1beta1.Code) {
if authType != "publicshares" {

View File

@@ -215,6 +215,54 @@ func (_c *UserBackend_GetUserByClaims_Call) RunAndReturn(run func(context.Contex
return _c
}
// SyncGroupMemberships provides a mock function with given fields: ctx, user, claims
func (_m *UserBackend) SyncGroupMemberships(ctx context.Context, user *userv1beta1.User, claims map[string]interface{}) error {
ret := _m.Called(ctx, user, claims)
if len(ret) == 0 {
panic("no return value specified for SyncGroupMemberships")
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, *userv1beta1.User, map[string]interface{}) error); ok {
r0 = rf(ctx, user, claims)
} else {
r0 = ret.Error(0)
}
return r0
}
// UserBackend_SyncGroupMemberships_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SyncGroupMemberships'
type UserBackend_SyncGroupMemberships_Call struct {
*mock.Call
}
// SyncGroupMemberships is a helper method to define mock.On call
// - ctx context.Context
// - user *userv1beta1.User
// - claims map[string]interface{}
func (_e *UserBackend_Expecter) SyncGroupMemberships(ctx interface{}, user interface{}, claims interface{}) *UserBackend_SyncGroupMemberships_Call {
return &UserBackend_SyncGroupMemberships_Call{Call: _e.mock.On("SyncGroupMemberships", ctx, user, claims)}
}
func (_c *UserBackend_SyncGroupMemberships_Call) Run(run func(ctx context.Context, user *userv1beta1.User, claims map[string]interface{})) *UserBackend_SyncGroupMemberships_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(*userv1beta1.User), args[2].(map[string]interface{}))
})
return _c
}
func (_c *UserBackend_SyncGroupMemberships_Call) Return(_a0 error) *UserBackend_SyncGroupMemberships_Call {
_c.Call.Return(_a0)
return _c
}
func (_c *UserBackend_SyncGroupMemberships_Call) RunAndReturn(run func(context.Context, *userv1beta1.User, map[string]interface{}) error) *UserBackend_SyncGroupMemberships_Call {
_c.Call.Return(run)
return _c
}
// UpdateUserIfNeeded provides a mock function with given fields: ctx, user, claims
func (_m *UserBackend) UpdateUserIfNeeded(ctx context.Context, user *userv1beta1.User, claims map[string]interface{}) error {
ret := _m.Called(ctx, user, claims)

View File

@@ -146,7 +146,7 @@ func (b *Bleve) Search(ctx context.Context, sir *searchService.SearchIndexReques
&query.TermQuery{
FieldVal: "RootID",
Term: storagespace.FormatResourceID(
storageProvider.ResourceId{
&storageProvider.ResourceId{
StorageId: sir.Ref.GetResourceId().GetStorageId(),
SpaceId: sir.Ref.GetResourceId().GetSpaceId(),
OpaqueId: sir.Ref.GetResourceId().GetOpaqueId(),

View File

@@ -43,7 +43,7 @@ func HandleEvents(s Searcher, bus events.Consumer, logger log.Logger, cfg *confi
getSpaceID := func(ref *provider.Reference) *provider.StorageSpaceId {
return &provider.StorageSpaceId{
OpaqueId: storagespace.FormatResourceID(
provider.ResourceId{
&provider.ResourceId{
StorageId: ref.GetResourceId().GetStorageId(),
SpaceId: ref.GetResourceId().GetSpaceId(),
},

View File

@@ -167,7 +167,7 @@ func (s *Service) Search(ctx context.Context, req *searchsvc.SearchRequest) (*se
continue
}
opaqueMap := sdk.DecodeOpaqueMap(space.Opaque)
grantSpaceID := storagespace.FormatResourceID(provider.ResourceId{
grantSpaceID := storagespace.FormatResourceID(&provider.ResourceId{
StorageId: opaqueMap["grantStorageID"],
SpaceId: opaqueMap["grantSpaceID"],
OpaqueId: opaqueMap["grantOpaqueID"],
@@ -443,7 +443,7 @@ func (s *Service) IndexSpace(spaceID *provider.StorageSpaceId) error {
s.logger.Debug().Str("path", ref.Path).Msg("Walking tree")
searchRes, err := s.engine.Search(ownerCtx, &searchsvc.SearchIndexRequest{
Query: "id:" + storagespace.FormatResourceID(*info.Id) + ` mtime>=` + utils.TSToTime(info.Mtime).Format(time.RFC3339Nano),
Query: "id:" + storagespace.FormatResourceID(info.Id) + ` mtime>=` + utils.TSToTime(info.Mtime).Format(time.RFC3339Nano),
})
if err == nil && len(searchRes.Matches) >= 1 {
@@ -471,7 +471,7 @@ func (s *Service) IndexSpace(spaceID *provider.StorageSpaceId) error {
// TrashItem marks the item as deleted.
func (s *Service) TrashItem(rID *provider.ResourceId) {
err := s.engine.Delete(storagespace.FormatResourceID(*rID))
err := s.engine.Delete(storagespace.FormatResourceID(rID))
if err != nil {
s.logger.Error().Err(err).Interface("Id", rID).Msg("failed to remove item from index")
}
@@ -491,8 +491,8 @@ func (s *Service) UpsertItem(ref *provider.Reference) {
}
r := engine.Resource{
ID: storagespace.FormatResourceID(*stat.Info.Id),
RootID: storagespace.FormatResourceID(provider.ResourceId{
ID: storagespace.FormatResourceID(stat.Info.Id),
RootID: storagespace.FormatResourceID(&provider.ResourceId{
StorageId: stat.Info.Id.StorageId,
OpaqueId: stat.Info.Id.SpaceId,
SpaceId: stat.Info.Id.SpaceId,
@@ -504,7 +504,7 @@ func (s *Service) UpsertItem(ref *provider.Reference) {
r.Hidden = strings.HasPrefix(r.Path, ".")
if parentID := stat.GetInfo().GetParentId(); parentID != nil {
r.ParentID = storagespace.FormatResourceID(*parentID)
r.ParentID = storagespace.FormatResourceID(parentID)
}
if err = s.engine.Upsert(r.ID, r); err != nil {
@@ -615,7 +615,7 @@ func (s *Service) RestoreItem(ref *provider.Reference) {
return
}
if err := s.engine.Restore(storagespace.FormatResourceID(*stat.Info.Id)); err != nil {
if err := s.engine.Restore(storagespace.FormatResourceID(stat.Info.Id)); err != nil {
s.logger.Error().Err(err).Msg("failed to restore the changed resource in the index")
}
}
@@ -627,7 +627,7 @@ func (s *Service) MoveItem(ref *provider.Reference) {
return
}
if err := s.engine.Move(storagespace.FormatResourceID(*stat.GetInfo().GetId()), storagespace.FormatResourceID(*stat.GetInfo().GetParentId()), path); err != nil {
if err := s.engine.Move(storagespace.FormatResourceID(stat.GetInfo().GetId()), storagespace.FormatResourceID(stat.GetInfo().GetParentId()), path); err != nil {
s.logger.Error().Err(err).Msg("failed to move the changed resource in the index")
}
}

View File

@@ -81,7 +81,7 @@ var _ = Describe("Searchprovider", func() {
gatewaySelector = pool.GetSelector[gateway.GatewayAPIClient](
"GatewaySelector",
"com.owncloud.api.gateway",
func(cc *grpc.ClientConn) gateway.GatewayAPIClient {
func(cc grpc.ClientConnInterface) gateway.GatewayAPIClient {
return gatewayClient
},
)

View File

@@ -53,7 +53,7 @@ var _ = Describe("trash", func() {
gatewaySelector = pool.GetSelector[gateway.GatewayAPIClient](
"GatewaySelector",
"com.owncloud.api.gateway",
func(cc *grpc.ClientConn) gateway.GatewayAPIClient {
func(cc grpc.ClientConnInterface) gateway.GatewayAPIClient {
return gatewayClient
},
)

View File

@@ -223,7 +223,7 @@ func (c *Converter) shareMessage(eventid string, nt NotificationTemplate, execut
Service: c.serviceName,
UserName: usr.GetUsername(),
Timestamp: ts.Format(time.RFC3339Nano),
ResourceID: storagespace.FormatResourceID(*info.GetId()),
ResourceID: storagespace.FormatResourceID(info.GetId()),
ResourceType: _resourceTypeShare,
Subject: subj,
SubjectRaw: subjraw,
@@ -257,7 +257,7 @@ func (c *Converter) virusMessage(eventid string, nt NotificationTemplate, execut
Service: c.serviceName,
UserName: executant.GetUsername(),
Timestamp: ts.Format(time.RFC3339Nano),
ResourceID: storagespace.FormatResourceID(*rid),
ResourceID: storagespace.FormatResourceID(rid),
ResourceType: _resourceTypeResource,
Subject: subj,
SubjectRaw: subjraw,
@@ -415,7 +415,7 @@ func generateDetails(user *user.User, space *storageprovider.StorageSpace, item
if item != nil {
details["resource"] = map[string]string{
"id": storagespace.FormatResourceID(*item.GetId()),
"id": storagespace.FormatResourceID(item.GetId()),
"name": item.GetName(),
}
}

View File

@@ -59,7 +59,7 @@ var _ = Describe("UserlogService", func() {
gatewaySelector = pool.GetSelector[gateway.GatewayAPIClient](
"GatewaySelector",
"com.owncloud.api.gateway",
func(cc *grpc.ClientConn) gateway.GatewayAPIClient {
func(cc grpc.ClientConnInterface) gateway.GatewayAPIClient {
return gatewayClient
},
)

View File

@@ -43,7 +43,7 @@ type ThumbnailRequest struct {
}
func addMissingStorageID(id string) string {
rid := providerv1beta1.ResourceId{}
rid := &providerv1beta1.ResourceId{}
rid.StorageId, rid.SpaceId, rid.OpaqueId, _ = storagespace.SplitID(id)
if rid.StorageId == "" && rid.SpaceId == utils.ShareStorageSpaceID {
rid.StorageId = utils.ShareStorageProviderID

View File

@@ -170,13 +170,13 @@ func matchToPropResponse(ctx context.Context, match *searchmsg.Match) (*propfind
Prop: []prop.PropertyXML{},
}
propstatOK.Prop = append(propstatOK.Prop, prop.Escaped("oc:fileid", storagespace.FormatResourceID(provider.ResourceId{
propstatOK.Prop = append(propstatOK.Prop, prop.Escaped("oc:fileid", storagespace.FormatResourceID(&provider.ResourceId{
StorageId: match.Entity.Id.StorageId,
SpaceId: match.Entity.Id.SpaceId,
OpaqueId: match.Entity.Id.OpaqueId,
})))
if match.Entity.ParentId != nil {
propstatOK.Prop = append(propstatOK.Prop, prop.Escaped("oc:file-parent", storagespace.FormatResourceID(provider.ResourceId{
propstatOK.Prop = append(propstatOK.Prop, prop.Escaped("oc:file-parent", storagespace.FormatResourceID(&provider.ResourceId{
StorageId: match.Entity.ParentId.StorageId,
SpaceId: match.Entity.ParentId.SpaceId,
OpaqueId: match.Entity.ParentId.OpaqueId,
@@ -185,7 +185,7 @@ func matchToPropResponse(ctx context.Context, match *searchmsg.Match) (*propfind
if match.Entity.Ref.ResourceId.StorageId == utils.ShareStorageProviderID {
propstatOK.Prop = append(propstatOK.Prop, prop.Escaped("oc:shareid", match.Entity.Ref.ResourceId.OpaqueId))
propstatOK.Prop = append(propstatOK.Prop, prop.Escaped("oc:shareroot", match.Entity.ShareRootName))
propstatOK.Prop = append(propstatOK.Prop, prop.Escaped("oc:remote-item-id", storagespace.FormatResourceID(provider.ResourceId{
propstatOK.Prop = append(propstatOK.Prop, prop.Escaped("oc:remote-item-id", storagespace.FormatResourceID(&provider.ResourceId{
StorageId: match.Entity.GetRemoteItemId().GetStorageId(),
SpaceId: match.Entity.GetRemoteItemId().GetSpaceId(),
OpaqueId: match.Entity.GetRemoteItemId().GetOpaqueId(),