diff options
author | Louis Chemineau <louis@chmn.me> | 2024-02-13 14:46:04 +0100 |
---|---|---|
committer | Louis Chemineau <louis@chmn.me> | 2024-02-21 15:06:01 +0100 |
commit | 8e95d0f3ae4fb9e186e3995cd2aa7d8393d7003d (patch) | |
tree | 4983e9675640ab789a3619ab24e3354a9908dea6 /apps/dav/tests/unit | |
parent | 7ff81838b0c75d27e6af7cfa8e292c6ffbedf548 (diff) | |
download | nextcloud-server-8e95d0f3ae4fb9e186e3995cd2aa7d8393d7003d.tar.gz nextcloud-server-8e95d0f3ae4fb9e186e3995cd2aa7d8393d7003d.zip |
Check share attributes when downloading versions
Signed-off-by: Louis Chemineau <louis@chmn.me>
Diffstat (limited to 'apps/dav/tests/unit')
-rw-r--r-- | apps/dav/tests/unit/DAV/ViewOnlyPluginTest.php | 28 | ||||
-rw-r--r-- | apps/dav/tests/unit/ServerTest.php | 1 |
2 files changed, 27 insertions, 2 deletions
diff --git a/apps/dav/tests/unit/DAV/ViewOnlyPluginTest.php b/apps/dav/tests/unit/DAV/ViewOnlyPluginTest.php index 00dde60d234..32fd9f452b5 100644 --- a/apps/dav/tests/unit/DAV/ViewOnlyPluginTest.php +++ b/apps/dav/tests/unit/DAV/ViewOnlyPluginTest.php @@ -27,10 +27,11 @@ use OCA\Files_Sharing\SharedStorage; use OCA\Files_Versions\Sabre\VersionFile; use OCA\Files_Versions\Versions\IVersion; use OCP\Files\File; +use OCP\Files\Folder; use OCP\Files\Storage\IStorage; +use OCP\IUser; use OCP\Share\IAttributes; use OCP\Share\IShare; -use Psr\Log\LoggerInterface; use Sabre\DAV\Server; use Sabre\DAV\Tree; use Sabre\HTTP\RequestInterface; @@ -43,10 +44,13 @@ class ViewOnlyPluginTest extends TestCase { private $tree; /** @var RequestInterface | \PHPUnit\Framework\MockObject\MockObject */ private $request; + /** @var Folder | \PHPUnit\Framework\MockObject\MockObject */ + private $userFolder; public function setUp(): void { + $this->userFolder = $this->createMock(Folder::class); $this->plugin = new ViewOnlyPlugin( - $this->createMock(LoggerInterface::class) + $this->userFolder, ); $this->request = $this->createMock(RequestInterface::class); $this->tree = $this->createMock(Tree::class); @@ -111,6 +115,26 @@ class ViewOnlyPluginTest extends TestCase { $davNode->expects($this->once()) ->method('getVersion') ->willReturn($version); + + $currentUser = $this->createMock(IUser::class); + $currentUser->expects($this->once()) + ->method('getUID') + ->willReturn('alice'); + $nodeInfo->expects($this->once()) + ->method('getOwner') + ->willReturn($currentUser); + + $nodeInfo = $this->createMock(File::class); + $owner = $this->createMock(IUser::class); + $owner->expects($this->once()) + ->method('getUID') + ->willReturn('bob'); + $this->userFolder->expects($this->once()) + ->method('getById') + ->willReturn([$nodeInfo]); + $this->userFolder->expects($this->once()) + ->method('getOwner') + ->willReturn($owner); } else { $davPath = 'files/path/to/file.odt'; $davNode = $this->createMock(DavFile::class); diff --git a/apps/dav/tests/unit/ServerTest.php b/apps/dav/tests/unit/ServerTest.php index 62e2accd697..26309d5fcd4 100644 --- a/apps/dav/tests/unit/ServerTest.php +++ b/apps/dav/tests/unit/ServerTest.php @@ -45,6 +45,7 @@ class ServerTest extends \Test\TestCase { /** @var IRequest | \PHPUnit\Framework\MockObject\MockObject $r */ $r = $this->createMock(IRequest::class); $r->expects($this->any())->method('getRequestUri')->willReturn($uri); + $this->loginAsUser('admin'); $s = new Server($r, '/'); $this->assertNotNull($s->server); foreach ($plugins as $plugin) { |