Skip to content

Commit

Permalink
Merge pull request #3159 from owncloud/change-enforced-expiration
Browse files Browse the repository at this point in the history
[Tests-Only] Add acceptance tests for enforced expiration on collaborators share
  • Loading branch information
individual-it authored Mar 17, 2020
2 parents 48ceee7 + c723f81 commit 2e2c93b
Show file tree
Hide file tree
Showing 7 changed files with 276 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ Feature: Sharing files and folders with internal groups
And user "user3" has logged in using the webUI
When the user edits the collaborator expiry date of "grp1" of file "lorem.txt" to "+7" days using the webUI
Then user "user1" should have received a share with target "lorem (2).txt" and expiration date in 7 days
Then user "user2" should have received a share with target "lorem (2).txt" and expiration date in 7 days
And user "user2" should have received a share with target "lorem (2).txt" and expiration date in 7 days
And user "user3" should have a share with these details:
| field | value |
| path | /lorem.txt |
Expand All @@ -367,3 +367,50 @@ Feature: Sharing files and folders with internal groups
| share_with | grp1 |
| expiration | +7 |

Scenario: share a resource with another internal group with default expiration date
Given the setting "shareapi_default_expire_date_group_share" of app "core" has been set to "yes"
And the setting "shareapi_expire_after_n_days_group_share" of app "core" has been set to "42"
And user "user3" has logged in using the webUI
When the user shares folder "lorem.txt" with group "grp1" as "Viewer" using the webUI
Then user "user3" should have a share with these details:
| field | value |
| path | /lorem.txt |
| share_type | group |
| uid_owner | user3 |
| share_with | grp1 |
| expiration | +42 |
And user "user1" should have received a share with target "lorem (2).txt" and expiration date in 42 days
And user "user2" should have received a share with target "lorem (2).txt" and expiration date in 42 days

Scenario Outline: share a resource with another internal group with expiration date beyond maximum enforced expiration date
Given the setting "shareapi_default_expire_date_group_share" of app "core" has been set to "yes"
And the setting "shareapi_enforce_expire_date_group_share" of app "core" has been set to "yes"
And the setting "shareapi_expire_after_n_days_group_share" of app "core" has been set to "5"
And user "user3" has logged in using the webUI
When the user tries to share resource "<shared-resource>" with group "grp1" which expires in "+6" days using the webUI
Then the expiration date shown on the webUI should be "+5" days
And user "user1" should not have created any shares
Examples:
| shared-resource |
| lorem.txt |
| simple-folder |

Scenario Outline: share a resource with another internal group with expiration date within maximum enforced expiration date
Given the setting "shareapi_default_expire_date_group_share" of app "core" has been set to "yes"
And the setting "shareapi_enforce_expire_date_group_share" of app "core" has been set to "yes"
And the setting "shareapi_expire_after_n_days_group_share" of app "core" has been set to "5"
And user "user3" has created a new share with following settings
| path | <shared-resource> |
| shareTypeString | group |
| shareWith | grp1 |
| expireDate | +4 |
And user "user3" has logged in using the webUI
When the user tries to edit the collaborator expiry date of "grp1" of resource "<shared-resource>" to "+7" days using the webUI
Then the expiration date shown on the webUI should be "+4" days
And it should not be possible to save the pending share on the webUI
And user "user1" should have received a share with target "<target-resource>" and expiration date in 4 days
And user "user2" should have received a share with target "<target-resource>" and expiration date in 4 days
Examples:
| shared-resource | target-resource |
| lorem.txt | lorem (2).txt |
| simple-folder | simple-folder (2) |
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ Feature: Sharing files and folders with internal users

Scenario: share a file with another internal user which should expire after 2 days
Given user "user1" has logged in using the webUI
When the user shares file "testimage.jpg" with user "User Two" which expires after 2 days using the webUI
When the user shares file "testimage.jpg" with user "User Two" which expires in "+2" days using the webUI
Then user "user2" should have received a share with target "testimage (2).jpg" and expiration date in 2 days

Scenario: share a file with another internal user with default expiration date
Expand All @@ -618,3 +618,97 @@ Feature: Sharing files and folders with internal users
| uid_owner | user1 |
| share_with | user2 |
| expiration | +7 |

