Merge pull request #10224 from owncloud/deleteConnectionTest

[test-only] delete connection tests
This commit is contained in:
Viktor Scharf
2024-10-04 15:37:53 +02:00
committed by GitHub
6 changed files with 284 additions and 35 deletions

View File

@@ -170,4 +170,38 @@ class OcmHelper {
self::getRequestHeaders()
);
}
/**
* @param string $baseUrl
* @param string $xRequestId
* @param string $user
* @param string $password
* @param string $userId
* @param string $idp
*
* @return ResponseInterface
* @throws GuzzleException
*/
public static function deleteConnection(
string $baseUrl,
string $xRequestId,
string $user,
string $password,
string $userId,
string $idp
): ResponseInterface {
$url = self::getFullUrl($baseUrl, 'delete-accepted-user');
$body = [
"idp" => $idp,
"user_id" => $userId
];
return HttpRequestHelper::delete(
$url,
$xRequestId,
$user,
$password,
self::getRequestHeaders(),
\json_encode($body)
);
}
}

View File

@@ -230,6 +230,24 @@ class OcmContext implements Context {
$this->featureContext->setResponse($this->findAcceptedUsers($user));
}
/**
*
* @param string $user
* @param string $ocmUserName
*
* @return array
* @throws GuzzleException
*/
public function getAcceptedUserByName(string $user, string $ocmUserName): array {
$users = ($this->featureContext->getJsonDecodedResponse($this->findAcceptedUsers($user)));
foreach ($users as $user) {
if (strpos($user["display_name"], $ocmUserName) !== false) {
return $user;
}
}
throw new \Exception("Could not find user with name '{$ocmUserName}' in the accepted users list.");
}
/**
* @param string $user
*
@@ -268,4 +286,51 @@ class OcmContext implements Context {
public function theUserWaitsForTokenToExpire(int $number): void {
\sleep($number);
}
/**
* @When user :user deletes federated connection with user :ocmUser using the Graph API
*
* @param string $user
* @param string $ocmUser
*
* @return void
* @throws GuzzleException
*/
public function userDeletesFederatedConnectionWithUserUsingTheGraphApi(string $user, string $ocmUser): void {
$this->featureContext->setResponse($this->deleteConnection($user, $ocmUser));
}
/**
* @When user :user has deleted federated connection with user :ocmUser
*
* @param string $user
* @param string $ocmUser
*
* @return void
* @throws GuzzleException
*/
public function userHasDeletedFederatedConnectionWithUser(string $user, string $ocmUser): void {
$response = $this->deleteConnection($user, $ocmUser);
$this->featureContext->theHTTPStatusCodeShouldBe(200, "failed while deleting connection with user $ocmUser", $response);
}
/**
* @param string $user
* @param string $ocmUser
*
* @return ResponseInterface
* @throws GuzzleException
*/
public function deleteConnection(string $user, string $ocmUser): ResponseInterface {
$ocmUser = $this->getAcceptedUserByName($user, $ocmUser);
return OcmHelper::deleteConnection(
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(),
$user,
$this->featureContext->getPasswordForUser($user),
$ocmUser['user_id'],
$ocmUser['idp']
);
}
}

View File

