test: add step to wait until shares are synced
This commit is contained in:
@@ -26,6 +26,7 @@ use Psr\Http\Message\ResponseInterface;
|
|||||||
use TestHelpers\GraphHelper;
|
use TestHelpers\GraphHelper;
|
||||||
use TestHelpers\OcisHelper;
|
use TestHelpers\OcisHelper;
|
||||||
use TestHelpers\WebDavHelper;
|
use TestHelpers\WebDavHelper;
|
||||||
|
use TestHelpers\HttpRequestHelper;
|
||||||
use Behat\Gherkin\Node\TableNode;
|
use Behat\Gherkin\Node\TableNode;
|
||||||
use PHPUnit\Framework\Assert;
|
use PHPUnit\Framework\Assert;
|
||||||
|
|
||||||
@@ -1240,6 +1241,65 @@ class SharingNgContext implements Context {
|
|||||||
$this->featureContext->setResponse($response);
|
$this->featureContext->setResponse($response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $user
|
||||||
|
* @param string $resource
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @throws GuzzleException
|
||||||
|
*/
|
||||||
|
public function isShareSynced(string $user, string $resource): bool {
|
||||||
|
$resource = \trim($resource, '/');
|
||||||
|
$response = GraphHelper::getSharesSharedWithMe(
|
||||||
|
$this->featureContext->getBaseUrl(),
|
||||||
|
$this->featureContext->getStepLineRef(),
|
||||||
|
$user,
|
||||||
|
$this->featureContext->getPasswordForUser($user)
|
||||||
|
);
|
||||||
|
|
||||||
|
$shares = $this->featureContext->getJsonDecodedResponse($response)["value"];
|
||||||
|
$syncStatus = false;
|
||||||
|
foreach ($shares as $share) {
|
||||||
|
if ($share["name"] === $resource) {
|
||||||
|
$syncStatus = $share["@client.synchronize"];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $syncStatus === true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Then /^user "([^"]*)" has a share "([^"]*)" synced$/
|
||||||
|
*
|
||||||
|
* @param string $user
|
||||||
|
* @param string $resource
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @throws GuzzleException
|
||||||
|
*/
|
||||||
|
public function userHasShareSynced(string $user, string $resource): void {
|
||||||
|
$shareSynced = false;
|
||||||
|
|
||||||
|
// Sharing is async so it might take some time for the share to be available
|
||||||
|
$retried = 0;
|
||||||
|
do {
|
||||||
|
$shareSynced = $this->isShareSynced($user, $resource);
|
||||||
|
|
||||||
|
$tryAgain = !$shareSynced && $retried < HttpRequestHelper::numRetriesOnHttpTooEarly();
|
||||||
|
if ($tryAgain) {
|
||||||
|
$retried += 1;
|
||||||
|
echo "[INFO] Wait for shares to be available...";
|
||||||
|
// wait 500ms and try again
|
||||||
|
\usleep(500 * 1000);
|
||||||
|
}
|
||||||
|
} while ($tryAgain);
|
||||||
|
|
||||||
|
Assert::assertTrue(
|
||||||
|
$shareSynced,
|
||||||
|
"Share '$resource' is expected to be synced but not"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Then /^user "([^"]*)" should have sync (enabled|disabled) for share "([^"]*)"$/
|
* @Then /^user "([^"]*)" should have sync (enabled|disabled) for share "([^"]*)"$/
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -180,6 +180,7 @@ Feature: sharing
|
|||||||
| sharee | grp1 |
|
| sharee | grp1 |
|
||||||
| shareType | group |
|
| shareType | group |
|
||||||
| permissionsRole | Viewer |
|
| permissionsRole | Viewer |
|
||||||
|
And user "Carol" has a share "/TMP" synced
|
||||||
When user "Carol" moves folder "/Shares/TMP" to "/Shares/new" using the WebDAV API
|
When user "Carol" moves folder "/Shares/TMP" to "/Shares/new" using the WebDAV API
|
||||||
And the administrator deletes user "Carol" using the provisioning API
|
And the administrator deletes user "Carol" using the provisioning API
|
||||||
Then the HTTP status code of responses on each endpoint should be "201, 204" respectively
|
Then the HTTP status code of responses on each endpoint should be "201, 204" respectively
|
||||||
|
|||||||
Reference in New Issue
Block a user