Skip to content

Commit

Permalink
Added acceptance tests for enforced expiration on collaborator shares
Browse files Browse the repository at this point in the history
  • Loading branch information
kiranparajuli589 committed Mar 12, 2020
1 parent c19224a commit f906430
Show file tree
Hide file tree
Showing 5 changed files with 198 additions and 12 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,66 @@ Feature: Sharing files and folders with internal groups
| share_with | grp1 |
| expiration | +7 |

Scenario Outline: default expiration date on group share
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 "<shared-resource>" with group "grp1" as "Viewer" using the webUI
Then user "user3" should have a share with these details:
| field | value |
| path | /<shared-resource> |
| share_type | group |
| uid_owner | user3 |
| share_with | grp1 |
| expiration | +42 |
And user "user1" should have received a share with target "<target-resource>" and expiration date in 42 days
And user "user2" should have received a share with target "<target-resource>" and expiration date in 42 days
Examples:
| shared-resource | target-resource |
| lorem.txt | lorem (2).txt |
| simple-folder | simple-folder (2) |

Scenario Outline: enforced expiration date on group share
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 file "<shared-resource>" with group "grp1" which expires after 6 days using the webUI
Then user "user3" should have a share with these details:
| field | value |
| path | /<shared-resource> |
| share_type | group |
| uid_owner | user3 |
| share_with | grp1 |
| expiration | +5 |
And user "user1" should have received a share with target "<target-resource>" and expiration date in 5 days
And user "user2" should have received a share with target "<target-resource>" and expiration date in 5 days
Examples:
| shared-resource | target-resource |
| lorem.txt | lorem (2).txt |
| simple-folder | simple-folder (2) |

Scenario Outline: user cannot change the expiry date of an existing group share to a date that is past enforced maximum 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 file "<shared-resource>" to "+7" days using the webUI
Then user "user3" should have a share with these details:
| field | value |
| path | /<shared-resource> |
| share_type | group |
| uid_owner | user3 |
| share_with | grp1 |
| expiration | +4 |
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 @@ -618,3 +618,83 @@ Feature: Sharing files and folders with internal users
| uid_owner | user1 |
| share_with | user2 |
| expiration | +7 |

Scenario Outline: user cannot set an expiry date that is past enforced maximum expiration date on user share
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 file "<shared-resource>" with user "User Two" which expires after 6 days using the webUI
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 | +5 |
And user "user2" should have received a share with target "<target-resource>" and expiration date in 5 days
Examples:
| shared-resource | target-resource |
| lorem.txt | lorem (2).txt |
| simple-folder | simple-folder (2) |

Scenario Outline: user cannot change the expiry date of an existing user share to a date that is past 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 file "<shared-resource>" to "+7" days using the webUI
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 | +4 |
Examples:
| shared-resource |
| lorem.txt |
| simple-folder |

Scenario: user can set an expiry date when creating a share to a date that is before the enforced max expiry 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 after 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 |

@issue-3174
Scenario Outline: user cannot share to date beyond enforced max expiry date if default expiry date for both user and group is enabled
Given user "user3" has been created with default attributes
And 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 "10"
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 shares file "<shared-resource>" with user "User Two" which expires after 6 days using the webUI
Then user "user3" should have a share with these details:
| field | value |
| path | /<shared-resource> |
| share_type | user |
| uid_owner | user3 |
| share_with | user2 |
| expiration | +5 |
Examples:
| shared-resource |
| lorem.txt |
| simple-folder |
1 change: 0 additions & 1 deletion tests/acceptance/helpers/sharingHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ module.exports = {
} else if (expectedDetail.field === 'expiration') {
expectedDetail.value = sharingHelper.calculateDate(expectedDetail.value)
}

