diff options
-rw-r--r-- | build/integration/features/bootstrap/FederationContext.php | 32 | ||||
-rw-r--r-- | build/integration/federation_features/federated.feature | 42 |
2 files changed, 74 insertions, 0 deletions
diff --git a/build/integration/features/bootstrap/FederationContext.php b/build/integration/features/bootstrap/FederationContext.php index d859afc610f..a4472c54b1b 100644 --- a/build/integration/features/bootstrap/FederationContext.php +++ b/build/integration/features/bootstrap/FederationContext.php @@ -28,6 +28,7 @@ */ use Behat\Behat\Context\Context; use Behat\Behat\Context\SnippetAcceptingContext; +use Behat\Gherkin\Node\TableNode; require __DIR__ . '/../../vendor/autoload.php'; @@ -97,6 +98,37 @@ class FederationContext implements Context, SnippetAcceptingContext { } /** + * @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 * @param string $server diff --git a/build/integration/federation_features/federated.feature b/build/integration/federation_features/federated.feature index 46794e02ff8..a8af32387a0 100644 --- a/build/integration/federation_features/federated.feature +++ b/build/integration/federation_features/federated.feature @@ -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 |