mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-02-17 19:08:36 -06:00
Merge pull request #6033 from owncloud/refactorAddGroupToGroup
[tests-only] [full-ci] Refactor api endpoint for adding group to group
This commit is contained in:
@@ -573,42 +573,6 @@ 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
|
||||
|
||||
@@ -161,14 +161,14 @@ The expected failures in this file are from features in the owncloud/ocis repo.
|
||||
- [apiGraph/addUserToGroup.feature:204](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/addUserToGroup.feature#L204)
|
||||
|
||||
### [Users are added in a group with wrong host in host-part of user](https://github.com/owncloud/ocis/issues/5871)
|
||||
- [apiGraph/addUserToGroup.feature:356](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/addUserToGroup.feature#L356)
|
||||
- [apiGraph/addUserToGroup.feature:370](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/addUserToGroup.feature#L370)
|
||||
- [apiGraph/addUserToGroup.feature:384](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/addUserToGroup.feature#L384)
|
||||
|
||||
#### [Admin user can't restore other user spaces](https://github.com/owncloud/ocis/issues/5872)
|
||||
- [apiSpaces/restoreSpaces.feature:94](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpaces/restoreSpaces.feature#L94)
|
||||
|
||||
### [Adding the same user as multiple members in a single request results in listing the same user twice in the group](https://github.com/owncloud/ocis/issues/5855)
|
||||
- [apiGraph/addUserToGroup.feature:407](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/addUserToGroup.feature#L407)
|
||||
- [apiGraph/addUserToGroup.feature:421](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/addUserToGroup.feature#L421)
|
||||
|
||||
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.
|
||||
|
||||
@@ -305,7 +305,7 @@ Feature: add users to group
|
||||
| Carol | grp1 |
|
||||
|
||||
@issue-5793
|
||||
Scenario: try to add a group to a group
|
||||
Scenario: try to add a group to another group with PATCH request
|
||||
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 |
|
||||
@@ -315,7 +315,21 @@ Feature: add users to group
|
||||
| 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
|
||||
When the administrator "Alice" tries to add a group "music" to another group "student" with PATCH request using the Graph API
|
||||
Then the HTTP status code should be "400"
|
||||
|
||||
@issue-5793
|
||||
Scenario: try to add a group to another group with POST request
|
||||
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 another group "student" with POST request using the Graph API
|
||||
Then the HTTP status code should be "400"
|
||||
|
||||
|
||||
|
||||
@@ -2072,7 +2072,7 @@ class GraphContext implements Context {
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^the administrator "([^"]*)" tries to add a group "([^"]*)" to a group "([^"]*)" using the Graph API$/
|
||||
* @When /^the administrator "([^"]*)" tries to add a group "([^"]*)" to another group "([^"]*)" with PATCH request using the Graph API$/
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $groupToAdd
|
||||
@@ -2082,19 +2082,56 @@ class GraphContext implements Context {
|
||||
* @throws GuzzleException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function theAdministratorAddGroupToAGroupAtOnceUsingTheGraphApi(string $user, string $groupToAdd, string $group) {
|
||||
public function theAdministratorTriesToAddGroupToAGroupAtOnceUsingTheGraphApi(string $user, string $groupToAdd, string $group) {
|
||||
$groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id");
|
||||
$groupIdToAdd = $this->featureContext->getAttributeOfCreatedGroup($groupToAdd, "id");
|
||||
$credentials = $this->getAdminOrUserCredentials($user);
|
||||
|
||||
$payload = [
|
||||
"members@odata.bind" => [GraphHelper::getFullUrl($this->featureContext->getBaseUrl(), 'groups/' . $groupIdToAdd)]
|
||||
];
|
||||
|
||||
$this->featureContext->setResponse(
|
||||
GraphHelper::addGroupToGroup(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
HttpRequestHelper::sendRequest(
|
||||
GraphHelper::getFullUrl($this->featureContext->getBaseUrl(), 'groups/' . $groupId),
|
||||
$this->featureContext->getStepLineRef(),
|
||||
'PATCH',
|
||||
$credentials["username"],
|
||||
$credentials["password"],
|
||||
['Content-Type' => 'application/json'],
|
||||
\json_encode($payload)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^the administrator "([^"]*)" tries to add a group "([^"]*)" to another group "([^"]*)" with POST request using the Graph API$/
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $groupToAdd
|
||||
* @param string $group
|
||||
*
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function theAdministratorTriesToAddAGroupToAGroupThroughPostRequestUsingTheGraphApi(string $user, string $groupToAdd, string $group) {
|
||||
$groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id");
|
||||
$groupIdToAdd = $this->featureContext->getAttributeOfCreatedGroup($groupToAdd, "id");
|
||||
$credentials = $this->getAdminOrUserCredentials($user);
|
||||
|
||||
$payload = [
|
||||
"@odata.id" => GraphHelper::getFullUrl($this->featureContext->getBaseUrl(), 'groups/' . $groupIdToAdd)
|
||||
];
|
||||
|
||||
$this->featureContext->setResponse(
|
||||
HttpRequestHelper::post(
|
||||
GraphHelper::getFullUrl($this->featureContext->getBaseUrl(), 'groups/' . $groupId . '/members/$ref'),
|
||||
$this->featureContext->getStepLineRef(),
|
||||
$credentials["username"],
|
||||
$credentials["password"],
|
||||
$groupId,
|
||||
$groupIdToAdd
|
||||
['Content-Type' => 'application/json'],
|
||||
\json_encode($payload)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user