if (!(expectedDetail.field in share) || share[expectedDetail.field].toString() !== expectedDetail.value) {
found = false
break
Expand Down
24 changes: 19 additions & 5 deletions tests/acceptance/pageObjects/FilesPageElement/sharingDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ module.exports = {

/**
*
* @param {string} sharee
* @param {string} receiver
* @param {boolean} [shareWithGroup=false]
* @param {boolean} remoteShare
*/
selectCollaboratorForShare: async function (receiver, shareWithGroup = false, remoteShare = false) {
let sharee = receiver
Expand Down Expand Up @@ -144,7 +145,7 @@ module.exports = {
await this.click('@collaboratorExpirationDateInput')
await this.useXpath().click(dateSelector)
await this.click('@collaboratorExpirationDateModalConfirmButton')

await this.useCss()
return this
},

Expand All @@ -154,8 +155,17 @@ module.exports = {
* @param {boolean} shareWithGroup
* @param {string} role
* @param {string} permissions
* @param {boolean} remote
* @param {int} days
*/
shareWithUserOrGroup: async function (sharee, shareWithGroup = false, role, permissions, remote = false, days) {
shareWithUserOrGroup: async function (
sharee,
shareWithGroup = false,
role,
permissions,
remote = false,
days
) {
await collaboratorDialog.clickCreateShare()
await this.selectCollaboratorForShare(sharee, shareWithGroup, remote)
await this.selectRoleForNewCollaborator(role)
Expand Down Expand Up @@ -489,16 +499,20 @@ module.exports = {
/**
* @param {string} collaborator Name of the collaborator
* @param {string} days number of days to be added or subtracted from current date
* @param {boolean} tries
*
* @return {Promise<*>}
*/
changeCollaboratorExpiryDate: async function (collaborator, days) {
changeCollaboratorExpiryDate: async function (collaborator, days, tries = false) {
await collaboratorDialog.clickEditShare(collaborator)
await this.api.page
.FilesPageElement
.expirationDatePicker()
.setExpirationDate(days)
return this.saveChanges()
if (!tries) {
this.saveChanges()
}
return this
}
},
elements: {
Expand Down
40 changes: 35 additions & 5 deletions tests/acceptance/stepDefinitions/sharingContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,8 @@ const assertUsersGroupsWithPatternInAutocompleteListExcluding = async function (
* @param {boolean} remote
*/
const userSharesFileOrFolderWithUserOrGroupWithExpirationDate = async function ({
resource, sharee, days, shareWithGroup = false, remote = false
resource, sharee, days,
shareWithGroup = false, remote = false
}) {
const api = client.page
.FilesPageElement
Expand All @@ -340,7 +341,14 @@ const userSharesFileOrFolderWithUserOrGroupWithExpirationDate = async function (
.closeSidebar(100)
.openSharingDialog(resource)

return api.sharingDialog().shareWithUserOrGroup(sharee, shareWithGroup, 'Viewer', undefined, remote, days)
return api.sharingDialog().shareWithUserOrGroup(
sharee,
shareWithGroup,
'Viewer',
undefined,
remote,
days
)
}

/**
Expand Down Expand Up @@ -787,6 +795,16 @@ When('the user edits the collaborator expiry date of {string} of file/folder/res
return api.sharingDialog().changeCollaboratorExpiryDate(collaborator, days)
})

When('the user tries to edit the collaborator expiry date of {string} of file/folder/resource {string} to {string} days/day using the webUI',
async function (collaborator, resource, days) {
const api = client.page.FilesPageElement
await api
.appSideBar()
.closeSidebar(100)
.openSharingDialog(resource)
return api.sharingDialog().changeCollaboratorExpiryDate(collaborator, days, true)
})

Then('user {string} should be listed as {string} in the collaborators list on the webUI', function (user, role) {
return assertCollaboratorslistContains('user', user, { role })
})
Expand Down Expand Up @@ -994,9 +1012,21 @@ Then('the following resources should have the following collaborators', async fu
}
})

When('the user shares file/folder/resource {string} with user {string} which expires after {int} day/days using the webUI', function (resource, sharee, days) {
return userSharesFileOrFolderWithUserOrGroupWithExpirationDate({ resource, sharee, days })
})
When('the user (tries to )share/shares file/folder/resource {string} with user {string} which expires after {int} day/days using the webUI',
function (resource, sharee, days) {
return userSharesFileOrFolderWithUserOrGroupWithExpirationDate({ resource, sharee, days })
})

When('the user (tries to )share/shares file/folder/resource {string} with group {string} which expires after {int} day/days using the webUI',
function (resource, sharee, days) {
return userSharesFileOrFolderWithUserOrGroupWithExpirationDate(
{
resource: resource,
sharee: sharee,
days: days,
shareWithGroup: true
})
})

When('the user shares file/folder/resource {string} with user {string} using the webUI', function (resource, user) {
return userSharesFileOrFolderWithUser(resource, user, 'Viewer')
Expand Down

0 comments on commit f906430

Please sign in to comment.