mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-03 19:00:05 -06:00
[tests-only][full-ci] refactoring the user delete code from ocs to graphapi (#7020)
* addressing the reviews * addressing the review * refactored test code * updated expected failures file
This commit is contained in:
@@ -591,10 +591,6 @@ Not everything needs to be implemented for ocis. While the oc10 testsuite covers
|
||||
- [coreApiFavorites/favorites.feature:150](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiFavorites/favorites.feature#L150)
|
||||
- [coreApiFavorites/favorites.feature:227](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiFavorites/favorites.feature#L227)
|
||||
|
||||
#### [OCS status code zero](https://github.com/owncloud/ocis/issues/3621)
|
||||
|
||||
- [coreApiShareManagementToShares/moveReceivedShare.feature:13](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiShareManagementToShares/moveReceivedShare.feature#L13)
|
||||
|
||||
#### [HTTP status code differ while deleting file of another user's trash bin](https://github.com/owncloud/ocis/issues/3544)
|
||||
|
||||
- [coreApiTrashbin/trashbinDelete.feature:105](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/coreApiTrashbin/trashbinDelete.feature#L105)
|
||||
|
||||
@@ -346,17 +346,14 @@ class GraphContext implements Context {
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function adminDeletesUserUsingTheGraphApi(string $user, ?string $byUser = null): void {
|
||||
public function adminDeletesUserUsingTheGraphApi(string $user, ?string $byUser = null): ResponseInterface {
|
||||
$credentials = $this->getAdminOrUserCredentials($byUser);
|
||||
|
||||
$this->featureContext->setResponse(
|
||||
GraphHelper::deleteUser(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$this->featureContext->getStepLineRef(),
|
||||
$credentials["username"],
|
||||
$credentials["password"],
|
||||
$user
|
||||
)
|
||||
return GraphHelper::deleteUser(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$this->featureContext->getStepLineRef(),
|
||||
$credentials["username"],
|
||||
$credentials["password"],
|
||||
$user
|
||||
);
|
||||
}
|
||||
|
||||
@@ -442,8 +439,8 @@ class GraphContext implements Context {
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function theUserHasDeletesAUserUsingTheGraphAPI(string $byUser, string $user): void {
|
||||
$this->adminDeletesUserUsingTheGraphApi($user, $byUser);
|
||||
$this->featureContext->thenTheHTTPStatusCodeShouldBe(204);
|
||||
$response = $this->adminDeletesUserUsingTheGraphApi($user, $byUser);
|
||||
$this->featureContext->theHttpStatusCodeShouldBe(204, "", $response);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1425,7 +1425,8 @@ trait Provisioning {
|
||||
*/
|
||||
public function theAdministratorHasDeletedUserUsingTheProvisioningApi(?string $user):void {
|
||||
$user = $this->getActualUsername($user);
|
||||
$this->deleteTheUserUsingTheProvisioningApi($user);
|
||||
$response = $this->deleteUser($user);
|
||||
$this->theHttpStatusCodeShouldBe(204, "", $response);
|
||||
WebDavHelper::removeSpaceIdReferenceForUser($user);
|
||||
$this->userShouldNotExist($user);
|
||||
}
|
||||
@@ -1440,51 +1441,8 @@ trait Provisioning {
|
||||
*/
|
||||
public function theAdminDeletesUserUsingTheProvisioningApi(string $user):void {
|
||||
$user = $this->getActualUsername($user);
|
||||
$this->deleteTheUserUsingTheProvisioningApi($user);
|
||||
$this->rememberThatUserIsNotExpectedToExist($user);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When the administrator deletes the following users using the provisioning API
|
||||
*
|
||||
* @param TableNode $table
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function theAdministratorDeletesTheFollowingUsersUsingTheProvisioningApi(TableNode $table):void {
|
||||
$this->verifyTableNodeColumns($table, ["username"]);
|
||||
$usernames = $table->getHash();
|
||||
foreach ($usernames as $username) {
|
||||
$this->theAdminDeletesUserUsingTheProvisioningApi($username["username"]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @When user :user deletes user :otherUser using the provisioning API
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $otherUser
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function userDeletesUserUsingTheProvisioningApi(
|
||||
string $user,
|
||||
string $otherUser
|
||||
):void {
|
||||
$actualUser = $this->getActualUsername($user);
|
||||
$actualPassword = $this->getUserPassword($actualUser);
|
||||
$actualOtherUser = $this->getActualUsername($otherUser);
|
||||
|
||||
$this->response = UserHelper::deleteUser(
|
||||
$this->getBaseUrl(),
|
||||
$actualOtherUser,
|
||||
$actualUser,
|
||||
$actualPassword,
|
||||
$this->getStepLineRef(),
|
||||
$this->ocsApiVersion
|
||||
);
|
||||
$this->setResponse($this->deleteUser($user));
|
||||
$this->pushToLastHttpStatusCodesArray();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2333,28 +2291,13 @@ trait Provisioning {
|
||||
if ($this->isTestingWithLdap() && \in_array($user, $this->ldapCreatedUsers)) {
|
||||
$this->deleteLdapUser($user);
|
||||
} else {
|
||||
$this->deleteTheUserUsingTheProvisioningApi($user);
|
||||
$response = $this->deleteUser($user);
|
||||
$this->theHTTPStatusCodeShouldBe(204, "", $response);
|
||||
}
|
||||
}
|
||||
$this->userShouldNotExist($user);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given the following users have been deleted
|
||||
*
|
||||
* @param TableNode $table
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function theFollowingUsersHaveBeenDeleted(TableNode $table):void {
|
||||
$this->verifyTableNodeColumns($table, ["username"]);
|
||||
$usernames = $table->getHash();
|
||||
foreach ($usernames as $username) {
|
||||
$this->userHasBeenDeleted($username["username"]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given these users have been initialized:
|
||||
* expects a table of users with the heading
|
||||
@@ -2722,17 +2665,6 @@ trait Provisioning {
|
||||
$this->initializeUser($user, $password);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $user
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function deleteUser(string $user):void {
|
||||
$this->deleteTheUserUsingTheProvisioningApi($user);
|
||||
$this->userShouldNotExist($user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to delete the group, catching anything bad that might happen.
|
||||
* Use this method only in places where you want to try as best you
|
||||
@@ -3538,15 +3470,13 @@ trait Provisioning {
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function deleteTheUserUsingTheProvisioningApi(string $user):void {
|
||||
$this->emptyLastHTTPStatusCodesArray();
|
||||
$this->emptyLastOCSStatusCodesArray();
|
||||
public function deleteUser(string $user):ResponseInterface {
|
||||
// Always try to delete the user
|
||||
if (OcisHelper::isTestingWithGraphApi()) {
|
||||
// users can be deleted using the username in the GraphApi too
|
||||
$this->graphContext->adminDeletesUserUsingTheGraphApi($user);
|
||||
$response = $this->graphContext->adminDeletesUserUsingTheGraphApi($user);
|
||||
} else {
|
||||
$this->response = UserHelper::deleteUser(
|
||||
$response = UserHelper::deleteUser(
|
||||
$this->getBaseUrl(),
|
||||
$user,
|
||||
$this->getAdminUsername(),
|
||||
@@ -3555,22 +3485,7 @@ trait Provisioning {
|
||||
$this->ocsApiVersion
|
||||
);
|
||||
}
|
||||
$this->pushToLastStatusCodesArrays();
|
||||
|
||||
// Only log a message if the test really expected the user to have been
|
||||
// successfully created (i.e. the delete is expected to work) and
|
||||
// there was a problem deleting the user. Because in this case there
|
||||
// might be an effect on later tests.
|
||||
if ($this->theUserShouldExist($user)
|
||||
&& (!\in_array($this->response->getStatusCode(), [200, 204]))
|
||||
) {
|
||||
\error_log(
|
||||
"INFORMATION: could not delete user '$user' "
|
||||
. $this->response->getStatusCode() . " " . $this->response->getBody()
|
||||
);
|
||||
}
|
||||
|
||||
$this->rememberThatUserIsNotExpectedToExist($user);
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -4974,10 +4889,12 @@ trait Provisioning {
|
||||
$this->usingServer('LOCAL');
|
||||
foreach ($this->createdUsers as $userData) {
|
||||
$this->deleteUser($userData['actualUsername']);
|
||||
$this->userShouldNotExist($userData['actualUsername']);
|
||||
}
|
||||
$this->usingServer('REMOTE');
|
||||
foreach ($this->createdRemoteUsers as $userData) {
|
||||
$this->deleteUser($userData['actualUsername']);
|
||||
$this->userShouldNotExist($userData['actualUsername']);
|
||||
}
|
||||
$this->usingServer($previousServer);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ Feature: sharing
|
||||
And user "Brian" moves folder "/Shares/TMP" to "/Shares/new" using the WebDAV API
|
||||
And the administrator deletes user "Carol" using the provisioning API
|
||||
Then the OCS status code of responses on all endpoints should be "100"
|
||||
And the HTTP status code of responses on all endpoints should be "200"
|
||||
And the HTTP status code of responses on each endpoint should be "200, 201, 204" respectively
|
||||
And user "Brian" should see the following elements
|
||||
| /Shares/new/|
|
||||
|
||||
|
||||
Reference in New Issue
Block a user