added steps for group removal in provisioning.php files (#7380)

This commit is contained in:
Sabin Panta
2023-11-29 10:35:55 +05:45
committed by GitHub
parent c196734829
commit 4d14e048d9
4 changed files with 37 additions and 188 deletions
@@ -104,13 +104,13 @@ cannot share a folder with create permission
#### [OCS error message for attempting to access share via share id as an unauthorized user is not informative](https://github.com/owncloud/ocis/issues/1233)
- [coreApiShareOperationsToShares1/gettingShares.feature:143](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiShareOperationsToShares1/gettingShares.feature#L143)
- [coreApiShareOperationsToShares1/gettingShares.feature:144](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiShareOperationsToShares1/gettingShares.feature#L144)
- [coreApiShareOperationsToShares1/gettingShares.feature:145](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiShareOperationsToShares1/gettingShares.feature#L145)
#### [Listing shares via ocs API does not show path for parent folders](https://github.com/owncloud/ocis/issues/1231)
- [coreApiShareOperationsToShares1/gettingShares.feature:177](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiShareOperationsToShares1/gettingShares.feature#L177)
- [coreApiShareOperationsToShares1/gettingShares.feature:178](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiShareOperationsToShares1/gettingShares.feature#L178)
- [coreApiShareOperationsToShares1/gettingShares.feature:179](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiShareOperationsToShares1/gettingShares.feature#L179)
#### [Public link enforce permissions](https://github.com/owncloud/ocis/issues/1269)
@@ -360,14 +360,16 @@ class GraphContext implements Context {
/**
* remove user from group
*
* @param string $groupId
* @param string $userId
* @param string $group
* @param string $user
* @param string|null $byUser
*
* @return ResponseInterface
* @throws GuzzleException
*/
public function removeUserFromGroup(string $groupId, string $userId, ?string $byUser = null): ResponseInterface {
public function removeUserFromGroup(string $group, string $user, ?string $byUser = null): ResponseInterface {
$groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id") ?: WebDavHelper::generateUUIDv4();
$userId = $this->featureContext->getAttributeOfCreatedUser($user, "id");
$credentials = $this->getAdminOrUserCredentials($byUser);
return GraphHelper::removeUserFromGroup(
$this->featureContext->getBaseUrl(),
@@ -453,11 +455,8 @@ class GraphContext implements Context {
*/
public function adminHasRemovedUserFromGroupUsingTheGraphApi(string $user, string $group): void {
$user = $this->featureContext->getActualUsername($user);
$groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id");
$userId = $this->featureContext->getAttributeOfCreatedUser($user, "id");
$response = $this->removeUserFromGroup($groupId, $userId);
$this->featureContext->setResponse($response);
$this->featureContext->thenTheHTTPStatusCodeShouldBe(204);
$response = $this->removeUserFromGroup($group, $user);
$this->featureContext->TheHTTPStatusCodeShouldBe(204, '', $response);
}
/**
@@ -1194,29 +1193,12 @@ class GraphContext implements Context {
$usersGroups = $table->getColumnsHash();
foreach ($usersGroups as $userGroup) {
$groupId = $this->featureContext->getAttributeOfCreatedGroup($userGroup['groupname'], "id");
$userId = $this->featureContext->getAttributeOfCreatedUser($userGroup['username'], "id");
$this->featureContext->setResponse($this->removeUserFromGroup($groupId, $userId));
$this->featureContext->setResponse($this->removeUserFromGroup($userGroup['groupname'], $userGroup['username']));
$this->featureContext->pushToLastHttpStatusCodesArray();
}
}
/**
* @When the administrator removes user :user from group :group using the Graph API
*
* @param string $user
* @param string $group
*
* @return void
*/
public function theAdministratorTriesToRemoveUserFromGroupUsingTheGraphAPI(string $user, string $group): void {
$groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id");
$userId = $this->featureContext->getAttributeOfCreatedUser($user, "id");
$this->featureContext->setResponse($this->removeUserFromGroup($groupId, $userId));
}
/**
* @When the administrator tries to remove user :user from group :group using the Graph API
* @When user :byUser tries to remove user :user from group :group using the Graph API
*
* @param string $user
@@ -1227,9 +1209,7 @@ class GraphContext implements Context {
* @throws Exception | GuzzleException
*/
public function theUserTriesToRemoveAnotherUserFromGroupUsingTheGraphAPI(string $user, string $group, ?string $byUser = null): void {
$groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id");
$userId = $this->featureContext->getAttributeOfCreatedUser($user, "id");
$this->featureContext->setResponse($this->removeUserFromGroup($groupId, $userId, $byUser));
$this->featureContext->setResponse($this->removeUserFromGroup($group, $user, $byUser));
}
/**
@@ -1243,9 +1223,7 @@ class GraphContext implements Context {
* @throws GuzzleException
*/
public function theUserTriesToRemoveAnotherUserFromNonExistentGroupUsingTheGraphAPI(string $user, ?string $byUser = null): void {
$groupId = WebDavHelper::generateUUIDv4();
$userId = $this->featureContext->getAttributeOfCreatedUser($user, "id");
$this->featureContext->setResponse($this->removeUserFromGroup($groupId, $userId, $byUser));
$this->featureContext->setResponse($this->removeUserFromGroup('', $user, $byUser));
}
/**
@@ -3640,57 +3640,6 @@ trait Provisioning {
return true;
}
/**
* @param string $user
* @param string $group
*
* @return void
* @throws Exception
*/
public function removeUserFromGroupAsAdminUsingTheProvisioningApi(string $user, string $group):void {
$this->userRemovesUserFromGroupUsingTheProvisioningApi(
$this->getAdminUsername(),
$user,
$group
);
}
/**
* @When the administrator removes user :user from group :group using the provisioning API
*
* @param string $user
* @param string $group
*
* @return void
* @throws Exception
*/
public function adminRemovesUserFromGroupUsingTheProvisioningApi(string $user, string $group):void {
$user = $this->getActualUsername($user);
$this->removeUserFromGroupAsAdminUsingTheProvisioningApi(
$user,
$group
);
$this->pushToLastStatusCodesArrays();
}
/**
* @When the administrator removes the following users from the following groups using the provisioning API
*
* @param TableNode $table
*
* @return void
* @throws Exception
*/
public function theAdministratorRemovesTheFollowingUserFromTheFollowingGroupUsingTheProvisioningApi(TableNode $table):void {
$this->verifyTableNodeColumns($table, ['username', 'groupname']);
$this->emptyLastHTTPStatusCodesArray();
$this->emptyLastOCSStatusCodesArray();
foreach ($table as $row) {
$this->adminRemovesUserFromGroupUsingTheProvisioningApi($row['username'], $row['groupname']);
$this->pushToLastStatusCodesArrays();
}
}
/**
* @Given user :user has been removed from group :group
*
@@ -3707,72 +3656,44 @@ trait Provisioning {
) {
$this->removeUserFromLdapGroup($user, $group);
} elseif (OcisHelper::isTestingWithGraphApi()) {
$this->graphContext->adminHasRemovedUserFromGroupUsingTheGraphApi($user, $group);
} else {
$this->removeUserFromGroupAsAdminUsingTheProvisioningApi(
$user,
$group
);
$user = $this->getActualUsername($user);
$response = $this->graphContext->removeUserFromGroup($group, $user);
$this->TheHTTPStatusCodeShouldBe(204, '', $response);
}
$this->userShouldNotBelongToGroup($user, $group);
}
/**
* @When user :user removes user :otherUser from group :group using the provisioning API
* @When the administrator removes user :user from group :group using the provisioning API
*
* @param string $user
* @param string $otherUser
* @param string $group
*
* @return void
* @throws Exception
*/
public function userRemovesUserFromGroupUsingTheProvisioningApi(
string $user,
string $otherUser,
string $group
):void {
$this->userTriesToRemoveUserFromGroupUsingTheProvisioningApi(
$user,
$otherUser,
$group
);
if ($this->response->getStatusCode() !== 200) {
\error_log(
"INFORMATION: could not remove user '$user' from group '$group'"
. $this->response->getStatusCode() . " " . $this->response->getBody()
public function adminRemovesUserFromGroupUsingTheProvisioningApi(string $user, string $group):void {
$user = $this->getActualUsername($user);
if (OcisHelper::isTestingWithGraphApi()) {
$this->setResponse(
$this->graphContext->removeUserFromGroup(
$group,
$user
)
);
} else {
$this->response = UserHelper::removeUserFromGroup(
$this->getBaseUrl(),
$user,
$group,
$this->getAdminUsername(),
$this->getAdminPassword(),
$this->getStepLineRef(),
$this->ocsApiVersion
);
}
}
/**
* @When user :user tries to remove user :otherUser from group :group using the provisioning API
*
* @param string $user
* @param string $otherUser
* @param string $group
*
* @return void
* @throws Exception
*/
public function userTriesToRemoveUserFromGroupUsingTheProvisioningApi(
string $user,
string $otherUser,
string $group
):void {
$actualUser = $this->getActualUsername($user);
$actualPassword = $this->getUserPassword($actualUser);
$actualOtherUser = $this->getActualUsername($otherUser);
$this->response = UserHelper::removeUserFromGroup(
$this->getBaseUrl(),
$actualOtherUser,
$group,
$actualUser,
$actualPassword,
$this->getStepLineRef(),
$this->ocsApiVersion
);
$this->pushToLastStatusCodesArrays();
}
/**
@@ -3928,55 +3849,6 @@ trait Provisioning {
);
}
/**
* @When the administrator removes user :user from being a subadmin of group :group using the provisioning API
*
* @param string $user
* @param string $group
*
* @return void
*/
public function theAdministratorRemovesUserFromBeingASubadminOfGroupUsingTheProvisioningApi(
string $user,
string $group
):void {
$this->userRemovesUserFromBeingASubadminOfGroupUsingTheProvisioningApi(
$this->getAdminUsername(),
$user,
$group
);
}
/**
* @When user :user removes user :otherUser from being a subadmin of group :group using the provisioning API
*
* @param string $user
* @param string $otherUser
* @param string $group
*
* @return void
* @throws Exception
*/
public function userRemovesUserFromBeingASubadminOfGroupUsingTheProvisioningApi(
string $user,
string $otherUser,
string $group
):void {
$actualOtherUser = $this->getActualUsername($otherUser);
$fullUrl = $this->getBaseUrl()
. "/ocs/v$this->ocsApiVersion.php/cloud/users/$actualOtherUser/subadmins";
$actualUser = $this->getActualUsername($user);
$actualPassword = $this->getUserPassword($actualUser);
$this->response = HttpRequestHelper::delete(
$fullUrl,
$this->getStepLineRef(),
$actualUser,
$actualPassword,
null,
['groupid' => $group]
);
}
/**
* @Then /^the users returned by the API should be$/
*
@@ -1,4 +1,3 @@
@skipOnReva
Feature: sharing
As a user
I want to get all the shares
@@ -144,7 +143,7 @@ Feature: sharing
| 1 | 200 |
| 2 | 404 |
@issue-1289 @skipOnGraph
@issue-1289
Scenario: share a folder to a group, and remove user from that group
Given using OCS API version "1"
And user "Carol" has been created with default attributes and without skeleton files
@@ -155,7 +154,7 @@ Feature: sharing
And user "Alice" has uploaded file with content "some data" to "/PARENT/parent.txt"
And user "Alice" has shared folder "/PARENT" with group "group0"
When the administrator removes user "Carol" from group "group0" using the provisioning API
Then the HTTP status code should be "200"
Then the HTTP status code should be "204"
And user "Brian" should see the following elements
| /Shares/PARENT/ |
| /Shares/PARENT/parent.txt |