Skip to content

Commit

Permalink
Fixed failing test on public link share
Browse files Browse the repository at this point in the history
  • Loading branch information
Talank committed Aug 2, 2020
1 parent 81842aa commit a4042ad
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
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()
}

/**
* 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

0 comments on commit a4042ad

Please sign in to comment.