Scenario: share a resource with another internal user with expiration date within enforced maximum expiration date
Given the setting "shareapi_default_expire_date_user_share" of app "core" has been set to "yes"
And the setting "shareapi_enforce_expire_date_user_share" of app "core" has been set to "yes"
And the setting "shareapi_expire_after_n_days_user_share" of app "core" has been set to "5"
And user "user1" has logged in using the webUI
When the user shares file "lorem.txt" with user "User Two" which expires in "+4" days using the webUI
Then user "user1" should have a share with these details:
| field | value |
| path | /lorem.txt |
| share_type | user |
| uid_owner | user1 |
| share_with | user2 |
| expiration | +4 |

Scenario Outline: share a resource with another internal user with expiration date beyond enforced maximum expiration date
Given the setting "shareapi_default_expire_date_user_share" of app "core" has been set to "yes"
And the setting "shareapi_enforce_expire_date_user_share" of app "core" has been set to "yes"
And the setting "shareapi_expire_after_n_days_user_share" of app "core" has been set to "5"
And user "user1" has logged in using the webUI
When the user tries to share resource "<shared-resource>" with user "User Two" which expires in "+6" days using the webUI
Then the expiration date shown on the webUI should be "+5" days
And user "user1" should not have created any shares
Examples:
| shared-resource |
| lorem.txt |
| simple-folder |

Scenario Outline: edit a share with another internal user changing expiration date within enforced maximum expiration date
Given the setting "shareapi_default_expire_date_user_share" of app "core" has been set to "yes"
And the setting "shareapi_enforce_expire_date_user_share" of app "core" has been set to "yes"
And the setting "shareapi_expire_after_n_days_user_share" of app "core" has been set to "5"
And user "user1" has created a new share with following settings
| path | <shared-resource> |
| shareWith | user2 |
| expireDate | +4 |
And user "user1" has logged in using the webUI
When the user tries to edit the collaborator expiry date of "User Two" of resource "<shared-resource>" to "+7" days using the webUI
Then the expiration date shown on the webUI should be "+4" days
And it should not be possible to save the pending share on the webUI
Examples:
| shared-resource |
| lorem.txt |
| simple-folder |

@issue-3174
Scenario Outline: enforced expiry date for group affect user shares
Given the setting "shareapi_default_expire_date_user_share" of app "core" has been set to "yes"
And the setting "shareapi_default_expire_date_group_share" of app "core" has been set to "yes"
And the setting "shareapi_enforce_expire_date_user_share" of app "core" has been set to "yes"
And the setting "shareapi_enforce_expire_date_group_share" of app "core" has been set to "yes"
And the setting "shareapi_expire_after_n_days_user_share" of app "core" has been set to "10"
And the setting "shareapi_expire_after_n_days_group_share" of app "core" has been set to "5"
And user "user1" has logged in using the webUI
When the user tries to share resource "<shared-resource>" with user "User Two" which expires in "+6" days using the webUI
Then the expiration date shown on the webUI should be "+5" days
# Then the expiration date shown on the webUI should be "+6" days
# Then user "user1" should have a share with these details:
# | field | value |
# | path | <shared-resource> |
# | share_type | user |
# | uid_owner | user1 |
# | share_with | user2 |
# | expiration | +6 |
Examples:
| shared-resource |
| lorem.txt |
| simple-folder |

@issue-3174
Scenario Outline: enforced expiry date for users affect group sharess
Given group "grp1" has been created
And user "user2" has been added to group "grp1"
And the setting "shareapi_default_expire_date_user_share" of app "core" has been set to "yes"
And the setting "shareapi_default_expire_date_group_share" of app "core" has been set to "yes"
And the setting "shareapi_enforce_expire_date_user_share" of app "core" has been set to "yes"
And the setting "shareapi_enforce_expire_date_group_share" of app "core" has been set to "yes"
And the setting "shareapi_expire_after_n_days_user_share" of app "core" has been set to "5"
And the setting "shareapi_expire_after_n_days_group_share" of app "core" has been set to "10"
And user "user1" has logged in using the webUI
When the user tries to share resource "<shared-resource>" with group "grp1" which expires in "+6" days using the webUI
Then the expiration date shown on the webUI should be "+5" days
# Then the expiration date shown on the webUI should be "+6" days
# Then user "user1" should have a share with these details:
# | field | value |
# | path | <shared-resource> |
# | share_type | group |
# | uid_owner | user1 |
# | share_with | grp1 |
# | expiration | +6 |
Examples:
| shared-resource |
| lorem.txt |
| simple-folder |
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const util = require('util')
const sharingHelper = require('../../helpers/sharingHelper')

