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

[CI] enable files sharing tests for ocis #4161

Merged
merged 2 commits into from
Oct 16, 2020
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
6 changes: 5 additions & 1 deletion .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,11 @@ config = {
'webUITrashbin',
'webUIUpload',
'webUIAccount'
]
],
'webUIOCIS3': [
'webUISharingInternalUsers',
'webUISharingPermissionsUsers',
],
},
'extraEnvironment': {
'NODE_TLS_REJECT_UNAUTHORIZED': '0',
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@skipOnOCIS @ocis-reva-issue-64
@ocis-reva-issue-64
Feature: Sharing files and folders with internal users with different permissions
As a user
I want to set different permissions on shared files and folders with other users
Expand All @@ -12,6 +12,7 @@ Feature: Sharing files and folders with internal users with different permission
| user1 |
| user2 |

@skipOnOCIS @issue-product-203
Scenario: Change permissions of the previously shared folder
Given user "user2" has shared folder "simple-folder" with user "user1" with "read" permissions
And user "user1" has accepted the share "simple-folder" offered by user "user2"
Expand All @@ -28,6 +29,7 @@ Feature: Sharing files and folders with internal users with different permission
| permissions | read, share |

@issue-1853
@skipOnOCIS @issue-product-207
Scenario: Change permissions of the previously shared folder
Given user "user2" has shared folder "simple-folder" with user "user1" with "read, share, create, delete" permissions
And user "user1" has accepted the share "simple-folder" offered by user "user2"
Expand All @@ -44,6 +46,7 @@ Feature: Sharing files and folders with internal users with different permission
| permissions | read, share, create, delete |

@issue-1853
@skipOnOCIS @issue-product-207
Scenario: Change permissions of the previously shared folder
Given user "user2" has shared folder "simple-folder" with user "user1" with "read, share, create" permissions
And user "user1" has accepted the share "simple-folder" offered by user "user2"
Expand All @@ -59,6 +62,7 @@ Feature: Sharing files and folders with internal users with different permission
| item_type | folder |
| permissions | read, update, delete |

@skipOnOCIS @issue-product-207
Scenario: Change permissions of the previously shared folder
Given user "user2" has shared folder "simple-folder" with user "user1" with "read, delete" permissions
And user "user1" has accepted the share "simple-folder" offered by user "user2"
Expand All @@ -74,6 +78,7 @@ Feature: Sharing files and folders with internal users with different permission
| item_type | folder |
| permissions | read, create, share |

@skipOnOCIS @issue-product-203
Scenario Outline: share a folder with another internal user assigning a role and the permissions
Given user "user2" has logged in using the webUI
When the user shares folder "simple-folder" with user "User One" as "<role>" with permissions "<extra-permissions>" using the webUI
Expand All @@ -95,6 +100,7 @@ Feature: Sharing files and folders with internal users with different permission
| Advanced permissions | Advanced permissions | update, share | share, update | read, update, share |
| Advanced permissions | Editor | delete, share, create, update | share | read, share, delete, update, create |

@skipOnOCIS @issue-product-203
Scenario Outline: Change permissions of the previously shared file
Given user "user2" has shared file "lorem.txt" with user "user1" with "<initial-permissions>" permissions
And user "user1" has accepted the share "lorem.txt" offered by user "user2"
Expand All @@ -114,6 +120,7 @@ Feature: Sharing files and folders with internal users with different permission
| read, update | read, share, update |
| read | read, share |

@skipOnOCIS @issue-product-203
Scenario: Delete all custom permissions of the previously shared file
Given user "user2" has shared file "lorem.txt" with user "user1" with "read, share" permissions
And user "user1" has accepted the share "lorem.txt" offered by user "user2"
Expand All @@ -129,6 +136,7 @@ Feature: Sharing files and folders with internal users with different permission
| item_type | file |
| permissions | read |

@skipOnOCIS @issue-product-203
Scenario Outline: share a file with another internal user assigning a role and the permissions
Given user "user2" has logged in using the webUI
When the user shares file "lorem.txt" with user "User One" as "<role>" with permissions "<collaborators-permissions>" using the webUI
Expand Down Expand Up @@ -156,6 +164,7 @@ Feature: Sharing files and folders with internal users with different permission
Then user "User One" should be listed as "Viewer" in the collaborators list for folder "simple-folder" on the webUI
And no custom permissions should be set for collaborator "User One" for folder "simple-folder" on the webUI

@skipOnOCIS @issue-product-207
Scenario: Resource owner upgrades share permissions of a re-share
Given user "user3" has been created with default attributes
And user "user2" has shared folder "simple-folder" with user "user1" with "read, share, delete" permissions
Expand All @@ -173,6 +182,7 @@ Feature: Sharing files and folders with internal users with different permission
| item_type | folder |
| permissions | delete, read, update |

@skipOnOCIS @issue-product-207
Scenario: User is not allowed to reshare sub-folder with more permissions
Given user "user3" has been created with default attributes
And user "user2" has shared folder "simple-folder" with user "user1" with "read, share, delete" permissions
Expand All @@ -185,6 +195,7 @@ Feature: Sharing files and folders with internal users with different permission
And user "user3" should not have received any shares
And as "user3" folder "/Shares/simple-empty-folder" should not exist

@skipOnOCIS @issue-product-207
Scenario: User is not allowed to update permissions of a reshared sub-folder to higher permissions than what user has received
Given user "user3" has been created with default attributes
And user "user2" has shared folder "simple-folder" with user "user1" with "read, share, delete, update" permissions
Expand All @@ -197,7 +208,8 @@ Feature: Sharing files and folders with internal users with different permission
Then the error message with header "Error while sharing." should be displayed on the webUI
And user "user3" should not have received any shares
And as "user3" folder "/Shares/simple-empty-folder" should not exist


@skipOnOCIS @issue-product-203
Scenario: User is allowed to update permissions of a reshared sub-folder within the permissions that the user has received
Given user "user3" has been created with default attributes
And user "user2" has shared folder "simple-folder" with user "user1" with "all" permissions
Expand Down
35 changes: 35 additions & 0 deletions tests/acceptance/helpers/sharingHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const httpHelper = require('./httpHelper')
const { normalize } = require('./path')
const codify = require('../helpers/codify')
const assert = require('assert')
const { client } = require('nightwatch-api')

module.exports = {
SHARE_TYPES: Object.freeze({
Expand Down Expand Up @@ -342,13 +343,47 @@ module.exports = {
.postOCS(apiURL, user)
.then(res => {
res = httpHelper.checkStatus(res, 'The response status is not the expected value')
if (client.globals.ocis) return res.text()
return res.json()
})
.then(res => {
if (client.globals.ocis) {
if (res !== '') {
throw new Error(`
This is a good error, seems like a bug in ocis has been fixed,
just fire up your text editor and remove this line,
dont forget to keep your fingers crossed in the meantime.
More on https://github.com/owncloud/product/issues/207
`)
}
return
}
httpHelper.checkOCSStatus(res, 'Could not perform the accept action')
})
}
},

/**
* Asynchronously delete the share with given shareID
*
* @async
* @param {string} shareID
* @param {string} user
*
*/
deleteShare: async function(shareID, user) {
const apiURL = `apps/files_sharing/api/v1/shares/${shareID}`
return httpHelper
.deleteOCS(apiURL, user)
.then(res => {
res = httpHelper.checkStatus(res, 'The response status is not the expected value')
console.log('deleted Share')
return res.json()
})
.then(res => {
return httpHelper.checkOCSStatus(res, `Could not delete the share with id ${shareID}`)
})
},
/**
* Asynchronously accepts the shares in pending state and meeting the conditions
*
Expand Down
13 changes: 13 additions & 0 deletions tests/acceptance/helpers/userSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,19 @@ module.exports = {
return userId
}
},

/**
* gets the username of a previously created user from displayName
*
* @param {string} displayName
*/
getUsernameFromDisplayname: function(displayName) {
for (const userid in this.createdUsers) {
if (this.createdUsers[userid].displayname === displayName) {
return userid
}
}
},
/**
* gets the display name of the specified user from the default users list
* returns null if the user is not in that list
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const util = require('util')
const _ = require('lodash')
const { COLLABORATOR_PERMISSION_ARRAY, calculateDate } = require('../../helpers/sharingHelper')
const { client } = require('nightwatch-api')
const userSettings = require('../../helpers/userSettings')
const collaboratorDialog = client.page.FilesPageElement.SharingDialog.collaboratorsDialog()
const SHARE_TYPE_STRING = {
user: 'user',
Expand Down Expand Up @@ -89,8 +90,12 @@ module.exports = {
shareWithGroup = false,
remoteShare = false
) {
let sharee = receiver
let sharee = client.globals.ocis
? userSettings.getUsernameFromDisplayname(receiver)
: receiver
if (remoteShare) sharee = util.format('%s@%s', receiver, this.api.globals.remote_backend_url)
const autocompleteUser = client.globals.ocis ? receiver : sharee

// We need waitForElementPresent here.
// waitForElementVisible would break even with 'abortOnFailure: false' if the element is not present
await this.enterAutoComplete(sharee).waitForElementPresent(
Expand All @@ -113,7 +118,7 @@ module.exports = {
receiverType = remoteShare === true ? SHARE_TYPE_STRING.federation : receiverType

const collaboratorSelector = this.getCollaboratorInAutocompleteListSelector(
sharee,
autocompleteUser,
receiverType
)

Expand Down
3 changes: 3 additions & 0 deletions tests/acceptance/stepDefinitions/generalContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ Given('the setting {string} of app {string} has been set to {string}', function(
app,
value
) {
if (client.globals.ocis) {
return
}
return occHelper.runOcc(['config:app:set', app, setting, '--value=' + value])
})

Expand Down
14 changes: 14 additions & 0 deletions tests/acceptance/stepDefinitions/provisioningContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const codify = require('../helpers/codify')
const { join } = require('../helpers/path')

const ldap = require('../helpers/ldapHelper')
const sharingHelper = require('../helpers/sharingHelper')

function createDefaultUser(userId) {
const password = userSettings.getPasswordForUser(userId)
Expand All @@ -31,6 +32,7 @@ function createUser(userId, password, displayName = false, email = false) {
}
body.append('userid', userId)
body.append('password', password)
body.append('displayname', displayName)
const promiseList = []

userSettings.addUserToCreatedUsersList(userId, password, displayName, email)
Expand Down Expand Up @@ -226,6 +228,18 @@ After(async function() {
const createdRemoteUsers = Object.keys(userSettings.getCreatedUsers('REMOTE'))
const createdGroups = userSettings.getCreatedGroups()

if (client.globals.ocis) {
const deleteSharePromises = createdUsers.map(user => {
return sharingHelper.getAllSharesSharedByUser(user).then(shares => {
if (shares.length) {
return Promise.all(shares.map(share => sharingHelper.deleteShare(share.id, user)))
}
})
})
await Promise.all(deleteSharePromises).catch(err => {
console.log('Error while deleting: ', err)
})
}
if (client.globals.ldap) {
const dataDir = user => join(client.globals.ocis_data_dir, user)
const deleteUserPromises = createdUsers.map(user =>
Expand Down
4 changes: 4 additions & 0 deletions tests/acceptance/stepDefinitions/sharingContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -1349,6 +1349,10 @@ When(
}
)

When('the user opens the sharing sidebar for file/folder {string}', function(file) {
return client.page.FilesPageElement.filesList().openSideBar(file)
})

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