Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
susnux committed Aug 26, 2024
1 parent 0463791 commit 63e897a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
15 changes: 9 additions & 6 deletions lib/private/Files/Node/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -432,11 +432,14 @@ public function move($targetPath) {
$targetPath = $this->normalizePath($targetPath);
$parent = $this->root->get(dirname($targetPath));
if (
$parent instanceof Folder and
$this->isValidPath($targetPath) and
(
$parent->isCreatable() ||
($parent->getInternalPath() === '' && $parent->getMountPoint() instanceof MoveableMount)
($parent instanceof Folder)
&& $this->isValidPath($targetPath)
&& (
$parent->isCreatable()
|| (
$parent->getInternalPath() === ''
&& ($parent->getMountPoint() instanceof MoveableMount)
)
)
) {
$nonExisting = $this->createNonExistingNode($targetPath);
Expand All @@ -460,7 +463,7 @@ public function move($targetPath) {
$this->path = $targetPath;
return $targetNode;
} else {
throw new NotPermittedException('No permission to move to path ' . $targetPath);
throw new NotPermittedException('No permission to move to path ' . $targetPath . ($parent instanceof Folder ? 'true':'faöse'). ($this->isValidPath($targetPath) ? 'true':'false'));
}
}

Expand Down
4 changes: 3 additions & 1 deletion lib/private/Files/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -1365,7 +1365,9 @@ public function getFileInfo($path, $includeMountPoints = true) {
}
// Ensure that parent path is valid (so it is writable)
try {
$this->verifyPath(dirname($path), basename($path));
if ($path && $path !== '/') {
$this->verifyPath(dirname($path), basename($path));
}
} catch (InvalidPathException) {
// Not a valid parent path so remove update and create permissions
$data['permissions'] &= ~(\OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE);
Expand Down
6 changes: 3 additions & 3 deletions tests/lib/Files/Node/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use OC\Files\View;
use OC\Memcache\ArrayCache;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Config\IUserMountCache;
use OCP\Files\Mount\IMountManager;
use OCP\ICacheFactory;
use OCP\IUserManager;
Expand Down Expand Up @@ -46,8 +47,7 @@ class IntegrationTest extends \Test\TestCase {
protected function setUp(): void {
parent::setUp();

/** @var IMountManager $manager */
$manager = \OC::$server->get(IMountManager::class);
$manager = \OCP\Server::get(IMountManager::class);

\OC_Hook::clear('OC_Filesystem');

Expand All @@ -64,7 +64,7 @@ protected function setUp(): void {
$manager,
$this->view,
$user,
\OC::$server->getUserMountCache(),
\OCP\Server::get(IUserMountCache::class),
$this->createMock(LoggerInterface::class),
$this->createMock(IUserManager::class),
$this->createMock(IEventDispatcher::class),
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/Files/PathVerificationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected function setUp(): void {

public function testPathVerificationFileNameTooLong() {
$this->expectException(\OCP\Files\InvalidPathException::class);
$this->expectExceptionMessage('File name is too long');
$this->expectExceptionMessage('Filename is too long');

$fileName = str_repeat('a', 500);
$this->view->verifyPath('', $fileName);
Expand Down

0 comments on commit 63e897a

Please sign in to comment.