Skip to content

Commit

Permalink
fixup! Fix leave share for root folder
Browse files Browse the repository at this point in the history
  • Loading branch information
Altahrim committed Aug 30, 2023
1 parent e88d1fb commit 5ce1a86
Show file tree
Hide file tree
Showing 2 changed files with 193 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/Unit/FileServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use OCA\EndToEndEncryption\FileService;
use OCP\Files\Folder;
use OCP\Files\Node;
use OCP\Files\Storage\IStorage;
use OCP\ILogger;
use Test\TestCase;

Expand Down Expand Up @@ -149,6 +150,7 @@ private function getSampleFolderForEmpty(): array {
$file3,
$file4,
]);
$folder->method('getName')->willReturn('root');

return [
$folder,
Expand All @@ -162,6 +164,8 @@ private function getSampleFolderForEmpty(): array {
}

private function getSampleFolderForNonEmpty(): array {
$storage = $this->createMock(IStorage::class);

$file1 = $this->createMock(Node::class);
$file1->method('getName')->willReturn('7215ee9c7d9dc229d2921a40e899ec5f.e2e-to-save');
$file1->method('getPath')->willReturn('/foo/bar/7215ee9c7d9dc229d2921a40e899ec5f.e2e-to-save');
Expand All @@ -176,6 +180,7 @@ private function getSampleFolderForNonEmpty(): array {
$file4 = $this->createMock(Node::class);
$file4->method('getName')->willReturn('a9473ded85aa51851deb4859cdd53f98.e2e-to-delete');
$file4->method('getPath')->willReturn('/foo/bar/a9473ded85aa51851deb4859cdd53f98.e2e-to-delete');
$file4->method('getStorage')->willReturn($storage);

$folder = $this->createMock(Folder::class);
$folder->method('getDirectoryListing')->willReturn([
Expand All @@ -184,6 +189,7 @@ private function getSampleFolderForNonEmpty(): array {
$file3,
$file4,
]);
$folder->method('getName')->willReturn('root');

return [
$folder,
Expand Down
187 changes: 187 additions & 0 deletions tests/stub.phpstub
Original file line number Diff line number Diff line change
Expand Up @@ -679,3 +679,190 @@ namespace OC\Files\Storage\Wrapper{
public function getQuota() {}
}
}

namespace OCA\Files_Sharing {
interface ISharedStorage extends \OCP\Files\Storage\IStorage
{
}

/**
* Convert target path to source path and pass the function call to the correct storage provider
*/
class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements \OCA\Files_Sharing\ISharedStorage, \OCP\Files\Storage\IDisableEncryptionStorage
{
public function __construct($arguments)
{
}
/**
* @inheritdoc
*/
public function instanceOfStorage($class) : bool
{
}
/**
* @return string
*/
public function getShareId()
{
}
/**
* get id of the mount point
*
* @return string
*/
public function getId() : string
{
}
/**
* Get the permissions granted for a shared file
*
* @param string $path Shared target file path
* @return int CRUDS permissions granted
*/
public function getPermissions($path = '') : int
{
}
public function isCreatable($path) : bool
{
}
public function isReadable($path) : bool
{
}
public function isUpdatable($path) : bool
{
}
public function isDeletable($path) : bool
{
}
public function isSharable($path) : bool
{
}
public function fopen($path, $mode)
{
}
/**
* see https://www.php.net/manual/en/function.rename.php
*
* @param string $source
* @param string $target
* @return bool
*/
public function rename($source, $target) : bool
{
}
/**
* return mount point of share, relative to data/user/files
*
* @return string
*/
public function getMountPoint() : string
{
}
/**
* @param string $path
*/
public function setMountPoint($path) : void
{
}
/**
* get the user who shared the file
*
* @return string
*/
public function getSharedFrom() : string
{
}
/**
* @return \OCP\Share\IShare
*/
public function getShare() : \OCP\Share\IShare
{
}
/**
* return share type, can be "file" or "folder"
*
* @return string
*/
public function getItemType() : string
{
}
public function getCache($path = '', $storage = null)
{
}
public function getScanner($path = '', $storage = null)
{
}
public function getOwner($path) : string
{
}
public function getWatcher($path = '', $storage = null) : \OC\Files\Cache\Watcher
{
}
/**
* unshare complete storage, also the grouped shares
*
* @return bool
*/
public function unshareStorage() : bool
{
}
/**
* @param string $path
* @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
* @param \OCP\Lock\ILockingProvider $provider
* @throws \OCP\Lock\LockedException
*/
public function acquireLock($path, $type, \OCP\Lock\ILockingProvider $provider)
{
}
/**
* @param string $path
* @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
* @param \OCP\Lock\ILockingProvider $provider
*/
public function releaseLock($path, $type, \OCP\Lock\ILockingProvider $provider)
{
}
/**
* @param string $path
* @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
* @param \OCP\Lock\ILockingProvider $provider
*/
public function changeLock($path, $type, \OCP\Lock\ILockingProvider $provider)
{
}
/**
* @return array [ available, last_checked ]
*/
public function getAvailability()
{
}
/**
* @param bool $isAvailable
*/
public function setAvailability($isAvailable)
{
}
public function getSourceStorage()
{
}
public function getWrapperStorage()
{
}
public function file_get_contents($path)
{
}
public function file_put_contents($path, $data)
{
}
/**
* @return void
*/
public function setMountOptions(array $options)
{
}
public function getUnjailedPath($path)
{
}
}
}

0 comments on commit 5ce1a86

Please sign in to comment.