|
@@ -46,6 +46,7 @@ use OCP\Files\IRootFolder;
|
|
|
use OCP\Files\Mount\IMountPoint;
|
|
|
use OCP\Files\NotFoundException;
|
|
|
use OCP\Files\Storage;
|
|
|
+use OCP\Files\Storage\IStorage;
|
|
|
use OCP\IConfig;
|
|
|
use OCP\IGroup;
|
|
|
use OCP\IGroupManager;
|
|
@@ -58,6 +59,7 @@ use OCP\IUser;
|
|
|
use OCP\IUserManager;
|
|
|
use OCP\Lock\LockedException;
|
|
|
use OCP\Share\Exceptions\GenericShareException;
|
|
|
+use OCP\Share\IAttributes as IShareAttributes;
|
|
|
use OCP\Share\IManager;
|
|
|
use OCP\Share\IShare;
|
|
|
use Test\TestCase;
|
|
@@ -124,7 +126,7 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
->willReturn(true);
|
|
|
$this->shareManager
|
|
|
->expects($this->any())
|
|
|
- ->method('shareProviderExists')->willReturn(true);
|
|
|
+ ->method('shareProviderExists')->willReturn(true);
|
|
|
$this->groupManager = $this->createMock(IGroupManager::class);
|
|
|
$this->userManager = $this->createMock(IUserManager::class);
|
|
|
$this->request = $this->createMock(IRequest::class);
|
|
@@ -194,6 +196,23 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ private function mockShareAttributes() {
|
|
|
+ $formattedShareAttributes = [
|
|
|
+ [
|
|
|
+ 'scope' => 'permissions',
|
|
|
+ 'key' => 'download',
|
|
|
+ 'enabled' => true
|
|
|
+ ]
|
|
|
+ ];
|
|
|
+
|
|
|
+ $shareAttributes = $this->createMock(IShareAttributes::class);
|
|
|
+ $shareAttributes->method('toArray')->willReturn($formattedShareAttributes);
|
|
|
+ $shareAttributes->method('getAttribute')->with('permissions', 'download')->willReturn(true);
|
|
|
+
|
|
|
+ // send both IShare attributes class and expected json string
|
|
|
+ return [$shareAttributes, \json_encode($formattedShareAttributes)];
|
|
|
+ }
|
|
|
+
|
|
|
public function testDeleteShareShareNotFound() {
|
|
|
$this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
|
|
|
$this->expectExceptionMessage('Wrong share ID, share does not exist');
|
|
@@ -505,7 +524,7 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
|
|
|
public function createShare($id, $shareType, $sharedWith, $sharedBy, $shareOwner, $path, $permissions,
|
|
|
$shareTime, $expiration, $parent, $target, $mail_send, $note = '', $token = null,
|
|
|
- $password = null, $label = '') {
|
|
|
+ $password = null, $label = '', $attributes = null) {
|
|
|
$share = $this->getMockBuilder(IShare::class)->getMock();
|
|
|
$share->method('getId')->willReturn($id);
|
|
|
$share->method('getShareType')->willReturn($shareType);
|
|
@@ -516,6 +535,7 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
$share->method('getPermissions')->willReturn($permissions);
|
|
|
$share->method('getNote')->willReturn($note);
|
|
|
$share->method('getLabel')->willReturn($label);
|
|
|
+ $share->method('getAttributes')->willReturn($attributes);
|
|
|
$time = new \DateTime();
|
|
|
$time->setTimestamp($shareTime);
|
|
|
$share->method('getShareTime')->willReturn($time);
|
|
@@ -565,6 +585,8 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
$folder->method('getParent')->willReturn($parentFolder);
|
|
|
$folder->method('getMimeType')->willReturn('myFolderMimeType');
|
|
|
|
|
|
+ [$shareAttributes, $shareAttributesReturnJson] = $this->mockShareAttributes();
|
|
|
+
|
|
|
// File shared with user
|
|
|
$share = $this->createShare(
|
|
|
100,
|
|
@@ -579,7 +601,8 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
6,
|
|
|
'target',
|
|
|
0,
|
|
|
- 'personal note'
|
|
|
+ 'personal note',
|
|
|
+ $shareAttributes,
|
|
|
);
|
|
|
$expected = [
|
|
|
'id' => 100,
|
|
@@ -597,6 +620,7 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
'token' => null,
|
|
|
'expiration' => null,
|
|
|
'permissions' => 4,
|
|
|
+ 'attributes' => $shareAttributesReturnJson,
|
|
|
'stime' => 5,
|
|
|
'parent' => null,
|
|
|
'storage_id' => 'STORAGE',
|
|
@@ -613,6 +637,7 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
'can_edit' => false,
|
|
|
'can_delete' => false,
|
|
|
'status' => [],
|
|
|
+ 'attributes' => null,
|
|
|
];
|
|
|
$data[] = [$share, $expected];
|
|
|
|
|
@@ -630,7 +655,8 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
6,
|
|
|
'target',
|
|
|
0,
|
|
|
- 'personal note'
|
|
|
+ 'personal note',
|
|
|
+ $shareAttributes,
|
|
|
);
|
|
|
$expected = [
|
|
|
'id' => 101,
|
|
@@ -647,6 +673,7 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
'token' => null,
|
|
|
'expiration' => null,
|
|
|
'permissions' => 4,
|
|
|
+ 'attributes' => $shareAttributesReturnJson,
|
|
|
'stime' => 5,
|
|
|
'parent' => null,
|
|
|
'storage_id' => 'STORAGE',
|
|
@@ -662,6 +689,7 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
'hide_download' => 0,
|
|
|
'can_edit' => false,
|
|
|
'can_delete' => false,
|
|
|
+ 'attributes' => null,
|
|
|
];
|
|
|
$data[] = [$share, $expected];
|
|
|
|
|
@@ -702,6 +730,7 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
'token' => 'token',
|
|
|
'expiration' => '2000-01-02 00:00:00',
|
|
|
'permissions' => 4,
|
|
|
+ 'attributes' => null,
|
|
|
'stime' => 5,
|
|
|
'parent' => null,
|
|
|
'storage_id' => 'STORAGE',
|
|
@@ -718,6 +747,7 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
'hide_download' => 0,
|
|
|
'can_edit' => false,
|
|
|
'can_delete' => false,
|
|
|
+ 'attributes' => null,
|
|
|
];
|
|
|
$data[] = [$share, $expected];
|
|
|
|
|
@@ -1646,8 +1676,10 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
$path = $this->getMockBuilder(File::class)->getMock();
|
|
|
$storage = $this->createMock(Storage::class);
|
|
|
$storage->method('instanceOfStorage')
|
|
|
- ->with('OCA\Files_Sharing\External\Storage')
|
|
|
- ->willReturn(false);
|
|
|
+ ->willReturnMap([
|
|
|
+ ['OCA\Files_Sharing\External\Storage', false],
|
|
|
+ ['OCA\Files_Sharing\SharedStorage', false],
|
|
|
+ ]);
|
|
|
$path->method('getStorage')->willReturn($storage);
|
|
|
$userFolder->expects($this->once())
|
|
|
->method('get')
|
|
@@ -1680,8 +1712,10 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
$path = $this->getMockBuilder(File::class)->getMock();
|
|
|
$storage = $this->createMock(Storage::class);
|
|
|
$storage->method('instanceOfStorage')
|
|
|
- ->with('OCA\Files_Sharing\External\Storage')
|
|
|
- ->willReturn(false);
|
|
|
+ ->willReturnMap([
|
|
|
+ ['OCA\Files_Sharing\External\Storage', false],
|
|
|
+ ['OCA\Files_Sharing\SharedStorage', false],
|
|
|
+ ]);
|
|
|
$path->method('getStorage')->willReturn($storage);
|
|
|
$userFolder->expects($this->once())
|
|
|
->method('get')
|
|
@@ -1732,8 +1766,10 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
$path = $this->getMockBuilder(File::class)->getMock();
|
|
|
$storage = $this->createMock(Storage::class);
|
|
|
$storage->method('instanceOfStorage')
|
|
|
- ->with('OCA\Files_Sharing\External\Storage')
|
|
|
- ->willReturn(false);
|
|
|
+ ->willReturnMap([
|
|
|
+ ['OCA\Files_Sharing\External\Storage', false],
|
|
|
+ ['OCA\Files_Sharing\SharedStorage', false],
|
|
|
+ ]);
|
|
|
$path->method('getStorage')->willReturn($storage);
|
|
|
$userFolder->expects($this->once())
|
|
|
->method('get')
|
|
@@ -1788,8 +1824,10 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
$path = $this->getMockBuilder(File::class)->getMock();
|
|
|
$storage = $this->createMock(Storage::class);
|
|
|
$storage->method('instanceOfStorage')
|
|
|
- ->with('OCA\Files_Sharing\External\Storage')
|
|
|
- ->willReturn(false);
|
|
|
+ ->willReturnMap([
|
|
|
+ ['OCA\Files_Sharing\External\Storage', false],
|
|
|
+ ['OCA\Files_Sharing\SharedStorage', false],
|
|
|
+ ]);
|
|
|
$path->method('getStorage')->willReturn($storage);
|
|
|
$userFolder->expects($this->once())
|
|
|
->method('get')
|
|
@@ -1847,8 +1885,10 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
$path = $this->getMockBuilder(Folder::class)->getMock();
|
|
|
$storage = $this->createMock(Storage::class);
|
|
|
$storage->method('instanceOfStorage')
|
|
|
- ->with('OCA\Files_Sharing\External\Storage')
|
|
|
- ->willReturn(false);
|
|
|
+ ->willReturnMap([
|
|
|
+ ['OCA\Files_Sharing\External\Storage', false],
|
|
|
+ ['OCA\Files_Sharing\SharedStorage', false],
|
|
|
+ ]);
|
|
|
$path->method('getStorage')->willReturn($storage);
|
|
|
$userFolder->expects($this->once())
|
|
|
->method('get')
|
|
@@ -1901,8 +1941,10 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
$path = $this->getMockBuilder(Folder::class)->getMock();
|
|
|
$storage = $this->createMock(Storage::class);
|
|
|
$storage->method('instanceOfStorage')
|
|
|
- ->with('OCA\Files_Sharing\External\Storage')
|
|
|
- ->willReturn(false);
|
|
|
+ ->willReturnMap([
|
|
|
+ ['OCA\Files_Sharing\External\Storage', false],
|
|
|
+ ['OCA\Files_Sharing\SharedStorage', false],
|
|
|
+ ]);
|
|
|
$path->method('getStorage')->willReturn($storage);
|
|
|
$userFolder->expects($this->once())
|
|
|
->method('get')
|
|
@@ -1935,8 +1977,10 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
$path = $this->getMockBuilder(Folder::class)->getMock();
|
|
|
$storage = $this->createMock(Storage::class);
|
|
|
$storage->method('instanceOfStorage')
|
|
|
- ->with('OCA\Files_Sharing\External\Storage')
|
|
|
- ->willReturn(false);
|
|
|
+ ->willReturnMap([
|
|
|
+ ['OCA\Files_Sharing\External\Storage', false],
|
|
|
+ ['OCA\Files_Sharing\SharedStorage', false],
|
|
|
+ ]);
|
|
|
$path->method('getStorage')->willReturn($storage);
|
|
|
$this->rootFolder->method('getUserFolder')->with($this->currentUser)->willReturnSelf();
|
|
|
$this->rootFolder->method('get')->with('valid-path')->willReturn($path);
|
|
@@ -1956,8 +2000,10 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
$path = $this->getMockBuilder(Folder::class)->getMock();
|
|
|
$storage = $this->createMock(Storage::class);
|
|
|
$storage->method('instanceOfStorage')
|
|
|
- ->with('OCA\Files_Sharing\External\Storage')
|
|
|
- ->willReturn(false);
|
|
|
+ ->willReturnMap([
|
|
|
+ ['OCA\Files_Sharing\External\Storage', false],
|
|
|
+ ['OCA\Files_Sharing\SharedStorage', false],
|
|
|
+ ]);
|
|
|
$path->method('getStorage')->willReturn($storage);
|
|
|
$this->rootFolder->method('getUserFolder')->with($this->currentUser)->willReturnSelf();
|
|
|
$this->rootFolder->method('get')->with('valid-path')->willReturn($path);
|
|
@@ -1978,8 +2024,10 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
$path = $this->getMockBuilder(File::class)->getMock();
|
|
|
$storage = $this->createMock(Storage::class);
|
|
|
$storage->method('instanceOfStorage')
|
|
|
- ->with('OCA\Files_Sharing\External\Storage')
|
|
|
- ->willReturn(false);
|
|
|
+ ->willReturnMap([
|
|
|
+ ['OCA\Files_Sharing\External\Storage', false],
|
|
|
+ ['OCA\Files_Sharing\SharedStorage', false],
|
|
|
+ ]);
|
|
|
$path->method('getStorage')->willReturn($storage);
|
|
|
$this->rootFolder->method('getUserFolder')->with($this->currentUser)->willReturnSelf();
|
|
|
$this->rootFolder->method('get')->with('valid-path')->willReturn($path);
|
|
@@ -1999,8 +2047,10 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
$path = $this->getMockBuilder(Folder::class)->getMock();
|
|
|
$storage = $this->createMock(Storage::class);
|
|
|
$storage->method('instanceOfStorage')
|
|
|
- ->with('OCA\Files_Sharing\External\Storage')
|
|
|
- ->willReturn(false);
|
|
|
+ ->willReturnMap([
|
|
|
+ ['OCA\Files_Sharing\External\Storage', false],
|
|
|
+ ['OCA\Files_Sharing\SharedStorage', false],
|
|
|
+ ]);
|
|
|
$path->method('getStorage')->willReturn($storage);
|
|
|
$this->rootFolder->method('getUserFolder')->with($this->currentUser)->willReturnSelf();
|
|
|
$this->rootFolder->method('get')->with('valid-path')->willReturn($path);
|
|
@@ -2035,8 +2085,10 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
$path = $this->getMockBuilder(Folder::class)->getMock();
|
|
|
$storage = $this->createMock(Storage::class);
|
|
|
$storage->method('instanceOfStorage')
|
|
|
- ->with('OCA\Files_Sharing\External\Storage')
|
|
|
- ->willReturn(false);
|
|
|
+ ->willReturnMap([
|
|
|
+ ['OCA\Files_Sharing\External\Storage', false],
|
|
|
+ ['OCA\Files_Sharing\SharedStorage', false],
|
|
|
+ ]);
|
|
|
$path->method('getStorage')->willReturn($storage);
|
|
|
$this->rootFolder->method('getUserFolder')->with($this->currentUser)->willReturnSelf();
|
|
|
$this->rootFolder->method('get')->with('valid-path')->willReturn($path);
|
|
@@ -2071,8 +2123,10 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
$path = $this->getMockBuilder(Folder::class)->getMock();
|
|
|
$storage = $this->createMock(Storage::class);
|
|
|
$storage->method('instanceOfStorage')
|
|
|
- ->with('OCA\Files_Sharing\External\Storage')
|
|
|
- ->willReturn(false);
|
|
|
+ ->willReturnMap([
|
|
|
+ ['OCA\Files_Sharing\External\Storage', false],
|
|
|
+ ['OCA\Files_Sharing\SharedStorage', false],
|
|
|
+ ]);
|
|
|
$path->method('getStorage')->willReturn($storage);
|
|
|
$this->rootFolder->method('getUserFolder')->with($this->currentUser)->willReturnSelf();
|
|
|
$this->rootFolder->method('get')->with('valid-path')->willReturn($path);
|
|
@@ -2114,8 +2168,10 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
$path = $this->getMockBuilder(Folder::class)->getMock();
|
|
|
$storage = $this->createMock(Storage::class);
|
|
|
$storage->method('instanceOfStorage')
|
|
|
- ->with('OCA\Files_Sharing\External\Storage')
|
|
|
- ->willReturn(false);
|
|
|
+ ->willReturnMap([
|
|
|
+ ['OCA\Files_Sharing\External\Storage', false],
|
|
|
+ ['OCA\Files_Sharing\SharedStorage', false],
|
|
|
+ ]);
|
|
|
$path->method('getStorage')->willReturn($storage);
|
|
|
$path->method('getPath')->willReturn('valid-path');
|
|
|
$this->rootFolder->method('getUserFolder')->with($this->currentUser)->willReturnSelf();
|
|
@@ -2150,8 +2206,10 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
$path = $this->getMockBuilder(Folder::class)->getMock();
|
|
|
$storage = $this->createMock(Storage::class);
|
|
|
$storage->method('instanceOfStorage')
|
|
|
- ->with('OCA\Files_Sharing\External\Storage')
|
|
|
- ->willReturn(false);
|
|
|
+ ->willReturnMap([
|
|
|
+ ['OCA\Files_Sharing\External\Storage', false],
|
|
|
+ ['OCA\Files_Sharing\SharedStorage', false],
|
|
|
+ ]);
|
|
|
$path->method('getStorage')->willReturn($storage);
|
|
|
$this->rootFolder->method('getUserFolder')->with($this->currentUser)->willReturnSelf();
|
|
|
$this->rootFolder->method('get')->with('valid-path')->willReturn($path);
|
|
@@ -2193,8 +2251,10 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
$path = $this->getMockBuilder(Folder::class)->getMock();
|
|
|
$storage = $this->createMock(Storage::class);
|
|
|
$storage->method('instanceOfStorage')
|
|
|
- ->with('OCA\Files_Sharing\External\Storage')
|
|
|
- ->willReturn(false);
|
|
|
+ ->willReturnMap([
|
|
|
+ ['OCA\Files_Sharing\External\Storage', false],
|
|
|
+ ['OCA\Files_Sharing\SharedStorage', false],
|
|
|
+ ]);
|
|
|
$path->method('getStorage')->willReturn($storage);
|
|
|
$this->rootFolder->method('getUserFolder')->with($this->currentUser)->willReturnSelf();
|
|
|
$this->rootFolder->method('get')->with('valid-path')->willReturn($path);
|
|
@@ -2241,8 +2301,10 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
$path = $this->getMockBuilder(File::class)->getMock();
|
|
|
$storage = $this->createMock(Storage::class);
|
|
|
$storage->method('instanceOfStorage')
|
|
|
- ->with('OCA\Files_Sharing\External\Storage')
|
|
|
- ->willReturn(false);
|
|
|
+ ->willReturnMap([
|
|
|
+ ['OCA\Files_Sharing\External\Storage', false],
|
|
|
+ ['OCA\Files_Sharing\SharedStorage', false],
|
|
|
+ ]);
|
|
|
$path->method('getStorage')->willReturn($storage);
|
|
|
$userFolder->expects($this->once())
|
|
|
->method('get')
|
|
@@ -2313,8 +2375,10 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
$path = $this->getMockBuilder(File::class)->getMock();
|
|
|
$storage = $this->createMock(Storage::class);
|
|
|
$storage->method('instanceOfStorage')
|
|
|
- ->with('OCA\Files_Sharing\External\Storage')
|
|
|
- ->willReturn(false);
|
|
|
+ ->willReturnMap([
|
|
|
+ ['OCA\Files_Sharing\External\Storage', false],
|
|
|
+ ['OCA\Files_Sharing\SharedStorage', false],
|
|
|
+ ]);
|
|
|
$path->method('getStorage')->willReturn($storage);
|
|
|
$userFolder->expects($this->once())
|
|
|
->method('get')
|
|
@@ -2367,8 +2431,10 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
$path = $this->getMockBuilder(File::class)->getMock();
|
|
|
$storage = $this->createMock(Storage::class);
|
|
|
$storage->method('instanceOfStorage')
|
|
|
- ->with('OCA\Files_Sharing\External\Storage')
|
|
|
- ->willReturn(false);
|
|
|
+ ->willReturnMap([
|
|
|
+ ['OCA\Files_Sharing\External\Storage', false],
|
|
|
+ ['OCA\Files_Sharing\SharedStorage', false],
|
|
|
+ ]);
|
|
|
$path->method('getStorage')->willReturn($storage);
|
|
|
$userFolder->expects($this->once())
|
|
|
->method('get')
|
|
@@ -2451,8 +2517,10 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
$path = $this->getMockBuilder(File::class)->getMock();
|
|
|
$storage = $this->createMock(Storage::class);
|
|
|
$storage->method('instanceOfStorage')
|
|
|
- ->with('OCA\Files_Sharing\External\Storage')
|
|
|
- ->willReturn(false);
|
|
|
+ ->willReturnMap([
|
|
|
+ ['OCA\Files_Sharing\External\Storage', false],
|
|
|
+ ['OCA\Files_Sharing\SharedStorage', false],
|
|
|
+ ]);
|
|
|
$path->method('getStorage')->willReturn($storage);
|
|
|
$path->method('getPath')->willReturn('valid-path');
|
|
|
$userFolder->expects($this->once())
|
|
@@ -2494,8 +2562,10 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
$path = $this->getMockBuilder(File::class)->getMock();
|
|
|
$storage = $this->createMock(Storage::class);
|
|
|
$storage->method('instanceOfStorage')
|
|
|
- ->with('OCA\Files_Sharing\External\Storage')
|
|
|
- ->willReturn(false);
|
|
|
+ ->willReturnMap([
|
|
|
+ ['OCA\Files_Sharing\External\Storage', false],
|
|
|
+ ['OCA\Files_Sharing\SharedStorage', false],
|
|
|
+ ]);
|
|
|
$path->method('getStorage')->willReturn($storage);
|
|
|
$userFolder->expects($this->once())
|
|
|
->method('get')
|
|
@@ -2575,8 +2645,10 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
$path = $this->getMockBuilder(Folder::class)->getMock();
|
|
|
$storage = $this->createMock(Storage::class);
|
|
|
$storage->method('instanceOfStorage')
|
|
|
- ->with('OCA\Files_Sharing\External\Storage')
|
|
|
- ->willReturn(true);
|
|
|
+ ->willReturnMap([
|
|
|
+ ['OCA\Files_Sharing\External\Storage', true],
|
|
|
+ ['OCA\Files_Sharing\SharedStorage', false],
|
|
|
+ ]);
|
|
|
$path->method('getStorage')->willReturn($storage);
|
|
|
$path->method('getPermissions')->willReturn(\OCP\Constants::PERMISSION_READ);
|
|
|
$userFolder->expects($this->once())
|
|
@@ -2935,8 +3007,17 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
$this->expectExceptionMessage('Invalid date. Format must be YYYY-MM-DD');
|
|
|
|
|
|
$ocs = $this->mockFormatShare();
|
|
|
+ $userFolder = $this->createMock(Folder::class);
|
|
|
+ $userFolder->method('getById')
|
|
|
+ ->with(42)
|
|
|
+ ->willReturn([]);
|
|
|
+ $this->rootFolder->method('getUserFolder')
|
|
|
+ ->with($this->currentUser)
|
|
|
+ ->willReturn($userFolder);
|
|
|
|
|
|
$folder = $this->getMockBuilder(Folder::class)->getMock();
|
|
|
+ $folder->method('getId')
|
|
|
+ ->willReturn(42);
|
|
|
|
|
|
$share = \OC::$server->getShareManager()->newShare();
|
|
|
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
|
|
@@ -2974,8 +3055,16 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
$this->expectExceptionMessage('Public upload disabled by the administrator');
|
|
|
|
|
|
$ocs = $this->mockFormatShare();
|
|
|
+ $userFolder = $this->createMock(Folder::class);
|
|
|
+ $userFolder->method('getById')
|
|
|
+ ->with(42)
|
|
|
+ ->willReturn([]);
|
|
|
+ $this->rootFolder->method('getUserFolder')
|
|
|
+ ->with($this->currentUser)
|
|
|
+ ->willReturn($userFolder);
|
|
|
|
|
|
$folder = $this->getMockBuilder(Folder::class)->getMock();
|
|
|
+ $folder->method('getId')->willReturn(42);
|
|
|
|
|
|
$share = \OC::$server->getShareManager()->newShare();
|
|
|
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
|
|
@@ -2997,6 +3086,15 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
$ocs = $this->mockFormatShare();
|
|
|
|
|
|
$file = $this->getMockBuilder(File::class)->getMock();
|
|
|
+ $file->method('getId')
|
|
|
+ ->willReturn(42);
|
|
|
+ $userFolder = $this->createMock(Folder::class);
|
|
|
+ $userFolder->method('getById')
|
|
|
+ ->with(42)
|
|
|
+ ->willReturn([]);
|
|
|
+ $this->rootFolder->method('getUserFolder')
|
|
|
+ ->with($this->currentUser)
|
|
|
+ ->willReturn($userFolder);
|
|
|
|
|
|
$share = \OC::$server->getShareManager()->newShare();
|
|
|
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
|
|
@@ -3010,13 +3108,21 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
$ocs->updateShare(42, null, 'password', null, 'true', '');
|
|
|
}
|
|
|
|
|
|
- public function testUpdateLinkSharePasswordDoesNotChangeOther() {
|
|
|
+ public function testUpdateLinkSharePasswordDoesNotChangeOther(): void {
|
|
|
$ocs = $this->mockFormatShare();
|
|
|
|
|
|
$date = new \DateTime('2000-01-01');
|
|
|
$date->setTime(0,0,0);
|
|
|
|
|
|
$node = $this->getMockBuilder(File::class)->getMock();
|
|
|
+ $node->method('getId')->willReturn(42);
|
|
|
+ $userFolder = $this->createMock(Folder::class);
|
|
|
+ $userFolder->method('getById')
|
|
|
+ ->with(42)
|
|
|
+ ->willReturn([]);
|
|
|
+ $this->rootFolder->method('getUserFolder')
|
|
|
+ ->with($this->currentUser)
|
|
|
+ ->willReturn($userFolder);
|
|
|
$share = $this->newShare();
|
|
|
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
|
|
|
->setSharedBy($this->currentUser)
|
|
@@ -3061,7 +3167,15 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
$date = new \DateTime('2000-01-01');
|
|
|
$date->setTime(0,0,0);
|
|
|
|
|
|
+ $userFolder = $this->createMock(Folder::class);
|
|
|
+ $userFolder->method('getById')
|
|
|
+ ->with(42)
|
|
|
+ ->willReturn([]);
|
|
|
+ $this->rootFolder->method('getUserFolder')
|
|
|
+ ->with($this->currentUser)
|
|
|
+ ->willReturn($userFolder);
|
|
|
$node = $this->getMockBuilder(File::class)->getMock();
|
|
|
+ $node->method('getId')->willReturn(42);
|
|
|
$share = $this->newShare();
|
|
|
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
|
|
|
->setSharedBy($this->currentUser)
|
|
@@ -3112,7 +3226,15 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
$date = new \DateTime('2000-01-01');
|
|
|
$date->setTime(0,0,0);
|
|
|
|
|
|
+ $userFolder = $this->createMock(Folder::class);
|
|
|
+ $userFolder->method('getById')
|
|
|
+ ->with(42)
|
|
|
+ ->willReturn([]);
|
|
|
+ $this->rootFolder->method('getUserFolder')
|
|
|
+ ->with($this->currentUser)
|
|
|
+ ->willReturn($userFolder);
|
|
|
$node = $this->getMockBuilder(File::class)->getMock();
|
|
|
+ $node->method('getId')->willReturn(42);
|
|
|
$share = $this->newShare();
|
|
|
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
|
|
|
->setSharedBy($this->currentUser)
|
|
@@ -3145,7 +3267,15 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
$date = new \DateTime('2000-01-01');
|
|
|
$date->setTime(0,0,0);
|
|
|
|
|
|
+ $userFolder = $this->createMock(Folder::class);
|
|
|
+ $userFolder->method('getById')
|
|
|
+ ->with(42)
|
|
|
+ ->willReturn([]);
|
|
|
+ $this->rootFolder->method('getUserFolder')
|
|
|
+ ->with($this->currentUser)
|
|
|
+ ->willReturn($userFolder);
|
|
|
$node = $this->getMockBuilder(File::class)->getMock();
|
|
|
+ $node->method('getId')->willReturn(42);
|
|
|
$share = $this->newShare();
|
|
|
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
|
|
|
->setSharedBy($this->currentUser)
|
|
@@ -3725,7 +3855,7 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
$recipient = $this->getMockBuilder(IUser::class)->getMock();
|
|
|
$recipient->method('getDisplayName')->willReturn('recipientDN');
|
|
|
$recipient->method('getSystemEMailAddress')->willReturn('recipient');
|
|
|
-
|
|
|
+ [$shareAttributes, $shareAttributesReturnJson] = $this->mockShareAttributes();
|
|
|
|
|
|
$result = [];
|
|
|
|
|
@@ -3735,6 +3865,7 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
->setSharedBy('initiator')
|
|
|
->setShareOwner('owner')
|
|
|
->setPermissions(\OCP\Constants::PERMISSION_READ)
|
|
|
+ ->setAttributes($shareAttributes)
|
|
|
->setNode($file)
|
|
|
->setShareTime(new \DateTime('2000-01-01T00:01:02'))
|
|
|
->setTarget('myTarget')
|
|
@@ -3749,6 +3880,7 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
'uid_owner' => 'initiator',
|
|
|
'displayname_owner' => 'initiator',
|
|
|
'permissions' => 1,
|
|
|
+ 'attributes' => $shareAttributesReturnJson,
|
|
|
'stime' => 946684862,
|
|
|
'parent' => null,
|
|
|
'expiration' => null,
|
|
@@ -3775,6 +3907,7 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
'can_edit' => false,
|
|
|
'can_delete' => false,
|
|
|
'status' => [],
|
|
|
+ 'attributes' => '[{"scope":"permissions","key":"download","enabled":true}]',
|
|
|
], $share, [], false
|
|
|
];
|
|
|
// User backend up
|
|
@@ -3785,6 +3918,7 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
'uid_owner' => 'initiator',
|
|
|
'displayname_owner' => 'initiatorDN',
|
|
|
'permissions' => 1,
|
|
|
+ 'attributes' => $shareAttributesReturnJson,
|
|
|
'stime' => 946684862,
|
|
|
'parent' => null,
|
|
|
'expiration' => null,
|
|
@@ -3811,6 +3945,7 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
'can_edit' => false,
|
|
|
'can_delete' => false,
|
|
|
'status' => [],
|
|
|
+ 'attributes' => '[{"scope":"permissions","key":"download","enabled":true}]',
|
|
|
], $share, [
|
|
|
['owner', $owner],
|
|
|
['initiator', $initiator],
|
|
@@ -3837,6 +3972,7 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
'uid_owner' => 'initiator',
|
|
|
'displayname_owner' => 'initiator',
|
|
|
'permissions' => 1,
|
|
|
+ 'attributes' => null,
|
|
|
'stime' => 946684862,
|
|
|
'parent' => null,
|
|
|
'expiration' => null,
|
|
@@ -3863,6 +3999,7 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
'can_edit' => false,
|
|
|
'can_delete' => false,
|
|
|
'status' => [],
|
|
|
+ 'attributes' => null,
|
|
|
], $share, [], false
|
|
|
];
|
|
|
|
|
@@ -3885,6 +4022,7 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
'uid_owner' => 'initiator',
|
|
|
'displayname_owner' => 'initiator',
|
|
|
'permissions' => 1,
|
|
|
+ 'attributes' => null,
|
|
|
'stime' => 946684862,
|
|
|
'parent' => null,
|
|
|
'expiration' => null,
|
|
@@ -3911,6 +4049,7 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
'can_edit' => true,
|
|
|
'can_delete' => true,
|
|
|
'status' => [],
|
|
|
+ 'attributes' => null,
|
|
|
], $share, [], false
|
|
|
];
|
|
|
|
|
@@ -3935,6 +4074,7 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
'uid_owner' => 'initiator',
|
|
|
'displayname_owner' => 'initiator',
|
|
|
'permissions' => 1,
|
|
|
+ 'attributes' => null,
|
|
|
'stime' => 946684862,
|
|
|
'parent' => null,
|
|
|
'expiration' => null,
|
|
@@ -3959,6 +4099,7 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
'hide_download' => 0,
|
|
|
'can_edit' => false,
|
|
|
'can_delete' => false,
|
|
|
+ 'attributes' => null,
|
|
|
], $share, [], false
|
|
|
];
|
|
|
|
|
@@ -4005,6 +4146,7 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
'hide_download' => 0,
|
|
|
'can_edit' => false,
|
|
|
'can_delete' => false,
|
|
|
+ 'attributes' => null,
|
|
|
], $share, [], false
|
|
|
];
|
|
|
|
|
@@ -4030,6 +4172,7 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
'uid_owner' => 'initiator',
|
|
|
'displayname_owner' => 'initiator',
|
|
|
'permissions' => 1,
|
|
|
+ 'attributes' => null,
|
|
|
'stime' => 946684862,
|
|
|
'parent' => null,
|
|
|
'expiration' => '2001-01-02 00:00:00',
|
|
@@ -4057,6 +4200,7 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
'hide_download' => 0,
|
|
|
'can_edit' => false,
|
|
|
'can_delete' => false,
|
|
|
+ 'attributes' => null,
|
|
|
], $share, [], false
|
|
|
];
|
|
|
|
|
@@ -4110,6 +4254,7 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
'hide_download' => 0,
|
|
|
'can_edit' => false,
|
|
|
'can_delete' => false,
|
|
|
+ 'attributes' => null,
|
|
|
], $share, [], false
|
|
|
];
|
|
|
|
|
@@ -4157,6 +4302,7 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
'hide_download' => 0,
|
|
|
'can_edit' => false,
|
|
|
'can_delete' => false,
|
|
|
+ 'attributes' => null,
|
|
|
], $share, [], false
|
|
|
];
|
|
|
|
|
@@ -4204,6 +4350,7 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
'hide_download' => 0,
|
|
|
'can_edit' => false,
|
|
|
'can_delete' => false,
|
|
|
+ 'attributes' => null,
|
|
|
], $share, [], false
|
|
|
];
|
|
|
|
|
@@ -4228,6 +4375,7 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
'uid_owner' => 'initiator',
|
|
|
'displayname_owner' => 'initiator',
|
|
|
'permissions' => 1,
|
|
|
+ 'attributes' => null,
|
|
|
'stime' => 946684862,
|
|
|
'parent' => null,
|
|
|
'expiration' => null,
|
|
@@ -4253,6 +4401,7 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
'hide_download' => 0,
|
|
|
'can_edit' => false,
|
|
|
'can_delete' => false,
|
|
|
+ 'attributes' => null,
|
|
|
], $share, [], false
|
|
|
];
|
|
|
|
|
@@ -4300,6 +4449,7 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
'hide_download' => 0,
|
|
|
'can_edit' => false,
|
|
|
'can_delete' => false,
|
|
|
+ 'attributes' => null,
|
|
|
], $share, [], false
|
|
|
];
|
|
|
|
|
@@ -4347,6 +4497,7 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
'hide_download' => 0,
|
|
|
'can_edit' => false,
|
|
|
'can_delete' => false,
|
|
|
+ 'attributes' => null,
|
|
|
], $share, [], false
|
|
|
];
|
|
|
|
|
@@ -4411,6 +4562,7 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
'can_edit' => false,
|
|
|
'can_delete' => false,
|
|
|
'password_expiration_time' => null,
|
|
|
+ 'attributes' => null,
|
|
|
], $share, [], false
|
|
|
];
|
|
|
|
|
@@ -4461,6 +4613,7 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
'can_edit' => false,
|
|
|
'can_delete' => false,
|
|
|
'password_expiration_time' => null,
|
|
|
+ 'attributes' => null,
|
|
|
], $share, [], false
|
|
|
];
|
|
|
|
|
@@ -4510,6 +4663,7 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
'can_edit' => true,
|
|
|
'can_delete' => true,
|
|
|
'status' => [],
|
|
|
+ 'attributes' => null,
|
|
|
], $share, [], false
|
|
|
];
|
|
|
|
|
@@ -4661,6 +4815,7 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
'label' => '',
|
|
|
'can_edit' => false,
|
|
|
'can_delete' => false,
|
|
|
+ 'attributes' => null,
|
|
|
], $share, false, []
|
|
|
];
|
|
|
|
|
@@ -4707,6 +4862,7 @@ class ShareAPIControllerTest extends TestCase {
|
|
|
'label' => '',
|
|
|
'can_edit' => false,
|
|
|
'can_delete' => false,
|
|
|
+ 'attributes' => null,
|
|
|
], $share, true, [
|
|
|
'share_with_displayname' => 'recipientRoomName'
|
|
|
]
|