Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/private/Share20/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -1419,10 +1419,12 @@ public function getAccessList(\OCP\Files\Node $path, $recursive = true, $current
return $al;
}

//Get node for the owner
//Get node for the owner and correct the owner in case of external storages
$userFolder = $this->rootFolder->getUserFolder($owner);
if ($path->getId() !== $userFolder->getId() && !$userFolder->isSubNode($path)) {
$path = $userFolder->getById($path->getId())[0];
$nodes = $userFolder->getById($path->getId());
$path = array_shift($nodes);
$owner = $path->getOwner()->getUID();
}

$providers = $this->factory->getAllProviders();
Expand Down
46 changes: 30 additions & 16 deletions tests/lib/Share20/ManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3431,26 +3431,33 @@ public function testGetAccessList() {
$extraProvider = $this->createMock(IShareProvider::class);
$factory->setSecondProvider($extraProvider);

$owner = $this->createMock(IUser::class);
$owner->expects($this->once())
$nodeOwner = $this->createMock(IUser::class);
$nodeOwner->expects($this->once())
->method('getUID')
->willReturn('owner');
->willReturn('user1');

$node = $this->createMock(Node::class);
$node->expects($this->once())
->method('getOwner')
->willReturn($owner);
->willReturn($nodeOwner);
$node->method('getId')
->willReturn(42);

$userFolder = $this->createMock(Folder::class);
$file = $this->createMock(File::class);
$folder = $this->createMock(Folder::class);

$owner = $this->createMock(IUser::class);
$owner->expects($this->once())
->method('getUID')
->willReturn('owner');

$file->method('getParent')
->willReturn($folder);
$file->method('getPath')
->willReturn('/owner/files/folder/file');
$file->method('getOwner')
->willReturn($owner);
$file->method('getId')
->willReturn(23);
$folder->method('getParent')
Expand All @@ -3459,12 +3466,12 @@ public function testGetAccessList() {
->willReturn('/owner/files/folder');
$userFolder->method('getById')
->with($this->equalTo(42))
->willReturn([$file]);
->willReturn([12 => $file]);
$userFolder->method('getPath')
->willReturn('/owner/files');
->willReturn('/user1/files');

$this->userManager->method('userExists')
->with($this->equalTo('owner'))
->with($this->equalTo('user1'))
->willReturn(true);

$this->defaultProvider->method('getAccessList')
Expand Down Expand Up @@ -3498,7 +3505,7 @@ public function testGetAccessList() {
]);

$this->rootFolder->method('getUserFolder')
->with($this->equalTo('owner'))
->with($this->equalTo('user1'))
->willReturn($userFolder);

$expected = [
Expand Down Expand Up @@ -3540,26 +3547,33 @@ public function testGetAccessListWithCurrentAccess() {
$extraProvider = $this->createMock(IShareProvider::class);
$factory->setSecondProvider($extraProvider);

$owner = $this->createMock(IUser::class);
$owner->expects($this->once())
$nodeOwner = $this->createMock(IUser::class);
$nodeOwner->expects($this->once())
->method('getUID')
->willReturn('owner');
->willReturn('user1');

$node = $this->createMock(Node::class);
$node->expects($this->once())
->method('getOwner')
->willReturn($owner);
->willReturn($nodeOwner);
$node->method('getId')
->willReturn(42);

$userFolder = $this->createMock(Folder::class);
$file = $this->createMock(File::class);

$owner = $this->createMock(IUser::class);
$owner->expects($this->once())
->method('getUID')
->willReturn('owner');
$folder = $this->createMock(Folder::class);

$file->method('getParent')
->willReturn($folder);
$file->method('getPath')
->willReturn('/owner/files/folder/file');
$file->method('getOwner')
->willReturn($owner);
$file->method('getId')
->willReturn(23);
$folder->method('getParent')
Expand All @@ -3568,12 +3582,12 @@ public function testGetAccessListWithCurrentAccess() {
->willReturn('/owner/files/folder');
$userFolder->method('getById')
->with($this->equalTo(42))
->willReturn([$file]);
->willReturn([42 => $file]);
$userFolder->method('getPath')
->willReturn('/owner/files');
->willReturn('/user1/files');

$this->userManager->method('userExists')
->with($this->equalTo('owner'))
->with($this->equalTo('user1'))
->willReturn(true);

$this->defaultProvider->method('getAccessList')
Expand Down Expand Up @@ -3609,7 +3623,7 @@ public function testGetAccessListWithCurrentAccess() {
]);

$this->rootFolder->method('getUserFolder')
->with($this->equalTo('owner'))
->with($this->equalTo('user1'))
->willReturn($userFolder);

$expected = [
Expand Down