|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
use Behat\Behat\Context\Context; |
|
4
|
|
|
use Behat\Behat\Context\SnippetAcceptingContext; |
|
5
|
|
|
use GuzzleHttp\Client; |
|
6
|
|
|
use GuzzleHttp\Message\ResponseInterface; |
|
7
|
|
|
|
|
8
|
|
|
require __DIR__ . '/../../vendor/autoload.php'; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Federation context. |
|
12
|
|
|
*/ |
|
13
|
|
|
class FederationContext implements Context, SnippetAcceptingContext { |
|
14
|
|
|
|
|
15
|
|
|
use WebDav; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* @Given /^User "([^"]*)" from server "(LOCAL|REMOTE)" shares "([^"]*)" with user "([^"]*)" from server "(LOCAL|REMOTE)"$/ |
|
19
|
|
|
* |
|
20
|
|
|
* @param string $sharerUser |
|
21
|
|
|
* @param string $sharerServer "LOCAL" or "REMOTE" |
|
22
|
|
|
* @param string $sharerPath |
|
23
|
|
|
* @param string $shareeUser |
|
24
|
|
|
* @param string $shareeServer "LOCAL" or "REMOTE" |
|
25
|
|
|
*/ |
|
26
|
|
|
public function federateSharing($sharerUser, $sharerServer, $sharerPath, $shareeUser, $shareeServer){ |
|
27
|
|
|
if ($shareeServer == "REMOTE"){ |
|
28
|
|
|
$shareWith = "$shareeUser@" . substr($this->remoteBaseUrl, 0, -4); |
|
29
|
|
|
} else { |
|
30
|
|
|
$shareWith = "$shareeUser@" . substr($this->localBaseUrl, 0, -4); |
|
31
|
|
|
} |
|
32
|
|
|
$previous = $this->usingServer($sharerServer); |
|
33
|
|
|
$this->createShare($sharerUser, $sharerPath, 6, $shareWith, null, null, null); |
|
34
|
|
|
$this->usingServer($previous); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @When /^User "([^"]*)" from server "(LOCAL|REMOTE)" accepts last pending share$/ |
|
39
|
|
|
* @param string $user |
|
40
|
|
|
* @param string $server |
|
41
|
|
|
*/ |
|
42
|
|
|
public function acceptLastPendingShare($user, $server){ |
|
43
|
|
|
$previous = $this->usingServer($server); |
|
44
|
|
|
$this->asAn($user); |
|
45
|
|
|
$this->sendingToWith('GET', "/apps/files_sharing/api/v1/remote_shares/pending", null); |
|
46
|
|
|
$this->theHTTPStatusCodeShouldBe('200'); |
|
47
|
|
|
$this->theOCSStatusCodeShouldBe('100'); |
|
48
|
|
|
$share_id = $this->response->xml()->data[0]->element[0]->id; |
|
49
|
|
|
$this->sendingToWith('POST', "/apps/files_sharing/api/v1/remote_shares/pending/{$share_id}", null); |
|
50
|
|
|
$this->theHTTPStatusCodeShouldBe('200'); |
|
51
|
|
|
$this->theOCSStatusCodeShouldBe('100'); |
|
52
|
|
|
$this->usingServer($previous); |
|
53
|
|
|
} |
|
54
|
|
|
} |
|
55
|
|
|
|