Skip to content

Commit

Permalink
review address
Browse files Browse the repository at this point in the history
Signed-off-by: nabim777 <[email protected]>
  • Loading branch information
nabim777 committed Sep 23, 2024
1 parent 59deff4 commit dcc3d9f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1307,6 +1307,7 @@ Feature: retrieve file information of a single file, using the file ID

Scenario: get information of a group folder
Given user "Carol" has been created
And groupfolder DAV path has been set
And group "grp1" has been created
And user "Carol" has been added to the group "grp1"
And group folder "groupFolder" has been created
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Feature: retrieve information of multiple files using the file IDs
Given user "Carol" has been created
And group "grp1" has been created
And user "Carol" has been added to the group "grp1"
And groupfolder DAV path has been set
And group folder "groupFolder" has been created
And group "grp1" has been added to group folder "groupFolder"
And user "Brian" has been created with display-name "Brian Adams"
Expand Down
1 change: 1 addition & 0 deletions tests/acceptance/features/api/setup.feature
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@ Feature: setup the integration through an API

# this test wil not pass locally if your system already has a `OpenProject` user/group setup
Scenario: Set up whole integration with project folder and user app password
Given groupfolder DAV path has been set
When the administrator sends a POST request to the "setup" endpoint with this data:
"""
{
Expand Down
42 changes: 20 additions & 22 deletions tests/acceptance/features/bootstrap/GroupfoldersContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,33 @@ class GroupfoldersContext implements Context {
/** @var array<mixed> */
private array $createdGroupFolders = [];

private function getDavPath():string {
// there is a change in the DAV path starting from version 19 of groupfolders, since this function returns
// "ocs/v2.php/" for versions 19 and above, and "index.php/" for versions below 19.
$capibilitiesResponse = $this->featureContext->sendOCSRequest(
/** @var string */
private string $groupFolderDavPath;

/**
* @Given groupfolder DAV path has been set
*/
public function groupfolderDavPathHasBeenSet(): void {
// groupfolder with version greater then 19.0.0 uses "ocs/v2.php/" endpoint
$capabilitiesResponse = $this->featureContext->sendOCSRequest(
'/cloud/capabilities', 'GET', $this->featureContext->getAdminUsername()
);

$responseAsJson = json_decode($capibilitiesResponse->getBody()->getContents());
$responseAsJson = $responseAsJson->ocs->data;

$getGroupFolderAppVersion = $responseAsJson->capabilities->integration_openproject->groupfolder_version;

if (version_compare($getGroupFolderAppVersion, '19') >= 0) {
return "ocs/v2.php/";
$this->featureContext->theHTTPStatusCodeShouldBe(200, "", $capabilitiesResponse);
$responseAsJson = json_decode($capabilitiesResponse->getBody()->getContents());
$groupFolderVersion = $responseAsJson->ocs->data->capabilities->integration_openproject->groupfolder_version ?? null;
Assert::assertNotNull($groupFolderVersion, 'Group folder version not found in the response');
$this->groupFolderDavPath = "index.php/";
if (version_compare($groupFolderVersion, '19') >= 0) {
$this->groupFolderDavPath = "ocs/v2.php/";
}
return "index.php/";
}

/**
* @Given group folder :folderName has been created
*/
public function groupFolderHasBeenCreated(string $folderName): void {
$davPath = $this->getDavPath();
$fullUrl = $this->featureContext->getBaseUrl() .
"$davPath" . "apps/groupfolders/folders";

"$this->groupFolderDavPath" . "apps/groupfolders/folders";
$headers['OCS-APIRequest'] = 'true';
$options = [
'multipart' => [
Expand Down Expand Up @@ -70,9 +71,8 @@ public function groupFolderHasBeenCreated(string $folderName): void {
*/
public function groupHasBeenAddedToGroupFolder(string $group, string $groupfolder):void {
$groupfolderId = $this->createdGroupFolders[$groupfolder];
$davPath = $this->getDavPath();
$fullUrl = $this->featureContext->getBaseUrl() .
"$davPath". "apps/groupfolders/folders/".$groupfolderId. "/groups";
"$this->groupFolderDavPath". "apps/groupfolders/folders/".$groupfolderId. "/groups";
$headers['OCS-APIRequest'] = 'true';
$options = [
'multipart' => [
Expand Down Expand Up @@ -175,9 +175,8 @@ private function getGroupfolderByMountpoint(string $mountpoint): array {
* @throws GuzzleException
*/
private function getAllGroupfolders() {
$davPath = $this->getDavPath();
$fullUrl = $this->featureContext->getBaseUrl() .
"$davPath". "apps/groupfolders/folders?format=json";
"$this->groupFolderDavPath". "apps/groupfolders/folders?format=json";

$headers['Content-Type'] = 'application/json';
$headers['OCS-APIRequest'] = 'true';
Expand All @@ -196,9 +195,8 @@ private function getAllGroupfolders() {
}

private function adminDeletesGroupfolder(int $id): void {
$davPath = $this->getDavPath();
$fullUrl = $this->featureContext->getBaseUrl() .
"$davPath". "apps/groupfolders/folders/" . $id;
"$this->groupFolderDavPath". "apps/groupfolders/folders/" . $id;
$headers['OCS-APIRequest'] = 'true';
$this->featureContext->sendHttpRequest(
$fullUrl,
Expand Down

0 comments on commit dcc3d9f

Please sign in to comment.