diff --git a/tests/acceptance/features/webUISharingInternalGroups/shareWithGroups.feature b/tests/acceptance/features/webUISharingInternalGroups/shareWithGroups.feature index 91f32fa1139..dc5a8ffe0f4 100644 --- a/tests/acceptance/features/webUISharingInternalGroups/shareWithGroups.feature +++ b/tests/acceptance/features/webUISharingInternalGroups/shareWithGroups.feature @@ -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 | @@ -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 "" with group "grp1" as "Viewer" using the webUI + Then user "user3" should have a share with these details: + | field | value | + | path | / | + | share_type | group | + | uid_owner | user3 | + | share_with | grp1 | + | expiration | +42 | + And user "user1" should have received a share with target "" and expiration date in 42 days + And user "user2" should have received a share with target "" 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 "" with group "grp1" which expires after 6 days using the webUI + Then user "user3" should have a share with these details: + | field | value | + | path | / | + | share_type | group | + | uid_owner | user3 | + | share_with | grp1 | + | expiration | +5 | + And user "user1" should have received a share with target "" and expiration date in 5 days + And user "user2" should have received a share with target "" 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 | | + | 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 "" to "+7" days using the webUI + Then user "user3" should have a share with these details: + | field | value | + | path | / | + | share_type | group | + | uid_owner | user3 | + | share_with | grp1 | + | expiration | +4 | + And user "user1" should have received a share with target "" and expiration date in 4 days + And user "user2" should have received a share with target "" and expiration date in 4 days + Examples: + | shared-resource | target-resource | + | lorem.txt | lorem (2).txt | + | simple-folder | simple-folder (2) | diff --git a/tests/acceptance/features/webUISharingInternalUsers/shareWithUsers.feature b/tests/acceptance/features/webUISharingInternalUsers/shareWithUsers.feature index 71a0fe548fd..036f2184cf4 100644 --- a/tests/acceptance/features/webUISharingInternalUsers/shareWithUsers.feature +++ b/tests/acceptance/features/webUISharingInternalUsers/shareWithUsers.feature @@ -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 "" 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 | / | + | share_type | user | + | uid_owner | user1 | + | share_with | user2 | + | expiration | +5 | + And user "user2" should have received a share with target "" 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 | | + | 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 "" to "+7" days using the webUI + Then user "user1" should have a share with these details: + | field | value | + | path | / | + | 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 "" 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 | / | + | share_type | user | + | uid_owner | user3 | + | share_with | user2 | + | expiration | +5 | + Examples: + | shared-resource | + | lorem.txt | + | simple-folder | diff --git a/tests/acceptance/helpers/sharingHelper.js b/tests/acceptance/helpers/sharingHelper.js index ce9888b2bfa..bcdd2948ad6 100644 --- a/tests/acceptance/helpers/sharingHelper.js +++ b/tests/acceptance/helpers/sharingHelper.js @@ -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 diff --git a/tests/acceptance/pageObjects/FilesPageElement/sharingDialog.js b/tests/acceptance/pageObjects/FilesPageElement/sharingDialog.js index 21b52e9f313..9391f7350c8 100644 --- a/tests/acceptance/pageObjects/FilesPageElement/sharingDialog.js +++ b/tests/acceptance/pageObjects/FilesPageElement/sharingDialog.js @@ -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 @@ -144,7 +145,7 @@ module.exports = { await this.click('@collaboratorExpirationDateInput') await this.useXpath().click(dateSelector) await this.click('@collaboratorExpirationDateModalConfirmButton') - + await this.useCss() return this }, @@ -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) @@ -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: { diff --git a/tests/acceptance/stepDefinitions/sharingContext.js b/tests/acceptance/stepDefinitions/sharingContext.js index 5c516ff9f9b..1c2f6f464a1 100644 --- a/tests/acceptance/stepDefinitions/sharingContext.js +++ b/tests/acceptance/stepDefinitions/sharingContext.js @@ -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 @@ -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 + ) } /** @@ -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 }) }) @@ -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')