Skip to content

Commit

Permalink
adapt spaces context
Browse files Browse the repository at this point in the history
  • Loading branch information
micbar committed Apr 29, 2022
1 parent 1ff55ef commit 254ac50
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 2 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -274,4 +274,3 @@ require (

// we need to use a fork to make the windows build pass
replace github.com/pkg/xattr => github.com/micbar/xattr v0.4.6-0.20220215112335-88e74d648fb7
replace github.com/cs3org/reva/v2 => ../reva
65 changes: 64 additions & 1 deletion tests/acceptance/features/bootstrap/SpacesContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,24 @@ public function getSpaceByName(string $user, string $spaceName): array {
return $spaces[$spaceName];
}

/**
* The method finds available spaces to the manager user and returns the space by spaceName
*
* @param string $user
* @param string $spaceName
*
* @return array
*/
public function getSpaceByNameManager(string $user, string $spaceName): array {
$this->theUserListsAllAvailableSpacesUsingTheGraphApi($user);

$spaces = $this->getAvailableSpaces();
Assert::assertIsArray($spaces[$spaceName], "Space with name $spaceName for user $user not found");
Assert::assertNotEmpty($spaces[$spaceName]["root"]["webDavUrl"], "WebDavUrl for space with name $spaceName for user $user not found");

return $spaces[$spaceName];
}

/**
* The method finds file by fileName and spaceName and returns data of file wich contains in responseHeader
* fileName contains the path, if the file is in the folder
Expand Down Expand Up @@ -410,6 +428,33 @@ public function listMySpacesRequest(
return HttpRequestHelper::get($fullUrl, $xRequestId, $user, $password, $headers, $body);
}

/**
* Send Graph List All Spaces Request
*
* @param string $user
* @param string $password
* @param string $urlArguments
* @param string $xRequestId
* @param array $body
* @param array $headers
*
* @return ResponseInterface
*
* @throws GuzzleException
*/
public function listAllSpacesRequest(
string $user,
string $password,
string $urlArguments = '',
string $xRequestId = '',
array $body = [],
array $headers = []
): ResponseInterface {
$fullUrl = $this->baseUrl . "/graph/v1.0/drives/" . $urlArguments;

return HttpRequestHelper::get($fullUrl, $xRequestId, $user, $password, $headers, $body);
}

/**
* Send Graph List Single Space Request
*
Expand Down Expand Up @@ -530,6 +575,24 @@ public function theUserListsAllHisAvailableSpacesUsingTheGraphApi(string $user):
$this->rememberTheAvailableSpaces();
}

/**
*
* @param string $user
*
* @return void
*
* @throws GuzzleException
*/
public function theUserListsAllAvailableSpacesUsingTheGraphApi(string $user): void {
$this->featureContext->setResponse(
$this->listAllSpacesRequest(
$user,
$this->featureContext->getPasswordForUser($user)
)
);
$this->rememberTheAvailableSpaces();
}

/**
* @When /^user "([^"]*)" lists all available spaces via the GraphApi with query "([^"]*)"$/
*
Expand Down Expand Up @@ -1951,7 +2014,7 @@ public function sendRestoreSpaceRequest(
string $userWithManagerRights = ''
): void {
if (!empty($userWithManagerRights)) {
$space = $this->getSpaceByName($userWithManagerRights, $spaceName);
$space = $this->getSpaceByNameManager($userWithManagerRights, $spaceName);
} else {
$space = $this->getSpaceByName($user, $spaceName);
}
Expand Down

0 comments on commit 254ac50

Please sign in to comment.