summaryrefslogtreecommitdiffstats
path: root/apps/federatedfilesharing/tests
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2016-06-24 15:59:32 +0200
committerRobin Appelman <icewind@owncloud.com>2016-06-27 14:28:12 +0200
commit8d32e1d35b05343ed17c96cbc5f5f360b88c1241 (patch)
tree1eb4ff6b5570ab99fa09f7a899f23ab231291f64 /apps/federatedfilesharing/tests
parentee674844f2e3dc1eaf8f864fcbfa4d92484075ce (diff)
downloadnextcloud-server-8d32e1d35b05343ed17c96cbc5f5f360b88c1241.tar.gz
nextcloud-server-8d32e1d35b05343ed17c96cbc5f5f360b88c1241.zip
Handle exceptions thrown while trying to notify remote server of a fed share
Diffstat (limited to 'apps/federatedfilesharing/tests')
-rw-r--r--apps/federatedfilesharing/tests/FederatedShareProviderTest.php60
1 files changed, 56 insertions, 4 deletions
diff --git a/apps/federatedfilesharing/tests/FederatedShareProviderTest.php b/apps/federatedfilesharing/tests/FederatedShareProviderTest.php
index 6792e534cc6..8c5efdab7b0 100644
--- a/apps/federatedfilesharing/tests/FederatedShareProviderTest.php
+++ b/apps/federatedfilesharing/tests/FederatedShareProviderTest.php
@@ -217,10 +217,6 @@ class FederatedShareProviderTest extends \Test\TestCase {
'sharedBy@http://localhost/'
)->willReturn(false);
- $this->rootFolder->expects($this->once())
- ->method('getUserFolder')
- ->with('shareOwner')
- ->will($this->returnSelf());
$this->rootFolder->method('getById')
->with('42')
->willReturn([$node]);
@@ -244,6 +240,62 @@ class FederatedShareProviderTest extends \Test\TestCase {
$this->assertFalse($data);
}
+ public function testCreateException() {
+ $share = $this->shareManager->newShare();
+
+ $node = $this->getMock('\OCP\Files\File');
+ $node->method('getId')->willReturn(42);
+ $node->method('getName')->willReturn('myFile');
+
+ $share->setSharedWith('user@server.com')
+ ->setSharedBy('sharedBy')
+ ->setShareOwner('shareOwner')
+ ->setPermissions(19)
+ ->setNode($node);
+
+ $this->tokenHandler->method('generateToken')->willReturn('token');
+
+ $this->addressHandler->expects($this->any())->method('generateRemoteURL')
+ ->willReturn('http://localhost/');
+ $this->addressHandler->expects($this->any())->method('splitUserRemote')
+ ->willReturn(['user', 'server.com']);
+
+ $this->notifications->expects($this->once())
+ ->method('sendRemoteShare')
+ ->with(
+ $this->equalTo('token'),
+ $this->equalTo('user@server.com'),
+ $this->equalTo('myFile'),
+ $this->anything(),
+ 'shareOwner',
+ 'shareOwner@http://localhost/',
+ 'sharedBy',
+ 'sharedBy@http://localhost/'
+ )->willThrowException(new \Exception('dummy'));
+
+ $this->rootFolder->method('getById')
+ ->with('42')
+ ->willReturn([$node]);
+
+ try {
+ $share = $this->provider->create($share);
+ $this->fail();
+ } catch (\Exception $e) {
+ $this->assertEquals('dummy', $e->getMessage());
+ }
+
+ $qb = $this->connection->getQueryBuilder();
+ $stmt = $qb->select('*')
+ ->from('share')
+ ->where($qb->expr()->eq('id', $qb->createNamedParameter($share->getId())))
+ ->execute();
+
+ $data = $stmt->fetch();
+ $stmt->closeCursor();
+
+ $this->assertFalse($data);
+ }
+
public function testCreateShareWithSelf() {
$share = $this->shareManager->newShare();