mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-02-23 05:59:28 -06:00
[test-only] ApiTests. check group in the space request (#5492)
* check response * fix test
This commit is contained in:
@@ -446,6 +446,33 @@ class GraphHelper {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $baseUrl
|
||||
* @param string $xRequestId
|
||||
* @param string $adminUser
|
||||
* @param string $adminPassword
|
||||
* @param string $groupName
|
||||
*
|
||||
* @return ResponseInterface
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public static function getGroup(
|
||||
string $baseUrl,
|
||||
string $xRequestId,
|
||||
string $adminUser,
|
||||
string $adminPassword,
|
||||
string $groupName
|
||||
): ResponseInterface {
|
||||
$url = self::getFullUrl($baseUrl, 'groups/' . $groupName);
|
||||
return HttpRequestHelper::get(
|
||||
$url,
|
||||
$xRequestId,
|
||||
$adminUser,
|
||||
$adminPassword,
|
||||
self::getRequestHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $baseUrl
|
||||
* @param string $xRequestId
|
||||
|
||||
@@ -17,7 +17,7 @@ Feature: Share spaces
|
||||
And using spaces DAV path
|
||||
|
||||
|
||||
Scenario Outline:: A Space Admin can share a space to another user
|
||||
Scenario Outline: A Space Admin can share a space to another user
|
||||
When user "Alice" shares a space "share space" to user "Brian" with role "<role>"
|
||||
Then the HTTP status code should be "200"
|
||||
And the OCS status code should be "200"
|
||||
@@ -42,6 +42,17 @@ Feature: Share spaces
|
||||
| root@@@permissions@@@1@@@roles@@@0 | viewer |
|
||||
|
||||
|
||||
Scenario: A user can see that the group has been granted access
|
||||
Given group "sales" has been created
|
||||
When user "Alice" shares a space "share space" to group "sales" with role "viewer"
|
||||
Then the HTTP status code should be "200"
|
||||
And the OCS status code should be "200"
|
||||
And the user "Alice" should have a space called "share space" granted to group "sales" with these key and value pairs:
|
||||
| key | value |
|
||||
| root@@@permissions@@@1@@@grantedToIdentities@@@0@@@group@@@id | %group_id% |
|
||||
| root@@@permissions@@@1@@@roles@@@0 | viewer |
|
||||
|
||||
|
||||
Scenario: A user can see a file in a received shared space
|
||||
Given user "Alice" has uploaded a file inside space "share space" with content "Test" to "test.txt"
|
||||
And user "Alice" has created a folder "Folder Main" in space "share space"
|
||||
|
||||
@@ -424,6 +424,33 @@ class SpacesContext implements Context {
|
||||
throw new Exception(__METHOD__ . " user with name $userName not found");
|
||||
}
|
||||
|
||||
/**
|
||||
* The method returns groupId
|
||||
*
|
||||
* @param string $groupName
|
||||
*
|
||||
* @return string
|
||||
* @throws Exception|GuzzleException
|
||||
*/
|
||||
public function getGroupIdByGroupName(string $groupName): string {
|
||||
$response = GraphHelper::getGroup(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$this->featureContext->getStepLineRef(),
|
||||
$this->featureContext->getAdminUsername(),
|
||||
$this->featureContext->getAdminPassword(),
|
||||
$groupName
|
||||
);
|
||||
if ($response) {
|
||||
$data = $this->featureContext->getJsonDecodedResponse($response);
|
||||
if (isset($data["id"])) {
|
||||
return $data["id"];
|
||||
} else {
|
||||
throw new Exception(__METHOD__ . " accounts-list is empty");
|
||||
}
|
||||
}
|
||||
throw new Exception(__METHOD__ . " Group with name $groupName not found");
|
||||
}
|
||||
|
||||
/**
|
||||
* using method from core to set share data
|
||||
*
|
||||
@@ -934,6 +961,7 @@ class SpacesContext implements Context {
|
||||
* @param string $spaceName
|
||||
* @param string|null $userName
|
||||
* @param string|null $fileName
|
||||
* @param string|null $groupName
|
||||
* @param TableNode $table
|
||||
*
|
||||
* @return void
|
||||
@@ -943,6 +971,7 @@ class SpacesContext implements Context {
|
||||
string $spaceName,
|
||||
?string $userName = null,
|
||||
?string $fileName = null,
|
||||
?string $groupName = null,
|
||||
TableNode $table
|
||||
): void {
|
||||
$this->featureContext->verifyTableNodeColumns($table, ['key', 'value']);
|
||||
@@ -979,6 +1008,12 @@ class SpacesContext implements Context {
|
||||
[$this, "getETag"],
|
||||
"parameter" => [$userName, $spaceName, $fileName]
|
||||
],
|
||||
[
|
||||
"code" => "%group_id%",
|
||||
"function" =>
|
||||
[$this, "getGroupIdByGroupName"],
|
||||
"parameter" => [$groupName]
|
||||
]
|
||||
]
|
||||
);
|
||||
$segments = explode("@@@", $row["key"]);
|
||||
@@ -1024,7 +1059,32 @@ class SpacesContext implements Context {
|
||||
200,
|
||||
"Expected response status code should be 200"
|
||||
);
|
||||
$this->jsonRespondedShouldContain($spaceName, $grantedUser, $fileName, $table);
|
||||
$this->jsonRespondedShouldContain($spaceName, $grantedUser, $fileName, null, $table);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then /^the user "([^"]*)" should have a space called "([^"]*)" granted to group "([^"]*)" with these key and value pairs:$/
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $spaceName
|
||||
* @param string $grantedGroup
|
||||
* @param TableNode $table
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception|GuzzleException
|
||||
*/
|
||||
public function userHasSpaceGrantedToGroup(
|
||||
string $user,
|
||||
string $spaceName,
|
||||
string $grantedGroup,
|
||||
TableNode $table
|
||||
): void {
|
||||
$this->theUserListsAllHisAvailableSpacesUsingTheGraphApi($user);
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe(
|
||||
200,
|
||||
"Expected response status code should be 200"
|
||||
);
|
||||
$this->jsonRespondedShouldContain($spaceName, null, null, $grantedGroup, $table);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user