Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
haribhandari07 committed Mar 16, 2020
1 parent c0bde37 commit a713423
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ Feature: Sharing files and folders with internal groups
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 input field of collaborators form should have value with "+5" days on 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 |
Expand All @@ -406,7 +406,7 @@ Feature: Sharing files and folders with internal groups
| 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 input field of collaborators form should have value with "+4" days on 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -638,8 +638,8 @@ Feature: Sharing files and folders with internal users
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 in "+6" days using the webUI
Then the expiration date input field of collaborators form should have value with "+5" days on 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 |
Expand All @@ -656,15 +656,15 @@ Feature: Sharing files and folders with internal users
| 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 input field of collaborators form should have value with "+4" days on 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: user cannot share with user with expiration date within set enforced maximum date if default expiry date for both user and group is enabled
Scenario Outline: enforced expiry date for groups does not affect user shares
Given user "user3" has been created with default attributes
And group "grp1" has been created
And user "user2" has been added to group "grp1"
Expand All @@ -675,8 +675,8 @@ Feature: Sharing files and folders with internal users
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 tries to share file "<shared-resource>" with user "User Two" which expires in "+6" days using the webUI
Then the expiration date input field of collaborators form should have value with "+5" days on 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 user "user2" should have received a share with target "<target-resource>" and expiration date in 6 days
# And user "user1" should have a share with these details:
# | field | value |
Expand All @@ -689,3 +689,21 @@ Feature: Sharing files and folders with internal users
| shared-resource |
| lorem.txt |
| simple-folder |

Scenario Outline: enforced expiry date for users does not affect group shares
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 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
Examples:
| shared-resource |
| lorem.txt |
| simple-folder |
16 changes: 7 additions & 9 deletions tests/acceptance/pageObjects/FilesPageElement/sharingDialog.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
const util = require('util')
const _ = require('lodash')
const sharingHelper = require('../../helpers/sharingHelper')
const { COLLABORATOR_PERMISSION_ARRAY, calculateDate } = require('../../helpers/sharingHelper')
const { client } = require('nightwatch-api')
const collaboratorDialog = client.page.FilesPageElement.SharingDialog.collaboratorsDialog()
const SHARE_TYPE_STRING = {
user: 'user',
group: 'group',
federation: 'remote'
}
const COLLABORATOR_PERMISSION_ARRAY = sharingHelper.COLLABORATOR_PERMISSION_ARRAY

module.exports = {
commands: {
Expand Down Expand Up @@ -150,11 +149,11 @@ module.exports = {
}

if (days) {
const dateToSet = sharingHelper.calculateDate(days)
const expectToSucceed = await this
const dateToSet = calculateDate(days)
const isExpiryDateChanged = await this
.openExpirationDatePicker()
.setExpirationDate(dateToSet)
if (!expectToSucceed) {
if (!isExpiryDateChanged) {
console.log('WARNING: Cannot create share with disabled expiration date!')
return
}
Expand Down Expand Up @@ -481,17 +480,16 @@ 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} expectToSucceed
*
* @return {Promise<*>}
*/
changeCollaboratorExpiryDate: async function (collaborator, days) {
await collaboratorDialog.clickEditShare(collaborator)
const dateToSet = sharingHelper.calculateDate(days)
const expectToSucceed = await this
const dateToSet = calculateDate(days)
const isExpiryDateChanged = await this
.openExpirationDatePicker()
.setExpirationDate(dateToSet)
if (!expectToSucceed) {
if (!isExpiryDateChanged) {
console.log('WARNING: Cannot create share with disabled expiration date!')
return
}
Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/stepDefinitions/sharingContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,7 @@ Then('user {string} should have received a share with target {string} and expira
return checkReceivedSharesExpirationDate(user, target, days)
})

Then('the expiration date input field of collaborators form should have value with {string} days on the webUI',
Then('the expiration date shown on the webUI should be {string} days',
async function (expectedDays) {
let expectedDate = sharingHelper.calculateDate(expectedDays)
expectedDate = new Date((Date.parse(expectedDate)))
Expand Down

0 comments on commit a713423

Please sign in to comment.