Skip to content

Commit

Permalink
add test for move and rename file between space in project-space (#7653)
Browse files Browse the repository at this point in the history
  • Loading branch information
nabim777 authored and nirajacharya2 committed Nov 27, 2023
1 parent ed46fa9 commit c76289c
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 50 deletions.
2 changes: 1 addition & 1 deletion tests/acceptance/features/bootstrap/GraphContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ public function adminHasDeletedGroupUsingTheGraphApi(string $group): void {
* @param string $user username is used as the id
* @param string|null $byUser
*
* @return void
* @return ResponseInterface
* @throws GuzzleException
*/
public function adminDeletesUserUsingTheGraphApi(string $user, ?string $byUser = null): ResponseInterface {
Expand Down
101 changes: 52 additions & 49 deletions tests/acceptance/features/bootstrap/Provisioning.php
Original file line number Diff line number Diff line change
Expand Up @@ -1441,8 +1441,11 @@ public function theAdministratorHasDeletedUserUsingTheProvisioningApi(?string $u
*/
public function theAdminDeletesUserUsingTheProvisioningApi(string $user):void {
$user = $this->getActualUsername($user);
$this->setResponse($this->deleteUser($user));
$this->pushToLastHttpStatusCodesArray();
$this->response = $this->deleteUser($user);
$this->pushToLastHttpStatusCodesArray(
(string) $this->response->getStatusCode()
);
$this->rememberThatUserIsNotExpectedToExist($user);
}

/**
Expand Down Expand Up @@ -1524,15 +1527,15 @@ public function theAdministratorHasChangedTheirOwnEmailAddressTo(?string $email)
* @param string $targetUser
* @param string $email
*
* @return void
* @return ResponseInterface
* @throws JsonException
*/
public function userChangesUserEmailUsingProvisioningApi(
string $requestingUser,
string $targetUser,
string $email
):void {
$this->response = UserHelper::editUser(
):ResponseInterface {
return UserHelper::editUser(
$this->getBaseUrl(),
$this->getActualUsername($targetUser),
'email',
Expand Down Expand Up @@ -1585,7 +1588,7 @@ public function userTriesToChangeTheEmailOfUserUsingTheProvisioningApi(
):void {
$requestingUser = $this->getActualUsername($requestingUser);
$targetUser = $this->getActualUsername($targetUser);
$this->userChangesUserEmailUsingProvisioningApi(
$this->response = $this->userChangesUserEmailUsingProvisioningApi(
$requestingUser,
$targetUser,
$email
Expand Down Expand Up @@ -1625,12 +1628,12 @@ public function userHasChangedTheEmailOfUserUsingTheProvisioningApi(
$updatedUserData['mail'],
);
} else {
$this->userChangesUserEmailUsingProvisioningApi(
$response = $this->userChangesUserEmailUsingProvisioningApi(
$requestingUser,
$targetUser,
$email
);
$this->theHTTPStatusCodeShouldBeSuccess();
$this->theHTTPStatusCodeShouldBeBetween(200, 299, $response);
}
$this->rememberUserEmailAddress($targetUser, $email);
}
Expand Down Expand Up @@ -1708,8 +1711,7 @@ public function adminHasChangedTheDisplayNameOfUser(
$this->getAdminPassword(),
$this->getStepLineRef()
);
$this->setResponse($response);
$this->theDisplayNameReturnedByTheApiShouldBe($displayName);
$this->theDisplayNameReturnedByTheApiShouldBe($displayName, $response);
}
$this->rememberUserDisplayName($user, $displayName);
}
Expand All @@ -1734,7 +1736,7 @@ public function adminChangesTheDisplayOfUserUsingTheProvisioningApi(
string $displayName
):void {
$user = $this->getActualUsername($user);
$this->adminChangesTheDisplayNameOfUserUsingKey(
$this->response = $this->adminChangesTheDisplayNameOfUserUsingKey(
$user,
'display',
$displayName
Expand All @@ -1748,14 +1750,14 @@ public function adminChangesTheDisplayOfUserUsingTheProvisioningApi(
* @param string $key
* @param string $displayName
*
* @return void
* @return ResponseInterface
* @throws Exception
*/
public function adminChangesTheDisplayNameOfUserUsingKey(
string $user,
string $key,
string $displayName
):void {
):ResponseInterface {
$result = UserHelper::editUser(
$this->getBaseUrl(),
$this->getActualUsername($user),
Expand All @@ -1766,13 +1768,14 @@ public function adminChangesTheDisplayNameOfUserUsingKey(
$this->getStepLineRef(),
$this->ocsApiVersion
);
$this->response = $result;
// $this->response = $result;
if ($result->getStatusCode() !== 200) {
throw new Exception(
__METHOD__ . " could not change display name of user using key $key "
. $result->getStatusCode() . " " . $result->getBody()
);
}
return $result;
}

/**
Expand Down Expand Up @@ -1827,7 +1830,7 @@ public function userTriesToChangeTheDisplayNameOfUserUsingTheProvisioningApi(
):void {
$requestingUser = $this->getActualUsername($requestingUser);
$targetUser = $this->getActualUsername($targetUser);
$this->userChangesTheDisplayNameOfUserUsingKey(
$this->response = $this->userChangesTheDisplayNameOfUserUsingKey(
$requestingUser,
$targetUser,
'displayname',
Expand Down Expand Up @@ -1902,13 +1905,14 @@ public function userHasChangedTheDisplayNameOfUserUsingTheProvisioningApi(
$updatedUserData['displayName']
);
} else {
$this->userChangesTheDisplayNameOfUserUsingKey(
$response = $this->userChangesTheDisplayNameOfUserUsingKey(
$requestingUser,
$targetUser,
'displayname',
$displayName
);
$this->theHTTPStatusCodeShouldBeSuccess();
$this->theHTTPStatusCodeShouldBeBetween(200, 299, $response);
}
$this->rememberUserDisplayName($targetUser, $displayName);
}
Expand All @@ -1919,15 +1923,15 @@ public function userHasChangedTheDisplayNameOfUserUsingTheProvisioningApi(
* @param string $key
* @param string $displayName
*
* @return void
* @return ResponseInterface
*/
public function userChangesTheDisplayNameOfUserUsingKey(
string $requestingUser,
string $targetUser,
string $key,
string $displayName
):void {
$result = UserHelper::editUser(
):ResponseInterface {
return UserHelper::editUser(
$this->getBaseUrl(),
$this->getActualUsername($targetUser),
$key,
Expand Down Expand Up @@ -1993,14 +1997,14 @@ public function adminHasChangedTheQuotaOfUserTo(
* @param string $targetUser
* @param string $quota
*
* @return void
* @return ResponseInterface
*/
public function userChangeQuotaOfUserUsingProvisioningApi(
string $requestingUser,
string $targetUser,
string $quota
):void {
$result = UserHelper::editUser(
):ResponseInterface {
return UserHelper::editUser(
$this->getBaseUrl(),
$this->getActualUsername($targetUser),
'quota',
Expand All @@ -2010,7 +2014,6 @@ public function userChangeQuotaOfUserUsingProvisioningApi(
$this->getStepLineRef(),
$this->ocsApiVersion
);
$this->response = $result;
}

/**
Expand All @@ -2027,7 +2030,7 @@ public function userChangesTheQuotaOfUserUsingTheProvisioningApi(
string $targetUser,
string $quota
):void {
$this->userChangeQuotaOfUserUsingProvisioningApi(
$this->response = $this->userChangeQuotaOfUserUsingProvisioningApi(
$requestingUser,
$targetUser,
$quota
Expand All @@ -2049,24 +2052,24 @@ public function userHasChangedTheQuotaOfUserUsingTheProvisioningApi(
string $targetUser,
string $quota
):void {
$this->userChangeQuotaOfUserUsingProvisioningApi(
$response = $this->userChangeQuotaOfUserUsingProvisioningApi(
$requestingUser,
$targetUser,
$quota
);
$this->theHTTPStatusCodeShouldBeSuccess();
$this->theHTTPStatusCodeShouldBeBetween(200, 299, $response);
}

/**
* @param string $user
*
* @return void
* @return ResponseInterface
* @throws JsonException
*/
public function retrieveUserInformationAsAdminUsingProvisioningApi(
string $user
):void {
$result = UserHelper::getUser(
):ResponseInterface {
return UserHelper::getUser(
$this->getBaseUrl(),
$this->getActualUsername($user),
$this->getAdminUsername(),
Expand Down Expand Up @@ -2813,18 +2816,18 @@ public function userShouldNotBelongToGroup(string $user, string $group):void {
$this->graphContext->userShouldNotBeMemberInGroupUsingTheGraphApi($user, $group);
} else {
$fullUrl = $this->getBaseUrl() . "/ocs/v2.php/cloud/users/$user/groups";
$this->response = HttpRequestHelper::get(
$response = HttpRequestHelper::get(
$fullUrl,
$this->getStepLineRef(),
$this->getAdminUsername(),
$this->getAdminPassword()
);
$respondedArray = $this->getArrayOfGroupsResponded($this->response);
$respondedArray = $this->getArrayOfGroupsResponded($response);
\sort($respondedArray);
Assert::assertNotContains($group, $respondedArray);
Assert::assertEquals(
200,
$this->response->getStatusCode()
$response->getStatusCode()
);
}
}
Expand Down Expand Up @@ -2856,13 +2859,13 @@ public function theTheFollowingUserShouldNotBelongToTheFollowingGroup(TableNode
public function groupShouldNotContainUser(string $group, string $username):void {
$username = $this->getActualUsername($username);
$fullUrl = $this->getBaseUrl() . "/ocs/v2.php/cloud/groups/$group";
$this->response = HttpRequestHelper::get(
$response = HttpRequestHelper::get(
$fullUrl,
$this->getStepLineRef(),
$this->getAdminUsername(),
$this->getAdminPassword()
);
$this->theUsersReturnedByTheApiShouldNotInclude($username);
$this->theUsersReturnedByTheApiShouldNotInclude($username, $response);
}

/**
Expand Down Expand Up @@ -4217,13 +4220,13 @@ public function theAppsShouldNotInclude(?TableNode $appList):void {
*/
public function appShouldNotBeInTheAppsList(string $appName):void {
$fullUrl = $this->getBaseUrl() . "/ocs/v2.php/cloud/apps";
$this->response = HttpRequestHelper::get(
$response = HttpRequestHelper::get(
$fullUrl,
$this->getStepLineRef(),
$this->getAdminUsername(),
$this->getAdminPassword()
);
$respondedArray = $this->getArrayOfAppsResponded($this->response);
$respondedArray = $this->getArrayOfAppsResponded($response);
Assert::assertNotContains($appName, $respondedArray);
}

Expand Down Expand Up @@ -4539,17 +4542,17 @@ public function getArrayOfAppInfoResponded(ResponseInterface $resp):array {
public function appShouldBeDisabled(string $app):void {
$fullUrl = $this->getBaseUrl()
. "/ocs/v2.php/cloud/apps?filter=disabled";
$this->response = HttpRequestHelper::get(
$response = HttpRequestHelper::get(
$fullUrl,
$this->getStepLineRef(),
$this->getAdminUsername(),
$this->getAdminPassword()
);
$respondedArray = $this->getArrayOfAppsResponded($this->response);
$respondedArray = $this->getArrayOfAppsResponded($response);
Assert::assertContains($app, $respondedArray);
Assert::assertEquals(
200,
$this->response->getStatusCode()
$response->getStatusCode()
);
}

Expand All @@ -4563,17 +4566,17 @@ public function appShouldBeDisabled(string $app):void {
*/
public function appShouldBeEnabled(string $app):void {
$fullUrl = $this->getBaseUrl() . "/ocs/v2.php/cloud/apps?filter=enabled";
$this->response = HttpRequestHelper::get(
$response = HttpRequestHelper::get(
$fullUrl,
$this->getStepLineRef(),
$this->getAdminUsername(),
$this->getAdminPassword()
);
$respondedArray = $this->getArrayOfAppsResponded($this->response);
$respondedArray = $this->getArrayOfAppsResponded($response);
Assert::assertContains($app, $respondedArray);
Assert::assertEquals(
200,
$this->response->getStatusCode()
$response->getStatusCode()
);
}

Expand All @@ -4587,17 +4590,17 @@ public function appShouldBeEnabled(string $app):void {
*/
public function theInformationForAppShouldHaveAValidVersion(string $app):void {
$fullUrl = $this->getBaseUrl() . "/ocs/v2.php/cloud/apps/$app";
$this->response = HttpRequestHelper::get(
$response = HttpRequestHelper::get(
$fullUrl,
$this->getStepLineRef(),
$this->getAdminUsername(),
$this->getAdminPassword()
);
Assert::assertEquals(
200,
$this->response->getStatusCode()
$response->getStatusCode()
);
$respondedArray = $this->getArrayOfAppInfoResponded($this->response);
$respondedArray = $this->getArrayOfAppInfoResponded($response);
Assert::assertArrayHasKey(
'version',
$respondedArray,
Expand All @@ -4622,15 +4625,15 @@ public function userShouldBeDisabled(string $user):void {
$user = $this->getActualUsername($user);
$fullUrl = $this->getBaseUrl()
. "/ocs/v$this->ocsApiVersion.php/cloud/users/$user";
$this->response = HttpRequestHelper::get(
$response = HttpRequestHelper::get(
$fullUrl,
$this->getStepLineRef(),
$this->getAdminUsername(),
$this->getAdminPassword()
);
Assert::assertEquals(
"false",
$this->getResponseXml(null, __METHOD__)->data[0]->enabled
$this->getResponseXml($response, __METHOD__)->data[0]->enabled
);
}

Expand Down Expand Up @@ -4662,15 +4665,15 @@ public function userShouldBeEnabled(string $user):void {
$user = $this->getActualUsername($user);
$fullUrl = $this->getBaseUrl()
. "/ocs/v$this->ocsApiVersion.php/cloud/users/$user";
$this->response = HttpRequestHelper::get(
$response = HttpRequestHelper::get(
$fullUrl,
$this->getStepLineRef(),
$this->getAdminUsername(),
$this->getAdminPassword()
);
Assert::assertEquals(
"true",
$this->getResponseXml(null, __METHOD__)->data[0]->enabled
$this->getResponseXml($response, __METHOD__)->data[0]->enabled
);
}

Expand Down

0 comments on commit c76289c

Please sign in to comment.