Skip to content

Commit

Permalink
Limit permission inheritance to received shares only
Browse files Browse the repository at this point in the history
  • Loading branch information
JammingBen committed May 20, 2022
1 parent 924cabb commit 84c521e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export default {
return SpacePeopleShareRoles.list()
}
if (this.resourceIsSharable && this.share) {
if (this.resource.isReceivedShare() && this.resourceIsSharable && this.share) {
return PeopleShareRoles.listByBitmask(
parseInt(this.share.permissions),
this.resource.isFolder,
Expand All @@ -186,7 +186,7 @@ export default {
return PeopleShareRoles.list(this.resource.isFolder, this.allowCustomSharing !== false)
},
availablePermissions() {
if (this.resourceIsSharable && this.share) {
if (this.resource.isReceivedShare() && this.resourceIsSharable && this.share) {
return this.customPermissionsRole.permissionsByBitmask(
parseInt(this.share.permissions),
this.allowSharePermission
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ describe('RoleDropdown', () => {
])("inherits the parents share's permissions: %s", (sharePermissions) => {
const wrapper = getShallowMountedWrapper({
existingRole: PeopleShareRoles.list(true)[0],
isReceivedShare: true,
sharesTree: {
'/testfolder': [
{
Expand All @@ -172,6 +173,7 @@ describe('RoleDropdown', () => {
it('does not render a button if only one role is available', () => {
const wrapper = getShallowMountedWrapper({
existingRole: PeopleShareRoles.list(true)[0],
isReceivedShare: true,
sharesTree: {
'/testfolder': [
{
Expand Down Expand Up @@ -252,13 +254,20 @@ function getShallowMountedWrapper(data) {
return shallowMount(RoleDropdown, getMountOptions(data))
}

function getMountOptions({ existingRole, shareId, resourceType = 'folder', sharesTree = {} }) {
function getMountOptions({
existingRole,
shareId,
resourceType = 'folder',
sharesTree = {},
isReceivedShare = false
}) {
return {
propsData: {
resource: getResource({
filename: resourceType === 'folder' ? 'testfolder' : 'testfile',
extension: resourceType === 'folder' ? '' : 'jpg',
type: resourceType
type: resourceType,
isReceivedShare
}),
existingRole,
shareId,
Expand All @@ -270,7 +279,12 @@ function getMountOptions({ existingRole, shareId, resourceType = 'folder', share
}
}

function getResource({ filename = 'testFile', extension = 'txt', type = 'file' }) {
function getResource({
filename = 'testFile',
extension = 'txt',
type = 'file',
isReceivedShare = false
}) {
return {
id: '4',
fileId: '4',
Expand All @@ -287,6 +301,7 @@ function getResource({ filename = 'testFile', extension = 'txt', type = 'file' }
starred: false,
etag: '"89128c0e8122002db57bd19c9ec33004"',
shareTypes: [],
downloadURL: ''
downloadURL: '',
isReceivedShare: () => isReceivedShare
}
}

0 comments on commit 84c521e

Please sign in to comment.