Skip to content

Commit

Permalink
Implementing spaces in apiFavorite feature
Browse files Browse the repository at this point in the history
  • Loading branch information
amrita-shrestha committed Jan 17, 2022
1 parent 743fadb commit 8b5d5fa
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 19 deletions.
10 changes: 3 additions & 7 deletions tests/TestHelpers/WebDavHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -460,18 +460,16 @@ public static function makeDavRequest(
):ResponseInterface {
$baseUrl = self::sanitizeUrl($baseUrl, true);

$usingSpacesDavPath = false;
$spaceId = null;
// get space id if testing with spaces dav
if ($davPathVersionToUse === 3) {
$usingSpacesDavPath = true;
$spaceId = self::getPersonalSpaceIdForUser($baseUrl, $user, $password, $xRequestId);
}

if ($doDavRequestAsUser === null) {
$davPath = self::getDavPath($user, $davPathVersionToUse, $type, $usingSpacesDavPath, $spaceId);
$davPath = self::getDavPath($user, $davPathVersionToUse, $type, $spaceId);
} else {
$davPath = self::getDavPath($doDavRequestAsUser, $davPathVersionToUse, $type, $usingSpacesDavPath, $spaceId);
$davPath = self::getDavPath($doDavRequestAsUser, $davPathVersionToUse, $type, $spaceId);
}

//replace %, # and ? and in the path, Guzzle will not encode them
Expand Down Expand Up @@ -536,7 +534,6 @@ public static function makeDavRequest(
* @param string|null $user
* @param int|null $davPathVersionToUse (1|2)
* @param string|null $type
* @param bool $usingSpaces
* @param string|null $spaceId
*
* @return string
Expand All @@ -545,7 +542,6 @@ public static function getDavPath(
?string $user,
?int $davPathVersionToUse = null,
?string $type = "files",
?bool $usingSpaces = false,
?string $spaceId = null
):string {
if ($type === "public-files" || $type === "public-files-old") {
Expand All @@ -560,7 +556,7 @@ public static function getDavPath(
if ($type === "customgroups") {
return "remote.php/dav/";
}
if ($usingSpaces) {
if ($davPathVersionToUse === 3) {
return "dav/spaces/" . $spaceId . '/';
} else {
if ($davPathVersionToUse === 1) {
Expand Down
46 changes: 44 additions & 2 deletions tests/acceptance/features/apiFavorites/favorites.feature
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ Feature: favorite
| old |
| new |

@skipOnOcV10
Examples:
| dav_version |
| spaces |

@issue-ocis-reva-276
Scenario Outline: Favorite and unfavorite a folder
Given using <dav_version> DAV path
Expand All @@ -44,6 +49,11 @@ Feature: favorite
| old |
| new |

@skipOnOcV10
Examples:
| dav_version |
| spaces |

@smokeTest @issue-ocis-reva-276
Scenario Outline: Favorite a file
Given using <dav_version> DAV path
Expand All @@ -59,6 +69,11 @@ Feature: favorite
| old |
| new |

@skipOnOcV10
Examples:
| dav_version |
| spaces |

@smokeTest @issue-ocis-reva-276
Scenario Outline: Favorite and unfavorite a file
Given using <dav_version> DAV path
Expand All @@ -75,6 +90,11 @@ Feature: favorite
| old |
| new |

@skipOnOcV10
Examples:
| dav_version |
| spaces |

@smokeTest
Scenario Outline: Get favorited elements of a folder
Given using <dav_version> DAV path
Expand All @@ -91,6 +111,11 @@ Feature: favorite
| old |
| new |

@skipOnOcV10
Examples:
| dav_version |
| spaces |

Scenario Outline: Get favorited elements of a subfolder
Given using <dav_version> DAV path
And user "Alice" has created folder "/subfolder"
Expand All @@ -112,7 +137,12 @@ Feature: favorite
| old |
| new |

@files_sharing-app-required
@skipOnOcV10
Examples:
| dav_version |
| spaces |

@files_sharing-app-required @issue_ocis_2968
Scenario Outline: moving a favorite file out of a share keeps favorite state
Given using <dav_version> DAV path
And user "Brian" has been created with default attributes and without skeleton files
Expand All @@ -128,6 +158,11 @@ Feature: favorite
| old |
| new |

@skipOnOcV10
Examples:
| dav_version |
| spaces |

@issue-33840 @skipOnOcV10
Scenario Outline: Get favorited elements and limit count of entries
Given using <dav_version> DAV path
Expand All @@ -147,6 +182,7 @@ Feature: favorite
| dav_version |
| old |
| new |
| spaces |

@issue-33840 @skipOnOcV10
Scenario Outline: Get favorited elements paginated in subfolder
Expand Down Expand Up @@ -175,6 +211,7 @@ Feature: favorite
| dav_version |
| old |
| new |
| spaces |

@files_sharing-app-required @notToImplementOnOCIS
Scenario Outline: sharer file favorite state should not change the favorite state of sharee
Expand Down Expand Up @@ -217,6 +254,11 @@ Feature: favorite
| old |
| new |

@skipOnOcV10
Examples:
| dav_version |
| spaces |

@files_sharing-app-required @notToImplementOnOCIS
Scenario Outline: favorite a file inside of a received share
Given using <dav_version> DAV path
Expand Down Expand Up @@ -252,4 +294,4 @@ Feature: favorite
Examples:
| dav_version |
| old |
| new |
| new |
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ Feature: favorite
| old |
| new |

@skipOnOcV10
Examples:
| dav_version |
| spaces |


Scenario Outline: favorite a folder inside of a received share
Given using <dav_version> DAV path
Expand All @@ -35,6 +40,11 @@ Feature: favorite
| old |
| new |

@skipOnOcV10
Examples:
| dav_version |
| spaces |


Scenario Outline: favorite a received share itself
Given using <dav_version> DAV path
Expand All @@ -48,6 +58,11 @@ Feature: favorite
| old |
| new |

@skipOnOcV10
Examples:
| dav_version |
| spaces |


Scenario Outline: moving a favorite file out of a share keeps favorite state
Given using <dav_version> DAV path
Expand All @@ -62,6 +77,11 @@ Feature: favorite
| old |
| new |

@skipOnOcV10
Examples:
| dav_version |
| spaces |


Scenario Outline: sharee file favorite state should not change the favorite state of sharer
Given using <dav_version> DAV path
Expand All @@ -75,3 +95,8 @@ Feature: favorite
| dav_version |
| old |
| new |

@skipOnOcV10
Examples:
| dav_version |
| spaces |
16 changes: 9 additions & 7 deletions tests/acceptance/features/bootstrap/ChecksumContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,17 @@ public function userRequestsTheChecksumOfViaPropfind(string $user, string $path)
$user,
$this->featureContext->getDavPathVersion()
) . $path;
$url = WebDavHelper::sanitizeUrl($url);
$response = HttpRequestHelper::sendRequest(
$url,
$this->featureContext->getStepLineRef(),
'PROPFIND',
$password = $this->featureContext->getPasswordForUser($user);
$response = WebDavHelper::makeDavRequest(
$this->featureContext->getBaseUrl(),
$user,
$this->featureContext->getPasswordForUser($user),
$password,
'PROPFIND',
$path,
null,
$body
$this->featureContext->getStepLineRef(),
$body,
$this->featureContext->getDavPathVersion()
);
$this->featureContext->setResponse($response);
}
Expand Down
15 changes: 15 additions & 0 deletions tests/acceptance/features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
use TestHelpers\UploadHelper;
use TestHelpers\OcisHelper;
use Laminas\Ldap\Ldap;
use TestHelpers\WebDavHelper;

require_once 'bootstrap.php';

Expand Down Expand Up @@ -3610,6 +3611,20 @@ public function clearFileLocks():void {
}
}

/**
* @AfterScenario
*
* clear space id reference
*
* @return void
* @throws Exception
*/
public function clearSpaceId():void {
if (\count(WebDavHelper::$spacesIdRef) > 0) {
WebDavHelper::$spacesIdRef = [];
}
}

/**
* @BeforeSuite
*
Expand Down
30 changes: 27 additions & 3 deletions tests/acceptance/features/bootstrap/WebDav.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,22 @@ public function usingSpacesDavPath():void {
* @return string
*/
public function getFullDavFilesPath(string $user):string {
$path = $this->getBasePath() . "/" .
WebDavHelper::getDavPath($user, $this->getDavPathVersion());
$spaceId = null;
$spaceDavPath = null;
if ($this->getDavPathVersion() === 3) {
$spaceId = WebDavHelper::getPersonalSpaceIdForUser(
$this->getBaseUrl(),
$user,
$this->getPasswordForUser($user),
$this->getStepLineRef()
);
$spaceDavPath = "dav/spaces/users/" . $spaceId . '/';
$path = $this->getBasePath() . "/" .
$spaceDavPath;
} else {
$path = $this->getBasePath() . "/" .
WebDavHelper::getDavPath($user, $this->getDavPathVersion());
}
$path = WebDavHelper::sanitizeUrl($path);
return \ltrim($path, "/");
}
Expand Down Expand Up @@ -593,10 +607,20 @@ public function waitForDavRequestsToFinish():void {
* @param string $fileDestination
*
* @return string
* @throws GuzzleException
*/
public function destinationHeaderValue(string $user, string $fileDestination):string {
$spaceId = null;
if ($this->getDavPathVersion() === 3) {
$spaceId = WebDavHelper::getPersonalSpaceIdForUser(
$this->getBaseUrl(),
$user,
$this->getPasswordForUser($user),
$this->getStepLineRef()
);
}
$fullUrl = $this->getBaseUrl() . '/' .
WebDavHelper::getDavPath($user, $this->getDavPathVersion());
WebDavHelper::getDavPath($user, $this->getDavPathVersion(), "files", $spaceId);
return \rtrim($fullUrl, '/') . '/' . \ltrim($fileDestination, '/');
}

Expand Down

0 comments on commit 8b5d5fa

Please sign in to comment.