From f60d5ca892e582113a0e2383555f0bd6c7444144 Mon Sep 17 00:00:00 2001 From: Artur Neumann Date: Tue, 19 Dec 2017 12:14:50 +0545 Subject: [PATCH] UI tests to add public link shares to remote server fix tests so that it does not lock up the server --- .../ui/features/bootstrap/SharingContext.php | 15 +++++++ tests/ui/features/lib/PublicLinkFilesPage.php | 40 +++++++++++++++++++ .../shareByPublicLink.feature | 33 +++++++++++++++ 3 files changed, 88 insertions(+) diff --git a/tests/ui/features/bootstrap/SharingContext.php b/tests/ui/features/bootstrap/SharingContext.php index 351315e4f6d8..c8dd13574837 100644 --- a/tests/ui/features/bootstrap/SharingContext.php +++ b/tests/ui/features/bootstrap/SharingContext.php @@ -281,6 +281,21 @@ public function iAccessTheLastCreatedPublicLink() { $this->featureContext->setCurrentPageObject($this->publicLinkFilesPage); } + /** + * @When I add the public link to :server as user :username with the password :password + * @param string $server + * @return void + */ + public function iAddThePublicLinkTo($server, $username, $password) { + if (!$this->publicLinkFilesPage->isOpen()) { + throw new Exception('Not on public link page!'); + } + $server = $this->featureContext->substituteInLineCodes($server); + $this->publicLinkFilesPage->addToServer($server); + $this->featureContext->loginAs($username, $password); + $this->featureContext->setCurrentServer($server); + } + /** * @Then all users and groups that contain the string :requiredString in their name should be listed in the autocomplete list * @param string $requiredString diff --git a/tests/ui/features/lib/PublicLinkFilesPage.php b/tests/ui/features/lib/PublicLinkFilesPage.php index 5ba30700afbf..8b9d69f6a4a4 100644 --- a/tests/ui/features/lib/PublicLinkFilesPage.php +++ b/tests/ui/features/lib/PublicLinkFilesPage.php @@ -34,6 +34,9 @@ class PublicLinkFilesPage extends FilesPageBasic { protected $fileNameMatchXpath = "//span[@class='nametext' and .=%s]"; protected $fileListXpath = ".//tbody[@id='fileList']"; protected $emptyContentXpath = ".//div[@id='emptycontent']"; + protected $addToYourOcBtnId = "save-button"; + protected $remoteAddressInputId = "remote_address"; + protected $confirmBtnId = "save-button-confirm"; /** * @return string @@ -63,6 +66,43 @@ protected function getEmptyContentXpath() { return $this->emptyContentXpath; } + /** + * adding public share to particular server + * + * @param string $server + * @throws ElementNotFoundException + * @return void + */ + public function addToServer($server) { + $addToYourOcBtn = $this->findById($this->addToYourOcBtnId); + if (is_null($addToYourOcBtn)) { + throw new ElementNotFoundException( + __METHOD__ . + " id " . $this->addToYourOcBtnId . + " could not find 'add to your owncloud' button" + ); + } + $addToYourOcBtn->click(); + $remoteAddressInput = $this->findById($this->remoteAddressInputId); + if (is_null($remoteAddressInput)) { + throw new ElementNotFoundException( + __METHOD__ . + " id " . $this->remoteAddressInput . + " could not find remote address input field" + ); + } + $remoteAddressInput->setValue($server); + $confirmBtn = $this->findById($this->confirmBtnId); + if (is_null($confirmBtn)) { + throw new ElementNotFoundException( + __METHOD__ . + " id " . $this->confirmBtn . + " could not find confirm button" + ); + } + $confirmBtn->click(); + } + /** * create a folder with the given name. * If name is not given a random one is chosen diff --git a/tests/ui/features/sharingExternalOther/shareByPublicLink.feature b/tests/ui/features/sharingExternalOther/shareByPublicLink.feature index a09510abb859..56d4b7970f76 100644 --- a/tests/ui/features/sharingExternalOther/shareByPublicLink.feature +++ b/tests/ui/features/sharingExternalOther/shareByPublicLink.feature @@ -40,3 +40,36 @@ So that public sharing is limited according to organization policy | permission | Read | And I access the last created public link Then it should not be possible to delete the file "lorem.txt" + + Scenario: mount public link + Given these users exist: + |username|password|displayname|email | + |user2 |1234 |User One |u1@oc.com.np| + When I create a new public link for the folder "simple-folder" + And I logout + And I access the last created public link + And I add the public link to "http://%remote_server%" as user "user2" with the password "1234" + And the offered remote shares are accepted + Then the folder "simple-folder (2)" should be listed + When I open the folder "simple-folder (2)" + Then the file "lorem.txt" should be listed + And the content of "lorem.txt" should be the same as the original "simple-folder/lorem.txt" + And it should not be possible to delete the file "lorem.txt" + + Scenario: mount public link and overwrite file + Given these users exist: + |username|password|displayname|email | + |user2 |1234 |User One |u1@oc.com.np| + When I create a new public link for the folder "simple-folder" with + | permission | Read & Write | + And I logout + And I access the last created public link + And I add the public link to "http://%remote_server%" as user "user2" with the password "1234" + And the offered remote shares are accepted + Then the folder "simple-folder (2)" should be listed + When I open the folder "simple-folder (2)" + Then the file "lorem.txt" should be listed + And the content of "lorem.txt" should be the same as the original "simple-folder/lorem.txt" + When I upload overwriting the file "lorem.txt" + Then the file "lorem.txt" should be listed + And the content of "lorem.txt" should be the same as the local "lorem.txt" \ No newline at end of file