aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/tests
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2016-08-16 22:45:49 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2016-08-17 20:45:27 +0200
commit22e23f304570e3eef1e56f73b7c15ba29025bcdd (patch)
tree5169b0836e6217e956817044825ebf89997cd167 /apps/files_sharing/tests
parentc40fa479447ac602887f25715bdb103ab8bab0ce (diff)
downloadnextcloud-server-22e23f304570e3eef1e56f73b7c15ba29025bcdd.tar.gz
nextcloud-server-22e23f304570e3eef1e56f73b7c15ba29025bcdd.zip
Use parameters in createShare
* Fix tests
Diffstat (limited to 'apps/files_sharing/tests')
-rw-r--r--apps/files_sharing/tests/API/Share20OCSTest.php153
-rw-r--r--apps/files_sharing/tests/ApiTest.php172
2 files changed, 63 insertions, 262 deletions
diff --git a/apps/files_sharing/tests/API/Share20OCSTest.php b/apps/files_sharing/tests/API/Share20OCSTest.php
index a89bdb065c4..c6b5a36512e 100644
--- a/apps/files_sharing/tests/API/Share20OCSTest.php
+++ b/apps/files_sharing/tests/API/Share20OCSTest.php
@@ -89,8 +89,6 @@ class Share20OCSTest extends \Test\TestCase {
$this->currentUser = $this->getMockBuilder('OCP\IUser')->getMock();
$this->currentUser->method('getUID')->willReturn('currentUser');
- $this->userManager->expects($this->any())->method('userExists')->willReturn(true);
-
$this->l = $this->getMockBuilder('\OCP\IL10N')->getMock();
$this->l->method('t')
->will($this->returnCallback(function($text, $parameters = []) {
@@ -565,12 +563,6 @@ class Share20OCSTest extends \Test\TestCase {
* @expectedExceptionMessage Wrong path, file/folder doesn't exist
*/
public function testCreateShareInvalidPath() {
- $this->request
- ->method('getParam')
- ->will($this->returnValueMap([
- ['path', null, 'invalid-path'],
- ]));
-
$userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$this->rootFolder->expects($this->once())
->method('getUserFolder')
@@ -582,7 +574,7 @@ class Share20OCSTest extends \Test\TestCase {
->with('invalid-path')
->will($this->throwException(new \OCP\Files\NotFoundException()));
- $this->ocs->createShare();
+ $this->ocs->createShare('invalid-path');
}
/**
@@ -593,13 +585,6 @@ class Share20OCSTest extends \Test\TestCase {
$share = $this->newShare();
$this->shareManager->method('newShare')->willReturn($share);
- $this->request
- ->method('getParam')
- ->will($this->returnValueMap([
- ['path', null, 'valid-path'],
- ['permissions', null, 32],
- ]));
-
$userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$this->rootFolder->expects($this->once())
->method('getUserFolder')
@@ -616,7 +601,7 @@ class Share20OCSTest extends \Test\TestCase {
->method('lock')
->with(\OCP\Lock\ILockingProvider::LOCK_SHARED);
- $this->ocs->createShare();
+ $this->ocs->createShare('valid-path', 32);
}
/**
@@ -627,14 +612,6 @@ class Share20OCSTest extends \Test\TestCase {
$share = $this->newShare();
$this->shareManager->method('newShare')->willReturn($share);
- $this->request
- ->method('getParam')
- ->will($this->returnValueMap([
- ['path', null, 'valid-path'],
- ['permissions', null, \OCP\Constants::PERMISSION_ALL],
- ['shareType', $this->any(), \OCP\Share::SHARE_TYPE_USER],
- ]));
-
$userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$this->rootFolder->expects($this->once())
->method('getUserFolder')
@@ -656,7 +633,7 @@ class Share20OCSTest extends \Test\TestCase {
->method('lock')
->with(\OCP\Lock\ILockingProvider::LOCK_SHARED);
- $this->ocs->createShare();
+ $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER);
}
/**
@@ -667,15 +644,6 @@ class Share20OCSTest extends \Test\TestCase {
$share = $this->newShare();
$this->shareManager->method('newShare')->willReturn($share);
- $this->request
- ->method('getParam')
- ->will($this->returnValueMap([
- ['path', null, 'valid-path'],
- ['permissions', null, \OCP\Constants::PERMISSION_ALL],
- ['shareType', $this->any(), \OCP\Share::SHARE_TYPE_USER],
- ['shareWith', $this->any(), 'invalidUser'],
- ]));
-
$userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$this->rootFolder->expects($this->once())
->method('getUserFolder')
@@ -692,12 +660,14 @@ class Share20OCSTest extends \Test\TestCase {
->method('get')
->with('valid-path')
->willReturn($path);
-
$path->expects($this->once())
->method('lock')
->with(\OCP\Lock\ILockingProvider::LOCK_SHARED);
+ $this->userManager->method('userExists')
+ ->with('invalidUser')
+ ->willReturn(false);
- $this->ocs->createShare();
+ $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, 'invalidUser');
}
public function testCreateShareUser() {
@@ -719,15 +689,6 @@ class Share20OCSTest extends \Test\TestCase {
])->setMethods(['formatShare'])
->getMock();
- $this->request
- ->method('getParam')
- ->will($this->returnValueMap([
- ['path', null, 'valid-path'],
- ['permissions', null, \OCP\Constants::PERMISSION_ALL],
- ['shareType', $this->any(), \OCP\Share::SHARE_TYPE_USER],
- ['shareWith', null, 'validUser'],
- ]));
-
$userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$this->rootFolder->expects($this->once())
->method('getUserFolder')
@@ -766,7 +727,7 @@ class Share20OCSTest extends \Test\TestCase {
->will($this->returnArgument(0));
$expected = new DataResponse(null);
- $result = $ocs->createShare();
+ $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, 'validUser');
$this->assertInstanceOf(get_class($expected), $result);
$this->assertEquals($expected->getData(), $result->getData());
@@ -774,21 +735,13 @@ class Share20OCSTest extends \Test\TestCase {
/**
* @expectedException \OCP\AppFramework\OCS\OCSNotFoundException
- * @expectedExceptionMessage Please specify a valid user
+ * @expectedExceptionMessage Please specify a valid group
*/
public function testCreateShareGroupNoValidShareWith() {
$share = $this->newShare();
$this->shareManager->method('newShare')->willReturn($share);
$this->shareManager->method('createShare')->will($this->returnArgument(0));
-
- $this->request
- ->method('getParam')
- ->will($this->returnValueMap([
- ['path', null, 'valid-path'],
- ['permissions', null, \OCP\Constants::PERMISSION_ALL],
- ['shareType', $this->any(), \OCP\Share::SHARE_TYPE_GROUP],
- ['shareWith', $this->any(), 'invalidGroup'],
- ]));
+ $this->shareManager->method('allowGroupSharing')->willReturn(true);
$userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$this->rootFolder->expects($this->once())
@@ -811,7 +764,7 @@ class Share20OCSTest extends \Test\TestCase {
->method('lock')
->with(\OCP\Lock\ILockingProvider::LOCK_SHARED);
- $this->ocs->createShare();
+ $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_GROUP, 'invalidGroup');
}
public function testCreateShareGroup() {
@@ -879,7 +832,7 @@ class Share20OCSTest extends \Test\TestCase {
->will($this->returnArgument(0));
$expected = new DataResponse(null);
- $result = $ocs->createShare();
+ $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_GROUP, 'validGroup');
$this->assertInstanceOf(get_class($expected), $result);
$this->assertEquals($expected->getData(), $result->getData());
@@ -893,15 +846,6 @@ class Share20OCSTest extends \Test\TestCase {
$share = $this->newShare();
$this->shareManager->method('newShare')->willReturn($share);
- $this->request
- ->method('getParam')
- ->will($this->returnValueMap([
- ['path', null, 'valid-path'],
- ['permissions', null, \OCP\Constants::PERMISSION_ALL],
- ['shareType', '-1', \OCP\Share::SHARE_TYPE_GROUP],
- ['shareWith', null, 'validGroup'],
- ]));
-
$userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$this->rootFolder->expects($this->once())
->method('getUserFolder')
@@ -925,7 +869,7 @@ class Share20OCSTest extends \Test\TestCase {
->method('allowGroupSharing')
->willReturn(false);
- $this->ocs->createShare();
+ $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_GROUP, 'invalidGroup');
}
/**
@@ -951,7 +895,7 @@ class Share20OCSTest extends \Test\TestCase {
$this->shareManager->method('newShare')->willReturn(\OC::$server->getShareManager()->newShare());
- $this->ocs->createShare();
+ $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK);
}
/**
@@ -959,14 +903,6 @@ class Share20OCSTest extends \Test\TestCase {
* @expectedExceptionMessage Public upload disabled by the administrator
*/
public function testCreateShareLinkNoPublicUpload() {
- $this->request
- ->method('getParam')
- ->will($this->returnValueMap([
- ['path', null, 'valid-path'],
- ['shareType', '-1', \OCP\Share::SHARE_TYPE_LINK],
- ['publicUpload', null, 'true'],
- ]));
-
$path = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$storage = $this->getMockBuilder('OCP\Files\Storage')->getMock();
$storage->method('instanceOfStorage')
@@ -979,7 +915,7 @@ class Share20OCSTest extends \Test\TestCase {
$this->shareManager->method('newShare')->willReturn(\OC::$server->getShareManager()->newShare());
$this->shareManager->method('shareApiAllowLinks')->willReturn(true);
- $this->ocs->createShare();
+ $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'true');
}
/**
@@ -987,14 +923,6 @@ class Share20OCSTest extends \Test\TestCase {
* @expectedExceptionMessage Public upload is only possible for publicly shared folders
*/
public function testCreateShareLinkPublicUploadFile() {
- $this->request
- ->method('getParam')
- ->will($this->returnValueMap([
- ['path', null, 'valid-path'],
- ['shareType', '-1', \OCP\Share::SHARE_TYPE_LINK],
- ['publicUpload', null, 'true'],
- ]));
-
$path = $this->getMockBuilder('\OCP\Files\File')->getMock();
$storage = $this->getMockBuilder('OCP\Files\Storage')->getMock();
$storage->method('instanceOfStorage')
@@ -1008,22 +936,12 @@ class Share20OCSTest extends \Test\TestCase {
$this->shareManager->method('shareApiAllowLinks')->willReturn(true);
$this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true);
- $this->ocs->createShare();
+ $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'true');
}
public function testCreateShareLinkPublicUploadFolder() {
$ocs = $this->mockFormatShare();
- $this->request
- ->method('getParam')
- ->will($this->returnValueMap([
- ['path', null, 'valid-path'],
- ['shareType', '-1', \OCP\Share::SHARE_TYPE_LINK],
- ['publicUpload', null, 'true'],
- ['expireDate', '', ''],
- ['password', '', ''],
- ]));
-
$path = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$storage = $this->getMockBuilder('OCP\Files\Storage')->getMock();
$storage->method('instanceOfStorage')
@@ -1049,7 +967,7 @@ class Share20OCSTest extends \Test\TestCase {
)->will($this->returnArgument(0));
$expected = new DataResponse(null);
- $result = $ocs->createShare();
+ $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'true', '', '');
$this->assertInstanceOf(get_class($expected), $result);
$this->assertEquals($expected->getData(), $result->getData());
@@ -1058,16 +976,6 @@ class Share20OCSTest extends \Test\TestCase {
public function testCreateShareLinkPassword() {
$ocs = $this->mockFormatShare();
- $this->request
- ->method('getParam')
- ->will($this->returnValueMap([
- ['path', null, 'valid-path'],
- ['shareType', '-1', \OCP\Share::SHARE_TYPE_LINK],
- ['publicUpload', null, 'false'],
- ['expireDate', '', ''],
- ['password', '', 'password'],
- ]));
-
$path = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$storage = $this->getMockBuilder('OCP\Files\Storage')->getMock();
$storage->method('instanceOfStorage')
@@ -1093,7 +1001,7 @@ class Share20OCSTest extends \Test\TestCase {
)->will($this->returnArgument(0));
$expected = new DataResponse(null);
- $result = $ocs->createShare();
+ $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', 'password', '');
$this->assertInstanceOf(get_class($expected), $result);
$this->assertEquals($expected->getData(), $result->getData());
@@ -1140,7 +1048,7 @@ class Share20OCSTest extends \Test\TestCase {
)->will($this->returnArgument(0));
$expected = new DataResponse(null);
- $result = $ocs->createShare();
+ $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', '', '2000-01-01');
$this->assertInstanceOf(get_class($expected), $result);
$this->assertEquals($expected->getData(), $result->getData());
@@ -1153,16 +1061,6 @@ class Share20OCSTest extends \Test\TestCase {
public function testCreateShareInvalidExpireDate() {
$ocs = $this->mockFormatShare();
- $this->request
- ->method('getParam')
- ->will($this->returnValueMap([
- ['path', null, 'valid-path'],
- ['shareType', '-1', \OCP\Share::SHARE_TYPE_LINK],
- ['publicUpload', null, 'false'],
- ['expireDate', '', 'a1b2d3'],
- ['password', '', ''],
- ]));
-
$path = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$storage = $this->getMockBuilder('OCP\Files\Storage')->getMock();
$storage->method('instanceOfStorage')
@@ -1176,7 +1074,7 @@ class Share20OCSTest extends \Test\TestCase {
$this->shareManager->method('shareApiAllowLinks')->willReturn(true);
$this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true);
- $ocs->createShare();
+ $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', '', 'a1b2d3');
}
/**
@@ -1201,15 +1099,6 @@ class Share20OCSTest extends \Test\TestCase {
])->setMethods(['formatShare'])
->getMock();
- $this->request
- ->method('getParam')
- ->will($this->returnValueMap([
- ['path', null, 'valid-path'],
- ['permissions', null, \OCP\Constants::PERMISSION_ALL],
- ['shareType', $this->any(), \OCP\Share::SHARE_TYPE_USER],
- ['shareWith', null, 'validUser'],
- ]));
-
$userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock();
$this->rootFolder->expects($this->once())
->method('getUserFolder')
@@ -1238,7 +1127,7 @@ class Share20OCSTest extends \Test\TestCase {
}))
->will($this->returnArgument(0));
- $ocs->createShare();
+ $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, 'validUser');
}
/**
diff --git a/apps/files_sharing/tests/ApiTest.php b/apps/files_sharing/tests/ApiTest.php
index f39ddeb5485..1417be3a904 100644
--- a/apps/files_sharing/tests/ApiTest.php
+++ b/apps/files_sharing/tests/ApiTest.php
@@ -130,14 +130,9 @@ class ApiTest extends TestCase {
* @medium
*/
function testCreateShareUserFile() {
- // simulate a post request
- $data['path'] = $this->filename;
- $data['shareWith'] = self::TEST_FILES_SHARING_API_USER2;
- $data['shareType'] = \OCP\Share::SHARE_TYPE_USER;
-
- $request = $this->createRequest($data);
+ $request = $this->createRequest([]);
$ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1);
- $result = $ocs->createShare();
+ $result = $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2);
$ocs->cleanup();
$data = $result->getData();
@@ -154,14 +149,9 @@ class ApiTest extends TestCase {
}
function testCreateShareUserFolder() {
- // simulate a post request
- $data['path'] = $this->folder;
- $data['shareWith'] = self::TEST_FILES_SHARING_API_USER2;
- $data['shareType'] = \OCP\Share::SHARE_TYPE_USER;
-
- $request = $this->createRequest($data);
+ $request = $this->createRequest([]);
$ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1);
- $result = $ocs->createShare();
+ $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2);
$ocs->cleanup();
$data = $result->getData();
@@ -179,14 +169,9 @@ class ApiTest extends TestCase {
function testCreateShareGroupFile() {
- // simulate a post request
- $data['path'] = $this->filename;
- $data['shareWith'] = self::TEST_FILES_SHARING_API_GROUP1;
- $data['shareType'] = \OCP\Share::SHARE_TYPE_GROUP;
-
- $request = $this->createRequest($data);
+ $request = $this->createRequest([]);
$ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1);
- $result = $ocs->createShare();
+ $result = $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_GROUP, self::TEST_FILES_SHARING_API_GROUP1);
$ocs->cleanup();
$data = $result->getData();
@@ -202,14 +187,9 @@ class ApiTest extends TestCase {
}
function testCreateShareGroupFolder() {
- // simulate a post request
- $data['path'] = $this->folder;
- $data['shareWith'] = self::TEST_FILES_SHARING_API_GROUP1;
- $data['shareType'] = \OCP\Share::SHARE_TYPE_GROUP;
-
- $request = $this->createRequest($data);
+ $request = $this->createRequest([]);
$ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1);
- $result = $ocs->createShare();
+ $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_GROUP, self::TEST_FILES_SHARING_API_GROUP1);
$ocs->cleanup();
$data = $result->getData();
@@ -226,13 +206,9 @@ class ApiTest extends TestCase {
}
public function testCreateShareLink() {
- // simulate a post request
- $data['path'] = $this->folder;
- $data['shareType'] = \OCP\Share::SHARE_TYPE_LINK;
-
- $request = $this->createRequest($data);
+ $request = $this->createRequest([]);
$ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1);
- $result = $ocs->createShare();
+ $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK);
$ocs->cleanup();
$data = $result->getData();
@@ -253,14 +229,9 @@ class ApiTest extends TestCase {
}
public function testCreateShareLinkPublicUpload() {
- // simulate a post request
- $data['path'] = $this->folder;
- $data['shareType'] = \OCP\Share::SHARE_TYPE_LINK;
- $data['publicUpload'] = 'true';
-
- $request = $this->createRequest($data);
+ $request = $this->createRequest([]);
$ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1);
- $result = $ocs->createShare();
+ $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'true');
$ocs->cleanup();
$data = $result->getData();
@@ -291,30 +262,20 @@ class ApiTest extends TestCase {
$appConfig = \OC::$server->getAppConfig();
$appConfig->setValue('core', 'shareapi_enforce_links_password', 'yes');
- // don't allow to share link without a password
- $data['path'] = $this->folder;
- $data['shareType'] = \OCP\Share::SHARE_TYPE_LINK;
-
- $request = $this->createRequest($data);
+ $request = $this->createRequest([]);
$ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1);
try {
- $ocs->createShare();
+ $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK);
$this->fail();
} catch (OCSForbiddenException $e) {
}
$ocs->cleanup();
- // don't allow to share link without a empty password
- $data = [];
- $data['path'] = $this->folder;
- $data['shareType'] = \OCP\Share::SHARE_TYPE_LINK;
- $data['password'] = '';
-
- $request = $this->createRequest($data);
+ $request = $this->createRequest([]);
$ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1);
try {
- $ocs->createShare();
+ $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', '');
$this->fail();
} catch (OCSForbiddenException $e) {
@@ -322,14 +283,9 @@ class ApiTest extends TestCase {
$ocs->cleanup();
// share with password should succeed
- $data = [];
- $data['path'] = $this->folder;
- $data['shareType'] = \OCP\Share::SHARE_TYPE_LINK;
- $data['password'] = 'foo';
-
- $request = $this->createRequest($data);
+ $request = $this->createRequest([]);
$ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1);
- $result = $ocs->createShare();
+ $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', 'bar');
$ocs->cleanup();
$data = $result->getData();
@@ -373,13 +329,10 @@ class ApiTest extends TestCase {
// sharing file to a user should work if shareapi_exclude_groups is set
// to no
\OC::$server->getAppConfig()->setValue('core', 'shareapi_exclude_groups', 'no');
- $post['path'] = $this->filename;
- $post['shareWith'] = self::TEST_FILES_SHARING_API_USER2;
- $post['shareType'] = \OCP\Share::SHARE_TYPE_USER;
- $request = $this->createRequest($post);
+ $request = $this->createRequest([]);
$ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1);
- $result = $ocs->createShare();
+ $result = $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2);
$ocs->cleanup();
$data = $result->getData();
@@ -388,21 +341,16 @@ class ApiTest extends TestCase {
$request = $this->createRequest([]);
$ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1);
- $result = $ocs->deleteShare($data['id']);
+ $ocs->deleteShare($data['id']);
$ocs->cleanup();
// exclude groups, but not the group the user belongs to. Sharing should still work
\OC::$server->getAppConfig()->setValue('core', 'shareapi_exclude_groups', 'yes');
\OC::$server->getAppConfig()->setValue('core', 'shareapi_exclude_groups_list', 'admin,group1,group2');
- $post = [];
- $post['path'] = $this->filename;
- $post['shareWith'] = self::TEST_FILES_SHARING_API_USER2;
- $post['shareType'] = \OCP\Share::SHARE_TYPE_USER;
-
- $request = $this->createRequest($post);
+ $request = $this->createRequest([]);
$ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1);
- $result = $ocs->createShare();
+ $result = $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2);
$ocs->cleanup();
$data = $result->getData();
@@ -417,14 +365,9 @@ class ApiTest extends TestCase {
// now we exclude the group the user belongs to ('group'), sharing should fail now
\OC::$server->getAppConfig()->setValue('core', 'shareapi_exclude_groups_list', 'admin,group');
- $post = [];
- $post['path'] = $this->filename;
- $post['shareWith'] = self::TEST_FILES_SHARING_API_USER2;
- $post['shareType'] = \OCP\Share::SHARE_TYPE_USER;
-
- $request = $this->createRequest($post);
+ $request = $this->createRequest([]);
$ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1);
- $ocs->createShare();
+ $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2);
$ocs->cleanup();
// cleanup
@@ -492,13 +435,9 @@ class ApiTest extends TestCase {
* @medium
*/
function testPublicLinkUrl() {
- // simulate a post request
- $post['path'] = $this->folder;
- $post['shareType'] = \OCP\Share::SHARE_TYPE_LINK;
-
- $request = $this->createRequest($post);
+ $request = $this->createRequest([]);
$ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1);
- $result = $ocs->createShare();
+ $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK);
$ocs->cleanup();
$data = $result->getData();
@@ -1473,15 +1412,11 @@ class ApiTest extends TestCase {
* @dataProvider datesProvider
*/
public function testPublicLinkExpireDate($date, $valid) {
- $request = $this->createRequest([
- 'path' => $this->folder,
- 'shareType' => \OCP\Share::SHARE_TYPE_LINK,
- 'expireDate' => $date,
- ]);
+ $request = $this->createRequest([]);
$ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1);
try {
- $result = $ocs->createShare();
+ $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', '', $date);
$this->assertTrue($valid);
} catch (OCSNotFoundException $e) {
$this->assertFalse($valid);
@@ -1516,13 +1451,9 @@ class ApiTest extends TestCase {
$date = new \DateTime();
$date->add(new \DateInterval('P5D'));
- $request = $this->createRequest([
- 'path' => $this->folder,
- 'shareType' => \OCP\Share::SHARE_TYPE_LINK,
- 'expireDate' => $date->format('Y-m-d'),
- ]);
+ $request = $this->createRequest([]);
$ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1);
- $result = $ocs->createShare();
+ $result = $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', '', $date->format('Y-m-d'));
$ocs->cleanup();
$data = $result->getData();
@@ -1553,15 +1484,11 @@ class ApiTest extends TestCase {
$date = new \DateTime();
$date->add(new \DateInterval('P8D'));
- $request = $this->createRequest([
- 'path' => $this->folder,
- 'shareType' => \OCP\Share::SHARE_TYPE_LINK,
- 'expireDate' => $date->format('Y-m-d'),
- ]);
+ $request = $this->createRequest([]);
$ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1);
try {
- $ocs->createShare();
+ $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', '', $date->format('Y-m-d'));
$this->fail();
} catch (OCSException $e) {
$this->assertEquals(404, $e->getCode());
@@ -1579,15 +1506,11 @@ class ApiTest extends TestCase {
$date = new \DateTime();
$date->sub(new \DateInterval('P8D'));
- $request = $this->createRequest([
- 'path' => $this->folder,
- 'shareType' => \OCP\Share::SHARE_TYPE_LINK,
- 'expireDate' => $date->format('Y-m-d'),
- ]);
+ $request = $this->createRequest([]);
$ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1);
try {
- $result = $ocs->createShare();
+ $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', '', $date->format('Y-m-d'));
$this->fail();
} catch(OCSException $e) {
$this->assertEquals(404, $e->getCode());
@@ -1605,13 +1528,9 @@ class ApiTest extends TestCase {
*/
public function testInvisibleSharesUser() {
// simulate a post request
- $request = $this->createRequest([
- 'path' => $this->folder,
- 'shareWith' => self::TEST_FILES_SHARING_API_USER2,
- 'shareType' => \OCP\Share::SHARE_TYPE_USER
- ]);
+ $request = $this->createRequest([]);
$ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1);
- $result = $ocs->createShare();
+ $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2);
$ocs->cleanup();
$data = $result->getData();
@@ -1622,7 +1541,7 @@ class ApiTest extends TestCase {
'shareType' => \OCP\Share::SHARE_TYPE_LINK,
]);
$ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER2);
- $result = $ocs->createShare();
+ $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK);
$ocs->cleanup();
$request = $this->createRequest([]);
@@ -1646,24 +1565,17 @@ class ApiTest extends TestCase {
*/
public function testInvisibleSharesGroup() {
// simulate a post request
- $request = $this->createRequest([
- 'path' => $this->folder,
- 'shareWith' => self::TEST_FILES_SHARING_API_GROUP1,
- 'shareType' => \OCP\Share::SHARE_TYPE_GROUP
- ]);
+ $request = $this->createRequest([]);
$ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER1);
- $result = $ocs->createShare();
+ $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_GROUP, self::TEST_FILES_SHARING_API_GROUP1);
$ocs->cleanup();
$data = $result->getData();
$topId = $data['id'];
- $request = $this->createRequest([
- 'path' => $this->folder . $this->subfolder,
- 'shareType' => \OCP\Share::SHARE_TYPE_LINK,
- ]);
+ $request = $this->createRequest([]);
$ocs = $this->createOCS($request, self::TEST_FILES_SHARING_API_USER2);
- $result = $ocs->createShare();
+ $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK);
$ocs->cleanup();
$request = $this->createRequest([]);