Skip to content

Commit

Permalink
UI tests to add public link shares to remote server
Browse files Browse the repository at this point in the history
fix tests  so that it does not lock up the server
  • Loading branch information
individual-it committed Dec 19, 2017
1 parent b4aaa40 commit f60d5ca
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/ui/features/bootstrap/SharingContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
40 changes: 40 additions & 0 deletions tests/ui/features/lib/PublicLinkFilesPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
33 changes: 33 additions & 0 deletions tests/ui/features/sharingExternalOther/shareByPublicLink.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit f60d5ca

Please sign in to comment.