mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-05-24 08:27:27 -04:00
Add tests to add user in a group at once (#5831)
This commit is contained in:
@@ -503,6 +503,8 @@ class GraphHelper {
|
||||
}
|
||||
|
||||
/**
|
||||
* add multiple users to a group at once
|
||||
*
|
||||
* @param string $baseUrl
|
||||
* @param string $xRequestId
|
||||
* @param string $adminUser
|
||||
@@ -537,6 +539,42 @@ class GraphHelper {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* tries to add a group to a group
|
||||
*
|
||||
* @param string $baseUrl
|
||||
* @param string $xRequestId
|
||||
* @param string $adminUser
|
||||
* @param string $adminPassword
|
||||
* @param string $groupId
|
||||
* @param string $groupIdToAdd
|
||||
*
|
||||
* @return ResponseInterface
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public static function addGroupToGroup(
|
||||
string $baseUrl,
|
||||
string $xRequestId,
|
||||
string $adminUser,
|
||||
string $adminPassword,
|
||||
string $groupId,
|
||||
string $groupIdToAdd
|
||||
): ResponseInterface {
|
||||
$url = self::getFullUrl($baseUrl, 'groups/' . $groupId);
|
||||
$payload = [
|
||||
"@odata.id" => self::getFullUrl($baseUrl, 'groups/' . $groupIdToAdd)
|
||||
];
|
||||
return HttpRequestHelper::sendRequest(
|
||||
$url,
|
||||
$xRequestId,
|
||||
'PATCH',
|
||||
$adminUser,
|
||||
$adminPassword,
|
||||
self::getRequestHeaders(),
|
||||
\json_encode($payload)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $baseUrl
|
||||
* @param string $xRequestId
|
||||
|
||||
@@ -110,5 +110,11 @@ The expected failures in this file are from features in the owncloud/ocis repo.
|
||||
#### [Using # in the onPremisesSamAccountName breaks getting users](https://github.com/owncloud/ocis/issues/5755)
|
||||
- [apiGraph/editUser.feature:44](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/editUser.feature#L44)
|
||||
|
||||
#### [Same users can be added in a group multiple time](https://github.com/owncloud/ocis/issues/5702)
|
||||
- [apiGraph/addUserToGroup.feature:222](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/addUserToGroup.feature#L222)
|
||||
|
||||
#### [Try to add group to a group return 204](https://github.com/owncloud/ocis/issues/5793)
|
||||
- [apiGraph/addUserToGroup.feature:244](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/addUserToGroup.feature#L244)
|
||||
|
||||
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.
|
||||
|
||||
@@ -217,3 +217,39 @@ Feature: add users to group
|
||||
And the following users should be listed in the following groups
|
||||
| username | groupname |
|
||||
| Alice | sales |
|
||||
|
||||
@issue-5702
|
||||
Scenario: try to add users to a group twice
|
||||
Given the administrator has given "Alice" the role "Admin" using the settings api
|
||||
And these users have been created with default attributes and without skeleton files:
|
||||
| username |
|
||||
| Brian |
|
||||
| Carol |
|
||||
And user "Alice" has created a group "grp1" using the Graph API
|
||||
And the administrator "Alice" has added the following users to a group "grp1" at once using the Graph API
|
||||
| username |
|
||||
| Brian |
|
||||
| Carol |
|
||||
When the administrator "Alice" adds the following users to a group "grp1" at once using the Graph API
|
||||
| username |
|
||||
| Brian |
|
||||
| Carol |
|
||||
Then the HTTP status code should be "400"
|
||||
And the following users should be listed in the following groups
|
||||
| username | groupname |
|
||||
| Brian | grp1 |
|
||||
| Carol | grp1 |
|
||||
|
||||
@issue-5793
|
||||
Scenario: try to add a group to a group
|
||||
Given the administrator has given "Alice" the role "Admin" using the settings api
|
||||
And these users have been created with default attributes and without skeleton files:
|
||||
| username |
|
||||
| Brian |
|
||||
And these groups have been created:
|
||||
| groupname |
|
||||
| student |
|
||||
| music |
|
||||
And user "Brian" has been added to group "music"
|
||||
When the administrator "Alice" tries to add a group "music" to a group "student" using the Graph API
|
||||
Then the HTTP status code should be "400"
|
||||
|
||||
@@ -2103,4 +2103,57 @@ class GraphContext implements Context {
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given /^the administrator "([^"]*)" has added the following users to a group "([^"]*)" at once using the Graph API$/
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $group
|
||||
* @param TableNode $table
|
||||
*
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function theAdministratorHasAddedTheFollowingUsersToAGroupAtOnceUsingTheGraphApi(string $user, string $group, TableNode $table) {
|
||||
$userIds = [];
|
||||
$groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id");
|
||||
foreach ($table->getHash() as $row) {
|
||||
$userIds[] = $this->featureContext->getAttributeOfCreatedUser($row['username'], "id");
|
||||
}
|
||||
$this->addMultipleUsersToGroup($user, $userIds, $groupId, $table);
|
||||
$response = $this->featureContext->getResponse();
|
||||
if ($response->getStatusCode() !== 204) {
|
||||
$$this->throwHttpException($response, "Cannot add users to group '$group'");
|
||||
}
|
||||
$this->featureContext->emptyLastHTTPStatusCodesArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^the administrator "([^"]*)" tries to add a group "([^"]*)" to a group "([^"]*)" using the Graph API$/
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $groupToAdd
|
||||
* @param string $group
|
||||
*
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function theAdministratorAddGroupToAGroupAtOnceUsingTheGraphApi(string $user, string $groupToAdd, string $group) {
|
||||
$groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id");
|
||||
$groupIdToAdd = $this->featureContext->getAttributeOfCreatedGroup($groupToAdd, "id");
|
||||
$credentials = $this->getAdminOrUserCredentials($user);
|
||||
|
||||
$this->featureContext->setResponse(
|
||||
GraphHelper::addGroupToGroup(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$this->featureContext->getStepLineRef(),
|
||||
$credentials["username"],
|
||||
$credentials["password"],
|
||||
$groupId,
|
||||
$groupIdToAdd
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user