module.exports = {
commands: {
Expand Down Expand Up @@ -105,11 +104,8 @@ module.exports = {
const monthSelector = this.setExpiryDateMonthSelectorXpath(
pastDate.toLocaleString('en-GB', { month: 'long' })
)
const daySelector = this.setExpiryDateDaySelectorXpath(pastDate.getDay())
const daySelector = this.setExpiryDateDaySelectorXpath(pastDate.getDate())
await this
.initAjaxCounters()
.waitForElementVisible('@linkExpirationDateField')
.click('@linkExpirationDateField')
.waitForElementVisible('@dateTimePopupYear')
.waitForAnimationToFinish()
.waitForElementEnabled(
Expand Down Expand Up @@ -150,25 +146,32 @@ module.exports = {
* sets expiration date on collaborators/public-link shares
*
* @param {string} value - provided date in format YYYY-MM-DD, or empty string to unset date
* @returns {Promise}
* @param {string} shareType link|collaborator
* @returns {Promise<boolean>} returns true if succeeds to set provided expiration date
*/
setExpirationDate: async function (value) {
setExpirationDate: async function (value, shareType = 'collaborator') {
if (value === '') {
return this.click('@publicLinkDeleteExpirationDateButton')
}
value = sharingHelper.calculateDate(value)
const dateToSet = new Date(Date.parse(value))
if (shareType === 'collaborator') {
const disabled = await this.isExpiryDateDisabled(dateToSet)
if (disabled) {
console.log('WARNING: Cannot change expiration date to disabled value!')
await this
.waitForElementVisible('@dateTimeCancelButton')
.click('@dateTimeCancelButton')
return false
}
}
const year = dateToSet.getFullYear()
const month = dateToSet.toLocaleString('en-GB', { month: 'long' })
const day = dateToSet.getDate()
await this
.initAjaxCounters()
.waitForElementVisible('@linkExpirationDateField')
.click('@linkExpirationDateField')
return this
.setExpiryDateYear(year)
.setExpiryDateMonth(month)
.setExpiryDateDay(day)
return true
}
},
elements: {
Expand All @@ -191,12 +194,13 @@ module.exports = {
selector: '//div[@class="vdatetime-popup__actions"]/div[.="Ok"]',
locateStrategy: 'xpath'
},
dateTimeCancelButton: {
selector: '//div[@class="vdatetime-popup__actions"]/div[.="Cancel"]',
locateStrategy: 'xpath'
},
dateTimePopupDate: {
selector: '.vdatetime-popup__date'
},
linkExpirationDateField: {
selector: '.vdatetime-input'
},
publicLinkDeleteExpirationDateButton: {
selector: '#oc-files-file-link-expire-date-delete'
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const util = require('util')
const _ = require('lodash')
const sharingHelper = require('../../helpers/sharingHelper')

module.exports = {
commands: {
Expand Down Expand Up @@ -79,10 +80,12 @@ module.exports = {
} else if (key === 'password') {
return this.setPublicLinkPassword(value)
} else if (key === 'expireDate') {
value = sharingHelper.calculateDate(value)
return this.api.page
.FilesPageElement
.expirationDatePicker()
.setExpirationDate(value)
.sharingDialog()
.openExpirationDatePicker()
.setExpirationDate(value, 'link')
}
return this
},
Expand All @@ -97,10 +100,10 @@ module.exports = {
* @param {string} editData.expireDate - Expire date for a public link share
* @returns {exports}
*/
editPublicLink: function (linkName, editData) {
this.clickLinkEditBtn(linkName)
editPublicLink: async function (linkName, editData) {
await this.clickLinkEditBtn(linkName)
for (const [key, value] of Object.entries(editData)) {
this.setPublicLinkForm(key, value)
await this.setPublicLinkForm(key, value)
}
return this
},
Expand Down
Loading

0 comments on commit 2e2c93b

Please sign in to comment.