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:
1 parent
8ec167d792
commit
028ca42fed
4 files changed
+160
No files matched your search
@@ -586,6 +586,37 @@ class GraphHelper {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns single group information along with its member information when groupId is provided
|
||||||
|
* else return all group information along with its member information
|
||||||
|
*
|
||||||
|
* @param string $baseUrl
|
||||||
|
* @param string $xRequestId
|
||||||
|
* @param string $adminUser
|
||||||
|
* @param string $adminPassword
|
||||||
|
* @param string|null $groupId
|
||||||
|
*
|
||||||
|
* @return ResponseInterface
|
||||||
|
* @throws GuzzleException
|
||||||
|
*/
|
||||||
|
public static function getSingleOrAllGroupsAlongWithMembers(
|
||||||
|
string $baseUrl,
|
||||||
|
string $xRequestId,
|
||||||
|
string $adminUser,
|
||||||
|
string $adminPassword,
|
||||||
|
?string $groupId = null
|
||||||
|
): ResponseInterface {
|
||||||
|
// we can expand to get list of members for a single group with groupId and also expand to get all groups with all its members
|
||||||
|
$endPath = ($groupId) ? '/' . $groupId . '?$expand=members' : '?$expand=members';
|
||||||
|
$url = self::getFullUrl($baseUrl, 'groups' . $endPath);
|
||||||
|
return HttpRequestHelper::get(
|
||||||
|
$url,
|
||||||
|
$xRequestId,
|
||||||
|
$adminUser,
|
||||||
|
$adminPassword
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns json encoded payload for user creating request
|
* returns json encoded payload for user creating request
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -105,5 +105,8 @@ The expected failures in this file are from features in the owncloud/ocis repo.
|
|||||||
#### [Space admin should not not be able to change the user quota](https://github.com/owncloud/ocis/issues/5475)
|
#### [Space admin should not not be able to change the user quota](https://github.com/owncloud/ocis/issues/5475)
|
||||||
- [apiSpaces/spaceManagement.feature:69](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/spaceManagement.feature#L69)
|
- [apiSpaces/spaceManagement.feature:69](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/spaceManagement.feature#L69)
|
||||||
|
|
||||||
|
#### [Normal user can get expanded members information of a group](https://github.com/owncloud/ocis/issues/5604)
|
||||||
|
- [apiGraph/getGroup.feature:100](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getGroup.feature#L100)
|
||||||
|
|
||||||
Note: always have an empty line at the end of this file.
|
Note: always have an empty line at the end of this file.
|
||||||
The bash script that processes this file requires that the last line has a newline on the end.
|
The bash script that processes this file requires that the last line has a newline on the end.
|
||||||
@@ -52,3 +52,56 @@ Feature: get groups and their members
|
|||||||
When user "Brian" gets all the members of group "tea-lover" using the Graph API
|
When user "Brian" gets all the members of group "tea-lover" using the Graph API
|
||||||
Then the HTTP status code should be "401"
|
Then the HTTP status code should be "401"
|
||||||
And the last response should be an unauthorized response
|
And the last response should be an unauthorized response
|
||||||
|
|
||||||
|
|
||||||
|
Scenario: admin user gets all groups along with its member's information
|
||||||
|
Given these users have been created with default attributes and without skeleton files:
|
||||||
|
| username |
|
||||||
|
| Brian |
|
||||||
|
| Carol |
|
||||||
|
And group "tea-lover" has been created
|
||||||
|
And group "coffee-lover" has been created
|
||||||
|
And user "Alice" has been added to group "tea-lover"
|
||||||
|
And user "Brian" has been added to group "coffee-lover"
|
||||||
|
And user "Carol" has been added to group "tea-lover"
|
||||||
|
When user "Alice" retrieves all groups along with their members using the Graph API
|
||||||
|
Then the HTTP status code should be "200"
|
||||||
|
And the group 'coffee-lover' should have the following member information
|
||||||
|
| displayName | id | mail | onPremisesSamAccountName |
|
||||||
|
| Brian Murphy | %uuid_v4% | brian@example.org | Brian |
|
||||||
|
And the group 'tea-lover' should have the following member information
|
||||||
|
| displayName | id | mail | onPremisesSamAccountName |
|
||||||
|
| Alice Hansen | %uuid_v4% | alice@example.org | Alice |
|
||||||
|
| Carol King | %uuid_v4% | carol@example.org | Carol |
|
||||||
|
|
||||||
|
|
||||||
|
Scenario: normal user gets all groups along with their members information
|
||||||
|
Given user "Brian" has been created with default attributes and without skeleton files
|
||||||
|
And group "tea-lover" has been created
|
||||||
|
And group "coffee-lover" has been created
|
||||||
|
And user "Alice" has been added to group "tea-lover"
|
||||||
|
And user "Brian" has been added to group "coffee-lover"
|
||||||
|
When user "Brian" retrieves all groups along with their members using the Graph API
|
||||||
|
Then the HTTP status code should be "401"
|
||||||
|
And the last response should be an unauthorized response
|
||||||
|
|
||||||
|
|
||||||
|
Scenario: admin user gets a group along with their members information
|
||||||
|
Given user "Brian" has been created with default attributes and without skeleton files
|
||||||
|
And group "tea-lover" has been created
|
||||||
|
And user "Alice" has been added to group "tea-lover"
|
||||||
|
And user "Brian" has been added to group "tea-lover"
|
||||||
|
When user "Alice" gets all the members information of group "tea-lover" using the Graph API
|
||||||
|
And the group 'tea-lover' should have the following member information
|
||||||
|
| displayName | id | mail | onPremisesSamAccountName |
|
||||||
|
| Alice Hansen | %uuid_v4% | alice@example.org | Alice |
|
||||||
|
| Brian Murphy | %uuid_v4% | brian@example.org | Brian |
|
||||||
|
|
||||||
|
Scenario: normal user gets a group along with their members information
|
||||||
|
Given user "Brian" has been created with default attributes and without skeleton files
|
||||||
|
And group "tea-lover" has been created
|
||||||
|
And user "Alice" has been added to group "tea-lover"
|
||||||
|
And user "Brian" has been added to group "tea-lover"
|
||||||
|
When user "Brian" gets all the members information of group "tea-lover" using the Graph API
|
||||||
|
Then the HTTP status code should be "401"
|
||||||
|
And the last response should be an unauthorized response
|
||||||
@@ -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
|
* returns list of users of a group
|
||||||
*
|
*
|
||||||
@@ -996,6 +1016,59 @@ class GraphContext implements Context {
|
|||||||
$this->featureContext->setResponse($this->listGroupMembers($group, $user));
|
$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
|
* @Then the last response should be an unauthorized response
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in new issue
Block a user