diff --git a/js/richobjectstringparser.js b/js/richobjectstringparser.js index 169fa6bba8a..3cd7ce15e90 100644 --- a/js/richobjectstringparser.js +++ b/js/richobjectstringparser.js @@ -16,7 +16,7 @@ _userLocalTemplate: '@{{name}}', _unknownTemplate: '{{name}}', - _unknownLinkTemplate: '{{name}}', + _unknownLinkTemplate: '{{name}}', /** * @param {string} subject diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 654b6e7dd2e..4b97a4945ce 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -29,6 +29,7 @@ use OCA\Spreed\GuestManager; use OCA\Spreed\HookListener; use OCA\Spreed\Notification\Notifier; +use OCA\Spreed\Participant; use OCA\Spreed\Room; use OCA\Spreed\Settings\Personal; use OCA\Spreed\Signaling\BackendNotifier; @@ -70,6 +71,7 @@ public function register() { $this->registerRoomInvitationHook($dispatcher); $this->registerCallNotificationHook($dispatcher); $this->registerChatHooks($dispatcher); + $this->registerRoomHooks($dispatcher); $this->registerClientLinks($server); /** @var Listener $systemMessageListener */ @@ -321,4 +323,38 @@ protected function registerChatHooks(EventDispatcherInterface $dispatcher) { }; $dispatcher->addListener(Room::class . '::postDeleteRoom', $listener); } + + protected function registerRoomHooks(EventDispatcherInterface $dispatcher) { + $listener = function(GenericEvent $event) { + /** @var Room $room */ + $room = $event->getSubject(); + + if ($event->getArgument('selfJoin')) { + /** @var \OCA\Spreed\Share\RoomShareProvider $roomShareProvider */ + $roomShareProvider = $this->getContainer()->query(\OCA\Spreed\Share\RoomShareProvider::class); + $roomShareProvider->deleteInRoom($room->getToken(), $event->getArgument('userId')); + } + }; + $dispatcher->addListener(Room::class . '::postUserDisconnectRoom', $listener); + + $listener = function(GenericEvent $event) { + /** @var Room $room */ + $room = $event->getSubject(); + + /** @var \OCA\Spreed\Share\RoomShareProvider $roomShareProvider */ + $roomShareProvider = $this->getContainer()->query(\OCA\Spreed\Share\RoomShareProvider::class); + $roomShareProvider->deleteInRoom($room->getToken(), $event->getArgument('user')->getUID()); + }; + $dispatcher->addListener(Room::class . '::postRemoveUser', $listener); + + $listener = function(GenericEvent $event) { + /** @var Room $room */ + $room = $event->getSubject(); + + /** @var \OCA\Spreed\Share\RoomShareProvider $roomShareProvider */ + $roomShareProvider = $this->getContainer()->query(\OCA\Spreed\Share\RoomShareProvider::class); + $roomShareProvider->deleteInRoom($room->getToken()); + }; + $dispatcher->addListener(Room::class . '::postDeleteRoom', $listener); + } } diff --git a/lib/Chat/SystemMessage/Listener.php b/lib/Chat/SystemMessage/Listener.php index 1ea295cde65..3037ee353a9 100644 --- a/lib/Chat/SystemMessage/Listener.php +++ b/lib/Chat/SystemMessage/Listener.php @@ -23,11 +23,14 @@ use OCA\Spreed\Chat\ChatManager; +use OCA\Spreed\Manager; use OCA\Spreed\Participant; use OCA\Spreed\Room; use OCA\Spreed\TalkSession; use OCP\IUser; use OCP\IUserSession; +use OCP\Share; +use OCP\Share\IShare; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\GenericEvent; @@ -37,14 +40,17 @@ class Listener { protected $dispatcher; /** @var ChatManager */ protected $chatManager; + /** @var Manager */ + protected $roomManager; /** @var TalkSession */ protected $talkSession; /** @var IUserSession */ protected $userSession; - public function __construct(EventDispatcherInterface $dispatcher, ChatManager $chatManager, TalkSession $talkSession, IUserSession $userSession) { + public function __construct(EventDispatcherInterface $dispatcher, ChatManager $chatManager, Manager $roomManager, TalkSession $talkSession, IUserSession $userSession) { $this->dispatcher = $dispatcher; $this->chatManager = $chatManager; + $this->roomManager = $roomManager; $this->talkSession = $talkSession; $this->userSession = $userSession; } @@ -129,6 +135,17 @@ public function register() { $this->sendSystemMessage($room, 'moderator_demoted', ['user' => $event->getArgument('user')]); } }); + $this->dispatcher->addListener('OCP\Share::postShare', function(GenericEvent $event) { + /** @var IShare $share */ + $share = $event->getSubject(); + + if ($share->getShareType() !== Share::SHARE_TYPE_ROOM) { + return; + } + + $room = $this->roomManager->getRoomByToken($share->getSharedWith()); + $this->sendSystemMessage($room, 'file_shared', ['share' => $share->getId()]); + }); } protected function sendSystemMessage(Room $room, string $message, array $parameters = []) { diff --git a/lib/Chat/SystemMessage/Parser.php b/lib/Chat/SystemMessage/Parser.php index dc9e3b91b48..918c360b0ac 100644 --- a/lib/Chat/SystemMessage/Parser.php +++ b/lib/Chat/SystemMessage/Parser.php @@ -24,8 +24,10 @@ use OCA\Spreed\Exceptions\ParticipantNotFoundException; use OCA\Spreed\GuestManager; +use OCA\Spreed\Share\RoomShareProvider; use OCP\Comments\IComment; use OCP\IL10N; +use OCP\IURLGenerator; use OCP\IUser; use OCP\IUserManager; use OCP\IUserSession; @@ -38,6 +40,10 @@ class Parser { protected $guestManager; /** @var IUserSession */ protected $userSession; + /** @var RoomShareProvider */ + protected $shareProvider; + /** @var IURLGenerator */ + protected $url; /** @var IL10N */ protected $l; @@ -46,10 +52,17 @@ class Parser { /** @var string[] */ protected $guestNames = []; - public function __construct(IUserManager $userManager, GuestManager $guestManager, IUserSession $userSession, IL10N $l) { + public function __construct(IUserManager $userManager, + GuestManager $guestManager, + IUserSession $userSession, + RoomShareProvider $shareProvider, + IURLGenerator $url, + IL10N $l) { $this->userManager = $userManager; $this->guestManager = $guestManager; $this->userSession = $userSession; + $this->shareProvider = $shareProvider; + $this->url = $url; $this->l = $l; } @@ -146,6 +159,19 @@ public function parseMessage(IComment $comment, string $displayName): array { } else if ($currentUser instanceof IUser && $currentUser->getUID() === $parsedParameters['user']['id']) { $parsedMessage = $this->l->t('{actor} demoted you from moderator'); } + } else if ($message === 'file_shared') { + try { + $parsedParameters['file'] = $this->getFileFromShare($parameters['share']); + $parsedMessage = $this->l->t('{actor} shared {file} into the conversation'); + if ($currentUserIsActor) { + $parsedMessage = $this->l->t('You shared {file} into the conversation'); + } + } catch (\Exception $e) { + $parsedMessage = $this->l->t('{actor} shared a file which is no longer available'); + if ($currentUserIsActor) { + $parsedMessage = $this->l->t('You shared a file which is no longer available'); + } + } } $comment->setMessage($message); @@ -161,6 +187,36 @@ protected function getActor(IComment $comment): array { return $this->getUser($comment->getActorId()); } + /** + * @param string $shareId + * @return array + * @throws \OCP\Files\InvalidPathException + * @throws \OCP\Files\NotFoundException + * @throws \OCP\Share\Exceptions\ShareNotFound + */ + protected function getFileFromShare(string $shareId): array { + $share = $this->shareProvider->getShareById($shareId); + $node = $share->getNode(); + + + if ($this->userSession->isLoggedIn()) { + $url = $this->url->linkToRouteAbsolute('files.viewcontroller.showFile', [ + 'fileid' => $node->getId(), + ]); + } else { + $url = $this->url->linkToRouteAbsolute('files_sharing.sharecontroller.showShare', [ + 'token' => $share->getToken(), + ]); + } + + return [ + 'type' => 'file', + 'id' => $shareId, + 'name' => $node->getName(), + 'link' => $url, + ]; + } + protected function getUser(string $uid): array { if (!isset($this->displayNames[$uid])) { $this->displayNames[$uid] = $this->getDisplayName($uid); diff --git a/lib/Share/Helper/DeletedShareAPIController.php b/lib/Share/Helper/DeletedShareAPIController.php new file mode 100644 index 00000000000..717ffd40a5d --- /dev/null +++ b/lib/Share/Helper/DeletedShareAPIController.php @@ -0,0 +1,101 @@ +. + * + */ + +namespace OCA\Spreed\Share\Helper; + +use OCA\Spreed\Exceptions\RoomNotFoundException; +use OCA\Spreed\Manager; +use OCA\Spreed\Room; +use OCP\IUserManager; +use OCP\Share\IShare; + +/** + * Helper of OCA\Files_Sharing\Controller\DeletedShareAPIController for room + * shares. + * + * The methods of this class are called from the DeletedShareAPIController to + * perform actions or checks specific to room shares. + */ +class DeletedShareAPIController { + + /** @var string */ + private $userId; + + /** @var IUserManager */ + private $userManager; + + /** @var Manager */ + private $manager; + + /** + * DeletedShareAPIController constructor. + * + * @param string $UserId + * @param IUserManager $userManager + * @param Manager $manager + */ + public function __construct( + string $UserId, + IUserManager $userManager, + Manager $manager + ) { + $this->userId = $UserId; + $this->userManager = $userManager; + $this->manager = $manager; + } + + /** + * Formats the specific fields of a room share for OCS output. + * + * The returned fields override those set by the main + * DeletedShareAPIController. + * + * @param IShare $share + * @return array + */ + public function formatShare(IShare $share): array { + $result = []; + + try { + $room = $this->manager->getRoomByToken($share->getSharedWith()); + } catch (RoomNotFoundException $e) { + return $result; + } + + // The display name of one-to-one rooms is set to the display name of + // the other participant. + $roomName = $room->getName(); + if ($room->getType() === Room::ONE_TO_ONE_CALL) { + $participantsList = $room->getParticipants()['users']; + unset($participantsList[$this->userId]); + + $roomName = $this->userManager->get(key($participantsList))->getDisplayName(); + } + + $result['share_with_displayname'] = $roomName; + + return $result; + } + +} diff --git a/lib/Share/Helper/ShareAPIController.php b/lib/Share/Helper/ShareAPIController.php new file mode 100644 index 00000000000..e46c3019b58 --- /dev/null +++ b/lib/Share/Helper/ShareAPIController.php @@ -0,0 +1,186 @@ +. + * + */ + +namespace OCA\Spreed\Share\Helper; + +use OCA\Spreed\Exceptions\ParticipantNotFoundException; +use OCA\Spreed\Exceptions\RoomNotFoundException; +use OCA\Spreed\Manager; +use OCA\Spreed\Room; +use OCP\AppFramework\OCS\OCSNotFoundException; +use OCP\IL10N; +use OCP\IUserManager; +use OCP\Share\IShare; + +/** + * Helper of OCA\Files_Sharing\Controller\ShareAPIController for room shares. + * + * The methods of this class are called from the ShareAPIController to perform + * actions or checks specific to room shares. + */ +class ShareAPIController { + + /** @var string */ + private $userId; + + /** @var IUserManager */ + private $userManager; + + /** @var Manager */ + private $manager; + + /** @var IL10N */ + private $l; + + /** + * ShareAPIController constructor. + * + * @param string $UserId + * @param IUserManager $userManager + * @param Manager $manager + * @param IL10N $l10n + */ + public function __construct( + string $UserId, + IUserManager $userManager, + Manager $manager, + IL10N $l10n + ) { + $this->userId = $UserId; + $this->userManager = $userManager; + $this->manager = $manager; + $this->l = $l10n; + } + + /** + * Formats the specific fields of a room share for OCS output. + * + * The returned fields override those set by the main ShareAPIController. + * + * @param IShare $share + * @return array + */ + public function formatShare(IShare $share): array { + $result = []; + + try { + $room = $this->manager->getRoomByToken($share->getSharedWith()); + } catch (RoomNotFoundException $e) { + return $result; + } + + // The display name of one-to-one rooms is set to the display name of + // the other participant. + $roomName = $room->getName(); + if ($room->getType() === Room::ONE_TO_ONE_CALL) { + $participantsList = $room->getParticipants()['users']; + unset($participantsList[$this->userId]); + + $roomName = $this->userManager->get(key($participantsList))->getDisplayName(); + } + + $result['share_with_displayname'] = $roomName; + + if ($room->getType() === Room::PUBLIC_CALL) { + $result['token'] = $share->getToken(); + } + + return $result; + } + + /** + * Prepares the given share to be passed to OC\Share20\Manager::createShare. + * + * @param IShare $share + * @param string $shareWith + * @param int $permissions + * @param string $expireDate + */ + public function createShare(IShare $share, string $shareWith, int $permissions, string $expireDate) { + $share->setSharedWith($shareWith); + $share->setPermissions($permissions); + + if ($expireDate !== '') { + try { + $expireDate = $this->parseDate($expireDate); + $share->setExpirationDate($expireDate); + } catch (\Exception $e) { + throw new OCSNotFoundException($this->l->t('Invalid date, date format must be YYYY-MM-DD')); + } + } + } + + /** + * Make sure that the passed date is valid ISO 8601 + * So YYYY-MM-DD + * If not throw an exception + * + * Copied from \OCA\Files_Sharing\Controller\ShareAPIController::parseDate. + * + * @param string $expireDate + * @return \DateTime + * @throws \Exception + */ + private function parseDate(string $expireDate): \DateTime { + try { + $date = new \DateTime($expireDate); + } catch (\Exception $e) { + throw new \Exception('Invalid date. Format must be YYYY-MM-DD'); + } + + if ($date === false) { + throw new \Exception('Invalid date. Format must be YYYY-MM-DD'); + } + + $date->setTime(0, 0, 0); + + return $date; + } + + /** + * Returns whether the given user can access the given room share or not. + * + * A user can access a room share only if she is a participant of the room. + * + * @param IShare $share + * @param string $user + * @return bool + */ + public function canAccessShare(IShare $share, string $user): bool { + try { + $room = $this->manager->getRoomByToken($share->getSharedWith()); + } catch (RoomNotFoundException $e) { + return false; + } + + try { + $room->getParticipant($user); + } catch (ParticipantNotFoundException $e) { + return false; + } + + return true; + } + +} diff --git a/lib/Share/RoomShareProvider.php b/lib/Share/RoomShareProvider.php new file mode 100644 index 00000000000..2f46d1c1c82 --- /dev/null +++ b/lib/Share/RoomShareProvider.php @@ -0,0 +1,1066 @@ +. + * + */ + +namespace OCA\Spreed\Share; + +use OCA\Spreed\Exceptions\ParticipantNotFoundException; +use OCA\Spreed\Exceptions\RoomNotFoundException; +use OCA\Spreed\Manager; +use OCA\Spreed\Room; +use OCP\DB\QueryBuilder\IQueryBuilder; +use OCP\Files\Folder; +use OCP\Files\IRootFolder; +use OCP\Files\Node; +use OCP\IDBConnection; +use OCP\IL10N; +use OCP\IUserManager; +use OCP\Security\ISecureRandom; +use OCP\Share\Exceptions\GenericShareException; +use OCP\Share\Exceptions\ShareNotFound; +use OCP\Share\IManager as IShareManager; +use OCP\Share\IShare; +use OCP\Share\IShareProvider; + +/** + * Share provider for room shares. + * + * Files are shared with a room identified by its token; only users currently in + * the room can share with and access the shared files (although the access + * checks are not enforced by the provider, but done on a higher layer). + * + * Like in group shares, a recipient can move or delete a share without + * modifying the share for the other users in the room. + */ +class RoomShareProvider implements IShareProvider { + + // Special share type for user modified room shares + const SHARE_TYPE_USERROOM = 11; + + /** @var IDBConnection */ + private $dbConnection; + + /** @var ISecureRandom */ + private $secureRandom; + + /** @var IUserManager */ + private $userManager; + + /** @var IShareManager */ + private $shareManager; + + /** @var IRootFolder */ + private $rootFolder; + + /** @var IL10N */ + private $l; + + /** @var Manager */ + private $manager; + + /** + * RoomShareProvider constructor. + * + * @param IDBConnection $connection + * @param ISecureRandom $secureRandom + * @param IUserManager $userManager + * @param IShareManager $shareManager + * @param IRootFolder $rootFolder + * @param IL10N $l10n + * @param Manager $manager + */ + public function __construct( + IDBConnection $connection, + ISecureRandom $secureRandom, + IUserManager $userManager, + IShareManager $shareManager, + IRootFolder $rootFolder, + IL10N $l, + Manager $manager + ) { + $this->dbConnection = $connection; + $this->secureRandom = $secureRandom; + $this->userManager = $userManager; + $this->shareManager = $shareManager; + $this->rootFolder = $rootFolder; + $this->l = $l; + $this->manager = $manager; + } + + /** + * Return the identifier of this provider. + * + * @return string Containing only [a-zA-Z0-9] + */ + public function identifier() { + return 'ocRoomShare'; + } + + /** + * Create a share + * + * @param IShare $share + * @return IShare The share object + * @throws GenericShareException + */ + public function create(IShare $share) { + try { + $room = $this->manager->getRoomByToken($share->getSharedWith()); + } catch (RoomNotFoundException $e) { + throw new GenericShareException("Room not found", $this->l->t('Conversation not found'), 404); + } + + try { + $room->getParticipant($share->getSharedBy()); + } catch (ParticipantNotFoundException $e) { + // If the sharer is not a participant of the room even if the room + // exists the error is still "Room not found". + throw new GenericShareException("Room not found", $this->l->t('Conversation not found'), 404); + } + + $existingShares = $this->getSharesByPath($share->getNode()); + foreach ($existingShares as $existingShare) { + if ($existingShare->getSharedWith() === $share->getSharedWith()) { + throw new GenericShareException("Already shared", $this->l->t('Path is already shared with this room'), 403); + } + } + + $share->setToken( + $this->secureRandom->generate( + 15, // \OC\Share\Constants::TOKEN_LENGTH + \OCP\Security\ISecureRandom::CHAR_HUMAN_READABLE + ) + ); + + $shareId = $this->addShareToDB( + $share->getSharedWith(), + $share->getSharedBy(), + $share->getShareOwner(), + $share->getNodeType(), + $share->getNodeId(), + $share->getTarget(), + $share->getPermissions(), + $share->getToken(), + $share->getExpirationDate() + ); + + $data = $this->getRawShare($shareId); + + return $this->createShareObject($data); + } + + /** + * Add share to the database and return the ID + * + * @param string $shareWith + * @param string $sharedBy + * @param string $shareOwner + * @param string $itemType + * @param int $itemSource + * @param string $target + * @param int $permissions + * @param string $token + * @param \DateTime|null $expirationDate + * @return int + */ + private function addShareToDB( + string $shareWith, + string $sharedBy, + string $shareOwner, + string $itemType, + int $itemSource, + string $target, + int $permissions, + string $token, + \DateTime $expirationDate = null + ): int { + $qb = $this->dbConnection->getQueryBuilder(); + $qb->insert('share') + ->setValue('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_ROOM)) + ->setValue('share_with', $qb->createNamedParameter($shareWith)) + ->setValue('uid_initiator', $qb->createNamedParameter($sharedBy)) + ->setValue('uid_owner', $qb->createNamedParameter($shareOwner)) + ->setValue('item_type', $qb->createNamedParameter($itemType)) + ->setValue('item_source', $qb->createNamedParameter($itemSource)) + ->setValue('file_source', $qb->createNamedParameter($itemSource)) + ->setValue('file_target', $qb->createNamedParameter($target)) + ->setValue('permissions', $qb->createNamedParameter($permissions)) + ->setValue('token', $qb->createNamedParameter($token)) + ->setValue('stime', $qb->createNamedParameter(time())); + + if ($expirationDate !== null) { + $qb->setValue('expiration', $qb->createNamedParameter($expirationDate, 'datetime')); + } + + $qb->execute(); + $id = $qb->getLastInsertId(); + + return (int)$id; + } + + /** + * Get database row of the given share + * + * @param int $id + * @return array + * @throws ShareNotFound + */ + private function getRawShare(int $id) { + $qb = $this->dbConnection->getQueryBuilder(); + $qb->select('*') + ->from('share') + ->where($qb->expr()->eq('id', $qb->createNamedParameter($id))); + + $cursor = $qb->execute(); + $data = $cursor->fetch(); + $cursor->closeCursor(); + + if ($data === false) { + throw new ShareNotFound(); + } + + return $data; + } + + /** + * Create a share object from a database row + * + * @param array $data + * @return IShare + */ + private function createShareObject($data) { + $share = $this->shareManager->newShare(); + $share->setId((int)$data['id']) + ->setShareType((int)$data['share_type']) + ->setPermissions((int)$data['permissions']) + ->setTarget($data['file_target']) + ->setToken($data['token']); + + $shareTime = new \DateTime(); + $shareTime->setTimestamp((int)$data['stime']); + $share->setShareTime($shareTime); + $share->setSharedWith($data['share_with']); + + $share->setSharedBy($data['uid_initiator']); + $share->setShareOwner($data['uid_owner']); + + if ($data['expiration'] !== null) { + $expiration = \DateTime::createFromFormat('Y-m-d H:i:s', $data['expiration']); + if ($expiration !== false) { + $share->setExpirationDate($expiration); + } + } + + $share->setNodeId((int)$data['file_source']); + $share->setNodeType($data['item_type']); + + $share->setProviderId($this->identifier()); + + return $share; + } + + /** + * Update a share + * + * @param IShare $share + * @return IShare The share object + */ + public function update(IShare $share) { + $qb = $this->dbConnection->getQueryBuilder(); + $qb->update('share') + ->where($qb->expr()->eq('id', $qb->createNamedParameter($share->getId()))) + ->set('uid_owner', $qb->createNamedParameter($share->getShareOwner())) + ->set('uid_initiator', $qb->createNamedParameter($share->getSharedBy())) + ->set('permissions', $qb->createNamedParameter($share->getPermissions())) + ->set('item_source', $qb->createNamedParameter($share->getNode()->getId())) + ->set('file_source', $qb->createNamedParameter($share->getNode()->getId())) + ->set('expiration', $qb->createNamedParameter($share->getExpirationDate(), IQueryBuilder::PARAM_DATE)) + ->execute(); + + /* + * Update all user defined group shares + */ + $qb = $this->dbConnection->getQueryBuilder(); + $qb->update('share') + ->where($qb->expr()->eq('parent', $qb->createNamedParameter($share->getId()))) + ->set('uid_owner', $qb->createNamedParameter($share->getShareOwner())) + ->set('uid_initiator', $qb->createNamedParameter($share->getSharedBy())) + ->set('item_source', $qb->createNamedParameter($share->getNode()->getId())) + ->set('file_source', $qb->createNamedParameter($share->getNode()->getId())) + ->set('expiration', $qb->createNamedParameter($share->getExpirationDate(), IQueryBuilder::PARAM_DATE)) + ->execute(); + + /* + * Now update the permissions for all children that have not set it to 0 + */ + $qb = $this->dbConnection->getQueryBuilder(); + $qb->update('share') + ->where($qb->expr()->eq('parent', $qb->createNamedParameter($share->getId()))) + ->andWhere($qb->expr()->neq('permissions', $qb->createNamedParameter(0))) + ->set('permissions', $qb->createNamedParameter($share->getPermissions())) + ->execute(); + + return $share; + } + + /** + * Delete a share + * + * @param IShare $share + */ + public function delete(IShare $share) { + $qb = $this->dbConnection->getQueryBuilder(); + $qb->delete('share') + ->where($qb->expr()->eq('id', $qb->createNamedParameter($share->getId()))); + + $qb->orWhere($qb->expr()->eq('parent', $qb->createNamedParameter($share->getId()))); + + $qb->execute(); + } + + /** + * Unshare a file from self as recipient. + * + * If a user unshares a room share from their self then the original room + * share should still exist. + * + * @param IShare $share + * @param string $recipient UserId of the recipient + */ + public function deleteFromSelf(IShare $share, $recipient) { + // Check if there is a userroom share + $qb = $this->dbConnection->getQueryBuilder(); + $stmt = $qb->select(['id', 'permissions']) + ->from('share') + ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_USERROOM))) + ->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($recipient))) + ->andWhere($qb->expr()->eq('parent', $qb->createNamedParameter($share->getId()))) + ->andWhere($qb->expr()->orX( + $qb->expr()->eq('item_type', $qb->createNamedParameter('file')), + $qb->expr()->eq('item_type', $qb->createNamedParameter('folder')) + )) + ->execute(); + + $data = $stmt->fetch(); + $stmt->closeCursor(); + + if ($data === false) { + // No userroom share yet. Create one. + $qb = $this->dbConnection->getQueryBuilder(); + $qb->insert('share') + ->values([ + 'share_type' => $qb->createNamedParameter(self::SHARE_TYPE_USERROOM), + 'share_with' => $qb->createNamedParameter($recipient), + 'uid_owner' => $qb->createNamedParameter($share->getShareOwner()), + 'uid_initiator' => $qb->createNamedParameter($share->getSharedBy()), + 'parent' => $qb->createNamedParameter($share->getId()), + 'item_type' => $qb->createNamedParameter($share->getNodeType()), + 'item_source' => $qb->createNamedParameter($share->getNodeId()), + 'file_source' => $qb->createNamedParameter($share->getNodeId()), + 'file_target' => $qb->createNamedParameter($share->getTarget()), + 'permissions' => $qb->createNamedParameter(0), + 'stime' => $qb->createNamedParameter($share->getShareTime()->getTimestamp()), + ])->execute(); + } else if ($data['permissions'] !== 0) { + // Already a userroom share. Update it. + $qb = $this->dbConnection->getQueryBuilder(); + $qb->update('share') + ->set('permissions', $qb->createNamedParameter(0)) + ->where($qb->expr()->eq('id', $qb->createNamedParameter($data['id']))) + ->execute(); + } + } + + /** + * Restore a share for a given recipient. The implementation could be provider independant. + * + * @param IShare $share + * @param string $recipient + * @return IShare The restored share object + * @throws GenericShareException In case the share could not be restored + */ + public function restore(IShare $share, string $recipient): IShare { + $qb = $this->dbConnection->getQueryBuilder(); + $qb->select('permissions') + ->from('share') + ->where( + $qb->expr()->eq('id', $qb->createNamedParameter($share->getId())) + ); + $cursor = $qb->execute(); + $data = $cursor->fetch(); + $cursor->closeCursor(); + + $originalPermission = $data['permissions']; + + $qb = $this->dbConnection->getQueryBuilder(); + $qb->update('share') + ->set('permissions', $qb->createNamedParameter($originalPermission)) + ->where( + $qb->expr()->eq('parent', $qb->createNamedParameter($share->getId())) + )->andWhere( + $qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_USERROOM)) + )->andWhere( + $qb->expr()->eq('share_with', $qb->createNamedParameter($recipient)) + ); + + $qb->execute(); + + return $this->getShareById($share->getId(), $recipient); + } + + /** + * Move a share as a recipient. + * + * This is updating the share target. Thus the mount point of the recipient. + * This may require special handling. If a user moves a room share + * the target should only be changed for them. + * + * @param IShare $share + * @param string $recipient userId of recipient + * @return IShare + */ + public function move(IShare $share, $recipient) { + // Check if there is a userroom share + $qb = $this->dbConnection->getQueryBuilder(); + $stmt = $qb->select('id') + ->from('share') + ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_USERROOM))) + ->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($recipient))) + ->andWhere($qb->expr()->eq('parent', $qb->createNamedParameter($share->getId()))) + ->andWhere($qb->expr()->orX( + $qb->expr()->eq('item_type', $qb->createNamedParameter('file')), + $qb->expr()->eq('item_type', $qb->createNamedParameter('folder')) + )) + ->setMaxResults(1) + ->execute(); + + $data = $stmt->fetch(); + $stmt->closeCursor(); + + if ($data === false) { + // No userroom share yet. Create one. + $qb = $this->dbConnection->getQueryBuilder(); + $qb->insert('share') + ->values([ + 'share_type' => $qb->createNamedParameter(self::SHARE_TYPE_USERROOM), + 'share_with' => $qb->createNamedParameter($recipient), + 'uid_owner' => $qb->createNamedParameter($share->getShareOwner()), + 'uid_initiator' => $qb->createNamedParameter($share->getSharedBy()), + 'parent' => $qb->createNamedParameter($share->getId()), + 'item_type' => $qb->createNamedParameter($share->getNodeType()), + 'item_source' => $qb->createNamedParameter($share->getNodeId()), + 'file_source' => $qb->createNamedParameter($share->getNodeId()), + 'file_target' => $qb->createNamedParameter($share->getTarget()), + 'permissions' => $qb->createNamedParameter($share->getPermissions()), + 'stime' => $qb->createNamedParameter($share->getShareTime()->getTimestamp()), + ])->execute(); + } else { + // Already a userroom share. Update it. + $qb = $this->dbConnection->getQueryBuilder(); + $qb->update('share') + ->set('file_target', $qb->createNamedParameter($share->getTarget())) + ->where($qb->expr()->eq('id', $qb->createNamedParameter($data['id']))) + ->execute(); + } + + return $share; + } + + /** + * Get all shares by the given user in a folder + * + * @param string $userId + * @param Folder $node + * @param bool $reshares Also get the shares where $user is the owner instead of just the shares where $user is the initiator + * @return IShare[] + */ + public function getSharesInFolder($userId, Folder $node, $reshares) { + $qb = $this->dbConnection->getQueryBuilder(); + $qb->select('*') + ->from('share', 's') + ->andWhere($qb->expr()->orX( + $qb->expr()->eq('item_type', $qb->createNamedParameter('file')), + $qb->expr()->eq('item_type', $qb->createNamedParameter('folder')) + )) + ->andWhere( + $qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_ROOM)) + ); + + /** + * Reshares for this user are shares where they are the owner. + */ + if ($reshares === false) { + $qb->andWhere($qb->expr()->eq('uid_initiator', $qb->createNamedParameter($userId))); + } else { + $qb->andWhere( + $qb->expr()->orX( + $qb->expr()->eq('uid_owner', $qb->createNamedParameter($userId)), + $qb->expr()->eq('uid_initiator', $qb->createNamedParameter($userId)) + ) + ); + } + + $qb->innerJoin('s', 'filecache' ,'f', $qb->expr()->eq('s.file_source', 'f.fileid')); + $qb->andWhere($qb->expr()->eq('f.parent', $qb->createNamedParameter($node->getId()))); + + $qb->orderBy('id'); + + $cursor = $qb->execute(); + $shares = []; + while ($data = $cursor->fetch()) { + $shares[$data['fileid']][] = $this->createShareObject($data); + } + $cursor->closeCursor(); + + return $shares; + } + + /** + * Get all shares by the given user + * + * @param string $userId + * @param int $shareType + * @param Node|null $node + * @param bool $reshares Also get the shares where $user is the owner instead of just the shares where $user is the initiator + * @param int $limit The maximum number of shares to be returned, -1 for all shares + * @param int $offset + * @return IShare[] + */ + public function getSharesBy($userId, $shareType, $node, $reshares, $limit, $offset) { + $qb = $this->dbConnection->getQueryBuilder(); + $qb->select('*') + ->from('share'); + + $qb->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_ROOM))); + + /** + * Reshares for this user are shares where they are the owner. + */ + if ($reshares === false) { + $qb->andWhere($qb->expr()->eq('uid_initiator', $qb->createNamedParameter($userId))); + } else { + $qb->andWhere( + $qb->expr()->orX( + $qb->expr()->eq('uid_owner', $qb->createNamedParameter($userId)), + $qb->expr()->eq('uid_initiator', $qb->createNamedParameter($userId)) + ) + ); + } + + if ($node !== null) { + $qb->andWhere($qb->expr()->eq('file_source', $qb->createNamedParameter($node->getId()))); + } + + if ($limit !== -1) { + $qb->setMaxResults($limit); + } + + $qb->setFirstResult($offset); + $qb->orderBy('id'); + + $cursor = $qb->execute(); + $shares = []; + while ($data = $cursor->fetch()) { + $shares[] = $this->createShareObject($data); + } + $cursor->closeCursor(); + + return $shares; + } + + /** + * Get share by id + * + * @param int $id + * @param string|null $recipientId + * @return IShare + * @throws ShareNotFound + */ + public function getShareById($id, $recipientId = null) { + $qb = $this->dbConnection->getQueryBuilder(); + + $qb->select('*') + ->from('share') + ->where($qb->expr()->eq('id', $qb->createNamedParameter($id))) + ->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_ROOM))); + + $cursor = $qb->execute(); + $data = $cursor->fetch(); + $cursor->closeCursor(); + + if ($data === false) { + throw new ShareNotFound(); + } + + $share = $this->createShareObject($data); + + if ($recipientId !== null) { + $share = $this->resolveSharesForRecipient([$share], $recipientId)[0]; + } + + return $share; + } + + /** + * Returns each given share as seen by the given recipient. + * + * If the recipient has not modified the share the original one is returned + * instead. + * + * @param Share[] $shares + * @param string $userId + * @return Share[] + */ + private function resolveSharesForRecipient(array $shares, string $userId): array { + $result = []; + + $start = 0; + while (true) { + /** @var Share[] $shareSlice */ + $shareSlice = array_slice($shares, $start, 100); + $start += 100; + + if ($shareSlice === []) { + break; + } + + /** @var int[] $ids */ + $ids = []; + /** @var Share[] $shareMap */ + $shareMap = []; + + foreach ($shareSlice as $share) { + $ids[] = (int)$share->getId(); + $shareMap[$share->getId()] = $share; + } + + $qb = $this->dbConnection->getQueryBuilder(); + + $query = $qb->select('*') + ->from('share') + ->where($qb->expr()->in('parent', $qb->createNamedParameter($ids, IQueryBuilder::PARAM_INT_ARRAY))) + ->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($userId))) + ->andWhere($qb->expr()->orX( + $qb->expr()->eq('item_type', $qb->createNamedParameter('file')), + $qb->expr()->eq('item_type', $qb->createNamedParameter('folder')) + )); + + $stmt = $query->execute(); + + while ($data = $stmt->fetch()) { + $shareMap[$data['parent']]->setPermissions((int)$data['permissions']); + $shareMap[$data['parent']]->setTarget($data['file_target']); + } + + $stmt->closeCursor(); + + foreach ($shareMap as $share) { + $result[] = $share; + } + } + + return $result; + } + + /** + * Get shares for a given path + * + * @param Node $path + * @return IShare[] + */ + public function getSharesByPath(Node $path) { + $qb = $this->dbConnection->getQueryBuilder(); + + $cursor = $qb->select('*') + ->from('share') + ->andWhere($qb->expr()->eq('file_source', $qb->createNamedParameter($path->getId()))) + ->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_ROOM))) + ->execute(); + + $shares = []; + while ($data = $cursor->fetch()) { + $shares[] = $this->createShareObject($data); + } + $cursor->closeCursor(); + + return $shares; + } + + /** + * Get shared with the given user + * + * @param string $userId get shares where this user is the recipient + * @param int $shareType + * @param Node|null $node + * @param int $limit The max number of entries returned, -1 for all + * @param int $offset + * @return IShare[] + */ + public function getSharedWith($userId, $shareType, $node, $limit, $offset) { + $allRooms = $this->manager->getRoomsForParticipant($userId); + + /** @var IShare[] $shares */ + $shares = []; + + $start = 0; + while (true) { + $rooms = array_slice($allRooms, $start, 100); + $start += 100; + + if ($rooms === []) { + break; + } + + $qb = $this->dbConnection->getQueryBuilder(); + $qb->select('*') + ->from('share') + ->orderBy('id') + ->setFirstResult(0); + + if ($limit !== -1) { + $qb->setMaxResults($limit); + } + + // Filter by node if provided + if ($node !== null) { + $qb->andWhere($qb->expr()->eq('file_source', $qb->createNamedParameter($node->getId()))); + } + + $rooms = array_map(function(Room $room) { return $room->getToken(); }, $rooms); + + $qb->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_ROOM))) + ->andWhere($qb->expr()->in('share_with', $qb->createNamedParameter( + $rooms, + IQueryBuilder::PARAM_STR_ARRAY + ))) + ->andWhere($qb->expr()->orX( + $qb->expr()->eq('item_type', $qb->createNamedParameter('file')), + $qb->expr()->eq('item_type', $qb->createNamedParameter('folder')) + )); + + $cursor = $qb->execute(); + while ($data = $cursor->fetch()) { + if ($offset > 0) { + $offset--; + continue; + } + + $shares[] = $this->createShareObject($data); + } + $cursor->closeCursor(); + } + + $shares = $this->resolveSharesForRecipient($shares, $userId); + + return $shares; + } + + /** + * Get a share by token + * + * Note that token here refers to share token, not room token. + * + * @param string $token + * @return IShare + * @throws ShareNotFound + */ + public function getShareByToken($token) { + $qb = $this->dbConnection->getQueryBuilder(); + + $cursor = $qb->select('*') + ->from('share') + ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_ROOM))) + ->andWhere($qb->expr()->eq('token', $qb->createNamedParameter($token))) + ->execute(); + + $data = $cursor->fetch(); + + if ($data === false) { + throw new ShareNotFound(); + } + + $roomToken = $data['share_with']; + try { + $room = $this->manager->getRoomByToken($roomToken); + } catch (RoomNotFoundException $e) { + throw new ShareNotFound(); + } + + if ($room->getType() !== Room::PUBLIC_CALL) { + throw new ShareNotFound(); + } + + return $this->createShareObject($data); + } + + /** + * A user is deleted from the system + * So clean up the relevant shares. + * + * @param string $uid + * @param int $shareType + */ + public function userDeleted($uid, $shareType) { + // A deleted user is handled automatically by the room hooks due to the + // user being removed from the room. + } + + /** + * A group is deleted from the system. + * We have to clean up all shares to this group. + * Providers not handling group shares should just return + * + * @param string $gid + */ + public function groupDeleted($gid) { + } + + /** + * A user is deleted from a group + * We have to clean up all the related user specific group shares + * Providers not handling group shares should just return + * + * @param string $uid + * @param string $gid + */ + public function userDeletedFromGroup($uid, $gid) { + } + + /** + * Get the access list to the array of provided nodes. + * + * @see IManager::getAccessList() for sample docs + * + * @param Node[] $nodes The list of nodes to get access for + * @param bool $currentAccess If current access is required (like for removed shares that might get revived later) + * @return array + */ + public function getAccessList($nodes, $currentAccess) { + $ids = []; + foreach ($nodes as $node) { + $ids[] = $node->getId(); + } + + $qb = $this->dbConn->getQueryBuilder(); + + $or = $qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_ROOM)); + + if ($currentAccess) { + $or->add($qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_USERROOM))); + } + + $qb->select('id', 'parent', 'share_type', 'share_with', 'file_source', 'file_target', 'permissions') + ->from('share') + ->where( + $or + ) + ->andWhere($qb->expr()->in('file_source', $qb->createNamedParameter($ids, IQueryBuilder::PARAM_INT_ARRAY))) + ->andWhere($qb->expr()->orX( + $qb->expr()->eq('item_type', $qb->createNamedParameter('file')), + $qb->expr()->eq('item_type', $qb->createNamedParameter('folder')) + )); + $cursor = $qb->execute(); + + $users = []; + while($row = $cursor->fetch()) { + $type = (int)$row['share_type']; + if ($type === \OCP\Share::SHARE_TYPE_ROOM) { + $roomToken = $row['share_with']; + try { + $room = $this->manager->getRoomByToken($roomToken); + } catch (RoomNotFoundException $e) { + continue; + } + + $userList = $room->getParticipants()['users']; + foreach ($userList as $uid => $participantData) { + $users[$uid] = isset($users[$uid]) ? $users[$uid] : []; + $users[$uid][$row['id']] = $row; + } + } else if ($type === self::SHARE_TYPE_USERROOM && $currentAccess === true) { + $uid = $row['share_with']; + $users[$uid] = isset($users[$uid]) ? $users[$uid] : []; + $users[$uid][$row['id']] = $row; + } + } + $cursor->closeCursor(); + + if ($currentAccess === true) { + $users = array_map([$this, 'filterSharesOfUser'], $users); + $users = array_filter($users); + } else { + $users = array_keys($users); + } + + return ['users' => $users]; + } + + /** + * For each user the path with the fewest slashes is returned + * @param array $shares + * @return array + */ + protected function filterSharesOfUser(array $shares) { + // Room shares when the user has a share exception + foreach ($shares as $id => $share) { + $type = (int) $share['share_type']; + $permissions = (int) $share['permissions']; + + if ($type === self::SHARE_TYPE_USERROOM) { + unset($shares[$share['parent']]); + + if ($permissions === 0) { + unset($shares[$id]); + } + } + } + + $best = []; + $bestDepth = 0; + foreach ($shares as $id => $share) { + $depth = substr_count($share['file_target'], '/'); + if (empty($best) || $depth < $bestDepth) { + $bestDepth = $depth; + $best = [ + 'node_id' => $share['file_source'], + 'node_path' => $share['file_target'], + ]; + } + } + + return $best; + } + + /** + * Get all children of this share + * + * Not part of IShareProvider API, but needed by OC\Share20\Manager. + * + * @param IShare $parent + * @return IShare[] + */ + public function getChildren(IShare $parent) { + $children = []; + + $qb = $this->dbConnection->getQueryBuilder(); + $qb->select('*') + ->from('share') + ->where($qb->expr()->eq('parent', $qb->createNamedParameter($parent->getId()))) + ->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_ROOM))) + ->orderBy('id'); + + $cursor = $qb->execute(); + while ($data = $cursor->fetch()) { + $children[] = $this->createShareObject($data); + } + $cursor->closeCursor(); + + return $children; + } + + /** + * Delete all shares in a room, or only those from the given user. + * + * When a user is given all her shares are removed, both own shares and + * received shares. + * + * Not part of IShareProvider API, but needed by the hooks in + * OCA\Spreed\AppInfo\Application + * + * @param string $roomToken + * @param string|null $user + */ + public function deleteInRoom(string $roomToken, string $user = null) { + //First delete all custom room shares for the original shares to be removed + $qb = $this->dbConnection->getQueryBuilder(); + $qb->select('id') + ->from('share') + ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_ROOM))) + ->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($roomToken))); + + if ($user !== null) { + $qb->andWhere($qb->expr()->eq('uid_initiator', $qb->createNamedParameter($user))); + } + + $cursor = $qb->execute(); + $ids = []; + while($row = $cursor->fetch()) { + $ids[] = (int)$row['id']; + } + $cursor->closeCursor(); + + if (!empty($ids)) { + $chunks = array_chunk($ids, 100); + foreach ($chunks as $chunk) { + $qb->delete('share') + ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_USERROOM))) + ->andWhere($qb->expr()->in('parent', $qb->createNamedParameter($chunk, IQueryBuilder::PARAM_INT_ARRAY))); + $qb->execute(); + } + } + + // Now delete all the original room shares + $qb = $this->dbConnection->getQueryBuilder(); + $qb->delete('share') + ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_ROOM))) + ->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($roomToken))); + + if ($user !== null) { + $qb->andWhere($qb->expr()->eq('uid_initiator', $qb->createNamedParameter($user))); + } + + $qb->execute(); + + // Finally delete all custom room shares leftovers for the given user + if ($user !== null) { + $qb = $this->dbConnection->getQueryBuilder(); + $qb->select('id') + ->from('share') + ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_ROOM))) + ->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($roomToken))); + + $cursor = $qb->execute(); + $ids = []; + while($row = $cursor->fetch()) { + $ids[] = (int)$row['id']; + } + $cursor->closeCursor(); + + if (!empty($ids)) { + $chunks = array_chunk($ids, 100); + foreach ($chunks as $chunk) { + $qb->delete('share') + ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_USERROOM))) + ->andWhere($qb->expr()->in('share_with', $qb->createNamedParameter($user))) + ->andWhere($qb->expr()->in('parent', $qb->createNamedParameter($chunk, IQueryBuilder::PARAM_INT_ARRAY))); + $qb->execute(); + } + } + } + } + +} diff --git a/tests/integration/config/behat.yml b/tests/integration/config/behat.yml index 0fcead7a5ac..03d87d1e8f5 100644 --- a/tests/integration/config/behat.yml +++ b/tests/integration/config/behat.yml @@ -7,6 +7,12 @@ default: - %paths.base%/../features contexts: - FeatureContext + - SharingContext: + baseUrl: http://localhost:8080/ + admin: + - admin + - admin + regularUserPassword: 123456 extensions: jarnaiz\JUnitFormatter\JUnitFormatterExtension: diff --git a/tests/integration/features/bootstrap/FeatureContext.php b/tests/integration/features/bootstrap/FeatureContext.php index 4a091a42c7b..e2cb45ae081 100644 --- a/tests/integration/features/bootstrap/FeatureContext.php +++ b/tests/integration/features/bootstrap/FeatureContext.php @@ -55,6 +55,16 @@ class FeatureContext implements Context, SnippetAcceptingContext { /** @var string */ protected $lastEtag; + /** @var array */ + protected $createdUsers = []; + + /** @var array */ + protected $createdGroups = []; + + public static function getTokenForIdentifier(string $identifier) { + return self::$identifierToToken[$identifier]; + } + /** * FeatureContext constructor. */ @@ -63,6 +73,30 @@ public function __construct() { $this->baseUrl = getenv('TEST_SERVER_URL'); } + /** + * @BeforeScenario + */ + public function setUp() { + self::$identifierToToken = []; + self::$tokenToIdentifier = []; + self::$sessionIdToUser = []; + + $this->createdUsers = []; + $this->createdGroups = []; + } + + /** + * @AfterScenario + */ + public function tearDown() { + foreach ($this->createdUsers as $user) { + $this->deleteUser($user); + } + foreach ($this->createdGroups as $group) { + $this->deleteGroup($group); + } + } + /** * @Then /^user "([^"]*)" is participant of the following rooms$/ * @@ -594,6 +628,41 @@ private function createUser($user) { ], ]; $client->send($client->createRequest('GET', $userProvisioningUrl . '/' . $user, $options2)); + + $this->createdUsers[] = $user; + } + + /** + * @Given /^user "([^"]*)" is deleted$/ + * @param string $user + */ + public function userIsDeleted($user) { + $deleted = false; + + $this->deleteUser($user); + try { + $this->userExists($user); + } catch (\GuzzleHttp\Exception\ClientException $ex) { + $deleted = true; + } + + if (!$deleted) { + PHPUnit_Framework_Assert::fail("User $user exists"); + } + } + + private function deleteUser($user) { + $userProvisioningUrl = $this->baseUrl . 'ocs/v2.php/cloud/users/' . $user; + $client = new Client(); + $options = [ + 'auth' => ['admin', 'admin'], + 'headers' => [ + 'OCS-APIREQUEST' => 'true', + ], + ]; + $client->send($client->createRequest('DELETE', $userProvisioningUrl, $options)); + + unset($this->createdUsers[array_search($user, $this->createdUsers)]); } private function setUserDisplayName($user) { @@ -650,6 +719,22 @@ private function createGroup($group) { ], ]; $client->send($client->createRequest('POST', $userProvisioningUrl, $options)); + + $this->createdGroups[] = $group; + } + + private function deleteGroup($group) { + $userProvisioningUrl = $this->baseUrl . 'ocs/v2.php/cloud/groups/' . $group; + $client = new Client(); + $options = [ + 'auth' => ['admin', 'admin'], + 'headers' => [ + 'OCS-APIREQUEST' => 'true', + ], + ]; + $client->send($client->createRequest('DELETE', $userProvisioningUrl, $options)); + + unset($this->createdGroups[array_search($group, $this->createdGroups)]); } /** diff --git a/tests/integration/features/bootstrap/SharingContext.php b/tests/integration/features/bootstrap/SharingContext.php new file mode 100644 index 00000000000..9e2b1616f71 --- /dev/null +++ b/tests/integration/features/bootstrap/SharingContext.php @@ -0,0 +1,767 @@ +. + * + */ + +use Behat\Behat\Context\Context; +use Behat\Gherkin\Node\TableNode; +use GuzzleHttp\Client; +use GuzzleHttp\Cookie\CookieJar; +use GuzzleHttp\Message\ResponseInterface; + +class SharingContext implements Context { + + /** @var string */ + private $baseUrl = ''; + + /** @var ResponseInterface */ + private $response = null; + + /** @var string */ + private $currentUser = ''; + + /** @var string */ + private $regularUserPassword; + + /** @var \SimpleXMLElement */ + private $lastCreatedShareData = null; + + public function __construct(string $baseUrl, array $admin, string $regularUserPassword) { + $this->baseUrl = $baseUrl; + $this->adminUser = $admin; + $this->regularUserPassword = $regularUserPassword; + + // in case of ci deployment we take the server url from the environment + $testServerUrl = getenv('TEST_SERVER_URL'); + if ($testServerUrl !== false) { + $this->baseUrl = $testServerUrl; + } + } + + /** + * @Given user :user creates folder :destination + * + * @param string $user + * @param string $destination + */ + public function userCreatesFolder($user, $destination) { + $this->currentUser = $user; + + $url = "/$user/$destination/"; + + $this->sendingToDav('MKCOL', $url); + + $this->theHTTPStatusCodeShouldBe(201); + } + + /** + * @Given user :user moves file :source to :destination + * + * @param string $user + * @param string $source + * @param string $destination + */ + public function userMovesFileTo(string $user, string $source, string $destination) { + $this->currentUser = $user; + + $url = "/$user/$source"; + + $headers = []; + $headers['Destination'] = $this->baseUrl . "remote.php/dav/files/$user/" . $destination; + + $this->sendingToDav('MOVE', $url, $headers); + } + + /** + * @Given user :user moves file :source to :destination with :statusCode + * + * @param string $user + * @param string $source + * @param string $destination + * @param int statusCode + */ + public function userMovesFileToWith(string $user, string $source, string $destination, int $statusCode) { + $this->userMovesFileTo($user, $source, $destination); + $this->theHTTPStatusCodeShouldBe($statusCode); + } + + /** + * @When user :user shares :path with user :sharee + * + * @param string $user + * @param string $path + * @param string $sharee + * @param TableNode|null $body + */ + public function userSharesWithUser(string $user, string $path, string $sharee, TableNode $body = null) { + $this->userSharesWith($user, $path, 0 /*Share::SHARE_TYPE_USER*/, $sharee, $body); + } + + /** + * @When user :user shares :path with user :sharee with OCS :statusCode + * + * @param string $user + * @param string $path + * @param string $sharee + * @param int $statusCode + */ + public function userSharesWithUserWithOcs(string $user, string $path, string $sharee, int $statusCode) { + $this->userSharesWithUser($user, $path, $sharee); + $this->theOCSStatusCodeShouldBe($statusCode); + } + + /** + * @When user :user shares :path with room :room + * + * @param string $user + * @param string $path + * @param string $room + * @param TableNode|null $body + */ + public function userSharesWithRoom(string $user, string $path, string $room, TableNode $body = null) { + $this->userSharesWith($user, $path, 10 /*Share::SHARE_TYPE_ROOM*/, FeatureContext::getTokenForIdentifier($room), $body); + } + + /** + * @When user :user shares :path with room :room with OCS :statusCode + * + * @param string $user + * @param string $path + * @param string $room + * @param int $statusCode + */ + public function userSharesWithRoomWithOcs(string $user, string $path, string $room, int $statusCode) { + $this->userSharesWithRoom($user, $path, $room); + $this->theOCSStatusCodeShouldBe($statusCode); + } + + /** + * @When user :user updates last share with + * + * @param string $user + * @param TableNode $body + */ + public function userUpdatesLastShareWith(string $user, TableNode $body) { + $this->currentUser = $user; + + $url = '/apps/files_sharing/api/v1/shares/' . $this->getLastShareId(); + + $this->sendingTo('PUT', $url, $body); + } + + /** + * @When user :user deletes last share + * + * @param string $user + */ + public function userDeletesLastShare(string $user) { + $this->currentUser = $user; + + $url = '/apps/files_sharing/api/v1/shares/' . $this->getLastShareId(); + + $this->sendingTo('DELETE', $url); + } + + /** + * @When user :user deletes last share with OCS :statusCode + * + * @param string $user + * @param int $statusCode + */ + public function userDeletesLastShareWithOcs(string $user, int $statusCode) { + $this->userDeletesLastShare($user); + $this->theOCSStatusCodeShouldBe($statusCode); + } + + /** + * @When user :user restores last share + * + * @param string $user + */ + public function userRestoresLastShareWithOcs(string $user) { + $this->currentUser = $user; + + $url = '/apps/files_sharing/api/v1/deletedshares/ocRoomShare:' . $this->getLastShareId(); + + $this->sendingTo('POST', $url); + } + + /** + * @When user :user gets last share + */ + public function userGetsLastShare(string $user) { + $this->currentUser = $user; + + $url = '/apps/files_sharing/api/v1/shares/' . $this->getLastShareId(); + + $this->sendingTo('GET', $url); + } + + /** + * @When user :user gets all shares + * + * @param string $user + */ + public function userGetsAllShares(string $user) { + $this->currentUser = $user; + + $url = '/apps/files_sharing/api/v1/shares'; + + $this->sendingTo('GET', $url); + } + + /** + * @When user :user gets all shares and reshares + * + * @param string $user + */ + public function userGetsAllSharesAndReshares(string $user) { + $this->currentUser = $user; + + $url = '/apps/files_sharing/api/v1/shares?reshares=true'; + + $this->sendingTo('GET', $url); + } + + /** + * @When user :user gets all shares for :path + * + * @param string $user + * @param string $path + */ + public function userGetsAllSharesFor(string $user, string $path) { + $this->currentUser = $user; + + $url = '/apps/files_sharing/api/v1/shares?path=' . $path; + + $this->sendingTo('GET', $url); + } + + /** + * @When user :user gets all shares and reshares for :path + * + * @param string $user + * @param string $path + */ + public function userGetsAllSharesAndResharesFor(string $user, string $path) { + $this->currentUser = $user; + + $url = '/apps/files_sharing/api/v1/shares?reshares=true&path=' . $path; + + $this->sendingTo('GET', $url); + } + + /** + * @When user :user gets all shares for :path and its subfiles + * + * @param string $user + * @param string $path + */ + public function userGetsAllSharesForAndItsSubfiles(string $user, string $path) { + $this->currentUser = $user; + + $url = '/apps/files_sharing/api/v1/shares?subfiles=true&path=' . $path; + + $this->sendingTo('GET', $url); + } + + /** + * @When user :user gets all received shares + * + * @param string $user + */ + public function userGetsAllReceivedShares(string $user) { + $this->currentUser = $user; + + $url = '/apps/files_sharing/api/v1/shares?shared_with_me=true'; + + $this->sendingTo('GET', $url); + } + + /** + * @When user :user gets all received shares for :path + * + * @param string $user + * @param string $path + */ + public function userGetsAllReceivedSharesFor(string $user, string $path) { + $this->currentUser = $user; + + $url = '/apps/files_sharing/api/v1/shares?shared_with_me=true&path=' . $path; + + $this->sendingTo('GET', $url); + } + + /** + * @When user :user gets deleted shares + * + * @param string $user + */ + public function userGetsDeletedShares(string $user) { + $this->currentUser = $user; + + $url = '/apps/files_sharing/api/v1/deletedshares'; + + $this->sendingTo('GET', $url); + } + + /** + * @When user :user gets the share-type DAV property for :path + * + * @param string $user + * @param string $path + */ + public function userGetsTheShareTypeDavPropertyFor(string $user, string $path) { + $this->currentUser = $user; + + $url = "/$user/$path"; + + $headers = null; + + $body = '' . + ' ' . + ' ' . + ' ' . + ''; + + $this->sendingToDav('PROPFIND', $url, $headers, $body); + + $this->theHTTPStatusCodeShouldBe(207); + } + + /** + * @When user :user gets recent files + * + * @param string $user + */ + public function userGetsRecentFiles(string $user) { + // Recents endpoint is not an OCS endpoint, so a request token must be + // provided. + list($requestToken, $cookieJar) = $this->loggingInUsingWebAs($user); + + $url = '/index.php/apps/files/api/v1/recent'; + + $this->sendingToWithRequestToken('GET', $url, $requestToken, $cookieJar); + } + + /** + * @When transfering ownership from :user1 to :user2 + * + * @param string $user1 + * @param string $user2 + */ + public function transferingOwnershipFromTo(string $user1, string $user2) { + $args = ['files:transfer-ownership', $user1, $user2]; + + $args = array_map(function($arg) { + return escapeshellarg($arg); + }, $args); + $args[] = '--no-ansi'; + $args = implode(' ', $args); + + $descriptor = [ + 0 => ['pipe', 'r'], + 1 => ['pipe', 'w'], + 2 => ['pipe', 'w'], + ]; + $process = proc_open('php console.php ' . $args, $descriptor, $pipes, '../../../../'); + $lastStdOut = stream_get_contents($pipes[1]); + $lastStdErr = stream_get_contents($pipes[2]); + $lastCode = proc_close($process); + + // Clean opcode cache + $client = new GuzzleHttp\Client(); + $client->send($client->createRequest('GET', $this->baseUrl . '/apps/testing/clean_opcode_cache.php')); + + PHPUnit_Framework_Assert::assertEquals(0, $lastCode); + } + + /** + * @Then the OCS status code should be :statusCode + * + * @param int $statusCode + */ + public function theOCSStatusCodeShouldBe(int $statusCode) { + $meta = $this->getXmlResponse()->meta[0]; + + PHPUnit_Framework_Assert::assertEquals($statusCode, (int)$meta->statuscode, 'Response message: ' . (string)$meta->message); + } + + /** + * @Then the HTTP status code should be :statusCode + * + * @param int $statusCode + */ + public function theHTTPStatusCodeShouldBe(int $statusCode) { + PHPUnit_Framework_Assert::assertEquals($statusCode, $this->response->getStatusCode()); + } + + /** + * @Then the list of returned shares has :count shares + */ + public function theListOfReturnedSharesHasShares(int $count) { + $this->theHTTPStatusCodeShouldBe(200); + $this->theOCSStatusCodeShouldBe(100); + + $returnedShares = $this->getXmlResponse()->data[0]; + + PHPUnit_Framework_Assert::assertEquals($count, count($returnedShares->element)); + } + + /** + * @Then share is returned with + * + * @param TableNode $body + */ + public function shareIsReturnedWith(TableNode $body) { + $this->shareXIsReturnedWith(0, $body); + } + + /** + * @Then share :number is returned with + * + * @param int $number + * @param TableNode $body + */ + public function shareXIsReturnedWith(int $number, TableNode $body) { + $this->theHTTPStatusCodeShouldBe(200); + $this->theOCSStatusCodeShouldBe(100); + + if (!($body instanceof TableNode)) { + return; + } + + $returnedShare = $this->getXmlResponse()->data[0]; + if ($returnedShare->element) { + $returnedShare = $returnedShare->element[$number]; + } + + $defaultExpectedFields = [ + 'id' => 'A_NUMBER', + 'share_type' => '10', // Share::SHARE_TYPE_ROOM, + 'permissions' => '19', + 'stime' => 'A_NUMBER', + 'parent' => '', + 'expiration' => '', + 'token' => '', + 'storage' => 'A_NUMBER', + 'item_source' => 'A_NUMBER', + 'file_source' => 'A_NUMBER', + 'file_parent' => 'A_NUMBER', + 'mail_send' => '0' + ]; + $expectedFields = array_merge($defaultExpectedFields, $body->getRowsHash()); + + if (!array_key_exists('uid_file_owner', $expectedFields) && + array_key_exists('uid_owner', $expectedFields)) { + $expectedFields['uid_file_owner'] = $expectedFields['uid_owner']; + } + if (!array_key_exists('displayname_file_owner', $expectedFields) && + array_key_exists('displayname_owner', $expectedFields)) { + $expectedFields['displayname_file_owner'] = $expectedFields['displayname_owner']; + } + + if (array_key_exists('share_type', $expectedFields) && + $expectedFields['share_type'] == 10 /* Share::SHARE_TYPE_ROOM */ && + array_key_exists('share_with', $expectedFields)) { + $expectedFields['share_with'] = FeatureContext::getTokenForIdentifier($expectedFields['share_with']); + } + + foreach ($expectedFields as $field => $value) { + $this->assertFieldIsInReturnedShare($field, $value, $returnedShare); + } + } + + /** + * @Then the response contains a share-types DAV property with + * + * @param TableNode|null $table + */ + public function theResponseContainsAShareTypesDavPropertyWith(TableNode $table = null) { + $xmlResponse = $this->getXmlResponse(); + $xmlResponse->registerXPathNamespace('oc', 'http://owncloud.org/ns'); + + $shareTypes = []; + foreach ($xmlResponse->xpath('//oc:share-types/oc:share-type') as $shareType) { + $shareTypes[] = (int)$shareType; + } + + $expectedShareTypes = []; + if ($table !== null) { + foreach ($table->getRows() as $row) { + $expectedShareTypes[] = (int)$row[0]; + } + } + + PHPUnit_Framework_Assert::assertEquals($expectedShareTypes, $shareTypes); + } + + /** + * @Then the response contains a share-types file property for :path with + * + * @param string $path + * @param TableNode|null $table + */ + public function theResponseContainsAShareTypesFilesPropertyForWith(string $path, TableNode $table = null) { + $response = json_decode($this->response->getBody()); + + $fileForPath = array_filter($response->files, function($file) use ($path) { + $filePath = $file->path . (substr($file->path, -1) === '/'? '': '/'); + return ($filePath . $file->name) === $path; + }); + + if (empty($fileForPath)) { + PHPUnit_Framework_Assert::fail("$path not found in the response"); + } + + $fileForPath = array_shift($fileForPath); + + $shareTypes = []; + if (property_exists($fileForPath, 'shareTypes')) { + foreach ($fileForPath->shareTypes as $shareType) { + $shareTypes[] = (int)$shareType; + } + } + + $expectedShareTypes = []; + if ($table !== null) { + foreach ($table->getRows() as $row) { + $expectedShareTypes[] = (int)$row[0]; + } + } + + PHPUnit_Framework_Assert::assertEquals($expectedShareTypes, $shareTypes); + } + + /** + * @param string $user + * @param string $path + * @param string $shareType + * @param string $shareWith + * @param TableNode|null $body + */ + private function userSharesWith(string $user, string $path, string $shareType, string $shareWith, TableNode $body = null) { + $this->currentUser = $user; + + $url = '/apps/files_sharing/api/v1/shares'; + + $parameters = []; + $parameters[] = 'path=' . $path; + $parameters[] = 'shareType=' . $shareType; + $parameters[] = 'shareWith=' . $shareWith; + + if ($body instanceof TableNode) { + foreach ($body->getRowsHash() as $key => $value) { + if ($key === 'expireDate' && $value !== 'invalid date'){ + $value = date('Y-m-d', strtotime($value)); + } + $parameters[] = $key . '=' . $value; + } + } + + $url .= '?' . implode('&', $parameters); + + $this->sendingTo('POST', $url); + + $this->lastCreatedShareData = $this->getXmlResponse(); + } + + /** + * @param string $verb + * @param string $url + * @param TableNode $body + */ + private function sendingTo(string $verb, string $url, TableNode $body = null) { + $fullUrl = $this->baseUrl . "ocs/v1.php" . $url; + $client = new Client(); + $options = []; + if ($this->currentUser === 'admin') { + $options['auth'] = $this->adminUser; + } else { + $options['auth'] = [$this->currentUser, $this->regularUserPassword]; + } + $options['headers'] = [ + 'OCS_APIREQUEST' => 'true' + ]; + if ($body instanceof TableNode) { + $fd = $body->getRowsHash(); + if (array_key_exists('expireDate', $fd)){ + $fd['expireDate'] = date('Y-m-d', strtotime($fd['expireDate'])); + } + $options['body'] = $fd; + } + + try { + $this->response = $client->send($client->createRequest($verb, $fullUrl, $options)); + } catch (GuzzleHttp\Exception\ClientException $ex) { + $this->response = $ex->getResponse(); + } + } + + /** + * @param string $verb + * @param string $url + * @param array $headers + * @param string $body + */ + private function sendingToDav(string $verb, string $url, array $headers = null, string $body = null) { + $fullUrl = $this->baseUrl . "remote.php/dav/files" . $url; + $client = new Client(); + $options = []; + if ($this->currentUser === 'admin') { + $options['auth'] = $this->adminUser; + } else { + $options['auth'] = [$this->currentUser, $this->regularUserPassword]; + } + $options['headers'] = [ + 'OCS_APIREQUEST' => 'true' + ]; + if ($headers !== null) { + $options['headers'] = array_merge($options['headers'], $headers); + } + if ($body !== null) { + $options['body'] = $body; + } + + try { + $this->response = $client->send($client->createRequest($verb, $fullUrl, $options)); + } catch (GuzzleHttp\Exception\ClientException $ex) { + $this->response = $ex->getResponse(); + } + } + + /** + * @param string $verb + * @param string $url + * @param string $requestToken + * @param CookieJar $cookieJar + */ + private function sendingToWithRequestToken(string $verb, string $url, string $requestToken, CookieJar $cookieJar) { + $fullUrl = $this->baseUrl . $url; + + $client = new Client(); + try { + $this->response = $client->send($client->createRequest( + $verb, + $fullUrl, + [ + 'cookies' => $cookieJar, + 'headers' => [ + 'requesttoken' => $requestToken + ] + ] + )); + } catch (GuzzleHttp\Exception\ClientException $e) { + $this->response = $e->getResponse(); + } + } + + /** + * @param ResponseInterface $response + * @return string + */ + private function extractRequestTokenFromResponse(ResponseInterface $response): string { + return substr(preg_replace('/(.*)data-requesttoken="(.*)">(.*)/sm', '\2', $response->getBody()->getContents()), 0, 89); + } + + /** + * @param string $user + */ + private function loggingInUsingWebAs(string $user) { + $loginUrl = $this->baseUrl . '/login'; + + $cookieJar = new CookieJar(); + + // Request a new session and extract CSRF token + $client = new Client(); + $response = $client->get( + $loginUrl, + [ + 'cookies' => $cookieJar, + ] + ); + $requestToken = $this->extractRequestTokenFromResponse($response); + + // Login and extract new token + $password = ($user === 'admin') ? $this->adminUser[1] : $this->regularUserPassword; + $client = new Client(); + $response = $client->post( + $loginUrl, + [ + 'body' => [ + 'user' => $user, + 'password' => $password, + 'requesttoken' => $requestToken, + ], + 'cookies' => $cookieJar, + ] + ); + $requestToken = $this->extractRequestTokenFromResponse($response); + + return [$requestToken, $cookieJar]; + } + + /** + * @return string + */ + private function getLastShareId(): string { + return (string)$this->lastCreatedShareData->data[0]->id; + } + + /** + * @return SimpleXMLElement + */ + private function getXmlResponse(): \SimpleXMLElement { + return simplexml_load_string($this->response->getBody()); + } + + /** + * @param string $field + * @param string $contentExpected + * @param \SimpleXMLElement $returnedShare + */ + private function assertFieldIsInReturnedShare(string $field, string $contentExpected, \SimpleXMLElement $returnedShare){ + if ($contentExpected === 'IGNORE') { + return; + } + + if (!array_key_exists($field, $returnedShare)) { + PHPUnit_Framework_Assert::fail("$field was not found in response"); + } + + if ($field === 'expiration' && !empty($contentExpected)){ + $contentExpected = date('Y-m-d', strtotime($contentExpected)) . " 00:00:00"; + } + + if ($contentExpected === 'A_NUMBER') { + PHPUnit_Framework_Assert::assertTrue(is_numeric((string)$returnedShare->$field), "Field '$field' is not a number: " . $returnedShare->$field); + } else if ($contentExpected === 'A_TOKEN') { + // A token is composed by 15 characters from + // ISecureRandom::CHAR_HUMAN_READABLE. + PHPUnit_Framework_Assert::assertRegExp('/^[abcdefgijkmnopqrstwxyzABCDEFGHJKLMNPQRSTWXYZ23456789]{15}$/', (string)$returnedShare->$field, "Field '$field' is not a token"); + } else if (strpos($contentExpected, 'REGEXP ') === 0) { + PHPUnit_Framework_Assert::assertRegExp(substr($contentExpected, strlen('REGEXP ')), (string)$returnedShare->$field, "Field '$field' does not match"); + } else { + PHPUnit_Framework_Assert::assertEquals($contentExpected, (string)$returnedShare->$field, "Field '$field' does not match"); + } + } + +} diff --git a/tests/integration/features/sharing/create.feature b/tests/integration/features/sharing/create.feature new file mode 100644 index 00000000000..80ba025daf4 --- /dev/null +++ b/tests/integration/features/sharing/create.feature @@ -0,0 +1,780 @@ +Feature: create + + Background: + Given user "participant1" exists + Given user "participant2" exists + Given user "participant3" exists + + Scenario: create share with an owned one-to-one room + Given user "participant1" creates room "own one-to-one room" + | roomType | 1 | + | invite | participant2 | + When user "participant1" shares "welcome.txt" with room "own one-to-one room" + Then share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | own one-to-one room | + | share_with_displayname | participant2-displayname | + And user "participant2" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | own one-to-one room | + | share_with_displayname | participant1-displayname | + + Scenario: create share with a one-to-one room invited to + Given user "participant2" creates room "one-to-one room invited to" + | roomType | 1 | + | invite | participant1 | + When user "participant1" shares "welcome.txt" with room "one-to-one room invited to" + Then share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | one-to-one room invited to | + | share_with_displayname | participant2-displayname | + And user "participant2" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | one-to-one room invited to | + | share_with_displayname | participant1-displayname | + + Scenario: create share with a one-to-one room not invited to + Given user "participant2" creates room "one-to-one room not invited to" + | roomType | 1 | + | invite | participant3 | + When user "participant1" shares "welcome.txt" with room "one-to-one room not invited to" + Then the OCS status code should be "404" + And the HTTP status code should be "200" + And user "participant1" gets all shares + And the list of returned shares has 0 shares + And user "participant2" gets all received shares + And the list of returned shares has 0 shares + And user "participant3" gets all received shares + And the list of returned shares has 0 shares + + Scenario: create share with an owned group room + Given user "participant1" creates room "own group room" + | roomType | 2 | + And user "participant1" renames room "own group room" to "Own group room" with 200 + And user "participant1" adds "participant2" to room "own group room" with 200 + When user "participant1" shares "welcome.txt" with room "own group room" + Then share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | own group room | + | share_with_displayname | Own group room | + And user "participant2" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | own group room | + | share_with_displayname | Own group room | + + Scenario: create share with a group room invited to + Given user "participant2" creates room "group room invited to" + | roomType | 2 | + And user "participant2" renames room "group room invited to" to "Group room invited to" with 200 + And user "participant2" adds "participant1" to room "group room invited to" with 200 + When user "participant1" shares "welcome.txt" with room "group room invited to" + Then share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | group room invited to | + | share_with_displayname | Group room invited to | + And user "participant2" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room invited to | + | share_with_displayname | Group room invited to | + + Scenario: create share with a group room not invited to + Given user "participant2" creates room "group room not invited to" + | roomType | 2 | + When user "participant1" shares "welcome.txt" with room "group room not invited to" + Then the OCS status code should be "404" + And the HTTP status code should be "200" + And user "participant1" gets all shares + And the list of returned shares has 0 shares + And user "participant2" gets all received shares + And the list of returned shares has 0 shares + + Scenario: create share with a group room no longer invited to + Given user "participant2" creates room "group room no longer invited to" + | roomType | 2 | + And user "participant2" adds "participant1" to room "group room no longer invited to" with 200 + And user "participant2" removes "participant1" from room "group room no longer invited to" with 200 + When user "participant1" shares "welcome.txt" with room "group room no longer invited to" + Then the OCS status code should be "404" + And the HTTP status code should be "200" + And user "participant1" gets all shares + And the list of returned shares has 0 shares + And user "participant2" gets all received shares + And the list of returned shares has 0 shares + + Scenario: create share with an owned public room + Given user "participant1" creates room "own public room" + | roomType | 3 | + And user "participant1" renames room "own public room" to "Own public room" with 200 + And user "participant1" adds "participant2" to room "own public room" with 200 + And user "participant3" joins room "own public room" with 200 + When user "participant1" shares "welcome.txt" with room "own public room" + Then share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | own public room | + | share_with_displayname | Own public room | + | token | A_TOKEN | + And user "participant2" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | own public room | + | share_with_displayname | Own public room | + | token | A_TOKEN | + And user "participant3" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | own public room | + | share_with_displayname | Own public room | + | token | A_TOKEN | + + Scenario: create share with a public room invited to + Given user "participant2" creates room "public room invited to" + | roomType | 3 | + And user "participant2" renames room "public room invited to" to "Public room invited to" with 200 + And user "participant2" adds "participant1" to room "public room invited to" with 200 + And user "participant3" joins room "public room invited to" with 200 + When user "participant1" shares "welcome.txt" with room "public room invited to" + Then share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | public room invited to | + | share_with_displayname | Public room invited to | + | token | A_TOKEN | + And user "participant2" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | public room invited to | + | share_with_displayname | Public room invited to | + | token | A_TOKEN | + And user "participant3" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | public room invited to | + | share_with_displayname | Public room invited to | + | token | A_TOKEN | + + Scenario: create share with a public room self joined to + Given user "participant2" creates room "public room self joined to" + | roomType | 3 | + And user "participant2" renames room "public room self joined to" to "Public room self joined to" with 200 + And user "participant1" joins room "public room self joined to" with 200 + And user "participant3" joins room "public room self joined to" with 200 + When user "participant1" shares "welcome.txt" with room "public room self joined to" + Then share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | public room self joined to | + | share_with_displayname | Public room self joined to | + | token | A_TOKEN | + And user "participant2" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | public room self joined to | + | share_with_displayname | Public room self joined to | + | token | A_TOKEN | + And user "participant3" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | public room self joined to | + | share_with_displayname | Public room self joined to | + | token | A_TOKEN | + + Scenario: create share with a public room not joined to + Given user "participant2" creates room "public room not joined to" + | roomType | 3 | + When user "participant1" shares "welcome.txt" with room "public room not joined to" + Then the OCS status code should be "404" + And the HTTP status code should be "200" + And user "participant1" gets all shares + And the list of returned shares has 0 shares + And user "participant2" gets all received shares + And the list of returned shares has 0 shares + + Scenario: create share with a public room no longer joined to + Given user "participant2" creates room "public room no longer joined to" + | roomType | 3 | + And user "participant1" joins room "public room no longer joined to" with 200 + And user "participant1" leaves room "public room no longer joined to" with 200 + When user "participant1" shares "welcome.txt" with room "public room no longer joined to" + Then the OCS status code should be "404" + And the HTTP status code should be "200" + And user "participant1" gets all shares + And the list of returned shares has 0 shares + And user "participant2" gets all received shares + And the list of returned shares has 0 shares + + + + Scenario: create share with a room of a received share whose owner is in the room + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" renames room "group room" to "Group room" with 200 + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" adds "participant3" to room "group room" with 200 + And user "participant2" shares "welcome.txt" with user "participant1" with OCS 100 + When user "participant1" shares "welcome (2).txt" with room "group room" + Then share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | uid_file_owner | participant2 | + | displayname_file_owner | participant2-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room | + | share_with_displayname | Group room | + And user "participant2" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | uid_file_owner | participant2 | + | displayname_file_owner | participant2-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant2 | + | file_target | /welcome (2).txt | + | share_with | group room | + | share_with_displayname | Group room | + And user "participant3" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | uid_file_owner | participant2 | + | displayname_file_owner | participant2-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room | + | share_with_displayname | Group room | + + Scenario: create share with a room of a received share whose owner is not in the room + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" renames room "group room" to "Group room" with 200 + And user "participant1" adds "participant3" to room "group room" with 200 + And user "participant2" shares "welcome.txt" with user "participant1" with OCS 100 + When user "participant1" shares "welcome (2).txt" with room "group room" + Then share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | uid_file_owner | participant2 | + | displayname_file_owner | participant2-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room | + | share_with_displayname | Group room | + And user "participant2" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | uid_file_owner | participant2 | + | displayname_file_owner | participant2-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant2 | + | file_target | /welcome (2).txt | + | share_with | group room | + | share_with_displayname | Group room | + And user "participant3" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | uid_file_owner | participant2 | + | displayname_file_owner | participant2-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room | + | share_with_displayname | Group room | + + Scenario: create share with a room of a received share without reshare permissions + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" adds "participant3" to room "group room" with 200 + And user "participant2" shares "welcome.txt" with user "participant1" + | permissions | 1 | + And share is returned with + | permissions | 1 | + | share_type | 0 | + | mail_send | 1 | + When user "participant1" shares "welcome (2).txt" with room "group room" + Then the OCS status code should be "404" + And the HTTP status code should be "200" + And user "participant1" gets all shares + And the list of returned shares has 0 shares + And user "participant1" gets all received shares + And the list of returned shares has 1 shares + And share 0 is returned with + | permissions | 1 | + | share_type | 0 | + And user "participant2" gets all shares + And the list of returned shares has 1 shares + And share 0 is returned with + | permissions | 1 | + | share_type | 0 | + And user "participant2" gets all received shares + And the list of returned shares has 0 shares + And user "participant3" gets all received shares + And the list of returned shares has 0 shares + + + + Scenario: create share with an expiration date + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" renames room "group room" to "Group room" with 200 + And user "participant1" adds "participant2" to room "group room" with 200 + When user "participant1" shares "welcome.txt" with room "group room" + | expireDate | +3 days | + Then share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | group room | + | share_with_displayname | Group room | + | expiration | +3 days | + And user "participant2" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room | + | share_with_displayname | Group room | + | expiration | +3 days | + + Scenario: create share with an invalid expiration date + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" adds "participant2" to room "group room" with 200 + When user "participant1" shares "welcome.txt" with room "group room" + | expireDate | invalid date | + Then the OCS status code should be "404" + And the HTTP status code should be "200" + And user "participant1" gets all shares + And the list of returned shares has 0 shares + And user "participant2" gets all received shares + And the list of returned shares has 0 shares + + Scenario: create share with specific permissions + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" renames room "group room" to "Group room" with 200 + And user "participant1" adds "participant2" to room "group room" with 200 + When user "participant1" shares "welcome.txt" with room "group room" + | permissions | 1 | + Then share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | group room | + | share_with_displayname | Group room | + | permissions | 1 | + And user "participant2" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room | + | share_with_displayname | Group room | + | permissions | 1 | + + + + Scenario: create share again with another room + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" renames room "group room" to "Group room" with 200 + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + And user "participant1" creates room "another group room" + | roomType | 2 | + And user "participant1" renames room "another group room" to "Another group room" with 200 + And user "participant1" adds "participant3" to room "another group room" with 200 + When user "participant1" shares "welcome.txt" with room "another group room" + Then share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | another group room | + | share_with_displayname | Another group room | + And user "participant1" gets all shares + And the list of returned shares has 2 shares + And share 0 is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | group room | + | share_with_displayname | Group room | + And share 1 is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | another group room | + | share_with_displayname | Another group room | + And user "participant2" gets all received shares + And the list of returned shares has 1 shares + And share 0 is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room | + | share_with_displayname | Group room | + And user "participant3" gets all received shares + And the list of returned shares has 1 shares + And share 0 is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | another group room | + | share_with_displayname | Another group room | + + Scenario: create share again with same room + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" renames room "group room" to "Group room" with 200 + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + When user "participant1" shares "welcome.txt" with room "group room" + Then the OCS status code should be "403" + And the HTTP status code should be "401" + And user "participant1" gets all shares + And the list of returned shares has 1 shares + And share 0 is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | group room | + | share_with_displayname | Group room | + And user "participant2" gets all received shares + And the list of returned shares has 1 shares + And share 0 is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room | + | share_with_displayname | Group room | + + Scenario: create share again with same room by a sharee + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" renames room "group room" to "Group room" with 200 + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + When user "participant2" shares "welcome (2).txt" with room "group room" + Then the OCS status code should be "403" + And the HTTP status code should be "401" + And user "participant1" gets all shares + And the list of returned shares has 1 shares + And share 0 is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | group room | + | share_with_displayname | Group room | + And user "participant2" gets all shares + And the list of returned shares has 0 shares + And user "participant2" gets all received shares + And the list of returned shares has 1 shares + And share 0 is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room | + | share_with_displayname | Group room | + + + + Scenario: create share with a room that includes a user who already received that share through another room + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" renames room "group room" to "Group room" with 200 + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + And user "participant1" creates room "another group room" + | roomType | 2 | + And user "participant1" renames room "another group room" to "Another group room" with 200 + And user "participant1" adds "participant2" to room "another group room" with 200 + When user "participant1" shares "welcome.txt" with room "another group room" + Then share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | another group room | + | share_with_displayname | Another group room | + And user "participant2" gets all received shares + And the list of returned shares has 2 shares + And share 0 is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room | + | share_with_displayname | Group room | + And share 1 is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | another group room | + | share_with_displayname | Another group room | + + Scenario: create share with a user who already received that share through a room + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" renames room "group room" to "Group room" with 200 + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + When user "participant1" shares "welcome.txt" with user "participant2" + Then share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | participant2 | + | share_with_displayname | participant2-displayname | + | share_type | 0 | + | mail_send | 1 | + And user "participant2" gets all received shares + And the list of returned shares has 2 shares + And share 0 is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | participant2 | + | share_with_displayname | participant2-displayname | + | share_type | 0 | + And share 1 is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room | + | share_with_displayname | Group room | + + Scenario: create share with a room including a user who already received that share directly + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" renames room "group room" to "Group room" with 200 + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" shares "welcome.txt" with user "participant2" with OCS 100 + When user "participant1" shares "welcome.txt" with room "group room" + Then share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | group room | + | share_with_displayname | Group room | + And user "participant2" gets all received shares + And the list of returned shares has 2 shares + And share 0 is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | participant2 | + | share_with_displayname | participant2-displayname | + | share_type | 0 | + And share 1 is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room | + | share_with_displayname | Group room | diff --git a/tests/integration/features/sharing/delete.feature b/tests/integration/features/sharing/delete.feature new file mode 100644 index 00000000000..9c3a52bd10d --- /dev/null +++ b/tests/integration/features/sharing/delete.feature @@ -0,0 +1,341 @@ +Feature: delete + + Background: + Given user "participant1" exists + Given user "participant2" exists + Given user "participant3" exists + + Scenario: delete share with an owned one-to-one room + Given user "participant1" creates room "own one-to-one room" + | roomType | 1 | + | invite | participant2 | + And user "participant1" shares "welcome.txt" with room "own one-to-one room" with OCS 100 + When user "participant1" deletes last share + Then the OCS status code should be "100" + And the HTTP status code should be "200" + And user "participant1" gets last share + And the OCS status code should be "404" + And user "participant2" gets last share + And the OCS status code should be "404" + + Scenario: delete share with a one-to-one room invited to + Given user "participant2" creates room "one-to-one room invited to" + | roomType | 1 | + | invite | participant1 | + And user "participant1" shares "welcome.txt" with room "one-to-one room invited to" with OCS 100 + When user "participant1" deletes last share + Then the OCS status code should be "100" + And the HTTP status code should be "200" + And user "participant1" gets last share + And the OCS status code should be "404" + And user "participant2" gets last share + And the OCS status code should be "404" + + Scenario: delete share with an owned group room + Given user "participant1" creates room "own group room" + | roomType | 2 | + And user "participant1" adds "participant2" to room "own group room" with 200 + And user "participant1" shares "welcome.txt" with room "own group room" with OCS 100 + When user "participant1" deletes last share + Then the OCS status code should be "100" + And the HTTP status code should be "200" + And user "participant1" gets last share + And the OCS status code should be "404" + And user "participant2" gets last share + And the OCS status code should be "404" + + Scenario: delete share with a group room invited to + Given user "participant2" creates room "group room invited to" + | roomType | 2 | + And user "participant2" adds "participant1" to room "group room invited to" with 200 + And user "participant1" shares "welcome.txt" with room "group room invited to" with OCS 100 + When user "participant1" deletes last share + Then the OCS status code should be "100" + And the HTTP status code should be "200" + And user "participant1" gets last share + And the OCS status code should be "404" + And user "participant2" gets last share + And the OCS status code should be "404" + + Scenario: delete share with an owned public room + Given user "participant1" creates room "own public room" + | roomType | 3 | + And user "participant1" adds "participant2" to room "own public room" with 200 + And user "participant3" joins room "own public room" with 200 + And user "participant1" shares "welcome.txt" with room "own public room" with OCS 100 + When user "participant1" deletes last share + Then the OCS status code should be "100" + And the HTTP status code should be "200" + And user "participant1" gets last share + And the OCS status code should be "404" + And user "participant2" gets last share + And the OCS status code should be "404" + And user "participant3" gets last share + And the OCS status code should be "404" + + Scenario: delete share with a public room invited to + Given user "participant2" creates room "public room invited to" + | roomType | 3 | + And user "participant2" adds "participant1" to room "public room invited to" with 200 + And user "participant3" joins room "public room invited to" with 200 + And user "participant1" shares "welcome.txt" with room "public room invited to" with OCS 100 + When user "participant1" deletes last share + Then the OCS status code should be "100" + And the HTTP status code should be "200" + And user "participant1" gets last share + And the OCS status code should be "404" + And user "participant2" gets last share + And the OCS status code should be "404" + And user "participant3" gets last share + And the OCS status code should be "404" + + Scenario: delete share with a public room self joined to + Given user "participant2" creates room "public room self joined to" + | roomType | 3 | + And user "participant1" joins room "public room self joined to" with 200 + And user "participant3" joins room "public room self joined to" with 200 + And user "participant1" shares "welcome.txt" with room "public room self joined to" with OCS 100 + When user "participant1" deletes last share + Then the OCS status code should be "100" + And the HTTP status code should be "200" + And user "participant1" gets last share + And the OCS status code should be "404" + And user "participant2" gets last share + And the OCS status code should be "404" + And user "participant3" gets last share + And the OCS status code should be "404" + + + + Scenario: delete (unknown) share with a one-to-one room not invited to + Given user "participant2" creates room "one-to-one room not invited to" + | roomType | 1 | + | invite | participant3 | + And user "participant2" shares "welcome.txt" with room "one-to-one room not invited to" with OCS 100 + When user "participant1" deletes last share + Then the OCS status code should be "404" + And the HTTP status code should be "200" + And user "participant2" gets last share + And share is returned with + | uid_owner | participant2 | + | displayname_owner | participant2-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant2 | + | file_target | /welcome.txt | + | share_with | one-to-one room not invited to | + | share_with_displayname | participant3-displayname | + And user "participant3" gets last share + And share is returned with + | uid_owner | participant2 | + | displayname_owner | participant2-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | one-to-one room not invited to | + | share_with_displayname | participant2-displayname | + + Scenario: delete (unknown) share with a group room not invited to + Given user "participant2" creates room "group room not invited to" + | roomType | 2 | + And user "participant2" renames room "group room not invited to" to "Group room not invited to" with 200 + And user "participant2" adds "participant3" to room "group room not invited to" with 200 + And user "participant2" shares "welcome.txt" with room "group room not invited to" with OCS 100 + When user "participant1" deletes last share + Then the OCS status code should be "404" + And the HTTP status code should be "200" + And user "participant2" gets last share + And share is returned with + | uid_owner | participant2 | + | displayname_owner | participant2-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant2 | + | file_target | /welcome.txt | + | share_with | group room not invited to | + | share_with_displayname | Group room not invited to | + And user "participant3" gets last share + And share is returned with + | uid_owner | participant2 | + | displayname_owner | participant2-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room not invited to | + | share_with_displayname | Group room not invited to | + + Scenario: delete (unknown) share with a public room not joined to + Given user "participant2" creates room "public room not joined to" + | roomType | 3 | + And user "participant2" renames room "public room not joined to" to "Public room not joined to" with 200 + And user "participant2" adds "participant3" to room "public room not joined to" with 200 + And user "participant2" shares "welcome.txt" with room "public room not joined to" with OCS 100 + When user "participant1" deletes last share + Then the OCS status code should be "404" + And the HTTP status code should be "200" + And user "participant2" gets last share + And share is returned with + | uid_owner | participant2 | + | displayname_owner | participant2-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant2 | + | file_target | /welcome.txt | + | share_with | public room not joined to | + | share_with_displayname | Public room not joined to | + | token | A_TOKEN | + And user "participant3" gets last share + And share is returned with + | uid_owner | participant2 | + | displayname_owner | participant2-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | public room not joined to | + | share_with_displayname | Public room not joined to | + | token | A_TOKEN | + + + + Scenario: delete share with a user who also received that share through a room + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" renames room "group room" to "Group room" with 200 + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + And user "participant1" shares "welcome.txt" with user "participant2" with OCS 100 + When user "participant1" deletes last share + Then the OCS status code should be "100" + And the HTTP status code should be "200" + And user "participant2" gets all received shares + And the list of returned shares has 1 shares + And share 0 is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room | + | share_with_displayname | Group room | + + Scenario: delete share with a room including a user who also received that share directly + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" shares "welcome.txt" with user "participant2" with OCS 100 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + When user "participant1" deletes last share + Then the OCS status code should be "100" + And the HTTP status code should be "200" + And user "participant2" gets all received shares + And the list of returned shares has 1 shares + And share 0 is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | participant2 | + | share_with_displayname | participant2-displayname | + | share_type | 0 | + + + + Scenario: delete received share + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" renames room "group room" to "Group room" with 200 + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" adds "participant3" to room "group room" with 200 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + When user "participant2" deletes last share + Then the OCS status code should be "100" + And the HTTP status code should be "200" + And user "participant2" gets last share + And the OCS status code should be "404" + And user "participant1" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | group room | + | share_with_displayname | Group room | + And user "participant3" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room | + | share_with_displayname | Group room | + + + + Scenario: delete share received directly and through a room + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" renames room "group room" to "Group room" with 200 + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" adds "participant3" to room "group room" with 200 + And user "participant1" shares "welcome.txt" with user "participant2" with OCS 100 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + When user "participant2" deletes last share + Then the OCS status code should be "100" + And the HTTP status code should be "200" + And user "participant2" gets last share + And the OCS status code should be "404" + And user "participant1" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | group room | + | share_with_displayname | Group room | + And user "participant3" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room | + | share_with_displayname | Group room | + And user "participant2" gets all received shares + And the list of returned shares has 1 shares + And share 0 is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | participant2 | + | share_with_displayname | participant2-displayname | + | share_type | 0 | diff --git a/tests/integration/features/sharing/get.feature b/tests/integration/features/sharing/get.feature new file mode 100644 index 00000000000..4e043af6ec1 --- /dev/null +++ b/tests/integration/features/sharing/get.feature @@ -0,0 +1,751 @@ +Feature: get + + Background: + Given user "participant1" exists + Given user "participant2" exists + Given user "participant3" exists + Given user "participant4" exists + + + + Scenario: get a share + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" renames room "group room" to "Group room" with 200 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + When user "participant1" gets last share + Then share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | group room | + | share_with_displayname | Group room | + + Scenario: get a received share + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" renames room "group room" to "Group room" with 200 + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + When user "participant2" gets last share + Then share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room | + | share_with_displayname | Group room | + + + + Scenario: get a share using a user not invited to the room + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" renames room "group room" to "Group room" with 200 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + When user "participant2" gets last share + Then the OCS status code should be "404" + And the HTTP status code should be "200" + + + + Scenario: get a share after changing the room name + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" renames room "group room" to "Group room" with 200 + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + And user "participant1" renames room "group room" to "New room name" with 200 + When user "participant1" gets last share + Then share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | group room | + | share_with_displayname | New room name | + And user "participant2" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room | + | share_with_displayname | New room name | + + + + Scenario: get an expired share + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" renames room "group room" to "Group room" with 200 + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" shares "welcome.txt" with room "group room" + | expireDate | -3 days | + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | group room | + | share_with_displayname | Group room | + | expiration | -3 days | + When user "participant1" gets last share + Then the OCS status code should be "404" + And the HTTP status code should be "200" + And user "participant2" gets last share + And the OCS status code should be "404" + And the HTTP status code should be "200" + + Scenario: get an expired share moved by the sharee + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" renames room "group room" to "Group room" with 200 + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + And user "participant2" moves file "/welcome (2).txt" to "/renamed.txt" with 201 + And user "participant1" updates last share with + | expireDate | -3 days | + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | group room | + | share_with_displayname | Group room | + | expiration | -3 days | + When user "participant1" gets last share + Then the OCS status code should be "404" + And the HTTP status code should be "200" + And user "participant2" gets last share + And the OCS status code should be "404" + And the HTTP status code should be "200" + + + + Scenario: get all shares of a user + Given user "participant1" creates room "own group room" + | roomType | 2 | + And user "participant1" renames room "own group room" to "Own group room" with 200 + And user "participant2" creates room "group room invited to" + | roomType | 2 | + And user "participant2" renames room "group room invited to" to "Group room invited to" with 200 + And user "participant2" adds "participant1" to room "group room invited to" with 200 + And user "participant1" creates room "own one-to-one room" + | roomType | 1 | + | invite | participant3 | + And user "participant3" creates room "one-to-one room not invited to" + | roomType | 1 | + | invite | participant4 | + And user "participant1" creates folder "/test" + And user "participant1" shares "welcome.txt" with room "own group room" with OCS 100 + And user "participant1" shares "test" with room "group room invited to" with OCS 100 + And user "participant1" shares "welcome.txt" with room "group room invited to" with OCS 100 + And user "participant1" shares "test" with room "own one-to-one room" with OCS 100 + And user "participant2" shares "welcome (2).txt" with user "participant3" with OCS 100 + And user "participant3" shares "welcome (2).txt" with room "one-to-one room not invited to" with OCS 100 + When user "participant1" gets all shares + Then the list of returned shares has 4 shares + And share 0 is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | own group room | + | share_with_displayname | Own group room | + And share 1 is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /test | + | item_type | folder | + | mimetype | httpd/unix-directory | + | storage_id | home::participant1 | + | file_target | /test | + | share_with | group room invited to | + | share_with_displayname | Group room invited to | + | permissions | 31 | + And share 2 is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | group room invited to | + | share_with_displayname | Group room invited to | + And share 3 is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /test | + | item_type | folder | + | mimetype | httpd/unix-directory | + | storage_id | home::participant1 | + | file_target | /test | + | share_with | own one-to-one room | + | share_with_displayname | participant3-displayname | + | permissions | 31 | + + Scenario: get all shares and reshares of a user + Given user "participant1" creates room "own group room" + | roomType | 2 | + And user "participant1" renames room "own group room" to "Own group room" with 200 + And user "participant2" creates room "group room invited to" + | roomType | 2 | + And user "participant2" renames room "group room invited to" to "Group room invited to" with 200 + And user "participant2" adds "participant1" to room "group room invited to" with 200 + And user "participant1" creates room "own one-to-one room" + | roomType | 1 | + | invite | participant3 | + And user "participant3" creates room "one-to-one room not invited to" + | roomType | 1 | + | invite | participant4 | + And user "participant1" creates folder "/test" + And user "participant1" shares "welcome.txt" with room "own group room" with OCS 100 + And user "participant1" shares "test" with room "group room invited to" with OCS 100 + And user "participant1" shares "welcome.txt" with room "group room invited to" with OCS 100 + And user "participant1" shares "test" with room "own one-to-one room" with OCS 100 + And user "participant2" shares "welcome (2).txt" with user "participant3" with OCS 100 + And user "participant3" shares "welcome (2).txt" with room "one-to-one room not invited to" with OCS 100 + When user "participant1" gets all shares and reshares + Then the list of returned shares has 6 shares + And share 0 is returned with + | uid_owner | participant2 | + | displayname_owner | participant2-displayname | + | uid_file_owner | participant1 | + | displayname_file_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome (2).txt | + | share_with | participant3 | + | share_with_displayname | participant3-displayname | + | share_type | 0 | + And share 1 is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | own group room | + | share_with_displayname | Own group room | + And share 2 is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /test | + | item_type | folder | + | mimetype | httpd/unix-directory | + | storage_id | home::participant1 | + | file_target | /test | + | share_with | group room invited to | + | share_with_displayname | Group room invited to | + | permissions | 31 | + And share 3 is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | group room invited to | + | share_with_displayname | Group room invited to | + And share 4 is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /test | + | item_type | folder | + | mimetype | httpd/unix-directory | + | storage_id | home::participant1 | + | file_target | /test | + | share_with | own one-to-one room | + | share_with_displayname | participant3-displayname | + | permissions | 31 | + And share 5 is returned with + | uid_owner | participant3 | + | displayname_owner | participant3-displayname | + | uid_file_owner | participant1 | + | displayname_file_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome (2).txt | + | share_with | one-to-one room not invited to | + | share_with_displayname | participant3-displayname | + + Scenario: get all shares of a file + Given user "participant1" creates room "own group room" + | roomType | 2 | + And user "participant1" renames room "own group room" to "Own group room" with 200 + And user "participant2" creates room "group room invited to" + | roomType | 2 | + And user "participant2" renames room "group room invited to" to "Group room invited to" with 200 + And user "participant2" adds "participant1" to room "group room invited to" with 200 + And user "participant1" creates room "own one-to-one room" + | roomType | 1 | + | invite | participant3 | + And user "participant3" creates room "one-to-one room not invited to" + | roomType | 1 | + | invite | participant4 | + And user "participant1" creates folder "/test" + And user "participant1" shares "welcome.txt" with room "own group room" with OCS 100 + And user "participant1" shares "test" with room "group room invited to" with OCS 100 + And user "participant1" shares "welcome.txt" with room "group room invited to" with OCS 100 + And user "participant1" shares "test" with room "own one-to-one room" with OCS 100 + And user "participant2" shares "welcome (2).txt" with user "participant3" with OCS 100 + And user "participant3" shares "welcome (2).txt" with room "one-to-one room not invited to" with OCS 100 + When user "participant1" gets all shares for "/welcome.txt" + Then the list of returned shares has 2 shares + And share 0 is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | own group room | + | share_with_displayname | Own group room | + And share 1 is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | group room invited to | + | share_with_displayname | Group room invited to | + + Scenario: get all shares and reshares of a file + Given user "participant1" creates room "own group room" + | roomType | 2 | + And user "participant1" renames room "own group room" to "Own group room" with 200 + And user "participant2" creates room "group room invited to" + | roomType | 2 | + And user "participant2" renames room "group room invited to" to "Group room invited to" with 200 + And user "participant2" adds "participant1" to room "group room invited to" with 200 + And user "participant1" creates room "own one-to-one room" + | roomType | 1 | + | invite | participant3 | + And user "participant3" creates room "one-to-one room not invited to" + | roomType | 1 | + | invite | participant4 | + And user "participant1" creates folder "/test" + And user "participant1" shares "welcome.txt" with room "own group room" with OCS 100 + And user "participant1" shares "test" with room "group room invited to" with OCS 100 + And user "participant1" shares "welcome.txt" with room "group room invited to" with OCS 100 + And user "participant1" shares "test" with room "own one-to-one room" with OCS 100 + And user "participant2" shares "welcome (2).txt" with user "participant3" with OCS 100 + And user "participant3" shares "welcome (2).txt" with room "one-to-one room not invited to" with OCS 100 + When user "participant1" gets all shares and reshares for "/welcome.txt" + Then the list of returned shares has 4 shares + And share 0 is returned with + | uid_owner | participant2 | + | displayname_owner | participant2-displayname | + | uid_file_owner | participant1 | + | displayname_file_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome (2).txt | + | share_with | participant3 | + | share_with_displayname | participant3-displayname | + | share_type | 0 | + And share 1 is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | own group room | + | share_with_displayname | Own group room | + And share 2 is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | group room invited to | + | share_with_displayname | Group room invited to | + And share 3 is returned with + | uid_owner | participant3 | + | displayname_owner | participant3-displayname | + | uid_file_owner | participant1 | + | displayname_file_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome (2).txt | + | share_with | one-to-one room not invited to | + | share_with_displayname | participant3-displayname | + + Scenario: get all shares of a folder + Given user "participant1" creates room "own group room" + | roomType | 2 | + And user "participant1" renames room "own group room" to "Own group room" with 200 + And user "participant2" creates room "group room invited to" + | roomType | 2 | + And user "participant2" renames room "group room invited to" to "Group room invited to" with 200 + And user "participant2" adds "participant1" to room "group room invited to" with 200 + And user "participant1" creates room "own one-to-one room" + | roomType | 1 | + | invite | participant3 | + And user "participant3" creates room "one-to-one room not invited to" + | roomType | 1 | + | invite | participant4 | + And user "participant1" creates folder "/test" + And user "participant1" creates folder "/test/subfolder" + And user "participant1" creates folder "/test/subfolder/subsubfolder" + And user "participant1" creates folder "/test2" + And user "participant1" shares "welcome.txt" with room "own group room" with OCS 100 + And user "participant1" shares "test/subfolder" with room "group room invited to" with OCS 100 + And user "participant1" shares "test/subfolder/subsubfolder" with room "group room invited to" with OCS 100 + And user "participant1" shares "welcome.txt" with room "group room invited to" with OCS 100 + And user "participant1" shares "test2" with room "own one-to-one room" with OCS 100 + And user "participant1" moves file "/welcome.txt" to "/test/renamed.txt" with 201 + And user "participant2" shares "subfolder" with user "participant3" with OCS 100 + And user "participant3" shares "subfolder" with room "one-to-one room not invited to" with OCS 100 + # Only direct children are taken into account + When user "participant1" gets all shares for "/test" and its subfiles + Then the list of returned shares has 3 shares + And share 0 is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /test/renamed.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | own group room | + | share_with_displayname | Own group room | + And share 1 is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /test/renamed.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | group room invited to | + | share_with_displayname | Group room invited to | + And share 2 is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /test/subfolder | + | item_type | folder | + | mimetype | httpd/unix-directory | + | storage_id | home::participant1 | + | file_target | /subfolder | + | share_with | group room invited to | + | share_with_displayname | Group room invited to | + | permissions | 31 | + + + + Scenario: get all received shares of a user + Given user "participant1" creates room "own group room" + | roomType | 2 | + And user "participant1" renames room "own group room" to "Own group room" with 200 + And user "participant1" adds "participant2" to room "own group room" with 200 + And user "participant2" creates room "group room invited to" + | roomType | 2 | + And user "participant2" renames room "group room invited to" to "Group room invited to" with 200 + And user "participant2" adds "participant1" to room "group room invited to" with 200 + And user "participant2" adds "participant3" to room "group room invited to" with 200 + And user "participant1" creates room "own one-to-one room" + | roomType | 1 | + | invite | participant3 | + And user "participant3" creates folder "/test" + And user "participant2" shares "welcome.txt" with room "own group room" with OCS 100 + And user "participant3" shares "test" with room "group room invited to" with OCS 100 + And user "participant2" shares "welcome.txt" with room "group room invited to" with OCS 100 + And user "participant3" shares "test" with room "own one-to-one room" with OCS 100 + When user "participant1" gets all received shares + Then the list of returned shares has 4 shares + And share 0 is returned with + | uid_owner | participant2 | + | displayname_owner | participant2-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | own group room | + | share_with_displayname | Own group room | + And share 1 is returned with + | uid_owner | participant3 | + | displayname_owner | participant3-displayname | + | path | /test | + | item_type | folder | + | mimetype | httpd/unix-directory | + | storage_id | shared::/test | + | file_target | /test | + | share_with | group room invited to | + | share_with_displayname | Group room invited to | + | permissions | 31 | + And share 2 is returned with + | uid_owner | participant2 | + | displayname_owner | participant2-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room invited to | + | share_with_displayname | Group room invited to | + And share 3 is returned with + | uid_owner | participant3 | + | displayname_owner | participant3-displayname | + | path | /test | + | item_type | folder | + | mimetype | httpd/unix-directory | + | storage_id | shared::/test | + | file_target | /test | + | share_with | own one-to-one room | + | share_with_displayname | participant3-displayname | + | permissions | 31 | + + Scenario: get all received shares of a file + Given user "participant1" creates room "own group room" + | roomType | 2 | + And user "participant1" renames room "own group room" to "Own group room" with 200 + And user "participant1" adds "participant2" to room "own group room" with 200 + And user "participant2" creates room "group room invited to" + | roomType | 2 | + And user "participant2" renames room "group room invited to" to "Group room invited to" with 200 + And user "participant2" adds "participant1" to room "group room invited to" with 200 + And user "participant2" adds "participant3" to room "group room invited to" with 200 + And user "participant1" creates room "own one-to-one room" + | roomType | 1 | + | invite | participant3 | + And user "participant3" creates folder "/test" + And user "participant2" shares "welcome.txt" with room "own group room" with OCS 100 + And user "participant3" shares "test" with room "group room invited to" with OCS 100 + And user "participant2" shares "welcome.txt" with room "group room invited to" with OCS 100 + And user "participant3" shares "test" with room "own one-to-one room" with OCS 100 + When user "participant1" gets all received shares for "/welcome (2).txt" + Then the list of returned shares has 2 shares + And share 0 is returned with + | uid_owner | participant2 | + | displayname_owner | participant2-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | own group room | + | share_with_displayname | Own group room | + And share 1 is returned with + | uid_owner | participant2 | + | displayname_owner | participant2-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room invited to | + | share_with_displayname | Group room invited to | + + + + Scenario: get deleted shares when deleting an own share + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + And user "participant1" deletes last share + When user "participant1" gets deleted shares + Then the list of returned shares has 0 shares + And user "participant2" gets deleted shares + And the list of returned shares has 0 shares + + Scenario: get deleted shares when deleting a received share + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" renames room "group room" to "Group room" with 200 + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" adds "participant3" to room "group room" with 200 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + And user "participant2" deletes last share + When user "participant2" gets deleted shares + Then the list of returned shares has 1 shares + And share 0 is returned with + | id | REGEXP /ocRoomShare:[0-9]+/ | + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome (2).txt | + | share_with | group room | + | share_with_displayname | Group room | + | permissions | 0 | + | mail_send | IGNORE | + And user "participant1" gets deleted shares + And the list of returned shares has 0 shares + And user "participant3" gets deleted shares + And the list of returned shares has 0 shares + + + + Scenario: get DAV properties for a share + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + When user "participant1" gets the share-type DAV property for "/welcome.txt" + Then the response contains a share-types DAV property with + | 10 | + + Scenario: get DAV properties for a folder with a share + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" creates folder "/test" + And user "participant1" moves file "/welcome.txt" to "/test/renamed.txt" with 201 + And user "participant1" shares "/test/renamed.txt" with room "group room" with OCS 100 + When user "participant1" gets the share-type DAV property for "/test" + Then the response contains a share-types DAV property with + | 10 | + + Scenario: get DAV properties for a received share + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + When user "participant2" gets the share-type DAV property for "/welcome (2).txt" + Then the response contains a share-types DAV property with + + Scenario: get DAV properties for a room share reshared with a user + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant2" creates room "another group room" + | roomType | 2 | + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + And user "participant2" shares "welcome (2).txt" with user "participant3" with OCS 100 + When user "participant1" gets the share-type DAV property for "/welcome.txt" + Then the response contains a share-types DAV property with + | 10 | + + Scenario: get DAV properties for a user share reshared with a room + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant2" creates room "another group room" + | roomType | 2 | + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" shares "welcome.txt" with user "participant2" with OCS 100 + And user "participant2" shares "welcome (2).txt" with room "group room" with OCS 100 + When user "participant1" gets the share-type DAV property for "/welcome.txt" + Then the response contains a share-types DAV property with + | 0 | + + Scenario: get DAV properties for a room share reshared with a user as the resharer + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant2" creates room "another group room" + | roomType | 2 | + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + And user "participant2" shares "welcome (2).txt" with user "participant3" with OCS 100 + When user "participant2" gets the share-type DAV property for "/welcome (2).txt" + Then the response contains a share-types DAV property with + | 0 | + + Scenario: get DAV properties for a user share reshared with a room as the resharer + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant2" creates room "another group room" + | roomType | 2 | + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" shares "welcome.txt" with user "participant2" with OCS 100 + And user "participant2" shares "welcome (2).txt" with room "group room" with OCS 100 + When user "participant2" gets the share-type DAV property for "/welcome (2).txt" + Then the response contains a share-types DAV property with + | 10 | + + # Reshares are taken into account only for the files in the folder, not the + # folder itself. + Scenario: get DAV properties for a reshared folder + Given user "participant2" creates room "group room" + | roomType | 2 | + And user "participant1" creates folder "/test" + And user "participant1" shares "/test" with user "participant2" with OCS 100 + And user "participant2" shares "/test" with room "group room" with OCS 100 + When user "participant1" gets the share-type DAV property for "/test" + Then the response contains a share-types DAV property with + | 0 | + + Scenario: get DAV properties for a folder with a reshare + Given user "participant2" creates room "group room" + | roomType | 2 | + And user "participant1" creates folder "/test" + And user "participant1" moves file "/welcome.txt" to "/test/renamed.txt" with 201 + And user "participant1" shares "/test/renamed.txt" with user "participant2" with OCS 100 + And user "participant2" shares "renamed.txt" with room "group room" with OCS 100 + When user "participant1" gets the share-type DAV property for "/test" + Then the response contains a share-types DAV property with + | 0 | + | 10 | + + Scenario: get DAV properties for a folder with a reshared folder + Given user "participant2" creates room "group room" + | roomType | 2 | + And user "participant1" creates folder "/test" + And user "participant1" creates folder "/test/subfolder" + And user "participant1" shares "/test/subfolder" with user "participant2" with OCS 100 + And user "participant2" shares "subfolder" with room "group room" with OCS 100 + When user "participant1" gets the share-type DAV property for "/test" + Then the response contains a share-types DAV property with + | 0 | + | 10 | + + + + Scenario: get recent files including a share + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" creates folder "/test" + And user "participant1" creates folder "/test/subfolder" + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + And user "participant1" shares "test/subfolder" with room "group room" with OCS 100 + And user "participant1" shares "test/subfolder" with user "participant3" with OCS 100 + When user "participant1" gets recent files + Then the response contains a share-types file property for "/welcome.txt" with + | 10 | + And the response contains a share-types file property for "/test" with + And the response contains a share-types file property for "/test/subfolder" with + | 0 | + | 10 | diff --git a/tests/integration/features/sharing/hooks.feature b/tests/integration/features/sharing/hooks.feature new file mode 100644 index 00000000000..e07fe11fab1 --- /dev/null +++ b/tests/integration/features/sharing/hooks.feature @@ -0,0 +1,1005 @@ +Feature: hooks + + Background: + Given user "participant1" exists + Given user "participant2" exists + Given user "participant3" exists + Given user "participant4" exists + + # Entering a room does not really require any hook to work, but conceptually + # these tests belong here. + Scenario: invite user to group room after a file was shared + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" renames room "group room" to "Group room" with 200 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + When user "participant1" adds "participant2" to room "group room" with 200 + Then user "participant2" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room | + | share_with_displayname | Group room | + + Scenario: join public room after a file was shared + Given user "participant1" creates room "public room" + | roomType | 3 | + And user "participant1" renames room "public room" to "Public room" with 200 + And user "participant1" shares "welcome.txt" with room "public room" with OCS 100 + And user "participant2" joins room "public room" with 200 + Then user "participant2" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | public room | + | share_with_displayname | Public room | + | token | A_TOKEN | + + + + Scenario: remove sharer from group room after sharing a file + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant2" shares "welcome.txt" with room "group room" with OCS 100 + When user "participant1" removes "participant2" from room "group room" with 200 + Then user "participant1" gets last share + And the OCS status code should be "404" + And user "participant2" gets last share + And the OCS status code should be "404" + + Scenario: remove herself from group room after sharing a file + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant2" shares "welcome.txt" with room "group room" with OCS 100 + When user "participant2" removes themselves from room "group room" with 200 + Then user "participant1" gets last share + And the OCS status code should be "404" + And user "participant2" gets last share + And the OCS status code should be "404" + + Scenario: leave group room after sharing a file + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" renames room "group room" to "Group room" with 200 + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant2" shares "welcome.txt" with room "group room" with OCS 100 + When user "participant2" leaves room "group room" with 200 + Then user "participant1" gets last share + And share is returned with + | uid_owner | participant2 | + | displayname_owner | participant2-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room | + | share_with_displayname | Group room | + And user "participant2" gets last share + And share is returned with + | uid_owner | participant2 | + | displayname_owner | participant2-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant2 | + | file_target | /welcome.txt | + | share_with | group room | + | share_with_displayname | Group room | + + Scenario: leave public room invited to after sharing a file + Given user "participant1" creates room "public room" + | roomType | 3 | + And user "participant1" renames room "public room" to "Public room" with 200 + And user "participant1" adds "participant2" to room "public room" with 200 + And user "participant2" shares "welcome.txt" with room "public room" with OCS 100 + When user "participant2" leaves room "public room" with 200 + Then user "participant1" gets last share + And share is returned with + | uid_owner | participant2 | + | displayname_owner | participant2-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | public room | + | share_with_displayname | Public room | + | token | A_TOKEN | + And user "participant2" gets last share + And share is returned with + | uid_owner | participant2 | + | displayname_owner | participant2-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant2 | + | file_target | /welcome.txt | + | share_with | public room | + | share_with_displayname | Public room | + | token | A_TOKEN | + + Scenario: leave public room self joined to after sharing a file + Given user "participant1" creates room "public room" + | roomType | 3 | + And user "participant2" joins room "public room" with 200 + And user "participant2" shares "welcome.txt" with room "public room" with OCS 100 + When user "participant2" leaves room "public room" with 200 + Then user "participant1" gets last share + And the OCS status code should be "404" + And user "participant2" gets last share + And the OCS status code should be "404" + + Scenario: remove sharer from group room with other shares after sharing a file + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" renames room "group room" to "Group room" with 200 + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" creates folder "test" + And user "participant1" shares "test" with room "group room" with OCS 100 + And user "participant2" shares "welcome.txt" with room "group room" with OCS 100 + When user "participant1" removes "participant2" from room "group room" with 200 + Then user "participant1" gets last share + And the OCS status code should be "404" + And user "participant2" gets last share + And the OCS status code should be "404" + And user "participant1" gets all shares + And the list of returned shares has 1 shares + And share 0 is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | uid_file_owner | participant1 | + | displayname_file_owner | participant1-displayname | + | path | /test | + | item_type | folder | + | mimetype | httpd/unix-directory | + | storage_id | home::participant1 | + | file_target | /test | + | share_with | group room | + | share_with_displayname | Group room | + | permissions | 31 | + + + + Scenario: remove sharer from group room after sharing a file and a receiver reshared it + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant2" shares "welcome.txt" with room "group room" with OCS 100 + And user "participant1" shares "welcome (2).txt" with user "participant3" with OCS 100 + When user "participant1" removes "participant2" from room "group room" with 200 + Then user "participant1" gets last share + And the OCS status code should be "404" + And user "participant1" gets all shares + And the list of returned shares has 0 shares + And user "participant2" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | uid_file_owner | participant2 | + | displayname_file_owner | participant2-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant2 | + | file_target | /welcome (2).txt | + | share_with | participant3 | + | share_with_displayname | participant3-displayname | + | share_type | 0 | + And user "participant2" gets all shares + And the list of returned shares has 0 shares + And user "participant3" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | uid_file_owner | participant2 | + | displayname_file_owner | participant2-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | participant3 | + | share_with_displayname | participant3-displayname | + | share_type | 0 | + + + + Scenario: remove sharee from group room after a file was shared + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" renames room "group room" to "Group room" with 200 + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + When user "participant1" removes "participant2" from room "group room" with 200 + Then user "participant1" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | group room | + | share_with_displayname | Group room | + And user "participant2" gets last share + And the OCS status code should be "404" + + Scenario: remove sharee from group room after a file was shared and the sharee moved it + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" renames room "group room" to "Group room" with 200 + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + And user "participant2" moves file "welcome (2).txt" to "renamed.txt" + When user "participant1" removes "participant2" from room "group room" with 200 + Then user "participant1" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | group room | + | share_with_displayname | Group room | + And user "participant2" gets last share + And the OCS status code should be "404" + + Scenario: remove herself from group room after a file was shared + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" renames room "group room" to "Group room" with 200 + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + When user "participant2" removes themselves from room "group room" with 200 + Then user "participant1" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | group room | + | share_with_displayname | Group room | + And user "participant2" gets last share + And the OCS status code should be "404" + + Scenario: remove herself from group room after a file was shared and the sharee moved it + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" renames room "group room" to "Group room" with 200 + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + And user "participant2" moves file "welcome (2).txt" to "renamed.txt" + When user "participant2" removes themselves from room "group room" with 200 + Then user "participant1" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | group room | + | share_with_displayname | Group room | + And user "participant2" gets last share + And the OCS status code should be "404" + + Scenario: leave public room self joined to after a file was shared + Given user "participant1" creates room "public room" + | roomType | 3 | + And user "participant1" renames room "public room" to "Public room" with 200 + And user "participant2" joins room "public room" with 200 + And user "participant1" shares "welcome.txt" with room "public room" with OCS 100 + When user "participant2" leaves room "public room" with 200 + Then user "participant1" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | public room | + | share_with_displayname | Public room | + | token | A_TOKEN | + And user "participant2" gets last share + And the OCS status code should be "404" + + Scenario: leave public room self joined to after a file was shared and the sharee moved it + Given user "participant1" creates room "public room" + | roomType | 3 | + And user "participant1" renames room "public room" to "Public room" with 200 + And user "participant2" joins room "public room" with 200 + And user "participant1" shares "welcome.txt" with room "public room" with OCS 100 + And user "participant2" moves file "welcome (2).txt" to "renamed.txt" + When user "participant2" leaves room "public room" with 200 + Then user "participant1" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | public room | + | share_with_displayname | Public room | + | token | A_TOKEN | + And user "participant2" gets last share + And the OCS status code should be "404" + + Scenario: remove sharee from group room with other sharees after a file was shared and the sharees moved it + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" renames room "group room" to "Group room" with 200 + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" adds "participant3" to room "group room" with 200 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + And user "participant2" moves file "welcome (2).txt" to "renamed.txt" + And user "participant3" moves file "welcome (2).txt" to "renamed too.txt" + When user "participant1" removes "participant2" from room "group room" with 200 + Then user "participant1" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | group room | + | share_with_displayname | Group room | + And user "participant2" gets last share + And the OCS status code should be "404" + And user "participant3" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /renamed too.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/renamed too.txt | + | file_target | /renamed too.txt | + | share_with | group room | + | share_with_displayname | Group room | + + + + Scenario: remove sharee from group room after a file was shared and the sharee reshared it + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + And user "participant2" shares "welcome (2).txt" with user "participant3" with OCS 100 + When user "participant1" removes "participant2" from room "group room" with 200 + Then user "participant1" gets last share + And share is returned with + | uid_owner | participant2 | + | displayname_owner | participant2-displayname | + | uid_file_owner | participant1 | + | displayname_file_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome (2).txt | + | share_with | participant3 | + | share_with_displayname | participant3-displayname | + | share_type | 0 | + And user "participant2" gets last share + And the OCS status code should be "404" + And user "participant2" gets all shares + And the list of returned shares has 0 shares + And user "participant3" gets last share + And share is returned with + | uid_owner | participant2 | + | displayname_owner | participant2-displayname | + | uid_file_owner | participant1 | + | displayname_file_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | participant3 | + | share_with_displayname | participant3-displayname | + | share_type | 0 | + + + + Scenario: add sharer again to group room after sharing a file and the sharer was removed from the room + Given user "participant2" creates room "group room" + | roomType | 2 | + And user "participant2" adds "participant1" to room "group room" with 200 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + And user "participant2" removes "participant1" from room "group room" with 200 + When user "participant2" adds "participant1" to room "group room" with 200 + Then user "participant1" gets all shares + And the list of returned shares has 0 shares + And user "participant2" gets all received shares + And the list of returned shares has 0 shares + + Scenario: add sharer again to group room after sharing a file and the sharer removed herself from the room + Given user "participant2" creates room "group room" + | roomType | 2 | + And user "participant2" adds "participant1" to room "group room" with 200 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + And user "participant1" removes themselves from room "group room" with 200 + When user "participant2" adds "participant1" to room "group room" with 200 + Then user "participant1" gets all shares + And the list of returned shares has 0 shares + And user "participant2" gets all received shares + And the list of returned shares has 0 shares + + Scenario: join public room again after sharing a file and the sharer left the room + Given user "participant2" creates room "public room" + | roomType | 3 | + And user "participant1" joins room "public room" with 200 + And user "participant1" shares "welcome.txt" with room "public room" with OCS 100 + And user "participant1" leaves room "public room" with 200 + When user "participant1" joins room "public room" with 200 + Then user "participant1" gets all shares + And the list of returned shares has 0 shares + And user "participant2" gets all received shares + And the list of returned shares has 0 shares + + + + Scenario: add sharer again to group room after sharing a file and a receiver reshared it and the sharer was removed from the room + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant2" shares "welcome.txt" with room "group room" with OCS 100 + And user "participant1" shares "welcome (2).txt" with user "participant3" with OCS 100 + And user "participant1" removes "participant2" from room "group room" with 200 + When user "participant1" adds "participant2" to room "group room" with 200 + Then user "participant1" gets last share + And the OCS status code should be "404" + And user "participant1" gets all shares + And the list of returned shares has 0 shares + And user "participant2" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | uid_file_owner | participant2 | + | displayname_file_owner | participant2-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant2 | + | file_target | /welcome (2).txt | + | share_with | participant3 | + | share_with_displayname | participant3-displayname | + | share_type | 0 | + And user "participant2" gets all shares + And the list of returned shares has 0 shares + And user "participant3" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | uid_file_owner | participant2 | + | displayname_file_owner | participant2-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | participant3 | + | share_with_displayname | participant3-displayname | + | share_type | 0 | + + + + Scenario: add sharee again to group room after a file was shared and the sharee was removed from the room + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" renames room "group room" to "Group room" with 200 + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + And user "participant1" removes "participant2" from room "group room" with 200 + When user "participant1" adds "participant2" to room "group room" with 200 + Then user "participant2" gets all received shares + And the list of returned shares has 1 shares + And share 0 is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room | + | share_with_displayname | Group room | + + Scenario: add sharee again to group room after a file was shared and moved by the sharee and the sharee was removed from the room + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" renames room "group room" to "Group room" with 200 + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + And user "participant2" moves file "welcome (2).txt" to "renamed.txt" + And user "participant1" removes "participant2" from room "group room" with 200 + When user "participant1" adds "participant2" to room "group room" with 200 + Then user "participant2" gets all received shares + And the list of returned shares has 1 shares + And share 0 is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room | + | share_with_displayname | Group room | + + Scenario: add sharee again to group room after a file was shared and the sharee removed herself from the room + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" renames room "group room" to "Group room" with 200 + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + And user "participant2" removes themselves from room "group room" with 200 + When user "participant1" adds "participant2" to room "group room" with 200 + Then user "participant2" gets all received shares + And the list of returned shares has 1 shares + And share 0 is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room | + | share_with_displayname | Group room | + + Scenario: add sharee again to group room after a file was shared and moved by the sharee and the sharee removed herself from the room + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" renames room "group room" to "Group room" with 200 + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + And user "participant2" moves file "welcome (2).txt" to "renamed.txt" + And user "participant2" removes themselves from room "group room" with 200 + When user "participant1" adds "participant2" to room "group room" with 200 + Then user "participant2" gets all received shares + And the list of returned shares has 1 shares + And share 0 is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room | + | share_with_displayname | Group room | + + Scenario: join sharee again to public room after a file was shared and the sharee left the room + Given user "participant1" creates room "public room" + | roomType | 3 | + And user "participant1" renames room "public room" to "Public room" with 200 + And user "participant2" joins room "public room" with 200 + And user "participant1" shares "welcome.txt" with room "public room" with OCS 100 + And user "participant2" leaves room "public room" with 200 + When user "participant2" joins room "public room" with 200 + Then user "participant2" gets all received shares + And the list of returned shares has 1 shares + And share 0 is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | public room | + | share_with_displayname | Public room | + | token | A_TOKEN | + + Scenario: join sharee again to public room after a file was shared and moved by the sharee and the sharee left the room + Given user "participant1" creates room "public room" + | roomType | 3 | + And user "participant1" renames room "public room" to "Public room" with 200 + And user "participant2" joins room "public room" with 200 + And user "participant1" shares "welcome.txt" with room "public room" with OCS 100 + And user "participant2" moves file "welcome (2).txt" to "renamed.txt" + And user "participant2" leaves room "public room" with 200 + When user "participant2" joins room "public room" with 200 + Then user "participant2" gets all received shares + And the list of returned shares has 1 shares + And share 0 is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | public room | + | share_with_displayname | Public room | + | token | A_TOKEN | + + + + Scenario: add sharee again to group room after a file was shared and the sharee reshared it and the sharee was removed from the room + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + And user "participant2" shares "welcome (2).txt" with user "participant3" with OCS 100 + And user "participant1" removes "participant2" from room "group room" with 200 + When user "participant1" adds "participant2" to room "group room" with 200 + Then user "participant1" gets last share + And share is returned with + | uid_owner | participant2 | + | displayname_owner | participant2-displayname | + | uid_file_owner | participant1 | + | displayname_file_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome (2).txt | + | share_with | participant3 | + | share_with_displayname | participant3-displayname | + | share_type | 0 | + And user "participant2" gets last share + And share is returned with + | uid_owner | participant2 | + | displayname_owner | participant2-displayname | + | uid_file_owner | participant1 | + | displayname_file_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | participant3 | + | share_with_displayname | participant3-displayname | + | share_type | 0 | + And user "participant3" gets last share + And share is returned with + | uid_owner | participant2 | + | displayname_owner | participant2-displayname | + | uid_file_owner | participant1 | + | displayname_file_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | participant3 | + | share_with_displayname | participant3-displayname | + | share_type | 0 | + + + + Scenario: delete one-to-one room after sharing a file + Given user "participant1" creates room "own one-to-one room" + | roomType | 1 | + | invite | participant2 | + And user "participant1" shares "welcome.txt" with room "own one-to-one room" with OCS 100 + When user "participant1" deletes room "own one-to-one room" with 200 + Then user "participant1" gets last share + And the OCS status code should be "404" + And user "participant2" gets last share + And the OCS status code should be "404" + + Scenario: delete group room after sharing a file + Given user "participant1" creates room "own group room" + | roomType | 2 | + And user "participant1" adds "participant2" to room "own group room" with 200 + And user "participant1" shares "welcome.txt" with room "own group room" with OCS 100 + When user "participant1" deletes room "own group room" with 200 + Then user "participant1" gets last share + And the OCS status code should be "404" + And user "participant2" gets last share + And the OCS status code should be "404" + + Scenario: delete public room after sharing a file + Given user "participant1" creates room "own public room" + | roomType | 3 | + And user "participant1" adds "participant2" to room "own public room" with 200 + And user "participant3" joins room "own public room" with 200 + And user "participant1" shares "welcome.txt" with room "own public room" with OCS 100 + When user "participant1" deletes room "own public room" with 200 + Then user "participant1" gets last share + And the OCS status code should be "404" + And user "participant2" gets last share + And the OCS status code should be "404" + And user "participant3" gets last share + And the OCS status code should be "404" + + Scenario: delete room after a file was shared and the sharee moved it + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + And user "participant2" moves file "welcome (2).txt" to "renamed.txt" + When user "participant1" deletes room "group room" with 200 + Then user "participant1" gets last share + And the OCS status code should be "404" + And user "participant2" gets last share + And the OCS status code should be "404" + + Scenario: delete room after a file was shared and the sharee reshared it + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + And user "participant2" shares "welcome (2).txt" with user "participant3" with OCS 100 + When user "participant1" deletes room "group room" with 200 + Then user "participant1" gets all shares + And the list of returned shares has 0 shares + And user "participant2" gets all shares + And the list of returned shares has 0 shares + And user "participant2" gets all received shares + And the list of returned shares has 0 shares + And user "participant3" gets all received shares + And the list of returned shares has 1 shares + And share 0 is returned with + | uid_owner | participant2 | + | displayname_owner | participant2-displayname | + | uid_file_owner | participant1 | + | displayname_file_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | participant3 | + | share_with_displayname | participant3-displayname | + | share_type | 0 | + + Scenario: delete room after a file was shared and the sharee moved and reshared it + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + And user "participant2" moves file "welcome (2).txt" to "renamed.txt" + And user "participant2" shares "renamed.txt" with user "participant3" with OCS 100 + When user "participant1" deletes room "group room" with 200 + Then user "participant1" gets all shares + And the list of returned shares has 0 shares + And user "participant2" gets all shares + And the list of returned shares has 0 shares + And user "participant2" gets all received shares + And the list of returned shares has 0 shares + And user "participant3" gets all received shares + And the list of returned shares has 1 shares + And share 0 is returned with + | uid_owner | participant2 | + | displayname_owner | participant2-displayname | + | uid_file_owner | participant1 | + | displayname_file_owner | participant1-displayname | + | path | /renamed.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/renamed.txt | + | file_target | /renamed.txt | + | share_with | participant3 | + | share_with_displayname | participant3-displayname | + | share_type | 0 | + + Scenario: delete room after sharing a file with several rooms + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" renames room "group room" to "Group room" with 200 + And user "participant1" creates room "another group room" + | roomType | 2 | + And user "participant1" renames room "another group room" to "Another group room" with 200 + And user "participant1" creates room "yet another group room" + | roomType | 2 | + And user "participant1" renames room "yet another group room" to "Yet another group room" with 200 + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" adds "participant2" to room "another group room" with 200 + And user "participant1" adds "participant2" to room "yet another group room" with 200 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + And user "participant1" shares "welcome.txt" with room "another group room" with OCS 100 + And user "participant1" shares "welcome.txt" with room "yet another group room" with OCS 100 + When user "participant1" deletes room "group room" with 200 + Then user "participant1" gets all shares + And the list of returned shares has 2 shares + And share 0 is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | another group room | + | share_with_displayname | Another group room | + And share 1 is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | yet another group room | + | share_with_displayname | Yet another group room | + And user "participant2" gets all received shares + And the list of returned shares has 2 shares + And share 0 is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | another group room | + | share_with_displayname | Another group room | + And share 1 is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | yet another group room | + | share_with_displayname | Yet another group room | + + + + Scenario: delete user after sharing a file + Given user "participant1" creates room "group room invited to" + | roomType | 2 | + And user "participant1" adds "participant2" to room "group room invited to" with 200 + And user "participant2" shares "welcome.txt" with room "group room invited to" with OCS 100 + When user "participant2" is deleted + Then user "participant1" gets last share + And the OCS status code should be "404" + + Scenario: delete user after receiving a shared a file + Given user "participant1" creates room "group room invited to" + | roomType | 2 | + And user "participant1" renames room "group room invited to" to "Group room invited to" with 200 + And user "participant1" adds "participant2" to room "group room invited to" with 200 + And user "participant1" adds "participant3" to room "group room invited to" with 200 + And user "participant1" shares "welcome.txt" with room "group room invited to" with OCS 100 + When user "participant2" is deleted + Then user "participant1" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | group room invited to | + | share_with_displayname | Group room invited to | + And user "participant3" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room invited to | + | share_with_displayname | Group room invited to | + + Scenario: delete user after receiving and moving a shared a file + Given user "participant1" creates room "group room invited to" + | roomType | 2 | + And user "participant1" renames room "group room invited to" to "Group room invited to" with 200 + And user "participant1" adds "participant2" to room "group room invited to" with 200 + And user "participant1" adds "participant3" to room "group room invited to" with 200 + And user "participant1" shares "welcome.txt" with room "group room invited to" with OCS 100 + And user "participant2" moves file "welcome (2).txt" to "renamed.txt" + When user "participant2" is deleted + Then user "participant1" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | group room invited to | + | share_with_displayname | Group room invited to | + And user "participant3" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room invited to | + | share_with_displayname | Group room invited to | + + Scenario: delete user after resharing a file + Given user "participant1" creates room "group room invited to" + | roomType | 2 | + And user "participant1" renames room "group room invited to" to "Group room invited to" with 200 + And user "participant1" adds "participant2" to room "group room invited to" with 200 + And user "participant1" adds "participant3" to room "group room invited to" with 200 + And user "participant1" shares "welcome.txt" with room "group room invited to" with OCS 100 + And user "participant2" shares "welcome (2).txt" with user "participant4" with OCS 100 + When user "participant2" is deleted + Then user "participant1" gets last share + And share is returned with + | uid_owner | participant2 | + | displayname_owner | participant2 | + | uid_file_owner | participant1 | + | displayname_file_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome (2).txt | + | share_with | participant4 | + | share_with_displayname | participant4-displayname | + | share_type | 0 | + And user "participant1" gets all shares + And the list of returned shares has 1 shares + And share 0 is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | group room invited to | + | share_with_displayname | Group room invited to | + And user "participant3" gets last share + And the OCS status code should be "404" + And the HTTP status code should be "200" + And user "participant3" gets all received shares + And the list of returned shares has 1 shares + And share 0 is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room invited to | + | share_with_displayname | Group room invited to | + And user "participant4" gets last share + And share is returned with + | uid_owner | participant2 | + | displayname_owner | participant2 | + | uid_file_owner | participant1 | + | displayname_file_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | participant4 | + | share_with_displayname | participant4-displayname | + | share_type | 0 | diff --git a/tests/integration/features/sharing/move.feature b/tests/integration/features/sharing/move.feature new file mode 100644 index 00000000000..3f4e7157959 --- /dev/null +++ b/tests/integration/features/sharing/move.feature @@ -0,0 +1,358 @@ +Feature: move + + Background: + Given user "participant1" exists + Given user "participant2" exists + Given user "participant3" exists + Given user "participant4" exists + + Scenario: move share to another folder + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" renames room "group room" to "Group room" with 200 + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" adds "participant3" to room "group room" with 200 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + And user "participant1" creates folder "/test" + When user "participant1" moves file "/welcome.txt" to "/test/renamed.txt" with 201 + Then user "participant1" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /test/renamed.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | group room | + | share_with_displayname | Group room | + And user "participant2" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room | + | share_with_displayname | Group room | + And user "participant3" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room | + | share_with_displayname | Group room | + + + + # When an own share is moved into a received shared folder the ownership of + # the share is handed over to the folder owner. + Scenario: move share to received shared folder from a user in the room + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" renames room "group room" to "Group room" with 200 + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" adds "participant3" to room "group room" with 200 + And user "participant3" creates folder "/test" + And user "participant3" shares "/test" with user "participant1" with OCS 100 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + When user "participant1" moves file "/welcome.txt" to "/test/renamed.txt" with 201 + Then user "participant1" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | uid_file_owner | participant3 | + | displayname_file_owner | participant3-displayname | + | path | /test/renamed.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/test | + | file_target | /welcome.txt | + | share_with | group room | + | share_with_displayname | Group room | + And user "participant2" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | uid_file_owner | participant3 | + | displayname_file_owner | participant3-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room | + | share_with_displayname | Group room | + And user "participant3" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | uid_file_owner | participant3 | + | displayname_file_owner | participant3-displayname | + | path | /test/renamed.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant3 | + | file_target | /welcome (2).txt | + | share_with | group room | + | share_with_displayname | Group room | + + Scenario: move share to received shared folder from a user not in the room + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" renames room "group room" to "Group room" with 200 + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" adds "participant3" to room "group room" with 200 + And user "participant4" creates folder "/test" + And user "participant4" shares "/test" with user "participant1" with OCS 100 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + When user "participant1" moves file "/welcome.txt" to "/test/renamed.txt" with 201 + Then user "participant1" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | uid_file_owner | participant4 | + | displayname_file_owner | participant4-displayname | + | path | /test/renamed.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/test | + | file_target | /welcome.txt | + | share_with | group room | + | share_with_displayname | Group room | + And user "participant2" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | uid_file_owner | participant4 | + | displayname_file_owner | participant4-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room | + | share_with_displayname | Group room | + And user "participant3" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | uid_file_owner | participant4 | + | displayname_file_owner | participant4-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room | + | share_with_displayname | Group room | + + Scenario: move share to received shared folder which is also a received shared folder + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" renames room "group room" to "Group room" with 200 + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant3" creates folder "/test" + And user "participant3" shares "/test" with user "participant4" with OCS 100 + And user "participant4" shares "/test" with user "participant1" with OCS 100 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + When user "participant1" moves file "/welcome.txt" to "/test/renamed.txt" with 201 + Then user "participant1" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | uid_file_owner | participant3 | + | displayname_file_owner | participant3-displayname | + | path | /test/renamed.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/test | + | file_target | /welcome.txt | + | share_with | group room | + | share_with_displayname | Group room | + And user "participant2" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | uid_file_owner | participant3 | + | displayname_file_owner | participant3-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room | + | share_with_displayname | Group room | + And user "participant3" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | uid_file_owner | participant3 | + | displayname_file_owner | participant3-displayname | + | path | /test/renamed.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant3 | + | file_target | /welcome.txt | + | share_with | group room | + | share_with_displayname | Group room | + And user "participant4" gets last share + Then the OCS status code should be "404" + And the HTTP status code should be "200" + + + + Scenario: move received share to another folder + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" renames room "group room" to "Group room" with 200 + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" adds "participant3" to room "group room" with 200 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + And user "participant2" creates folder "/test" + When user "participant2" moves file "/welcome (2).txt" to "/test/renamed.txt" with 201 + Then user "participant1" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | group room | + | share_with_displayname | Group room | + And user "participant2" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /test/renamed.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/test/renamed.txt | + | file_target | /test/renamed.txt | + | share_with | group room | + | share_with_displayname | Group room | + And user "participant3" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room | + | share_with_displayname | Group room | + + + + # Received shares can not be moved into other shares (general limitation of + # the sharing system, not related to room shares). + Scenario: move received share to shared folder + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" renames room "group room" to "Group room" with 200 + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" adds "participant3" to room "group room" with 200 + And user "participant3" creates folder "/test" + And user "participant3" shares "/test" with user "participant2" with OCS 100 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + When user "participant3" moves file "/welcome (2).txt" to "/test/renamed.txt" + Then the HTTP status code should be "403" + + # Received shares can be moved into other received shares, though. However, + # they are moved back to the default share folder. + Scenario: move received share to received shared folder from a user in the room + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" renames room "group room" to "Group room" with 200 + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" adds "participant3" to room "group room" with 200 + And user "participant3" creates folder "/test" + And user "participant3" shares "/test" with user "participant2" with OCS 100 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + When user "participant2" moves file "/welcome (2).txt" to "/test/renamed.txt" + Then user "participant1" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | group room | + | share_with_displayname | Group room | + And user "participant2" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /renamed.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/renamed.txt | + | file_target | /renamed.txt | + | share_with | group room | + | share_with_displayname | Group room | + And user "participant3" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room | + | share_with_displayname | Group room | + + Scenario: move received share to received shared folder from a user not in the room + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" renames room "group room" to "Group room" with 200 + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" adds "participant3" to room "group room" with 200 + And user "participant4" creates folder "/test" + And user "participant4" shares "/test" with user "participant2" with OCS 100 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + When user "participant2" moves file "/welcome (2).txt" to "/test/renamed.txt" + Then user "participant1" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | group room | + | share_with_displayname | Group room | + And user "participant2" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /renamed.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/renamed.txt | + | file_target | /renamed.txt | + | share_with | group room | + | share_with_displayname | Group room | + And user "participant3" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room | + | share_with_displayname | Group room | diff --git a/tests/integration/features/sharing/restore.feature b/tests/integration/features/sharing/restore.feature new file mode 100644 index 00000000000..295ca41ed02 --- /dev/null +++ b/tests/integration/features/sharing/restore.feature @@ -0,0 +1,153 @@ +Feature: delete + + Background: + Given user "participant1" exists + Given user "participant2" exists + Given user "participant3" exists + + Scenario: restore deleted share + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" renames room "group room" to "Group room" with 200 + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" adds "participant3" to room "group room" with 200 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + And user "participant2" deletes last share + When user "participant2" restores last share + Then the OCS status code should be "100" + And the HTTP status code should be "200" + And user "participant2" gets deleted shares + And the list of returned shares has 0 shares + And user "participant2" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room | + | share_with_displayname | Group room | + And user "participant1" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | group room | + | share_with_displayname | Group room | + And user "participant3" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room | + | share_with_displayname | Group room | + + Scenario: restore share deleted after moving it + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" renames room "group room" to "Group room" with 200 + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" adds "participant3" to room "group room" with 200 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + And user "participant2" moves file "/welcome (2).txt" to "/renamed.txt" with 201 + And user "participant2" deletes last share + When user "participant2" restores last share + Then the OCS status code should be "100" + And the HTTP status code should be "200" + And user "participant2" gets deleted shares + And the list of returned shares has 0 shares + And user "participant2" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /renamed.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/renamed.txt | + | file_target | /renamed.txt | + | share_with | group room | + | share_with_displayname | Group room | + And user "participant1" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | group room | + | share_with_displayname | Group room | + And user "participant3" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room | + | share_with_displayname | Group room | + + Scenario: restore deleted share after owner updated it + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" renames room "group room" to "Group room" with 200 + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" adds "participant3" to room "group room" with 200 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + And user "participant2" deletes last share + And user "participant1" updates last share with + | permissions | 1 | + When user "participant2" restores last share + Then the OCS status code should be "100" + And the HTTP status code should be "200" + And user "participant2" gets deleted shares + And the list of returned shares has 0 shares + And user "participant2" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room | + | share_with_displayname | Group room | + | permissions | 1 | + And user "participant1" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | group room | + | share_with_displayname | Group room | + | permissions | 1 | + And user "participant3" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room | + | share_with_displayname | Group room | + | permissions | 1 | diff --git a/tests/integration/features/sharing/transfer-ownership.feature b/tests/integration/features/sharing/transfer-ownership.feature new file mode 100644 index 00000000000..4c1b1d98805 --- /dev/null +++ b/tests/integration/features/sharing/transfer-ownership.feature @@ -0,0 +1,140 @@ +Feature: transfer-ownership + + Background: + Given user "participant1" exists + Given user "participant2" exists + Given user "participant3" exists + + Scenario: transfer ownership of a file shared with a room to a user in the room + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" renames room "group room" to "Group room" with 200 + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" adds "participant3" to room "group room" with 200 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + When transfering ownership from "participant1" to "participant2" + Then user "participant1" gets last share + And share is returned with + | uid_owner | participant2 | + | displayname_owner | participant2-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome.txt | + | file_target | /welcome.txt | + | share_with | group room | + | share_with_displayname | Group room | + And user "participant2" gets last share + And share is returned with + | uid_owner | participant2 | + | displayname_owner | participant2-displayname | + | path | REGEXP /\/transferred from participant1 on .*\/welcome.txt/ | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant2 | + | file_target | /welcome (2).txt | + | share_with | group room | + | share_with_displayname | Group room | + And user "participant3" gets last share + And share is returned with + | uid_owner | participant2 | + | displayname_owner | participant2-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room | + | share_with_displayname | Group room | + + Scenario: transfer ownership of a file reshared with a room to a user in the room + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" renames room "group room" to "Group room" with 200 + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" adds "participant3" to room "group room" with 200 + And user "participant3" shares "welcome.txt" with user "participant1" with OCS 100 + And user "participant1" shares "welcome (2).txt" with room "group room" with OCS 100 + When transfering ownership from "participant1" to "participant2" + Then user "participant1" gets last share + And share is returned with + | uid_owner | participant2 | + | displayname_owner | participant2-displayname | + | uid_file_owner | participant3 | + | displayname_file_owner | participant3-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room | + | share_with_displayname | Group room | + And user "participant2" gets last share + And share is returned with + | uid_owner | participant2 | + | displayname_owner | participant2-displayname | + | uid_file_owner | participant3 | + | displayname_file_owner | participant3-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room | + | share_with_displayname | Group room | + And user "participant3" gets last share + And share is returned with + | uid_owner | participant2 | + | displayname_owner | participant2-displayname | + | uid_file_owner | participant3 | + | displayname_file_owner | participant3-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant3 | + | file_target | /welcome (2).txt | + | share_with | group room | + | share_with_displayname | Group room | + + # This is a special case in which even if the (now) sharer is not in a room + # the room share is valid and other participants can access that share. + Scenario: transfer ownership of a file shared with a room to a user not in the room + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" renames room "group room" to "Group room" with 200 + And user "participant1" adds "participant3" to room "group room" with 200 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + When transfering ownership from "participant1" to "participant2" + Then user "participant1" gets last share + And share is returned with + | uid_owner | participant2 | + | displayname_owner | participant2-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome.txt | + | file_target | /welcome.txt | + | share_with | group room | + | share_with_displayname | Group room | + And user "participant2" gets last share + And share is returned with + | uid_owner | participant2 | + | displayname_owner | participant2-displayname | + | path | REGEXP /\/transferred from participant1 on .*\/welcome.txt/ | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant2 | + | file_target | /welcome.txt | + | share_with | group room | + | share_with_displayname | Group room | + And user "participant3" gets last share + And share is returned with + | uid_owner | participant2 | + | displayname_owner | participant2-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room | + | share_with_displayname | Group room | diff --git a/tests/integration/features/sharing/update.feature b/tests/integration/features/sharing/update.feature new file mode 100644 index 00000000000..f03a5a6f087 --- /dev/null +++ b/tests/integration/features/sharing/update.feature @@ -0,0 +1,1195 @@ +Feature: update + + Background: + Given user "participant1" exists + Given user "participant2" exists + Given user "participant3" exists + + Scenario: update share with an owned one-to-one room + Given user "participant1" creates room "own one-to-one room" + | roomType | 1 | + | invite | participant2 | + And user "participant1" shares "welcome.txt" with room "own one-to-one room" with OCS 100 + When user "participant1" updates last share with + | permissions | 1 | + | expireDate | +3 days | + Then share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | own one-to-one room | + | share_with_displayname | participant2-displayname | + | permissions | 1 | + | expiration | +3 days | + And user "participant1" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | own one-to-one room | + | share_with_displayname | participant2-displayname | + | permissions | 1 | + | expiration | +3 days | + And user "participant2" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | own one-to-one room | + | share_with_displayname | participant1-displayname | + | permissions | 1 | + | expiration | +3 days | + + Scenario: update share with a one-to-one room invited to + Given user "participant2" creates room "one-to-one room invited to" + | roomType | 1 | + | invite | participant1 | + And user "participant1" shares "welcome.txt" with room "one-to-one room invited to" with OCS 100 + When user "participant1" updates last share with + | permissions | 1 | + | expireDate | +3 days | + Then share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | one-to-one room invited to | + | share_with_displayname | participant2-displayname | + | permissions | 1 | + | expiration | +3 days | + And user "participant1" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | one-to-one room invited to | + | share_with_displayname | participant2-displayname | + | permissions | 1 | + | expiration | +3 days | + And user "participant2" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | one-to-one room invited to | + | share_with_displayname | participant1-displayname | + | permissions | 1 | + | expiration | +3 days | + + Scenario: update share with an owned group room + Given user "participant1" creates room "own group room" + | roomType | 2 | + And user "participant1" renames room "own group room" to "Own group room" with 200 + And user "participant1" adds "participant2" to room "own group room" with 200 + And user "participant1" shares "welcome.txt" with room "own group room" with OCS 100 + When user "participant1" updates last share with + | permissions | 1 | + | expireDate | +3 days | + Then share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | own group room | + | share_with_displayname | Own group room | + | permissions | 1 | + | expiration | +3 days | + And user "participant1" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | own group room | + | share_with_displayname | Own group room | + | permissions | 1 | + | expiration | +3 days | + And user "participant2" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | own group room | + | share_with_displayname | Own group room | + | permissions | 1 | + | expiration | +3 days | + + Scenario: update share with a group room invited to + Given user "participant2" creates room "group room invited to" + | roomType | 2 | + And user "participant2" renames room "group room invited to" to "Group room invited to" with 200 + And user "participant2" adds "participant1" to room "group room invited to" with 200 + And user "participant1" shares "welcome.txt" with room "group room invited to" with OCS 100 + When user "participant1" updates last share with + | permissions | 1 | + | expireDate | +3 days | + Then share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | group room invited to | + | share_with_displayname | Group room invited to | + | permissions | 1 | + | expiration | +3 days | + And user "participant1" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | group room invited to | + | share_with_displayname | Group room invited to | + | permissions | 1 | + | expiration | +3 days | + And user "participant2" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room invited to | + | share_with_displayname | Group room invited to | + | permissions | 1 | + | expiration | +3 days | + + Scenario: update share with an owned public room + Given user "participant1" creates room "own public room" + | roomType | 3 | + And user "participant1" renames room "own public room" to "Own public room" with 200 + And user "participant1" adds "participant2" to room "own public room" with 200 + And user "participant3" joins room "own public room" with 200 + And user "participant1" shares "welcome.txt" with room "own public room" with OCS 100 + When user "participant1" updates last share with + | permissions | 1 | + | expireDate | +3 days | + Then share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | own public room | + | share_with_displayname | Own public room | + | token | A_TOKEN | + | permissions | 1 | + | expiration | +3 days | + And user "participant1" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | own public room | + | share_with_displayname | Own public room | + | token | A_TOKEN | + | permissions | 1 | + | expiration | +3 days | + And user "participant2" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | own public room | + | share_with_displayname | Own public room | + | token | A_TOKEN | + | permissions | 1 | + | expiration | +3 days | + And user "participant3" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | own public room | + | share_with_displayname | Own public room | + | token | A_TOKEN | + | permissions | 1 | + | expiration | +3 days | + + Scenario: update share with a public room invited to + Given user "participant2" creates room "public room invited to" + | roomType | 3 | + And user "participant2" renames room "public room invited to" to "Public room invited to" with 200 + And user "participant2" adds "participant1" to room "public room invited to" with 200 + And user "participant3" joins room "public room invited to" with 200 + And user "participant1" shares "welcome.txt" with room "public room invited to" with OCS 100 + When user "participant1" updates last share with + | permissions | 1 | + | expireDate | +3 days | + Then share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | public room invited to | + | share_with_displayname | Public room invited to | + | token | A_TOKEN | + | permissions | 1 | + | expiration | +3 days | + And user "participant1" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | public room invited to | + | share_with_displayname | Public room invited to | + | token | A_TOKEN | + | permissions | 1 | + | expiration | +3 days | + And user "participant2" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | public room invited to | + | share_with_displayname | Public room invited to | + | token | A_TOKEN | + | permissions | 1 | + | expiration | +3 days | + And user "participant3" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | public room invited to | + | share_with_displayname | Public room invited to | + | token | A_TOKEN | + | permissions | 1 | + | expiration | +3 days | + + Scenario: update share with a public room self joined to + Given user "participant2" creates room "public room self joined to" + | roomType | 3 | + And user "participant2" renames room "public room self joined to" to "Public room self joined to" with 200 + And user "participant1" joins room "public room self joined to" with 200 + And user "participant3" joins room "public room self joined to" with 200 + And user "participant1" shares "welcome.txt" with room "public room self joined to" with OCS 100 + When user "participant1" updates last share with + | permissions | 1 | + | expireDate | +3 days | + Then share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | public room self joined to | + | share_with_displayname | Public room self joined to | + | token | A_TOKEN | + | permissions | 1 | + | expiration | +3 days | + And user "participant1" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | public room self joined to | + | share_with_displayname | Public room self joined to | + | token | A_TOKEN | + | permissions | 1 | + | expiration | +3 days | + And user "participant2" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | public room self joined to | + | share_with_displayname | Public room self joined to | + | token | A_TOKEN | + | permissions | 1 | + | expiration | +3 days | + And user "participant3" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | public room self joined to | + | share_with_displayname | Public room self joined to | + | token | A_TOKEN | + | permissions | 1 | + | expiration | +3 days | + + + + Scenario: update (unknown) share with a one-to-one room not invited to + Given user "participant2" creates room "one-to-one room not invited to" + | roomType | 1 | + | invite | participant3 | + And user "participant2" shares "welcome.txt" with room "one-to-one room not invited to" with OCS 100 + When user "participant1" updates last share with + | permissions | 1 | + | expireDate | +3 days | + Then the OCS status code should be "404" + And the HTTP status code should be "200" + And user "participant2" gets last share + And share is returned with + | uid_owner | participant2 | + | displayname_owner | participant2-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant2 | + | file_target | /welcome.txt | + | share_with | one-to-one room not invited to | + | share_with_displayname | participant3-displayname | + And user "participant3" gets last share + And share is returned with + | uid_owner | participant2 | + | displayname_owner | participant2-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | one-to-one room not invited to | + | share_with_displayname | participant2-displayname | + + Scenario: update (unknown) share with a group room not invited to + Given user "participant2" creates room "group room not invited to" + | roomType | 2 | + And user "participant2" renames room "group room not invited to" to "Group room not invited to" with 200 + And user "participant2" adds "participant3" to room "group room not invited to" with 200 + And user "participant2" shares "welcome.txt" with room "group room not invited to" with OCS 100 + When user "participant1" updates last share with + | permissions | 1 | + | expireDate | +3 days | + Then the OCS status code should be "404" + And the HTTP status code should be "200" + And user "participant2" gets last share + And share is returned with + | uid_owner | participant2 | + | displayname_owner | participant2-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant2 | + | file_target | /welcome.txt | + | share_with | group room not invited to | + | share_with_displayname | Group room not invited to | + And user "participant3" gets last share + And share is returned with + | uid_owner | participant2 | + | displayname_owner | participant2-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room not invited to | + | share_with_displayname | Group room not invited to | + + Scenario: update (unknown) share with a public room not joined to + Given user "participant2" creates room "public room not joined to" + | roomType | 3 | + And user "participant2" renames room "public room not joined to" to "Public room not joined to" with 200 + And user "participant2" adds "participant3" to room "public room not joined to" with 200 + And user "participant2" shares "welcome.txt" with room "public room not joined to" with OCS 100 + When user "participant1" updates last share with + | permissions | 1 | + | expireDate | +3 days | + Then the OCS status code should be "404" + And the HTTP status code should be "200" + And user "participant2" gets last share + And share is returned with + | uid_owner | participant2 | + | displayname_owner | participant2-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant2 | + | file_target | /welcome.txt | + | share_with | public room not joined to | + | share_with_displayname | Public room not joined to | + | token | A_TOKEN | + And user "participant3" gets last share + And share is returned with + | uid_owner | participant2 | + | displayname_owner | participant2-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | public room not joined to | + | share_with_displayname | Public room not joined to | + | token | A_TOKEN | + + + + Scenario: update received share with an owned one-to-one room + Given user "participant2" creates room "own one-to-one room" + | roomType | 1 | + | invite | participant1 | + And user "participant1" shares "welcome.txt" with room "own one-to-one room" with OCS 100 + When user "participant2" updates last share with + | permissions | 1 | + | expireDate | +3 days | + Then share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | own one-to-one room | + | share_with_displayname | participant1-displayname | + | permissions | 1 | + | expiration | +3 days | + And user "participant1" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | own one-to-one room | + | share_with_displayname | participant2-displayname | + | permissions | 1 | + | expiration | +3 days | + And user "participant2" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | own one-to-one room | + | share_with_displayname | participant1-displayname | + | permissions | 1 | + | expiration | +3 days | + + Scenario: update received share with a one-to-one room invited to + Given user "participant1" creates room "one-to-one room invited to" + | roomType | 1 | + | invite | participant2 | + And user "participant1" shares "welcome.txt" with room "one-to-one room invited to" with OCS 100 + When user "participant2" updates last share with + | permissions | 1 | + | expireDate | +3 days | + Then share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | one-to-one room invited to | + | share_with_displayname | participant1-displayname | + | permissions | 1 | + | expiration | +3 days | + And user "participant1" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | one-to-one room invited to | + | share_with_displayname | participant2-displayname | + | permissions | 1 | + | expiration | +3 days | + And user "participant2" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | one-to-one room invited to | + | share_with_displayname | participant1-displayname | + | permissions | 1 | + | expiration | +3 days | + + Scenario: update received share with an owned group room + Given user "participant2" creates room "own group room" + | roomType | 2 | + And user "participant2" renames room "own group room" to "Own group room" with 200 + And user "participant2" adds "participant1" to room "own group room" with 200 + And user "participant1" shares "welcome.txt" with room "own group room" with OCS 100 + When user "participant2" updates last share with + | permissions | 1 | + | expireDate | +3 days | + Then share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | own group room | + | share_with_displayname | Own group room | + | permissions | 1 | + | expiration | +3 days | + And user "participant1" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | own group room | + | share_with_displayname | Own group room | + | permissions | 1 | + | expiration | +3 days | + And user "participant2" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | own group room | + | share_with_displayname | Own group room | + | permissions | 1 | + | expiration | +3 days | + + Scenario: update received share with a group room invited to + Given user "participant1" creates room "group room invited to" + | roomType | 2 | + And user "participant1" renames room "group room invited to" to "Group room invited to" with 200 + And user "participant1" adds "participant2" to room "group room invited to" with 200 + And user "participant1" adds "participant3" to room "group room invited to" with 200 + And user "participant1" shares "welcome.txt" with room "group room invited to" with OCS 100 + When user "participant2" updates last share with + | permissions | 1 | + | expireDate | +3 days | + Then share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room invited to | + | share_with_displayname | Group room invited to | + | permissions | 1 | + | expiration | +3 days | + And user "participant1" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | group room invited to | + | share_with_displayname | Group room invited to | + | permissions | 1 | + | expiration | +3 days | + And user "participant2" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room invited to | + | share_with_displayname | Group room invited to | + | permissions | 1 | + | expiration | +3 days | + And user "participant3" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room invited to | + | share_with_displayname | Group room invited to | + | permissions | 1 | + | expiration | +3 days | + + Scenario: update received share with a group room no longer invited to + Given user "participant1" creates room "group room no longer invited to" + | roomType | 2 | + And user "participant1" renames room "group room no longer invited to" to "Group room no longer invited to" with 200 + And user "participant1" adds "participant2" to room "group room no longer invited to" with 200 + And user "participant1" adds "participant3" to room "group room no longer invited to" with 200 + And user "participant1" shares "welcome.txt" with room "group room no longer invited to" with OCS 100 + And user "participant1" removes "participant2" from room "group room no longer invited to" with 200 + When user "participant2" updates last share with + | permissions | 1 | + | expiration | +3 days | + Then the OCS status code should be "404" + And the HTTP status code should be "200" + And user "participant1" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | group room no longer invited to | + | share_with_displayname | Group room no longer invited to | + And user "participant2" gets last share + And the OCS status code should be "404" + And the HTTP status code should be "200" + And user "participant3" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room no longer invited to | + | share_with_displayname | Group room no longer invited to | + + Scenario: update received share with an owned public room + Given user "participant2" creates room "own public room" + | roomType | 3 | + And user "participant2" renames room "own public room" to "Own public room" with 200 + And user "participant2" adds "participant1" to room "own public room" with 200 + And user "participant3" joins room "own public room" with 200 + And user "participant1" shares "welcome.txt" with room "own public room" with OCS 100 + When user "participant2" updates last share with + | permissions | 1 | + | expireDate | +3 days | + Then share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | own public room | + | share_with_displayname | Own public room | + | token | A_TOKEN | + | permissions | 1 | + | expiration | +3 days | + And user "participant1" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | own public room | + | share_with_displayname | Own public room | + | token | A_TOKEN | + | permissions | 1 | + | expiration | +3 days | + And user "participant2" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | own public room | + | share_with_displayname | Own public room | + | token | A_TOKEN | + | permissions | 1 | + | expiration | +3 days | + And user "participant3" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | own public room | + | share_with_displayname | Own public room | + | token | A_TOKEN | + | permissions | 1 | + | expiration | +3 days | + + Scenario: update received share with a public room invited to + Given user "participant1" creates room "public room invited to" + | roomType | 3 | + And user "participant1" renames room "public room invited to" to "Public room invited to" with 200 + And user "participant1" adds "participant2" to room "public room invited to" with 200 + And user "participant3" joins room "public room invited to" with 200 + And user "participant1" shares "welcome.txt" with room "public room invited to" with OCS 100 + When user "participant2" updates last share with + | permissions | 1 | + | expireDate | +3 days | + Then share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | public room invited to | + | share_with_displayname | Public room invited to | + | token | A_TOKEN | + | permissions | 1 | + | expiration | +3 days | + And user "participant1" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | public room invited to | + | share_with_displayname | Public room invited to | + | token | A_TOKEN | + | permissions | 1 | + | expiration | +3 days | + And user "participant2" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | public room invited to | + | share_with_displayname | Public room invited to | + | token | A_TOKEN | + | permissions | 1 | + | expiration | +3 days | + And user "participant3" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | public room invited to | + | share_with_displayname | Public room invited to | + | token | A_TOKEN | + | permissions | 1 | + | expiration | +3 days | + + Scenario: update received share with a public room self joined to + Given user "participant1" creates room "public room self joined to" + | roomType | 3 | + And user "participant1" renames room "public room self joined to" to "Public room self joined to" with 200 + And user "participant2" joins room "public room self joined to" with 200 + And user "participant3" joins room "public room self joined to" with 200 + And user "participant1" shares "welcome.txt" with room "public room self joined to" with OCS 100 + When user "participant2" updates last share with + | permissions | 1 | + | expireDate | +3 days | + Then share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | public room self joined to | + | share_with_displayname | Public room self joined to | + | token | A_TOKEN | + | permissions | 1 | + | expiration | +3 days | + And user "participant1" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | public room self joined to | + | share_with_displayname | Public room self joined to | + | token | A_TOKEN | + | permissions | 1 | + | expiration | +3 days | + And user "participant2" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | public room self joined to | + | share_with_displayname | Public room self joined to | + | token | A_TOKEN | + | permissions | 1 | + | expiration | +3 days | + And user "participant3" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | public room self joined to | + | share_with_displayname | Public room self joined to | + | token | A_TOKEN | + | permissions | 1 | + | expiration | +3 days | + + Scenario: update received share with a public room no longer joined to + Given user "participant1" creates room "public room no longer joined to" + | roomType | 3 | + And user "participant1" renames room "public room no longer joined to" to "Public room no longer joined to" with 200 + And user "participant2" joins room "public room no longer joined to" with 200 + And user "participant3" joins room "public room no longer joined to" with 200 + And user "participant1" shares "welcome.txt" with room "public room no longer joined to" with OCS 100 + And user "participant2" leaves room "public room no longer joined to" with 200 + When user "participant2" updates last share with + | permissions | 1 | + | expiration | +3 days | + Then the OCS status code should be "404" + And the HTTP status code should be "200" + And user "participant1" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | public room no longer joined to | + | share_with_displayname | Public room no longer joined to | + | token | A_TOKEN | + And user "participant2" gets last share + And the OCS status code should be "404" + And the HTTP status code should be "200" + And user "participant3" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | public room no longer joined to | + | share_with_displayname | Public room no longer joined to | + | token | A_TOKEN | + + + + Scenario: update received share after moving it + Given user "participant1" creates room "group room invited to" + | roomType | 2 | + And user "participant1" renames room "group room invited to" to "Group room invited to" with 200 + And user "participant1" adds "participant2" to room "group room invited to" with 200 + And user "participant1" adds "participant3" to room "group room invited to" with 200 + And user "participant1" shares "welcome.txt" with room "group room invited to" with OCS 100 + And user "participant2" creates folder "/test" + And user "participant2" moves file "/welcome (2).txt" to "/test/renamed.txt" with 201 + When user "participant2" updates last share with + | permissions | 1 | + | expireDate | +3 days | + Then share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /test/renamed.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/test/renamed.txt | + | file_target | /test/renamed.txt | + | share_with | group room invited to | + | share_with_displayname | Group room invited to | + | permissions | 1 | + | expiration | +3 days | + And user "participant1" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | group room invited to | + | share_with_displayname | Group room invited to | + | permissions | 1 | + | expiration | +3 days | + And user "participant2" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /test/renamed.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/test/renamed.txt | + | file_target | /test/renamed.txt | + | share_with | group room invited to | + | share_with_displayname | Group room invited to | + | permissions | 1 | + | expiration | +3 days | + And user "participant3" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room invited to | + | share_with_displayname | Group room invited to | + | permissions | 1 | + | expiration | +3 days | + + Scenario: update received share with a room no longer invited to after moving it + Given user "participant1" creates room "group room invited to" + | roomType | 2 | + And user "participant1" renames room "group room invited to" to "Group room invited to" with 200 + And user "participant1" adds "participant2" to room "group room invited to" with 200 + And user "participant1" adds "participant3" to room "group room invited to" with 200 + And user "participant1" shares "welcome.txt" with room "group room invited to" with OCS 100 + And user "participant2" creates folder "/test" + And user "participant2" moves file "/welcome (2).txt" to "/test/renamed.txt" with 201 + And user "participant1" removes "participant2" from room "group room invited to" with 200 + When user "participant2" updates last share with + | permissions | 1 | + | expireDate | +3 days | + Then the OCS status code should be "404" + And the HTTP status code should be "200" + And user "participant1" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | group room invited to | + | share_with_displayname | Group room invited to | + And user "participant2" gets last share + And the OCS status code should be "404" + And the HTTP status code should be "200" + And user "participant3" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room invited to | + | share_with_displayname | Group room invited to | + + + + Scenario: update received share with increased permissions + Given user "participant1" creates room "group room invited to" + | roomType | 2 | + And user "participant1" renames room "group room invited to" to "Group room invited to" with 200 + And user "participant1" adds "participant2" to room "group room invited to" with 200 + And user "participant1" shares "welcome.txt" with room "group room invited to" with OCS 100 + And user "participant1" updates last share with + | permissions | 1 | + When user "participant2" updates last share with + | permissions | 19 | + Then the OCS status code should be "404" + And the HTTP status code should be "200" + And user "participant1" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | group room invited to | + | share_with_displayname | Group room invited to | + | permissions | 1 | + And user "participant2" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome (2).txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | shared::/welcome (2).txt | + | file_target | /welcome (2).txt | + | share_with | group room invited to | + | share_with_displayname | Group room invited to | + | permissions | 1 | + + + + Scenario: update share after sharee deleted it + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" renames room "group room" to "Group room" with 200 + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + And user "participant2" deletes last share with OCS 100 + When user "participant1" updates last share with + | permissions | 1 | + | expireDate | +3 days | + Then share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | group room | + | share_with_displayname | Group room | + | permissions | 1 | + | expiration | +3 days | + And user "participant1" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | group room | + | share_with_displayname | Group room | + | permissions | 1 | + | expiration | +3 days | + And user "participant2" gets last share + And the OCS status code should be "404" + + Scenario: update received share after deleting it + Given user "participant1" creates room "group room" + | roomType | 2 | + And user "participant1" renames room "group room" to "Group room" with 200 + And user "participant1" adds "participant2" to room "group room" with 200 + And user "participant1" shares "welcome.txt" with room "group room" with OCS 100 + And user "participant2" deletes last share with OCS 100 + When user "participant2" updates last share with + | permissions | 1 | + | expireDate | +3 days | + Then the OCS status code should be "404" + And the HTTP status code should be "200" + And user "participant1" gets last share + And share is returned with + | uid_owner | participant1 | + | displayname_owner | participant1-displayname | + | path | /welcome.txt | + | item_type | file | + | mimetype | text/plain | + | storage_id | home::participant1 | + | file_target | /welcome.txt | + | share_with | group room | + | share_with_displayname | Group room | + And user "participant2" gets last share + And the OCS status code should be "404" diff --git a/tests/integration/spreedcheats/lib/Controller/ApiController.php b/tests/integration/spreedcheats/lib/Controller/ApiController.php index 50a4e05290a..61aed6ef7c5 100644 --- a/tests/integration/spreedcheats/lib/Controller/ApiController.php +++ b/tests/integration/spreedcheats/lib/Controller/ApiController.php @@ -59,6 +59,14 @@ public function resetSpreed() { $query = $this->db->getQueryBuilder(); $query->delete('talk_participants')->execute(); + $query = $this->db->getQueryBuilder(); + $query->delete('share') + ->where($query->expr()->orX( + $query->expr()->eq('share_type', $query->createNamedParameter(\OCP\Share::SHARE_TYPE_ROOM)), + $query->expr()->eq('share_type', $query->createNamedParameter(11 /*RoomShareProvider::SHARE_TYPE_USERROOM*/)) + )) + ->execute(); + return new DataResponse(); } }