|
|
|
@ -218,7 +218,7 @@ class Test_Share extends \Test\TestCase { |
|
|
|
|
|
|
|
public function testShareWithUser() { |
|
|
|
// Invalid shares
|
|
|
|
$message = 'Sharing test.txt failed, because the user '.$this->user1.' is the item owner'; |
|
|
|
$message = 'Sharing test.txt failed, because you can not share with yourself'; |
|
|
|
try { |
|
|
|
OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user1, \OCP\Constants::PERMISSION_READ); |
|
|
|
$this->fail('Exception was expected: '.$message); |
|
|
|
@ -255,7 +255,7 @@ class Test_Share extends \Test\TestCase { |
|
|
|
|
|
|
|
// Attempt to share back
|
|
|
|
OC_User::setUserId($this->user2); |
|
|
|
$message = 'Sharing test.txt failed, because the user '.$this->user1.' is the original sharer'; |
|
|
|
$message = 'Sharing failed, because the user '.$this->user1.' is the original sharer'; |
|
|
|
try { |
|
|
|
OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user1, \OCP\Constants::PERMISSION_READ); |
|
|
|
$this->fail('Exception was expected: '.$message); |
|
|
|
@ -640,7 +640,7 @@ class Test_Share extends \Test\TestCase { |
|
|
|
|
|
|
|
// Attempt to share back to owner of group share
|
|
|
|
OC_User::setUserId($this->user2); |
|
|
|
$message = 'Sharing test.txt failed, because the user '.$this->user1.' is the original sharer'; |
|
|
|
$message = 'Sharing failed, because the user '.$this->user1.' is the original sharer'; |
|
|
|
try { |
|
|
|
OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_USER, $this->user1, \OCP\Constants::PERMISSION_READ); |
|
|
|
$this->fail('Exception was expected: '.$message); |
|
|
|
@ -1736,6 +1736,24 @@ class Test_Share extends \Test\TestCase { |
|
|
|
$this->assertCount(4, $res); |
|
|
|
} |
|
|
|
|
|
|
|
public function testShareWithSelfError() { |
|
|
|
OC_User::setUserId($this->user1); |
|
|
|
$view = new \OC\Files\View('/' . $this->user1 . '/'); |
|
|
|
$view->mkdir('files/folder1'); |
|
|
|
|
|
|
|
$fileInfo = $view->getFileInfo('files/folder1'); |
|
|
|
$this->assertInstanceOf('\OC\Files\FileInfo', $fileInfo); |
|
|
|
$fileId = $fileInfo->getId(); |
|
|
|
|
|
|
|
try { |
|
|
|
OCP\Share::shareItem('folder', $fileId, OCP\Share::SHARE_TYPE_USER, $this->user1, \OCP\Constants::PERMISSION_ALL); |
|
|
|
$this->fail(); |
|
|
|
} catch (\Exception $e) { |
|
|
|
$this->assertEquals('Sharing /folder1 failed, because you can not share with yourself', $e->getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function testShareWithOwnerError() { |
|
|
|
OC_User::setUserId($this->user1); |
|
|
|
$view = new \OC\Files\View('/' . $this->user1 . '/'); |
|
|
|
@ -1750,13 +1768,12 @@ class Test_Share extends \Test\TestCase { |
|
|
|
'Failed asserting that user 1 successfully shared "test" with user 2.' |
|
|
|
); |
|
|
|
|
|
|
|
OC_User::setUserId($this->user1); |
|
|
|
|
|
|
|
OC_User::setUserId($this->user2); |
|
|
|
try { |
|
|
|
OCP\Share::shareItem('folder', $fileId, OCP\Share::SHARE_TYPE_USER, $this->user1, \OCP\Constants::PERMISSION_ALL); |
|
|
|
$this->fail(); |
|
|
|
} catch (\Exception $e) { |
|
|
|
$this->assertEquals('Sharing /folder1 failed, because the user ' . $this->user1 . ' is the item owner', $e->getMessage()); |
|
|
|
$this->assertEquals('Sharing failed, because the user ' . $this->user1 . ' is the original sharer', $e->getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|