Merge pull request #10149 from owncloud/enableOcmSharingTests

[test-only] adjust ocm sharing tests
This commit is contained in:
Viktor Scharf
2024-09-25 12:21:17 +02:00
committed by GitHub
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:$/
*

View File

@@ -254,11 +254,6 @@ The expected failures in this file are from features in the owncloud/ocis repo.
- [apiSpacesDavOperation/moveByFileId.feature:492](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpacesDavOperation/moveByFileId.feature#L492)
- [apiSpacesDavOperation/moveByFileId.feature:493](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpacesDavOperation/moveByFileId.feature#L493)
#### [OCM. sharing issues](https://github.com/owncloud/ocis/issues/9534)
- [apiOcm/share.feature:12](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiOcm/share.feature#L12)
- [apiOcm/share.feature:91](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiOcm/share.feature#L91)
#### [OCM. admin cannot get federated users if he hasn't connection with them ](https://github.com/owncloud/ocis/issues/9829)
tests/acceptance/features/apiOcm/searchFederationUsers.feature

View File

@@ -16,15 +16,16 @@ Feature: an user shares resources usin ScienceMesh application
And "Brian" has accepted invitation
And using server "LOCAL"
And user "Alice" has created folder "folderToShare"
When user "Alice" sends the following resource share invitation using the Graph API:
| resource | folderToShare |
| space | Personal |
| sharee | Brian |
| shareType | user |
| permissionsRole | Viewer |
When user "Alice" sends the following resource share invitation to federated user using the Graph API:
| resource | folderToShare |
| space | Personal |
| sharee | Brian |
| shareType | user |
| permissionsRole | Viewer |
| federatedServer | @federation-ocis-server:10200 |
Then the HTTP status code should be "200"
When using server "REMOTE"
And user "Brian" lists the shares shared with him using the Graph API
And user "Brian" lists the shares shared with him without retry using the Graph API
Then the HTTP status code should be "200"
And the JSON data of the response should match
"""
@@ -47,13 +48,13 @@ Feature: an user shares resources usin ScienceMesh application
"name"
],
"properties": {
"@UI.Hidden":{
"@UI.Hidden": {
"type": "boolean",
"enum": [false]
},
"@client.synchronize":{
"@client.synchronize": {
"type": "boolean",
"enum": [true]
"enum": [false]
},
"createdBy": {
"type": "object",
@@ -63,7 +64,10 @@ Feature: an user shares resources usin ScienceMesh application
"properties": {
"user": {
"type": "object",
"required": ["displayName", "id"],
"required": [
"displayName",
"id"
],
"properties": {
"displayName": {
"type": "string",
@@ -71,7 +75,7 @@ Feature: an user shares resources usin ScienceMesh application
},
"id": {
"type": "string",
"pattern": "^%user_id_pattern%$"
"pattern": "^%federated_user_id_pattern%$"
}
}
}
@@ -94,12 +98,13 @@ Feature: an user shares resources usin ScienceMesh application
And using server "REMOTE"
And "Brian" has accepted invitation
And user "Brian" has created folder "folderToShare"
When user "Brian" sends the following resource share invitation using the Graph API:
| resource | folderToShare |
| space | Personal |
| sharee | Alice |
| shareType | user |
| permissionsRole | Viewer |
When user "Brian" sends the following resource share invitation to federated user using the Graph API:
| resource | folderToShare |
| space | Personal |
| sharee | Alice |
| shareType | user |
| permissionsRole | Viewer |
| federatedServer | @ocis-server:9200 |
Then the HTTP status code should be "200"
When using server "LOCAL"
And user "Alice" lists the shares shared with her using the Graph API
@@ -125,11 +130,13 @@ Feature: an user shares resources usin ScienceMesh application
"name"
],
"properties": {
"@UI.Hidden":{
"const": "false"
"@UI.Hidden": {
"type": "boolean",
"enum": [false]
},
"@client.synchronize":{
"const": "true"
"@client.synchronize": {
"type": "boolean",
"enum": [false]
},
"createdBy": {
"type": "object",
@@ -139,14 +146,17 @@ Feature: an user shares resources usin ScienceMesh application
"properties": {
"user": {
"type": "object",
"required": ["displayName", "id"],
"required": [
"displayName",
"id"
],
"properties": {
"displayName": {
"const": "Brian Murphy"
},
"id": {
"type": "string",
"pattern": "^%user_id_pattern%$"
"pattern": "^%federated_user_id_pattern%$"
}
}
}