Skip to content

Commit 43f96c3

Browse files
committed
Add integration tests for listing federated shares
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
1 parent 1a87214 commit 43f96c3

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed

build/integration/features/bootstrap/FederationContext.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
*/
2929
use Behat\Behat\Context\Context;
3030
use Behat\Behat\Context\SnippetAcceptingContext;
31+
use Behat\Gherkin\Node\TableNode;
3132

3233
require __DIR__ . '/../../vendor/autoload.php';
3334

@@ -96,6 +97,37 @@ public function federateGroupSharing($sharerUser, $sharerServer, $sharerPath, $s
9697
$this->usingServer($previous);
9798
}
9899

100+
/**
101+
* @Then remote share :count is returned with
102+
*
103+
* @param int $number
104+
* @param TableNode $body
105+
*/
106+
public function remoteShareXIsReturnedWith(int $number, TableNode $body) {
107+
$this->theHTTPStatusCodeShouldBe('200');
108+
$this->theOCSStatusCodeShouldBe('100');
109+
110+
if (!($body instanceof TableNode)) {
111+
return;
112+
}
113+
114+
$returnedShare = $this->getXmlResponse()->data[0];
115+
if ($returnedShare->element) {
116+
$returnedShare = $returnedShare->element[$number];
117+
}
118+
119+
$defaultExpectedFields = [
120+
'id' => 'A_NUMBER',
121+
'remote_id' => 'A_NUMBER',
122+
'accepted' => '1',
123+
];
124+
$expectedFields = array_merge($defaultExpectedFields, $body->getRowsHash());
125+
126+
foreach ($expectedFields as $field => $value) {
127+
$this->assertFieldIsInReturnedShare($field, $value, $returnedShare);
128+
}
129+
}
130+
99131
/**
100132
* @When /^User "([^"]*)" from server "(LOCAL|REMOTE)" accepts last pending share$/
101133
* @param string $user

build/integration/federation_features/federated.feature

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,48 @@ Feature: federated
278278

279279

280280

281+
Scenario: List federated share from another server not accepted yet
282+
Given Using server "LOCAL"
283+
And user "user0" exists
284+
Given Using server "REMOTE"
285+
And user "user1" exists
286+
# Rename file so it has a unique name in the target server (as the target
287+
# server may have its own /textfile0.txt" file)
288+
And User "user1" copies file "/textfile0.txt" to "/remote-share.txt"
289+
And User "user1" from server "REMOTE" shares "/remote-share.txt" with user "user0" from server "LOCAL"
290+
And Using server "LOCAL"
291+
When As an "user0"
292+
And sending "GET" to "/apps/files_sharing/api/v1/remote_shares"
293+
Then the list of returned shares has 0 shares
294+
295+
Scenario: List federated share from another server
296+
Given Using server "LOCAL"
297+
And user "user0" exists
298+
Given Using server "REMOTE"
299+
And user "user1" exists
300+
# Rename file so it has a unique name in the target server (as the target
301+
# server may have its own /textfile0.txt" file)
302+
And User "user1" copies file "/textfile0.txt" to "/remote-share.txt"
303+
And User "user1" from server "REMOTE" shares "/remote-share.txt" with user "user0" from server "LOCAL"
304+
And Using server "LOCAL"
305+
And User "user0" from server "LOCAL" accepts last pending share
306+
When As an "user0"
307+
And sending "GET" to "/apps/files_sharing/api/v1/remote_shares"
308+
Then the list of returned shares has 1 shares
309+
And remote share 0 is returned with
310+
| remote | http://localhost:8180/ |
311+
| name | /remote-share.txt |
312+
| owner | user1 |
313+
| user | user0 |
314+
| mountpoint | /remote-share.txt |
315+
| mimetype | text/plain |
316+
| mtime | A_NUMBER |
317+
| permissions | 27 |
318+
| type | file |
319+
| file_id | A_NUMBER |
320+
321+
322+
281323
Scenario: Delete federated share with another server
282324
Given Using server "LOCAL"
283325
And user "user0" exists

0 commit comments

Comments
 (0)