adjust ocm sharing tests

This commit is contained in:
Viktor Scharf
2024-09-24 15:59:10 +02:00
parent a70ec12917
commit 99ecc5a752
4 changed files with 73 additions and 42 deletions

View File

@@ -2538,15 +2538,16 @@ class GraphContext implements Context {
}
/**
* @When /^user "([^"]*)" lists the shares shared with (?:him|her)(| after clearing user cache) using the Graph API$/
* @When /^user "([^"]*)" lists the shares shared with (?:him|her)(| after clearing user cache)(| without retry) using the Graph API$/
*
* @param string $user
* @param string $cacheStepString
* @param string $retryOption
*
* @return void
* @throws GuzzleException
*/
public function userListsTheResourcesSharedWithThemUsingGraphApi(string $user, string $cacheStepString): void {
public function userListsTheResourcesSharedWithThemUsingGraphApi(string $user, string $cacheStepString, string $retryOption): void {
if ($cacheStepString !== '') {
// ENV (GRAPH_SPACES_GROUPS_CACHE_TTL | GRAPH_SPACES_USERS_CACHE_TTL) is set default to 60 sec
// which means 60 sec is required to clean up all the user|group cache once they are deleted
@@ -2559,6 +2560,7 @@ class GraphContext implements Context {
// Sometimes listing shares might not return the updated shares list
// so try again until @client.synchronize is true for the max. number of retries (i.e. 10)
// and do not retry when the share is expected to be not synced
$retryEnabled = ($retryOption === '');
$tryAgain = false;
$retried = 0;
do {
@@ -2571,17 +2573,19 @@ class GraphContext implements Context {
$jsonBody = $this->featureContext->getJsonDecodedResponseBodyContent($response);
foreach ($jsonBody->value as $share) {
$autoSync = $this->featureContext->getUserAutoSyncSetting($credentials['username']);
$tryAgain = !$share->{'@client.synchronize'} && $autoSync && $retried < HttpRequestHelper::numRetriesOnHttpTooEarly();
if ($retryEnabled) {
foreach ($jsonBody->value as $share) {
$autoSync = $this->featureContext->getUserAutoSyncSetting($credentials['username']);
$tryAgain = !$share->{'@client.synchronize'} && $autoSync && $retried < HttpRequestHelper::numRetriesOnHttpTooEarly();
if ($tryAgain) {
$retried += 1;
echo "auto-sync share for user '$user' is enabled\n";
echo "but share '$share->name' was not auto-synced, retrying ($retried)...\n";
// wait 500ms and try again
\usleep(500 * 1000);
break;
if ($tryAgain) {
$retried += 1;
echo "auto-sync share for user '$user' is enabled\n";
echo "but share '$share->name' was not auto-synced, retrying ($retried)...\n";
// wait 500ms and try again
\usleep(500 * 1000);
break;
}
}
}
} while ($tryAgain);

View File

@@ -239,6 +239,7 @@ class SharingNgContext implements Context {
* @param string $user
* @param array $shareInfo
* @param string|null $fileId
* @param bool $isFederated
*
* @return ResponseInterface
*
@@ -246,7 +247,7 @@ class SharingNgContext implements Context {
* @throws GuzzleException
* @throws Exception
*/
public function sendShareInvitation(string $user, array $shareInfo, string $fileId = null): ResponseInterface {
public function sendShareInvitation(string $user, array $shareInfo, string $fileId = null, $isFederated = false): ResponseInterface {
if ($shareInfo['space'] === 'Personal' || $shareInfo['space'] === 'Shares') {
$space = $this->spacesContext->getSpaceByName($user, $shareInfo['space']);
} else {
@@ -282,6 +283,9 @@ class SharingNgContext implements Context {
$shareeId = "";
if ($shareType === "user") {
$shareeId = $this->featureContext->getAttributeOfCreatedUser($sharee, 'id');
if ($isFederated) {
$shareeId = base64_encode($shareeId . $shareInfo['federatedServer']);
}
} elseif ($shareType === "group") {
$shareeId = $this->featureContext->getAttributeOfCreatedGroup($sharee, 'id');
}
@@ -426,6 +430,24 @@ class SharingNgContext implements Context {
);
}
/**
* @When /^user "([^"]*)" sends the following resource share invitation to federated user using the Graph API:$/
*
* @param string $user
* @param TableNode $table
*
* @return void
* @throws Exception
* @throws GuzzleException
*/
public function userSendsTheFollowingResourceShareInvitationTofederatedUserUsingTheGraphApi(string $user, TableNode $table): void {
$rows = $table->getRowsHash();
Assert::assertArrayHasKey("resource", $rows, "'resource' should be provided in the data-table while sharing a resource");
$this->featureContext->setResponse(
$this->sendShareInvitation($user, $rows, null, true)
);
}
/**
* @When /^user "([^"]*)" sends the following space share invitation using permissions endpoint of the Graph API:$/
*