Skip to content

Commit

Permalink
Merge pull request #32699 from owncloud/create-share-with-expiry
Browse files Browse the repository at this point in the history
Add test steps to create a public share with an expiry date
  • Loading branch information
DeepDiver1975 authored Sep 14, 2018
2 parents 7e68672 + d50d109 commit 4c935dd
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 6 deletions.
5 changes: 4 additions & 1 deletion tests/TestHelpers/SharingHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public static function createShare(
$sharePassword = null,
$permissions = null,
$linkName = null,
$expireDate = null, // unused, to be implemented
$expireDate = null,
$ocsApiVersion = 1,
$sharingApiVersion = 1
) {
Expand Down Expand Up @@ -170,6 +170,9 @@ public static function createShare(
if ($linkName !== null) {
$fd['name'] = $linkName;
}
if ($expireDate !== null) {
$fd['expireDate'] = \date('Y-m-d', \strtotime($expireDate));
}

return HttpRequestHelper::post($fullUrl, $user, $password, null, $fd);
}
Expand Down
52 changes: 47 additions & 5 deletions tests/acceptance/features/bootstrap/Sharing.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ public function theUserHasCreatedAShareWithSettings($body) {
* @param boolean $publicUpload
* @param string|null $sharePassword
* @param string|int|string[]|int[]|null $permissions
* @param string $linkName
* @param string $expireDate
*
* @return void
*/
Expand All @@ -138,7 +140,9 @@ public function createAPublicShare(
$path,
$publicUpload = false,
$sharePassword = null,
$permissions = null
$permissions = null,
$linkName = null,
$expireDate = null
) {
$this->response = SharingHelper::createShare(
$this->getBaseUrl(),
Expand All @@ -150,8 +154,8 @@ public function createAPublicShare(
$publicUpload,
$sharePassword,
$permissions,
null, // linkName
null, // expireDate
$linkName,
$expireDate,
$this->ocsApiVersion,
$this->sharingApiVersion
);
Expand Down Expand Up @@ -213,6 +217,42 @@ public function aPublicShareOfIsCreatedWithPermission($path, $permissions) {
);
}

/**
* @When /^user "([^"]*)" creates a public share of (?:file|folder) "([^"]*)" using the sharing API with expiry "([^"]*)"$/
* @Given /^user "([^"]*)" has created a public share of (?:file|folder) "([^"]*)" with expiry "([^"]*)"$/
*
* @param string $user
* @param string $path
* @param string $expiryDate in a valid date format, e.g. "+30 days"
*
* @return void
*/
public function userCreatesAPublicShareOfWithExpiry(
$user, $path, $expiryDate
) {
$this->createAPublicShare(
$user, $path, true, null, null, null, $expiryDate
);
}

/**
* @When /^the user creates a public share of (?:file|folder) "([^"]*)" using the sharing API with expiry "([^"]*)$"/
* @Given /^the user has created a public share of (?:file|folder) "([^"]*)" with expiry "([^"]*)$/
*
* @param string $user
* @param string $path
* @param string $expiryDate in a valid date format, e.g. "+30 days"
*
* @return void
*/
public function aPublicShareOfIsCreatedWithExpiry(
$user, $path, $expiryDate
) {
$this->createAPublicShare(
$this->currentUser, $path, true, null, null, null, $expiryDate
);
}

/**
* @Then /^the public shared file "([^"]*)" should not be able to be downloaded$/
*
Expand Down Expand Up @@ -544,6 +584,7 @@ public function userUpdatesTheLastShareWith($user, $body) {
* @param string $password
* @param int $permissions
* @param string $linkName
* @param string $expireDate
*
* @return void
*/
Expand All @@ -555,7 +596,8 @@ public function createShare(
$publicUpload = null,
$password = null,
$permissions = null,
$linkName = null
$linkName = null,
$expireDate = null
) {
$this->response = SharingHelper::createShare(
$this->getBaseUrl(),
Expand All @@ -568,7 +610,7 @@ public function createShare(
$password,
$permissions,
$linkName,
null, //expireDate
$expireDate,
$this->ocsApiVersion,
$this->sharingApiVersion
);
Expand Down

0 comments on commit 4c935dd

Please sign in to comment.