Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix public link permissions mix up #1985

Merged
merged 2 commits into from
Sep 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions apps/files/src/components/FileLinkForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@
</div>
<div v-if="$_isFolder" class="uk-margin uk-grid-small" uk-grid>
<div class="uk-width-auto">
<input type="radio" class="uk-radio" v-model="permissions" value="15" id="oc-files-file-link-collaborator-role-contributor" />
<input type="radio" class="uk-radio" v-model="permissions" value="5" id="oc-files-file-link-collaborator-role-contributor" />
</div>
<label class="uk-width-expand" @click="permissions = 15">
<label class="uk-width-expand" @click="permissions = 5">
<span v-translate>Contributor</span><br>
<span class="uk-text-meta" v-translate>Recipients can view, download and upload contents.</span>
</label>
</div>
<div v-if="$_isFolder" class="uk-margin uk-grid-small" uk-grid>
<div class="uk-width-auto">
<input type="radio" class="uk-radio" v-model="permissions" value="5" id="oc-files-file-link-collaborator-role-editor" />
<input type="radio" class="uk-radio" v-model="permissions" value="15" id="oc-files-file-link-collaborator-role-editor" />
</div>
<label class="uk-width-expand" @click="permissions = 5">
<label class="uk-width-expand" @click="permissions = 15">
<span v-translate>Editor</span><br>
<span class="uk-text-meta" v-translate>Recipients can view, download, edit, delete and upload contents.</span>
</label>
Expand Down
9 changes: 5 additions & 4 deletions apps/files/src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,17 +162,18 @@ function _buildLink (l, $gettext) {
const link = l.shareInfo
let description = ''

// FIXME: use bitmask matching with constants
switch (link.permissions) {
case ('1'):
case ('1'): // read (1)
description = $gettext('Viewer')
break
case ('15'):
case ('5'): // read (1) + create (4)
description = $gettext('Contributor')
break
case ('4'):
case ('4'): // create (4)
description = $gettext('Uploader')
break
case ('5'):
case ('15'): // read (1) + update (2) + create (4) + delete (8)
description = $gettext('Editor')
break
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,40 @@ Feature: Share by public link
| simple-folder |
| lorem.txt |

@smokeTest
Scenario Outline: simple sharing by public link with different roles
When the user creates a new public link for folder "simple-folder" using the webUI with
| role | <role> |
Then user "user1" should have a share with these details:
| field | value |
| share_type | public_link |
| uid_owner | user1 |
| permissions | <permissions> |
| path | /simple-folder |
| name | Public link |
And a link named "Public link" should be listed with role "<role>" in the public link list of folder "simple-folder" on the webUI
When the public uses the webUI to access the last public link created by user "user1"
Then file "lorem.txt" should be listed on the webUI
Examples:
| role | permissions |
| Viewer | read |
| Editor | read, change, create, delete |
| Contributor | read, create |

Scenario: sharing by public link with "Uploader" role
When the user creates a new public link for folder "simple-folder" using the webUI with
| role | Uploader |
Then user "user1" should have a share with these details:
| field | value |
| share_type | public_link |
| uid_owner | user1 |
| permissions | create |
| path | /simple-folder |
| name | Public link |
And a link named "Public link" should be listed with role "Uploader" in the public link list of folder "simple-folder" on the webUI
When the public uses the webUI to access the last public link created by user "user1"
Then there should be no files/folders listed on the webUI

@skip @yetToImplement
Scenario: creating a public link with read & write permissions makes it possible to delete files via the link
When the user creates a new public link for folder "simple-folder" using the webUI with
Expand Down
16 changes: 13 additions & 3 deletions tests/acceptance/pageObjects/FilesPageElement/publicLinksDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,20 @@ module.exports = {
* creates a new public link
* @returns {*}
*/
addNewLink: function () {
addNewLink: async function (role = null) {
const addLinkButtonXpath = this.elements.publicLinkContainer.selector + this.elements.addLinkButton.selector
const createLinkButtonXpath = this.elements.publicLinkContainer.selector + this.elements.createLinkButton.selector
return this
this
.click({ locateStrategy: 'xpath', selector: addLinkButtonXpath })
.waitForElementVisible({ locateStrategy: 'xpath', selector: createLinkButtonXpath })
.click({ locateStrategy: 'xpath', selector: createLinkButtonXpath })

if (role !== null) {
const util = require('util')
const roleSelectorXpath = util.format(this.elements.roleButton.selector, role)
await this.click({ locateStrategy: 'xpath', selector: roleSelectorXpath })
}

return this.click({ locateStrategy: 'xpath', selector: createLinkButtonXpath })
.waitForOutstandingAjaxCalls()
.waitForElementNotPresent({ locateStrategy: 'xpath', selector: createLinkButtonXpath })
},
Expand Down Expand Up @@ -54,6 +61,9 @@ module.exports = {
createLinkButton: {
selector: '//button[contains(.,"Create")]',
locateStrategy: 'xpath'
},
roleButton: {
selector: '//*[contains(@class,"oc-files-file-link-form")]//*[.="%s"]'
}
}
}
12 changes: 12 additions & 0 deletions tests/acceptance/stepDefinitions/publicLinkContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ When(
}
)

When(
'the user creates a new public link for file/folder/resource {string} using the webUI with',
function (resource, settingsTable) {
const settings = settingsTable.rowsHash()
return client.page.FilesPageElement
.filesList()
.closeSidebar(100)
.openPublicLinkDialog(resource)
.addNewLink(settings.role)
}
)

When('the public uses the webUI to access the last public link created by user {string}', async function (linkCreator) {
const headers = httpHelper.createAuthHeader(linkCreator)
const apiURL = client.globals.backend_url + '/ocs/v2.php/apps/files_sharing/api/v1/shares?format=json'
Expand Down