mirror of
https://github.com/owncloud/ocis
synced 2026-04-25 17:25:21 +02:00
test: test coverage for trying to delete deleted user
This commit is contained in:
@@ -37,6 +37,7 @@ class OcmContext implements Context {
|
||||
private SpacesContext $spacesContext;
|
||||
private ArchiverContext $archiverContext;
|
||||
private string $invitationToken;
|
||||
private array $acceptedUsers = ["LOCAL" => [], "REMOTE" => []];
|
||||
|
||||
/**
|
||||
* This will run before EVERY scenario.
|
||||
@@ -213,12 +214,19 @@ class OcmContext implements Context {
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function findAcceptedUsers(string $user): ResponseInterface {
|
||||
return OcmHelper::findAcceptedUsers(
|
||||
$currentServer = $this->featureContext->getCurrentServer();
|
||||
$response = OcmHelper::findAcceptedUsers(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$this->featureContext->getStepLineRef(),
|
||||
$user,
|
||||
$this->featureContext->getPasswordForUser($user)
|
||||
);
|
||||
if ($response->getStatusCode() === 200) {
|
||||
$users = $this->featureContext->getJsonDecodedResponse($response);
|
||||
$this->acceptedUsers[$currentServer] = \array_merge($this->acceptedUsers[$currentServer], $users);
|
||||
$response->getBody()->rewind();
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -242,10 +250,25 @@ class OcmContext implements Context {
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function getAcceptedUserByName(string $user, string $ocmUserName): array {
|
||||
$users = ($this->featureContext->getJsonDecodedResponse($this->findAcceptedUsers($user)));
|
||||
foreach ($users as $user) {
|
||||
if (strpos($user["display_name"], $ocmUserName) !== false) {
|
||||
return $user;
|
||||
$currentServer = $this->featureContext->getCurrentServer();
|
||||
$displayName = $this->featureContext->getUserDisplayName($ocmUserName);
|
||||
$acceptedUsers = $this->acceptedUsers[$currentServer];
|
||||
foreach ($acceptedUsers as $acceptedUser) {
|
||||
if ($acceptedUser["display_name"] === $displayName) {
|
||||
return $acceptedUser;
|
||||
}
|
||||
}
|
||||
// fetch the accepted users
|
||||
$response = $this->findAcceptedUsers($user);
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe(
|
||||
200,
|
||||
"failed to list accepted users by '$user'",
|
||||
$response
|
||||
);
|
||||
$users = ($this->featureContext->getJsonDecodedResponse($response));
|
||||
foreach ($users as $acceptedUser) {
|
||||
if ($acceptedUser["display_name"] === $displayName) {
|
||||
return $acceptedUser;
|
||||
}
|
||||
}
|
||||
throw new \Exception("Could not find user with name '{$ocmUserName}' in the accepted users list.");
|
||||
@@ -292,6 +315,7 @@ class OcmContext implements Context {
|
||||
|
||||
/**
|
||||
* @When user :user deletes federated connection with user :ocmUser using the Graph API
|
||||
* @When user :user tries to delete federated connection with user :ocmUser using the Graph API
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $ocmUser
|
||||
|
||||
Reference in New Issue
Block a user