mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-06 12:19:37 -06:00
Forward port getallgroupmemberswithallmembers to master (#5658)
* Added graph API test for getting all groups along with its members Signed-off-by: sagargurung1001@gmail.com <sagargurung1001@gmail.com> * Refactor implementation code Signed-off-by: sagargurung1001@gmail.com <sagargurung1001@gmail.com> * PR address Signed-off-by: sagargurung1001@gmail.com <sagargurung1001@gmail.com> * Update the local api expected to failure * Review Address --------- Signed-off-by: sagargurung1001@gmail.com <sagargurung1001@gmail.com>
This commit is contained in:
@@ -598,6 +598,26 @@ class GraphContext implements Context {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $user
|
||||
* @param string|null $group
|
||||
*
|
||||
* @return ResponseInterface
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function listSingleOrAllGroupsAlongWithAllMemberInformation(string $user, ?string $group = null): ResponseInterface {
|
||||
$credentials = $this->getAdminOrUserCredentials($user);
|
||||
|
||||
return GraphHelper::getSingleOrAllGroupsAlongWithMembers(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$this->featureContext->getStepLineRef(),
|
||||
$credentials["username"],
|
||||
$credentials["password"],
|
||||
($group) ? $this->featureContext->getAttributeOfCreatedGroup($group, 'id') : null
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns list of users of a group
|
||||
*
|
||||
@@ -996,6 +1016,59 @@ class GraphContext implements Context {
|
||||
$this->featureContext->setResponse($this->listGroupMembers($group, $user));
|
||||
}
|
||||
|
||||
/**
|
||||
* @When user :user retrieves all groups along with their members using the Graph API
|
||||
* @When user :user gets all the members information of group :group using the Graph API
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $group
|
||||
*
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function userRetrievesAllMemberInformationOfSingleOrAllGroups(string $user, string $group = ''): void {
|
||||
$this->featureContext->setResponse($this->listSingleOrAllGroupsAlongWithAllMemberInformation($user, $group));
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then the group :group should have the following member information
|
||||
*
|
||||
* @param string $group
|
||||
* @param TableNode $table
|
||||
*
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function theGroupShouldHaveTheFollowingMemberInformation(string $group, TableNode $table): void {
|
||||
$response = $this->featureContext->getJsonDecodedResponse($this->featureContext->getResponse());
|
||||
$rows = $table->getHash();
|
||||
$currentMemberIndex = 0;
|
||||
if (isset($response['value'])) {
|
||||
$response = $response['value'];
|
||||
$groupFoundInResponse = false;
|
||||
foreach ($response as $value) {
|
||||
if ($value['displayName'] === $group) {
|
||||
$groupFoundInResponse = true;
|
||||
foreach ($rows as $row) {
|
||||
$this->checkUserInformation($row, $value['members'][$currentMemberIndex]);
|
||||
$currentMemberIndex++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!$groupFoundInResponse) {
|
||||
throw new Error(
|
||||
'Group ' . $group . " could not be found in the response."
|
||||
);
|
||||
}
|
||||
} else {
|
||||
foreach ($rows as $row) {
|
||||
$this->checkUserInformation($row, $response['members'][$currentMemberIndex]);
|
||||
$currentMemberIndex++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then the last response should be an unauthorized response
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user