diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2019-11-13 20:30:43 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2019-11-13 20:30:43 +0100 |
commit | 4fcba8a597016c0f640a452b8ebcb7429eca875c (patch) | |
tree | db176d39bee2ba4fce2895244291b98825aae48e /tests | |
parent | 0bd1378f819915529d17a53147c0a43ff10c09f1 (diff) | |
parent | 570bb4064369f3bea6f22d8ff48fd7f16b8bfbf8 (diff) | |
download | nextcloud-server-4fcba8a597016c0f640a452b8ebcb7429eca875c.tar.gz nextcloud-server-4fcba8a597016c0f640a452b8ebcb7429eca875c.zip |
Merge remote-tracking branch 'origin/master' into fix/5456/respect_avatar_privacy
Diffstat (limited to 'tests')
7 files changed, 274 insertions, 51 deletions
diff --git a/tests/acceptance/features/app-files-sharing-link.feature b/tests/acceptance/features/app-files-sharing-link.feature index c35338fea28..38680f110d4 100644 --- a/tests/acceptance/features/app-files-sharing-link.feature +++ b/tests/acceptance/features/app-files-sharing-link.feature @@ -126,8 +126,7 @@ Feature: app-files-sharing-link Given I am logged in And I share the link for "welcome.txt" When I protect the shared link with the password "abcdef" - Then I see that the working icon for password protect is shown - And I see that the working icon for password protect is eventually not shown + Then I see that the password protect is disabled while loading And I see that the link share is password protected # As Talk is not enabled in the acceptance tests of the server the checkbox # is never shown. diff --git a/tests/acceptance/features/app-files-tags.feature b/tests/acceptance/features/app-files-tags.feature index 5c0942472a8..093ae371912 100644 --- a/tests/acceptance/features/app-files-tags.feature +++ b/tests/acceptance/features/app-files-tags.feature @@ -19,15 +19,6 @@ Feature: app-files-tags # When I open the input field for tags in the details view # Then I see that the input field for tags in the details view is shown - Scenario: show the input field for tags in the details view after the sharing tab has loaded - Given I am logged in - And I open the details view for "welcome.txt" - And I see that the details view is open - And I open the "Sharing" tab in the details view - And I see that the "Sharing" tab in the details view is eventually loaded - When I open the input field for tags in the details view - Then I see that the input field for tags in the details view is shown - Scenario: create tags using the Administration settings Given I am logged in as the admin And I visit the settings page diff --git a/tests/acceptance/features/bootstrap/FilesAppContext.php b/tests/acceptance/features/bootstrap/FilesAppContext.php index 880303fe1d6..32b01916189 100644 --- a/tests/acceptance/features/bootstrap/FilesAppContext.php +++ b/tests/acceptance/features/bootstrap/FilesAppContext.php @@ -98,7 +98,7 @@ class FilesAppContext implements Context, ActorAwareInterface { * @return Locator */ public static function fileNameInDetailsView() { - return Locator::forThe()->css(".fileName")-> + return Locator::forThe()->css(".app-sidebar-header__title")-> descendantOf(self::detailsView())-> describedAs("File name in details view in Files app"); } @@ -107,7 +107,7 @@ class FilesAppContext implements Context, ActorAwareInterface { * @return Locator */ public static function favoriteActionInFileDetailsInDetailsView() { - return Locator::forThe()->css(".action-favorite")-> + return Locator::forThe()->css(".app-sidebar-header__star")-> descendantOf(self::fileDetailsInDetailsView())-> describedAs("Favorite action in file details in details view in Files app"); } @@ -143,7 +143,7 @@ class FilesAppContext implements Context, ActorAwareInterface { * @return Locator */ private static function fileDetailsInDetailsView() { - return Locator::forThe()->css(".file-details")-> + return Locator::forThe()->css(".app-sidebar-header__desc")-> descendantOf(self::detailsView())-> describedAs("File details in details view in Files app"); } @@ -205,7 +205,7 @@ class FilesAppContext implements Context, ActorAwareInterface { * @return Locator */ private static function tabHeadersInDetailsView() { - return Locator::forThe()->css(".tabHeaders")-> + return Locator::forThe()->css(".app-sidebar-tabs__nav")-> descendantOf(self::detailsView())-> describedAs("Tab headers in details view in Files app"); } @@ -214,7 +214,7 @@ class FilesAppContext implements Context, ActorAwareInterface { * @return Locator */ public static function tabInDetailsViewNamed($tabName) { - return Locator::forThe()->xpath("//div[@id=//*[contains(concat(' ', normalize-space(@class), ' '), ' tabHeader ') and normalize-space() = '$tabName']/@data-tabid]")-> + return Locator::forThe()->xpath("//div[contains(concat(' ', normalize-space(@class), ' '), ' app-sidebar-tabs__content ')]/section[@aria-labelledby = '$tabName' and @role = 'tabpanel']")-> descendantOf(self::detailsView())-> describedAs("Tab named $tabName in details view in Files app"); } @@ -223,7 +223,7 @@ class FilesAppContext implements Context, ActorAwareInterface { * @return Locator */ public static function loadingIconForTabInDetailsViewNamed($tabName) { - return Locator::forThe()->css(".loading")-> + return Locator::forThe()->css(".icon-loading")-> descendantOf(self::tabInDetailsViewNamed($tabName))-> describedAs("Loading icon for tab named $tabName in details view in Files app"); } diff --git a/tests/acceptance/features/bootstrap/FilesAppSharingContext.php b/tests/acceptance/features/bootstrap/FilesAppSharingContext.php index 5353f05c110..6bebfc5b3d3 100644 --- a/tests/acceptance/features/bootstrap/FilesAppSharingContext.php +++ b/tests/acceptance/features/bootstrap/FilesAppSharingContext.php @@ -31,7 +31,7 @@ class FilesAppSharingContext implements Context, ActorAwareInterface { * @return Locator */ public static function sharedByLabel() { - return Locator::forThe()->css(".reshare")-> + return Locator::forThe()->css(".sharing-entry__reshare")-> descendantOf(FilesAppContext::detailsView())-> describedAs("Shared by label in the details view in Files app"); } @@ -40,7 +40,7 @@ class FilesAppSharingContext implements Context, ActorAwareInterface { * @return Locator */ public static function shareWithInput() { - return Locator::forThe()->css(".shareWithField")-> + return Locator::forThe()->css(".sharing-input .multiselect__input")-> descendantOf(FilesAppContext::detailsView())-> describedAs("Share with input in the details view in Files app"); } @@ -48,8 +48,26 @@ class FilesAppSharingContext implements Context, ActorAwareInterface { /** * @return Locator */ + public static function shareWithInputResults() { + return Locator::forThe()->css(".sharing-input .multiselect__content-wrapper")-> + descendantOf(FilesAppContext::detailsView())-> + describedAs("Share with input results list in the details view in Files app"); + } + + /** + * @return Locator + */ + public static function shareWithInputResult($result) { + return Locator::forThe()->xpath("//li[contains(concat(' ', normalize-space(@class), ' '), ' multiselect__element ')]//span[normalize-space() = '$result']/ancestor::li")-> + descendantOf(self::shareWithInputResults())-> + describedAs("Share with input result from the results list in the details view in Files app"); + } + + /** + * @return Locator + */ public static function shareeList() { - return Locator::forThe()->css(".shareeListView")-> + return Locator::forThe()->css(".sharing-sharee-list")-> descendantOf(FilesAppContext::detailsView())-> describedAs("Sharee list in the details view in Files app"); } @@ -60,7 +78,7 @@ class FilesAppSharingContext implements Context, ActorAwareInterface { public static function sharedWithRow($sharedWithName) { // "username" class is used for any type of share, not only for shares // with users. - return Locator::forThe()->xpath("//span[contains(concat(' ', normalize-space(@class), ' '), ' username ') and normalize-space() = '$sharedWithName']/ancestor::li")-> + return Locator::forThe()->xpath("//li[contains(concat(' ', normalize-space(@class), ' '), ' sharing-entry ')]//h5[normalize-space() = '$sharedWithName']/ancestor::li")-> descendantOf(self::shareeList())-> describedAs("Shared with $sharedWithName row in the details view in Files app"); } @@ -69,7 +87,7 @@ class FilesAppSharingContext implements Context, ActorAwareInterface { * @return Locator */ public static function shareWithMenuButton($sharedWithName) { - return Locator::forThe()->css(".share-menu > .icon")-> + return Locator::forThe()->css(".sharing-entry__actions > .action-item__menutoggle")-> descendantOf(self::sharedWithRow($sharedWithName))-> describedAs("Share with $sharedWithName menu button in the details view in Files app"); } @@ -78,7 +96,7 @@ class FilesAppSharingContext implements Context, ActorAwareInterface { * @return Locator */ public static function shareWithMenu($sharedWithName) { - return Locator::forThe()->css(".share-menu > .menu")-> + return Locator::forThe()->css(".sharing-entry__actions > .action-item__menu")-> descendantOf(self::sharedWithRow($sharedWithName))-> describedAs("Share with $sharedWithName menu in the details view in Files app"); } @@ -108,7 +126,7 @@ class FilesAppSharingContext implements Context, ActorAwareInterface { * @return Locator */ public static function shareLinkRow() { - return Locator::forThe()->css(".linkShareView .shareWithList:first-child")-> + return Locator::forThe()->css(".sharing-link-list .sharing-entry__link:first-child")-> descendantOf(FilesAppContext::detailsView())-> describedAs("Share link row in the details view in Files app"); } @@ -119,7 +137,7 @@ class FilesAppSharingContext implements Context, ActorAwareInterface { public static function shareLinkAddNewButton() { // When there is no link share the "Add new share" item is shown instead // of the menu button as a direct child of ".share-menu". - return Locator::forThe()->css(".share-menu > .new-share")-> + return Locator::forThe()->css(".action-item.icon-add")-> descendantOf(self::shareLinkRow())-> describedAs("Add new share link button in the details view in Files app"); } @@ -128,7 +146,7 @@ class FilesAppSharingContext implements Context, ActorAwareInterface { * @return Locator */ public static function copyLinkButton() { - return Locator::forThe()->css("a.clipboard-button")-> + return Locator::forThe()->css("a.sharing-entry__copy")-> descendantOf(self::shareLinkRow())-> describedAs("Copy link button in the details view in Files app"); } @@ -137,7 +155,7 @@ class FilesAppSharingContext implements Context, ActorAwareInterface { * @return Locator */ public static function shareLinkMenuButton() { - return Locator::forThe()->css(".share-menu > .icon")-> + return Locator::forThe()->css(".sharing-entry__actions .action-item__menutoggle")-> descendantOf(self::shareLinkRow())-> describedAs("Share link menu button in the details view in Files app"); } @@ -146,7 +164,7 @@ class FilesAppSharingContext implements Context, ActorAwareInterface { * @return Locator */ public static function shareLinkMenu() { - return Locator::forThe()->css(".share-menu > .menu")-> + return Locator::forThe()->css(".sharing-entry__actions .action-item__menu")-> descendantOf(self::shareLinkRow())-> describedAs("Share link menu in the details view in Files app"); } @@ -209,16 +227,16 @@ class FilesAppSharingContext implements Context, ActorAwareInterface { * @return Locator */ public static function passwordProtectField() { - return Locator::forThe()->css(".linkPassText")->descendantOf(self::shareLinkMenu())-> + return Locator::forThe()->css(".share-link-password input.action-input__input")->descendantOf(self::shareLinkMenu())-> describedAs("Password protect field in the details view in Files app"); } /** * @return Locator */ - public static function passwordProtectWorkingIcon() { - return Locator::forThe()->css(".linkPassMenu .icon-loading-small")->descendantOf(self::shareLinkMenu())-> - describedAs("Password protect working icon in the details view in Files app"); + public static function disabledPasswordProtectField() { + return Locator::forThe()->css(".share-link-password input.action-input__input[disabled]")->descendantOf(self::shareLinkMenu())-> + describedAs("Disabled password protect field in the details view in Files app"); } /** @@ -257,7 +275,12 @@ class FilesAppSharingContext implements Context, ActorAwareInterface { public function iShareWith($fileName, $shareWithName) { $this->actor->find(FileListContext::shareActionForFile(FilesAppContext::currentSectionMainView(), $fileName), 10)->click(); - $this->actor->find(self::shareWithInput(), 5)->setValue($shareWithName . "\r"); + $this->actor->find(self::shareWithInput(), 5)->setValue($shareWithName); + // "setValue()" ends sending a tab, which unfocuses the input and causes + // the results to be hidden, so the input needs to be clicked to show + // the results again. + $this->actor->find(self::shareWithInput())->click(); + $this->actor->find(self::shareWithInputResult($shareWithName), 5)->click(); } /** @@ -269,7 +292,7 @@ class FilesAppSharingContext implements Context, ActorAwareInterface { // Clicking on the menu item copies the link to the clipboard, but it is // not possible to access that value from the acceptance tests. Due to // this the value of the attribute that holds the URL is used instead. - $this->actor->getSharedNotebook()["shared link"] = $this->actor->find(self::copyLinkButton(), 2)->getWrappedElement()->getAttribute("data-clipboard-text"); + $this->actor->getSharedNotebook()["shared link"] = $this->actor->find(self::copyLinkButton(), 2)->getWrappedElement()->getAttribute("href"); } /** @@ -412,21 +435,16 @@ class FilesAppSharingContext implements Context, ActorAwareInterface { } /** - * @Then I see that the working icon for password protect is shown + * @Then I see that the password protect is disabled while loading */ - public function iSeeThatTheWorkingIconForPasswordProtectIsShown() { - PHPUnit_Framework_Assert::assertNotNull($this->actor->find(self::passwordProtectWorkingIcon(), 10)); - } + public function iSeeThatThePasswordProtectIsDisabledWhileLoading() { + PHPUnit_Framework_Assert::assertNotNull($this->actor->find(self::disabledPasswordProtectField(), 10)); - /** - * @Then I see that the working icon for password protect is eventually not shown - */ - public function iSeeThatTheWorkingIconForPasswordProtectIsEventuallyNotShown() { if (!WaitFor::elementToBeEventuallyNotShown( $this->actor, - self::passwordProtectWorkingIcon(), + self::disabledPasswordProtectField(), $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) { - PHPUnit_Framework_Assert::fail("The working icon for password protect is still shown after $timeout seconds"); + PHPUnit_Framework_Assert::fail("The password protect field is still disabled after $timeout seconds"); } } @@ -477,8 +495,7 @@ class FilesAppSharingContext implements Context, ActorAwareInterface { public function iShareTheLinkForProtectedByThePassword($fileName, $password) { $this->iShareTheLinkFor($fileName); $this->iProtectTheSharedLinkWithThePassword($password); - $this->iSeeThatTheWorkingIconForPasswordProtectIsShown(); - $this->iSeeThatTheWorkingIconForPasswordProtectIsEventuallyNotShown(); + $this->iSeeThatThePasswordProtectIsDisabledWhileLoading(); } private function showShareLinkMenuIfNeeded() { diff --git a/tests/lib/Collaboration/Collaborators/RemotePluginTest.php b/tests/lib/Collaboration/Collaborators/RemotePluginTest.php index aff68185767..560e72a984d 100644 --- a/tests/lib/Collaboration/Collaborators/RemotePluginTest.php +++ b/tests/lib/Collaboration/Collaborators/RemotePluginTest.php @@ -152,7 +152,7 @@ class RemotePluginTest extends TestCase { 'test@remote', [], true, - ['remotes' => [], 'exact' => ['remotes' => [['label' => 'test@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'test@remote']]]]], + ['remotes' => [], 'exact' => ['remotes' => [['label' => 'test (remote)', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'test@remote', 'server' => 'remote'], 'uuid' => 'test', 'name' => 'test']]]], false, true, ], @@ -160,7 +160,7 @@ class RemotePluginTest extends TestCase { 'test@remote', [], false, - ['remotes' => [], 'exact' => ['remotes' => [['label' => 'test@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'test@remote']]]]], + ['remotes' => [], 'exact' => ['remotes' => [['label' => 'test (remote)', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'test@remote', 'server' => 'remote'], 'uuid' => 'test', 'name' => 'test']]]], false, true, ], @@ -238,7 +238,7 @@ class RemotePluginTest extends TestCase { ], ], true, - ['remotes' => [['name' => 'User @ Localhost', 'label' => 'User @ Localhost (username@localhost)', 'uuid' => 'uid', 'type' => '', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'username@localhost', 'server' => 'localhost']]], 'exact' => ['remotes' => [['label' => 'test@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'test@remote']]]]], + ['remotes' => [['name' => 'User @ Localhost', 'label' => 'User @ Localhost (username@localhost)', 'uuid' => 'uid', 'type' => '', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'username@localhost', 'server' => 'localhost']]], 'exact' => ['remotes' => [['label' => 'test (remote)', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'test@remote', 'server' => 'remote'], 'uuid' => 'test', 'name' => 'test']]]], false, true, ], @@ -264,7 +264,7 @@ class RemotePluginTest extends TestCase { ], ], false, - ['remotes' => [], 'exact' => ['remotes' => [['label' => 'test@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'test@remote']]]]], + ['remotes' => [], 'exact' => ['remotes' => [['label' => 'test (remote)', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'test@remote', 'server' => 'remote'], 'uuid' => 'test', 'name' => 'test']]]], false, true, ], @@ -370,7 +370,7 @@ class RemotePluginTest extends TestCase { ], ], false, - ['remotes' => [], 'exact' => ['remotes' => [['label' => 'user space@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'user space@remote']]]]], + ['remotes' => [], 'exact' => ['remotes' => [['label' => 'user space (remote)', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'user space@remote', 'server' => 'remote'], 'uuid' => 'user space', 'name' => 'user space']]]], false, true, ], diff --git a/tests/lib/Share20/DefaultShareProviderTest.php b/tests/lib/Share20/DefaultShareProviderTest.php index f5f710cbbd3..8f725022eda 100644 --- a/tests/lib/Share20/DefaultShareProviderTest.php +++ b/tests/lib/Share20/DefaultShareProviderTest.php @@ -2742,4 +2742,169 @@ class DefaultShareProviderTest extends \Test\TestCase { $u5->delete(); $g1->delete(); } + + public function testGetAllShares() { + $qb = $this->dbConn->getQueryBuilder(); + + $qb->insert('share') + ->values([ + 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER), + 'share_with' => $qb->expr()->literal('sharedWith1'), + 'uid_owner' => $qb->expr()->literal('shareOwner1'), + 'uid_initiator' => $qb->expr()->literal('sharedBy1'), + 'item_type' => $qb->expr()->literal('file'), + 'file_source' => $qb->expr()->literal(42), + 'file_target' => $qb->expr()->literal('myTarget1'), + 'permissions' => $qb->expr()->literal(13), + ]); + $qb->execute(); + + $id1 = $qb->getLastInsertId(); + + $qb->insert('share') + ->values([ + 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_GROUP), + 'share_with' => $qb->expr()->literal('sharedWith2'), + 'uid_owner' => $qb->expr()->literal('shareOwner2'), + 'uid_initiator' => $qb->expr()->literal('sharedBy2'), + 'item_type' => $qb->expr()->literal('file'), + 'file_source' => $qb->expr()->literal(43), + 'file_target' => $qb->expr()->literal('myTarget2'), + 'permissions' => $qb->expr()->literal(14), + ]); + $qb->execute(); + + $id2 = $qb->getLastInsertId(); + + $qb->insert('share') + ->values([ + 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_LINK), + 'token' => $qb->expr()->literal('token3'), + 'uid_owner' => $qb->expr()->literal('shareOwner3'), + 'uid_initiator' => $qb->expr()->literal('sharedBy3'), + 'item_type' => $qb->expr()->literal('file'), + 'file_source' => $qb->expr()->literal(44), + 'file_target' => $qb->expr()->literal('myTarget3'), + 'permissions' => $qb->expr()->literal(15), + ]); + $qb->execute(); + + $id3 = $qb->getLastInsertId(); + + $qb->insert('share') + ->values([ + 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_EMAIL), + 'share_with' => $qb->expr()->literal('shareOwner4'), + 'token' => $qb->expr()->literal('token4'), + 'uid_owner' => $qb->expr()->literal('shareOwner4'), + 'uid_initiator' => $qb->expr()->literal('sharedBy4'), + 'item_type' => $qb->expr()->literal('file'), + 'file_source' => $qb->expr()->literal(45), + 'file_target' => $qb->expr()->literal('myTarget4'), + 'permissions' => $qb->expr()->literal(16), + ]); + $qb->execute(); + + $id4 = $qb->getLastInsertId(); + + $qb->insert('share') + ->values([ + 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_LINK), + 'token' => $qb->expr()->literal('token5'), + 'uid_owner' => $qb->expr()->literal('shareOwner5'), + 'uid_initiator' => $qb->expr()->literal('sharedBy5'), + 'item_type' => $qb->expr()->literal('file'), + 'file_source' => $qb->expr()->literal(46), + 'file_target' => $qb->expr()->literal('myTarget5'), + 'permissions' => $qb->expr()->literal(17), + ]); + $qb->execute(); + + $id5 = $qb->getLastInsertId(); + + $ownerPath1 = $this->createMock(File::class); + $shareOwner1Folder = $this->createMock(Folder::class); + $shareOwner1Folder->method('getById')->willReturn([$ownerPath1]); + + $ownerPath2 = $this->createMock(File::class); + $shareOwner2Folder = $this->createMock(Folder::class); + $shareOwner2Folder->method('getById')->willReturn([$ownerPath2]); + + $ownerPath3 = $this->createMock(File::class); + $shareOwner3Folder = $this->createMock(Folder::class); + $shareOwner3Folder->method('getById')->willReturn([$ownerPath3]); + + $ownerPath4 = $this->createMock(File::class); + $shareOwner4Folder = $this->createMock(Folder::class); + $shareOwner4Folder->method('getById')->willReturn([$ownerPath4]); + + $ownerPath5 = $this->createMock(File::class); + $shareOwner5Folder = $this->createMock(Folder::class); + $shareOwner5Folder->method('getById')->willReturn([$ownerPath5]); + + $this->rootFolder + ->method('getUserFolder') + ->will($this->returnValueMap( + [ + ['shareOwner1', $shareOwner1Folder], + ['shareOwner2', $shareOwner2Folder], + ['shareOwner3', $shareOwner3Folder], + ['shareOwner4', $shareOwner4Folder], + ['shareOwner5', $shareOwner5Folder], + ] + )); + + $shares = iterator_to_array($this->provider->getAllShares()); + $this->assertEquals(4, count($shares)); + + $share = $shares[0]; + + // We fetch the node so the root folder is eventually called + + $this->assertEquals($id1, $share->getId()); + $this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $share->getShareType()); + $this->assertEquals('sharedWith1', $share->getSharedWith()); + $this->assertEquals('sharedBy1', $share->getSharedBy()); + $this->assertEquals('shareOwner1', $share->getShareOwner()); + $this->assertEquals($ownerPath1, $share->getNode()); + $this->assertEquals(13, $share->getPermissions()); + $this->assertEquals(null, $share->getToken()); + $this->assertEquals('myTarget1', $share->getTarget()); + + $share = $shares[1]; + + $this->assertEquals($id2, $share->getId()); + $this->assertEquals(\OCP\Share::SHARE_TYPE_GROUP, $share->getShareType()); + $this->assertEquals('sharedWith2', $share->getSharedWith()); + $this->assertEquals('sharedBy2', $share->getSharedBy()); + $this->assertEquals('shareOwner2', $share->getShareOwner()); + $this->assertEquals($ownerPath2, $share->getNode()); + $this->assertEquals(14, $share->getPermissions()); + $this->assertEquals(null, $share->getToken()); + $this->assertEquals('myTarget2', $share->getTarget()); + + $share = $shares[2]; + + $this->assertEquals($id3, $share->getId()); + $this->assertEquals(\OCP\Share::SHARE_TYPE_LINK, $share->getShareType()); + $this->assertEquals(null, $share->getSharedWith()); + $this->assertEquals('sharedBy3', $share->getSharedBy()); + $this->assertEquals('shareOwner3', $share->getShareOwner()); + $this->assertEquals($ownerPath3, $share->getNode()); + $this->assertEquals(15, $share->getPermissions()); + $this->assertEquals('token3', $share->getToken()); + $this->assertEquals('myTarget3', $share->getTarget()); + + $share = $shares[3]; + + $this->assertEquals($id5, $share->getId()); + $this->assertEquals(\OCP\Share::SHARE_TYPE_LINK, $share->getShareType()); + $this->assertEquals(null, $share->getSharedWith()); + $this->assertEquals('sharedBy5', $share->getSharedBy()); + $this->assertEquals('shareOwner5', $share->getShareOwner()); + $this->assertEquals($ownerPath5, $share->getNode()); + $this->assertEquals(17, $share->getPermissions()); + $this->assertEquals('token5', $share->getToken()); + $this->assertEquals('myTarget5', $share->getTarget()); + } } diff --git a/tests/lib/Share20/ManagerTest.php b/tests/lib/Share20/ManagerTest.php index 6f46d69d8df..4a7686acd35 100644 --- a/tests/lib/Share20/ManagerTest.php +++ b/tests/lib/Share20/ManagerTest.php @@ -3685,6 +3685,57 @@ class ManagerTest extends \Test\TestCase { $this->assertSame($expected['users'], $result['users']); } + + public function testGetAllShares() { + $factory = new DummyFactory2($this->createMock(IServerContainer::class)); + + $manager = new Manager( + $this->logger, + $this->config, + $this->secureRandom, + $this->hasher, + $this->mountManager, + $this->groupManager, + $this->l, + $this->l10nFactory, + $factory, + $this->userManager, + $this->rootFolder, + $this->eventDispatcher, + $this->mailer, + $this->urlGenerator, + $this->defaults + ); + + $factory->setProvider($this->defaultProvider); + $extraProvider = $this->createMock(IShareProvider::class); + $factory->setSecondProvider($extraProvider); + + $share1 = $this->createMock(IShare::class); + $share2 = $this->createMock(IShare::class); + $share3 = $this->createMock(IShare::class); + $share4 = $this->createMock(IShare::class); + + $this->defaultProvider->method('getAllShares') + ->willReturnCallback(function() use ($share1, $share2) { + yield $share1; + yield $share2; + }); + $extraProvider->method('getAllShares') + ->willReturnCallback(function() use ($share3, $share4) { + yield $share3; + yield $share4; + }); + + // "yield from", used in "getAllShares()", does not reset the keys, so + // "use_keys" has to be disabled to collect all the values while + // ignoring the keys returned by the generator. + $result = iterator_to_array($manager->getAllShares(), $use_keys = false); + + $expects = [$share1, $share2, $share3, $share4]; + + $this->assertSame($expects, $result); + } } class DummyFactory implements IProviderFactory { |