Merge pull request #11017 from owncloud/test/test-coverage-for-deleted-user

[tests-only][full-ci] Test coverage for federated user trying to delete deleted federation connection
This commit is contained in:
Pradip Subedi
2025-03-24 12:16:39 +05:45
committed by GitHub
3 changed files with 52 additions and 25 deletions

View File

@@ -40,6 +40,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.
@@ -217,12 +218,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;
}
/**
@@ -246,10 +254,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.");
@@ -296,6 +319,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