Skip to content

Commit

Permalink
add ocs endpoint on groupfolder on tests
Browse files Browse the repository at this point in the history
Signed-off-by: nabim777 <[email protected]>
  • Loading branch information
nabim777 committed Sep 17, 2024
1 parent b4bb9d1 commit edf3837
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/shared_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ jobs:
phpVersionMinor: [ 1, 2, 3 ]
database: [ mysql ]
include:
# Each database once on the newest Server with preinstalled PHP version
Each database once on the newest Server with preinstalled PHP version
- nextcloudVersion: stable30
phpVersionMajor: 8
phpVersionMinor: 1
Expand All @@ -204,7 +204,7 @@ jobs:
phpVersionMajor: 8
phpVersionMinor: 1
database: mysql
- nextcloudVersion: stable30
- nextcloudVersion: master
phpVersionMajor: 8
phpVersionMinor: 3
database: mysql
Expand Down
29 changes: 25 additions & 4 deletions tests/acceptance/features/bootstrap/GroupfoldersContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,31 @@ 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(
'/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/";
}
return "index.php/";
}

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

$headers['OCS-APIRequest'] = 'true';
$options = [
Expand Down Expand Up @@ -52,8 +70,9 @@ 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() .
"index.php/apps/groupfolders/folders/".$groupfolderId. "/groups";
"$davPath". "/apps/groupfolders/folders/".$groupfolderId. "/groups";
$headers['OCS-APIRequest'] = 'true';
$options = [
'multipart' => [
Expand Down Expand Up @@ -156,8 +175,9 @@ private function getGroupfolderByMountpoint(string $mountpoint): array {
* @throws GuzzleException
*/
private function getAllGroupfolders() {
$davPath = $this->getDavPath();
$fullUrl = $this->featureContext->getBaseUrl() .
"index.php/apps/groupfolders/folders?format=json";
"$davPath". "apps/groupfolders/folders?format=json";

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

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

0 comments on commit edf3837

Please sign in to comment.