mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-05 19:59:37 -06:00
[tests-only][full-ci] Restructure the steps implementation for group delete to use graph API endpoint (#8006) (#8227)
* remove ocs endpoint from delete group * remove adminHasDeletedGroupUsingTheGraphApi * adressing reviews
This commit is contained in:
@@ -188,68 +188,6 @@ class UserHelper {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string|null $baseUrl
|
||||
* @param string|null $group
|
||||
* @param string|null $adminUser
|
||||
* @param string|null $adminPassword
|
||||
* @param string|null $xRequestId
|
||||
*
|
||||
* @return ResponseInterface
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public static function createGroup(
|
||||
?string $baseUrl,
|
||||
?string $group,
|
||||
?string $adminUser,
|
||||
?string $adminPassword,
|
||||
?string $xRequestId = ''
|
||||
):ResponseInterface {
|
||||
return OcsApiHelper::sendRequest(
|
||||
$baseUrl,
|
||||
$adminUser,
|
||||
$adminPassword,
|
||||
"POST",
|
||||
"/cloud/groups",
|
||||
$xRequestId,
|
||||
['groupid' => $group]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string|null $baseUrl
|
||||
* @param string|null $group
|
||||
* @param string|null $adminUser
|
||||
* @param string|null $adminPassword
|
||||
* @param string|null $xRequestId
|
||||
* @param int|null $ocsApiVersion
|
||||
*
|
||||
* @return ResponseInterface
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public static function deleteGroup(
|
||||
?string $baseUrl,
|
||||
?string $group,
|
||||
?string $adminUser,
|
||||
?string $adminPassword,
|
||||
?string $xRequestId = '',
|
||||
?int $ocsApiVersion = 2
|
||||
):ResponseInterface {
|
||||
$group = \rawurlencode($group);
|
||||
return OcsApiHelper::sendRequest(
|
||||
$baseUrl,
|
||||
$adminUser,
|
||||
$adminPassword,
|
||||
"DELETE",
|
||||
"/cloud/groups/" . $group,
|
||||
$xRequestId,
|
||||
[],
|
||||
$ocsApiVersion
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string|null $baseUrl
|
||||
|
||||
@@ -287,21 +287,15 @@ class GraphContext implements Context {
|
||||
|
||||
/**
|
||||
* @param string $groupId
|
||||
* @param bool $checkResult
|
||||
*
|
||||
* @return void
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function adminDeletesGroupWithGroupId(
|
||||
string $groupId,
|
||||
bool $checkResult = false
|
||||
string $groupId
|
||||
): void {
|
||||
$this->featureContext->setResponse(
|
||||
$this->userDeletesGroupWithGroupId($groupId)
|
||||
);
|
||||
if ($checkResult) {
|
||||
$this->featureContext->thenTheHTTPStatusCodeShouldBe(204);
|
||||
}
|
||||
$response = $this->userDeletesGroupWithGroupId($groupId);
|
||||
$this->featureContext->theHTTPStatusCodeShouldBe(204, "", $response);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -315,26 +309,7 @@ class GraphContext implements Context {
|
||||
string $group
|
||||
): void {
|
||||
$groupId = $this->featureContext->getAttributeOfCreatedGroup($group, "id");
|
||||
if ($groupId) {
|
||||
$this->adminDeletesGroupWithGroupId($groupId);
|
||||
} else {
|
||||
throw new Exception(
|
||||
"Group id does not exist for '$group' in the created list."
|
||||
. " Cannot delete group without id when using the Graph API."
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $group
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function adminHasDeletedGroupUsingTheGraphApi(string $group): void {
|
||||
$this->adminDeletesGroupUsingTheGraphApi($group);
|
||||
$this->featureContext->thenTheHTTPStatusCodeShouldBe(204);
|
||||
$this->adminDeletesGroupWithGroupId($groupId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2672,10 +2672,10 @@ trait Provisioning {
|
||||
*/
|
||||
public function cleanupGroup(string $group):void {
|
||||
try {
|
||||
if (OcisHelper::isTestingWithGraphApi()) {
|
||||
$this->graphContext->adminHasDeletedGroupUsingTheGraphApi($group);
|
||||
if ($this->isTestingWithLdap()) {
|
||||
$this->deleteLdapGroup($group);
|
||||
} else {
|
||||
$this->deleteTheGroupUsingTheProvisioningApi($group);
|
||||
$this->graphContext->adminDeletesGroupUsingTheGraphApi($group);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
\error_log(
|
||||
@@ -3467,23 +3467,6 @@ trait Provisioning {
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $group group name
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
* @throws LdapException
|
||||
*/
|
||||
public function deleteGroup(string $group):void {
|
||||
if ($this->groupExists($group)) {
|
||||
if ($this->isTestingWithLdap() && \in_array($group, $this->ldapCreatedGroups)) {
|
||||
$this->deleteLdapGroup($group);
|
||||
} else {
|
||||
$this->deleteTheGroupUsingTheProvisioningApi($group);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given /^group "([^"]*)" has been deleted$/
|
||||
*
|
||||
@@ -3494,96 +3477,14 @@ trait Provisioning {
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function groupHasBeenDeleted(string $group):void {
|
||||
if (OcisHelper::isTestingWithGraphApi()) {
|
||||
$this->graphContext->adminHasDeletedGroupUsingTheGraphApi($group);
|
||||
if ($this->isTestingWithLdap()) {
|
||||
$this->deleteLdapGroup($group);
|
||||
} else {
|
||||
$this->deleteGroup($group);
|
||||
$this->graphContext->adminDeletesGroupUsingTheGraphApi($group);
|
||||
}
|
||||
$this->groupShouldNotExist($group);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^the administrator deletes group "([^"]*)" from the default user backend$/
|
||||
*
|
||||
* @param string $group
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function adminDeletesGroup(string $group):void {
|
||||
$this->deleteGroup($group);
|
||||
$this->pushToLastStatusCodesArrays();
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^the administrator deletes group "([^"]*)" using the provisioning API$/
|
||||
*
|
||||
* @param string $group
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function deleteTheGroupUsingTheProvisioningApi(string $group):void {
|
||||
$this->emptyLastHTTPStatusCodesArray();
|
||||
$this->emptyLastOCSStatusCodesArray();
|
||||
$this->response = UserHelper::deleteGroup(
|
||||
$this->getBaseUrl(),
|
||||
$group,
|
||||
$this->getAdminUsername(),
|
||||
$this->getAdminPassword(),
|
||||
$this->getStepLineRef(),
|
||||
$this->ocsApiVersion
|
||||
);
|
||||
$this->pushToLastStatusCodesArrays();
|
||||
if ($this->theGroupShouldExist($group)
|
||||
&& $this->theGroupShouldBeAbleToBeDeleted($group)
|
||||
&& ($this->response->getStatusCode() !== 200)
|
||||
) {
|
||||
\error_log(
|
||||
"INFORMATION: could not delete group '$group'"
|
||||
. $this->response->getStatusCode() . " " . $this->response->getBody()
|
||||
);
|
||||
}
|
||||
|
||||
$this->rememberThatGroupIsNotExpectedToExist($group);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When the administrator deletes the following groups using the provisioning API
|
||||
*
|
||||
* @param TableNode $table
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function theAdministratorDeletesTheFollowingGroupsUsingTheProvisioningApi(TableNode $table):void {
|
||||
$this->verifyTableNodeColumns($table, ["groupname"]);
|
||||
$groups = $table->getHash();
|
||||
foreach ($groups as $group) {
|
||||
$this->deleteTheGroupUsingTheProvisioningApi($group["groupname"]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @When user :user tries to delete group :group using the provisioning API
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $group
|
||||
*
|
||||
* @return void
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function userTriesToDeleteGroupUsingTheProvisioningApi(string $user, string $group):void {
|
||||
$this->response = UserHelper::deleteGroup(
|
||||
$this->getBaseUrl(),
|
||||
$group,
|
||||
$this->getActualUsername($user),
|
||||
$this->getActualPassword($user),
|
||||
$this->getStepLineRef(),
|
||||
$this->ocsApiVersion
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $group
|
||||
*
|
||||
|
||||
@@ -452,13 +452,13 @@ Feature: sharing
|
||||
Then the OCS status code should be "<ocs_status_code>"
|
||||
And the HTTP status code should be "200"
|
||||
And the fields of the last response to user "Alice" sharing with group "grp1" should include
|
||||
| share_with | grp1 |
|
||||
| file_target | /textfile0.txt |
|
||||
| path | /textfile0.txt |
|
||||
| uid_owner | %username% |
|
||||
| share_with | grp1 |
|
||||
| file_target | /Shares/textfile0.txt |
|
||||
| path | /textfile0.txt |
|
||||
| uid_owner | %username% |
|
||||
Then as "Brian" file "/Shares/textfile0.txt" should exist
|
||||
And as "Carol" file "/Shares/textfile0.txt" should exist
|
||||
When the administrator deletes group "grp1" using the provisioning API
|
||||
When the administrator deletes group "grp1" using the Graph API
|
||||
And user "Alice" sends HTTP method "GET" to OCS API endpoint "/apps/files_sharing/api/v1/shares"
|
||||
Then the OCS status code should be "<ocs_status_code>"
|
||||
And the HTTP status code should be "200"
|
||||
|
||||
Reference in New Issue
Block a user