Add integration tests for listing federated shares

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
pull/25332/head
Daniel Calviño Sánchez 2021-04-08 21:00:11 +07:00 committed by Vincent Petry
parent 66b5a2d56a
commit 9497a7c4ff
No known key found for this signature in database
GPG Key ID: E055D6A4D513575C
2 changed files with 74 additions and 0 deletions

@ -28,6 +28,7 @@
*/
use Behat\Behat\Context\Context;
use Behat\Behat\Context\SnippetAcceptingContext;
use Behat\Gherkin\Node\TableNode;
require __DIR__ . '/../../vendor/autoload.php';
@ -96,6 +97,37 @@ class FederationContext implements Context, SnippetAcceptingContext {
$this->usingServer($previous);
}
/**
* @Then remote share :count is returned with
*
* @param int $number
* @param TableNode $body
*/
public function remoteShareXIsReturnedWith(int $number, TableNode $body) {
$this->theHTTPStatusCodeShouldBe('200');
$this->theOCSStatusCodeShouldBe('100');
if (!($body instanceof TableNode)) {
return;
}
$returnedShare = $this->getXmlResponse()->data[0];
if ($returnedShare->element) {
$returnedShare = $returnedShare->element[$number];
}
$defaultExpectedFields = [
'id' => 'A_NUMBER',
'remote_id' => 'A_NUMBER',
'accepted' => '1',
];
$expectedFields = array_merge($defaultExpectedFields, $body->getRowsHash());
foreach ($expectedFields as $field => $value) {
$this->assertFieldIsInReturnedShare($field, $value, $returnedShare);
}
}
/**
* @When /^User "([^"]*)" from server "(LOCAL|REMOTE)" accepts last pending share$/
* @param string $user

@ -278,6 +278,48 @@ Feature: federated
Scenario: List federated share from another server not accepted yet
Given Using server "LOCAL"
And user "user0" exists
Given Using server "REMOTE"
And user "user1" exists
# Rename file so it has a unique name in the target server (as the target
# server may have its own /textfile0.txt" file)
And User "user1" copies file "/textfile0.txt" to "/remote-share.txt"
And User "user1" from server "REMOTE" shares "/remote-share.txt" with user "user0" from server "LOCAL"
And Using server "LOCAL"
When As an "user0"
And sending "GET" to "/apps/files_sharing/api/v1/remote_shares"
Then the list of returned shares has 0 shares
Scenario: List federated share from another server
Given Using server "LOCAL"
And user "user0" exists
Given Using server "REMOTE"
And user "user1" exists
# Rename file so it has a unique name in the target server (as the target
# server may have its own /textfile0.txt" file)
And User "user1" copies file "/textfile0.txt" to "/remote-share.txt"
And User "user1" from server "REMOTE" shares "/remote-share.txt" with user "user0" from server "LOCAL"
And Using server "LOCAL"
And User "user0" from server "LOCAL" accepts last pending share
When As an "user0"
And sending "GET" to "/apps/files_sharing/api/v1/remote_shares"
Then the list of returned shares has 1 shares
And remote share 0 is returned with
| remote | http://localhost:8180/ |
| name | /remote-share.txt |
| owner | user1 |
| user | user0 |
| mountpoint | /remote-share.txt |
| mimetype | text/plain |
| mtime | A_NUMBER |
| permissions | 27 |
| type | file |
| file_id | A_NUMBER |
Scenario: Delete federated share with another server
Given Using server "LOCAL"
And user "user0" exists