@@ -239,7 +239,6 @@ class SharingNgContext implements Context {
* @param string $user
* @param array $shareInfo
* @param string|null $fileId
* @param bool $isFederated
*
* @return ResponseInterface
*
@@ -247,7 +246,7 @@ class SharingNgContext implements Context {
* @throws GuzzleException
* @throws Exception
*/
public function sendShareInvitation(string $user, array $shareInfo, string $fileId = null, $isFederated = false): ResponseInterface {
public function sendShareInvitation(string $user, array $shareInfo, string $fileId = null): ResponseInterface {
if ($shareInfo['space'] === 'Personal' || $shareInfo['space'] === 'Shares') {
$space = $this->spacesContext->getSpaceByName($user, $shareInfo['space']);
} else {
@@ -283,8 +282,8 @@ class SharingNgContext implements Context {
$shareeId = "";
if ($shareType === "user") {
$shareeId = $this->featureContext->getAttributeOfCreatedUser($sharee, 'id');
if ($isFederated) {
$shareeId = base64_encode($shareeId . $shareInfo['federatedServer']);
if (isset($shareInfo['federatedServer'])) {
$shareeId = ($this->featureContext->ocmContext->getAcceptedUserByName($user, $sharee))['user_id'];
}
} elseif ($shareType === "group") {
$shareeId = $this->featureContext->getAttributeOfCreatedGroup($sharee, 'id');
@@ -352,6 +351,9 @@ class SharingNgContext implements Context {
$shareeId = "";
if ($shareType === "user") {
$shareeId = $this->featureContext->getAttributeOfCreatedUser($sharee, 'id');
if (isset($shareInfo['federatedServer'])) {
$shareeId = ($this->featureContext->ocmContext->getAcceptedUserByName($user, $sharee))['user_id'];
}
} elseif ($shareType === "group") {
$shareeId = $this->featureContext->getAttributeOfCreatedGroup($sharee, 'id');
}
@@ -379,6 +381,7 @@ class SharingNgContext implements Context {
/**
* @Given /^user "([^"]*)" has sent the following resource share invitation:$/
* @Given /^user "([^"]*)" has sent the following resource share invitation to federated user:$/
*
* @param string $user
* @param TableNode $table
@@ -414,6 +417,7 @@ class SharingNgContext implements Context {
/**
* @When /^user "([^"]*)" sends the following resource share invitation using the Graph API:$/
* @When /^user "([^"]*)" tries to send the following resource share invitation using the Graph API:$/
* @When /^user "([^"]*)" sends the following resource share invitation to federated user using the Graph API:$/
*
* @param string $user
* @param TableNode $table
@@ -430,24 +434,6 @@ 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

@@ -256,10 +256,19 @@ The expected failures in this file are from features in the owncloud/ocis repo.
#### [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
- [apiOcm/searchFederationUsers.feature:429](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiOcm/searchFederationUsers.feature#L429)
- [apiOcm/searchFederationUsers.feature:601](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiOcm/searchFederationUsers.feature#L601)
#### [OCM. federated connection is not dropped when one of the users deletes the connection](https://github.com/owncloud/ocis/issues/10216)
- [apiOcm/deleteFederatedConnections.feature:39](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiOcm/deleteFederatedConnections.feature#L39)
- [apiOcm/deleteFederatedConnections.feature:66](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiOcm/deleteFederatedConnections.feature#L66)
#### [OCM. server crash after deleting share for ocm user](https://github.com/owncloud/ocis/issues/10213)
- [apiOcm/deleteFederatedConnections.feature:103](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiOcm/deleteFederatedConnections.feature#L103)
Note: always have an empty line at the end of this file.
The bash script that processes this file requires that the last line has a newline on the end.

View File

@@ -0,0 +1,137 @@
@ocm
Feature: delete federated connections
As a user
I want to delete federated connections if they are no longer needed
Background:
Given user "Alice" has been created with default attributes and without skeleton files
And using server "REMOTE"
And user "Brian" has been created with default attributes and without skeleton files
Scenario: federated user deletes the federated connection
Given using server "LOCAL"
And "Alice" has created the federation share invitation
And using server "REMOTE"
And "Brian" has accepted invitation
When user "Brian" deletes federated connection with user "Alice" using the Graph API
Then the HTTP status code should be "200"
When user "Brian" searches for federated user "alice" using Graph API
Then the HTTP status code should be "200"
And the JSON data of the response should match
"""
{
"type": "object",
"required": [
"value"
],
"properties": {
"value": {
"type": "array",
"minItems": 0,
"maxItems": 0
}
}
}
"""
@issue-10216
Scenario: local user should not be able to find federated user after federated user has deleted connection
Given using server "LOCAL"
And "Alice" has created the federation share invitation
And using server "REMOTE"
And "Brian" has accepted invitation
And user "Brian" has deleted federated connection with user "Alice"
And using server "LOCAL"
When user "Alice" searches for federated user "brian" using Graph API
Then the HTTP status code should be "200"
And the JSON data of the response should match
"""
{
"type": "object",
"required": [
"value"
],
"properties": {
"value": {
"type": "array",
"minItems": 0,
"maxItems": 0
}
}
}
"""
@issue-10216
Scenario: federated user should not be able to find federated share after federated user has deleted connection
Given using server "LOCAL"
And "Alice" has created the federation share invitation
And using server "REMOTE"
And "Brian" has accepted invitation
And using server "LOCAL"
And user "Alice" has created folder "folderToShare"
And user "Alice" has sent the following resource share invitation to federated user:
| resource | folderToShare |
| space | Personal |
| sharee | Brian |
| shareType | user |
| permissionsRole | Viewer |
| federatedServer | @federation-ocis-server:10200 |
And using server "REMOTE"
When user "Brian" deletes federated connection with user "Alice" using the Graph API
Then the HTTP status code should be "200"
When 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
"""
{
"type": "object",
"required": [
"value"
],
"properties": {
"value": {
"type": "array",
"minItems": 0,
"maxItems": 0,
}
}
}
"""
@issue-10213
Scenario: federated user should not be able to find federated share after local user has deleted connection
Given using server "LOCAL"
And "Alice" has created the federation share invitation
And using server "REMOTE"
And "Brian" has accepted invitation
And using server "LOCAL"
And user "Alice" has created folder "folderToShare"
And user "Alice" has sent the following resource share invitation to federated user:
| resource | folderToShare |
| space | Personal |
| sharee | Brian |
| shareType | user |
| permissionsRole | Viewer |
| federatedServer | @federation-ocis-server:10200 |
When user "Alice" deletes federated connection with user "Brian" using the Graph API
Then the HTTP status code should be "200"
And using server "REMOTE"
When 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
"""
{
"type": "object",
"required": [
"value"
],
"properties": {
"value": {
"type": "array",
"minItems": 0,
"maxItems": 0,
}
}
}
"""

View File

@@ -9,15 +9,16 @@ Feature: an user shares resources usin ScienceMesh application
And user "Brian" has been created with default attributes and without skeleton files
@issue-9534
Scenario: users shares folder to federation users after receiver accepted invitation
Scenario Outline: local user shares resources to federation user
Given using server "LOCAL"
And "Alice" has created the federation share invitation
And using server "REMOTE"
And "Brian" has accepted invitation
And using server "LOCAL"
And user "Alice" has created folder "folderToShare"
And user "Alice" has uploaded file with content "ocm test" to "/textfile.txt"
When user "Alice" sends the following resource share invitation to federated user using the Graph API:
| resource | folderToShare |
| resource | <resource> |
| space | Personal |
| sharee | Brian |
| shareType | user |
@@ -50,11 +51,15 @@ Feature: an user shares resources usin ScienceMesh application
"properties": {
"@UI.Hidden": {
"type": "boolean",
"enum": [false]
"enum": [
false
]
},
"@client.synchronize": {
"type": "boolean",
"enum": [false]
"enum": [
false
]
},
"createdBy": {
"type": "object",
@@ -82,7 +87,7 @@ Feature: an user shares resources usin ScienceMesh application
}
},
"name": {
"const": "folderToShare"
"const": "<resource>"
}
}
}
@@ -90,16 +95,21 @@ Feature: an user shares resources usin ScienceMesh application
}
}
"""
Examples:
| resource |
| folderToShare |
| textfile.txt |
@issue-9534
Scenario: users shares folder to federation users after accepting invitation
Scenario Outline: federation user shares resource to local user after accepting invitation
Given using server "LOCAL"
And "Alice" has created the federation share invitation
And using server "REMOTE"
And "Brian" has accepted invitation
And user "Brian" has created folder "folderToShare"
And user "Brian" has uploaded file with content "ocm test" to "/textfile.txt"
When user "Brian" sends the following resource share invitation to federated user using the Graph API:
| resource | folderToShare |
| resource | <resource> |
| space | Personal |
| sharee | Alice |
| shareType | user |
@@ -107,7 +117,7 @@ Feature: an user shares resources usin ScienceMesh application
| 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
And user "Alice" lists the shares shared with her without retry using the Graph API
Then the HTTP status code should be "200"
And the JSON data of the response should match
"""
@@ -132,11 +142,15 @@ Feature: an user shares resources usin ScienceMesh application
"properties": {
"@UI.Hidden": {
"type": "boolean",
"enum": [false]
"enum": [
false
]
},
"@client.synchronize": {
"type": "boolean",
"enum": [false]
"enum": [
false
]
},
"createdBy": {
"type": "object",
@@ -163,7 +177,7 @@ Feature: an user shares resources usin ScienceMesh application
}
},
"name": {
"const": "folderToShare"
"const": "<resource>"
}
}
}
@@ -171,3 +185,7 @@ Feature: an user shares resources usin ScienceMesh application
}
}
"""
Examples:
| resource |
| folderToShare |
| textfile.txt |