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

[Tests-Only]Fixed failing test on public link share #3852

Merged
merged 1 commit into from
Aug 3, 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
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ Feature: Share by public link
And the public uses the webUI to access the last public link created by user "user1" with password "qwertyui"
Then file "lorem.txt" should be listed on the webUI

@skipOnOCIS @skip @issue-3830
@skipOnOCIS @issue-3830
Scenario: user edits the password of an already existing public link and tries to access with old password
Given user "user1" has shared folder "simple-folder" with link with "read, update, create, delete" permissions and password "pass123"
And user "user1" has created a public link with following settings
Expand Down
24 changes: 22 additions & 2 deletions tests/acceptance/stepDefinitions/sharingContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const _ = require('lodash')
const path = require('../helpers/path')
const util = require('util')
const { COLLABORATOR_PERMISSION_ARRAY, calculateDate } = require('../helpers/sharingHelper')
let timeOfLastShareOperation = Date.now()

/**
*
Expand Down Expand Up @@ -107,6 +108,23 @@ Given(
}
)

/**
* makes sure share operations are carried out maximum once a second to avoid same stime
*/
const waitBetweenShareOperations = async function() {
const timeSinceLastShare = Date.now() - timeOfLastShareOperation
if (timeSinceLastShare <= 1001) {
await client.pause(1001 - timeSinceLastShare)
}
}

/**
* update time in which the last share operation was carried out
*/
const updateTimeOfLastShareOperation = function() {
timeOfLastShareOperation = Date.now()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be updated after sharing as sharing might take some time

}

/**
* creates a new share
*
Expand All @@ -120,7 +138,7 @@ Given(
* @param {string} extraParams.password Password of the share (public links)
* @param {string} extraParams.expireDate Expiry date of the share
*/
const shareFileFolder = function(
const shareFileFolder = async function(
elementToShare,
sharer,
receiver = null,
Expand All @@ -129,6 +147,7 @@ const shareFileFolder = function(
name = null,
extraParams = {}
) {
await waitBetweenShareOperations()
const params = new URLSearchParams()
elementToShare = path.resolve(elementToShare)
const permissions = sharingHelper.humanReadablePermissionsToBitmask(permissionString)
Expand All @@ -147,12 +166,13 @@ const shareFileFolder = function(
}
}
const url = 'apps/files_sharing/api/v1/shares'
return httpHelper
await httpHelper
.postOCS(url, sharer, params)
.then(res => res.json())
.then(function(json) {
httpHelper.checkOCSStatus(json, 'Could not create share. Message: ' + json.ocs.meta.message)
})
await updateTimeOfLastShareOperation()
}
/**
* create any share using dataTable
Expand Down