Skip to content

Commit

Permalink
Merge pull request #31523 from owncloud/acceptance-test-use-01
Browse files Browse the repository at this point in the history
Acceptance test refactoring and bug fixes
  • Loading branch information
phil-davis authored May 25, 2018
2 parents 784904e + 0720641 commit 6e3b0e4
Show file tree
Hide file tree
Showing 32 changed files with 331 additions and 224 deletions.
12 changes: 6 additions & 6 deletions tests/acceptance/features/apiMain/carddav.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,28 @@ Feature: carddav

@carddav
Scenario: Accessing a not existing addressbook of another user
When user "admin" requests addressbook "user0/MyAddressbook" using the API
When user "admin" requests address book "user0/MyAddressbook" using the API
Then the CardDAV HTTP status code should be "404"
And the CardDAV exception should be "Sabre\DAV\Exception\NotFound"
And the CardDAV error message should be "Addressbook with name 'MyAddressbook' could not be found"

@carddav
Scenario: Accessing a not shared addressbook of another user
And user "admin" has successfully created an addressbook named "MyAddressbook"
When user "user0" requests addressbook "admin/MyAddressbook" using the API
And user "admin" has successfully created an address book named "MyAddressbook"
When user "user0" requests address book "admin/MyAddressbook" using the API
Then the CardDAV HTTP status code should be "404"
And the CardDAV exception should be "Sabre\DAV\Exception\NotFound"
And the CardDAV error message should be "Addressbook with name 'MyAddressbook' could not be found"

@carddav
Scenario: Accessing a not existing addressbook of myself
When user "user0" requests addressbook "admin/MyAddressbook" using the API
When user "user0" requests address book "admin/MyAddressbook" using the API
Then the CardDAV HTTP status code should be "404"
And the CardDAV exception should be "Sabre\DAV\Exception\NotFound"
And the CardDAV error message should be "Addressbook with name 'MyAddressbook' could not be found"

@carddav
Scenario: Creating a new addressbook
Given user "user0" has successfully created an addressbook named "MyAddressbook"
When user "user0" requests addressbook "user0/MyAddressbook" using the API
Given user "user0" has successfully created an address book named "MyAddressbook"
When user "user0" requests address book "user0/MyAddressbook" using the API
Then the CardDAV HTTP status code should be "200"
32 changes: 16 additions & 16 deletions tests/acceptance/features/apiMain/tags.feature
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,10 @@ Feature: tags
When user "user0" adds the tag "MyFirstTag" to "/myFileToTag.txt" owned by "user0" using the API
And user "another_admin" adds the tag "MySecondTag" to "/myFileToTag.txt" shared by "user0" using the API
Then the HTTP status code should be "201"
And file "/myFileToTag.txt" shared by "user0" should have the following tags for "another_admin"
And file "/myFileToTag.txt" should have the following tags for user "another_admin"
| MyFirstTag | normal |
| MySecondTag | not user-visible |
And file "/myFileToTag.txt" shared by "user0" should have the following tags for "user0"
And file "/myFileToTag.txt" should have the following tags for user "user0"
| MyFirstTag | normal |

Scenario: Assigning a not user-assignable tag to a file shared by someone else as admin user should work
Expand All @@ -202,10 +202,10 @@ Feature: tags
When user "user0" adds the tag "MyFirstTag" to "/myFileToTag.txt" shared by "user0" using the API
And user "another_admin" adds the tag "MySecondTag" to "/myFileToTag.txt" shared by "user0" using the API
Then the HTTP status code should be "201"
And file "/myFileToTag.txt" shared by "user0" should have the following tags for "another_admin"
And file "/myFileToTag.txt" should have the following tags for user "another_admin"
| MyFirstTag | normal |
| MySecondTag | not user-assignable |
And file "/myFileToTag.txt" shared by "user0" should have the following tags for "user0"
And file "/myFileToTag.txt" should have the following tags for user "user0"
| MyFirstTag | normal |
| MySecondTag | not user-assignable |

Expand All @@ -220,7 +220,7 @@ Feature: tags
And user "user0" has added the tag "MySecondTag" to "/myFileToTag.txt" owned by "user0"
When user "user1" removes the tag "MyFirstTag" from "/myFileToTag.txt" shared by "user0" using the API
Then the HTTP status code should be "204"
And file "/myFileToTag.txt" shared by "user0" should have the following tags for "user0"
And file "/myFileToTag.txt" should have the following tags for user "user0"
| MySecondTag | normal |

Scenario: Unassigning a normal tag from a file unshared by someone else as regular user should fail
Expand All @@ -233,7 +233,7 @@ Feature: tags
And user "user0" has added the tag "MySecondTag" to "/myFileToTag.txt" shared by "user0"
When user "user1" removes the tag "MyFirstTag" from "/myFileToTag.txt" shared by "user0" using the API
Then the HTTP status code should be "404"
And file "/myFileToTag.txt" shared by "user0" should have the following tags for "user0"
And file "/myFileToTag.txt" should have the following tags for user "user0"
| MyFirstTag | normal |
| MySecondTag | normal |

Expand All @@ -251,9 +251,9 @@ Feature: tags
And user "user0" has added the tag "MySecondTag" to "/myFileToTag.txt" shared by "user0"
When user "user1" removes the tag "MyFirstTag" from "/myFileToTag.txt" shared by "user0" using the API
Then the HTTP status code should be "404"
And file "/myFileToTag.txt" shared by "user0" should have the following tags for "user0"
And file "/myFileToTag.txt" should have the following tags for user "user0"
| MySecondTag | normal |
And file "/myFileToTag.txt" shared by "user0" should have the following tags for "another_admin"
And file "/myFileToTag.txt" should have the following tags for user "another_admin"
| MyFirstTag | not user-visible |
| MySecondTag | normal |

Expand All @@ -271,9 +271,9 @@ Feature: tags
And user "user0" has added the tag "MySecondTag" to "/myFileToTag.txt" shared by "user0"
When user "another_admin" removes the tag "MyFirstTag" from "/myFileToTag.txt" shared by "user0" using the API
Then the HTTP status code should be "204"
And file "/myFileToTag.txt" shared by "user0" should have the following tags for "user0"
And file "/myFileToTag.txt" should have the following tags for user "user0"
| MySecondTag | normal |
And file "/myFileToTag.txt" shared by "user0" should have the following tags for "another_admin"
And file "/myFileToTag.txt" should have the following tags for user "another_admin"
| MySecondTag | normal |

Scenario: Unassigning a not user-visible tag from a file unshared by someone else should fail
Expand Down Expand Up @@ -306,10 +306,10 @@ Feature: tags
And user "user0" has added the tag "MySecondTag" to "/myFileToTag.txt" shared by "user0"
When user "user1" removes the tag "MyFirstTag" from "/myFileToTag.txt" shared by "user0" using the API
Then the HTTP status code should be "403"
And file "/myFileToTag.txt" shared by "user0" should have the following tags for "user0"
And file "/myFileToTag.txt" should have the following tags for user "user0"
| MyFirstTag | not user-assignable |
| MySecondTag | normal |
And file "/myFileToTag.txt" shared by "user0" should have the following tags for "another_admin"
And file "/myFileToTag.txt" should have the following tags for user "another_admin"
| MyFirstTag | not user-assignable |
| MySecondTag | normal |

Expand All @@ -327,9 +327,9 @@ Feature: tags
And user "user0" has added the tag "MySecondTag" to "/myFileToTag.txt" shared by "user0"
When user "another_admin" removes the tag "MyFirstTag" from "/myFileToTag.txt" shared by "user0" using the API
Then the HTTP status code should be "204"
And file "/myFileToTag.txt" shared by "user0" should have the following tags for "user0"
And file "/myFileToTag.txt" should have the following tags for user "user0"
| MySecondTag | normal |
And file "/myFileToTag.txt" shared by "user0" should have the following tags for "another_admin"
And file "/myFileToTag.txt" should have the following tags for user "another_admin"
| MySecondTag | normal |

Scenario: Unassigning a not user-assignable tag from a file unshared by someone else should fail
Expand Down Expand Up @@ -370,9 +370,9 @@ Feature: tags
And user "admin" has created a "normal" tag with name "MyFirstTag"
And user "user0" has uploaded file "data/textfile.txt" to "/myFileToTag.txt"
When user "user0" adds the tag "MyFirstTag" to "/myFileToTag.txt" shared by "user0" using the API
Then file "/myFileToTag.txt" shared by "user0" should have the following tags for "user0"
Then file "/myFileToTag.txt" should have the following tags for user "user0"
| MyFirstTag | normal |
And file "/myFileToTag.txt" shared by "user0" should have the following tags for "user1"
And file "/myFileToTag.txt" should have the following tags for user "user1"
||

Scenario: User can assign tags when in the tag's groups
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,12 @@ So that I can manage group membership
When user "anotheruser" sends HTTP method "GET" to API endpoint "/cloud/users/newuser/groups"
Then the OCS status code should be "997"
And the HTTP status code should be "401"
And the API should not return any data
And the API should not return any data

Scenario: admin gets groups of an user who is not in any groups
Given user "brand-new-user" has been created
And group "unused-group" has been created
When user "admin" sends HTTP method "GET" to API endpoint "/cloud/users/brand-new-user/groups"
Then the OCS status code should be "100"
And the HTTP status code should be "200"
And the list of groups returned by the API should be empty
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Feature: trashbin-new-endpoint
And user "user0" has deleted file "/textfile0.txt"
And user "user0" has deleted file "/textfile1.txt"
And as "user0" the file "/textfile0.txt" should exist in trash
And as "user0" the file "/textfile0.txt" should exist in trash
And as "user0" the file "/textfile1.txt" should exist in trash
When user "user0" empties the trashbin using the API
Then as "user0" the file with original path "/textfile0.txt" should not exist in trash
And as "user0" the file with original path "/textfile1.txt" should not exist in trash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Feature: trashbin-new-endpoint
And user "user0" has deleted file "/textfile0.txt"
And user "user0" has deleted file "/textfile1.txt"
And as "user0" the file "/textfile0.txt" should exist in trash
And as "user0" the file "/textfile0.txt" should exist in trash
And as "user0" the file "/textfile1.txt" should exist in trash
When user "user0" empties the trashbin using the API
Then as "user0" the file with original path "/textfile0.txt" should not exist in trash
And as "user0" the file with original path "/textfile1.txt" should not exist in trash
Expand Down
9 changes: 4 additions & 5 deletions tests/acceptance/features/bootstrap/AppConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*
*/

use Behat\Behat\Hook\Scope\BeforeScenarioScope;
use Behat\Gherkin\Node\TableNode;
use TestHelpers\AppConfigHelper;

require __DIR__ . '/../../../../lib/composer/autoload.php';
Expand Down Expand Up @@ -58,7 +58,7 @@ abstract public function sendingTo($verb, $url);
/**
* @param string $verb
* @param string $url
* @param \Behat\Gherkin\Node\TableNode $body
* @param TableNode $body
*
* @return void
*/
Expand Down Expand Up @@ -247,7 +247,7 @@ protected function modifyServerConfig($app, $parameter, $value) {
}

/**
* @param string $appParameterValues
* @param array $appParameterValues
*
* @return void
*/
Expand Down Expand Up @@ -300,10 +300,9 @@ abstract protected function resetAppConfigs();
/**
* @BeforeScenario
*
* @param BeforeScenarioScope $scope
* @return void
*/
public function prepareParametersBeforeScenario(BeforeScenarioScope $scope) {
public function prepareParametersBeforeScenario() {
$user = $this->currentUser;
$this->currentUser = $this->getAdminUsername();
$this->resetAppConfigs();
Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/features/bootstrap/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public function aNewBrowserSessionForHasBeenStarted($user) {
* @param string $hasOrNot
*
* @return void
* @throws Exception
* @throws \Exception
*/
public function tokenAuthHasBeenEnforced($hasOrNot) {
$enforce = (($hasOrNot !== "not") && ($hasOrNot !== "does not enforce"));
Expand Down
7 changes: 4 additions & 3 deletions tests/acceptance/features/bootstrap/BasicStructure.php
Original file line number Diff line number Diff line change
Expand Up @@ -929,12 +929,12 @@ public function statusPhpRespondedShouldMatch(PyStringNode $jsonExpected) {
$jsonExpectedDecoded['version'] = \trim($version[1]);
$jsonExpectedDecoded['versionstring'] = \trim($versionString[1]);
$jsonExpectedEncoded = \json_encode($jsonExpectedDecoded);
PHPUnit\Framework\Assert::assertEquals(
$jsonExpectedEncoded, $jsonRespondedEncoded
);
} else {
PHPUnit_Framework_Assert::fail('Cannot get version variables from occ');
}
PHPUnit\Framework\Assert::assertEquals(
$jsonExpectedEncoded, $jsonRespondedEncoded
);
}

/**
Expand Down Expand Up @@ -1052,6 +1052,7 @@ public static function removeFilesFromLocalStorageAfter() {
* @param BeforeSuiteScope $scope
*
* @return void
* @throws \Exception
*/
public static function useBigFileIDs(BeforeSuiteScope $scope) {
$fullUrl = \getenv('TEST_SERVER_URL');
Expand Down
1 change: 1 addition & 0 deletions tests/acceptance/features/bootstrap/CalDavContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ public function theCalDavErrorMessageShouldBe($message) {
* @param string $name
*
* @return void
* @throws \Exception
*/
public function userHasCreatedACalendarNamed($user, $name) {
$davUrl = $this->featureContext->getBaseUrl()
Expand Down
8 changes: 4 additions & 4 deletions tests/acceptance/features/bootstrap/CardDavContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,15 @@ public function afterScenario() {
}

/**
* @When user :user requests addressbook :addressBook using the API
* @When user :user requests address book :addressBook using the API
*
* @param string $user
* @param string $addressBook
*
* @return void
* @throws \Exception
*/
public function userRequestsAddressbookUsingTheAPI($user, $addressBook) {
public function userRequestsAddressBookUsingTheAPI($user, $addressBook) {
$davUrl = $this->featureContext->getBaseUrl()
. '/remote.php/dav/addressbooks/users/' . $addressBook;

Expand All @@ -109,15 +109,15 @@ public function userRequestsAddressbookUsingTheAPI($user, $addressBook) {
}

/**
* @Given user :user has successfully created an addressbook named :addressBook
* @Given user :user has successfully created an address book named :addressBook
*
* @param string $user
* @param string $addressBook
*
* @return void
* @throws \Exception
*/
public function userHasCreatedAnAddressbookNamed($user, $addressBook) {
public function userHasCreatedAnAddressBookNamed($user, $addressBook) {
$davUrl = $this->featureContext->getBaseUrl()
. '/remote.php/dav/addressbooks/users/' . $user . '/' . $addressBook;

Expand Down
3 changes: 3 additions & 0 deletions tests/acceptance/features/bootstrap/Checksums.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ public function theHeaderChecksumShouldMatch($checksum) {
* @Then the webdav checksum should be empty
*
* @return void
* @throws \Sabre\Xml\ParseException
* @throws \Exception
*/
public function theWebdavChecksumShouldBeEmpty() {
$service = new Sabre\Xml\Service();
Expand All @@ -163,6 +165,7 @@ public function theWebdavChecksumShouldBeEmpty() {
* @Then the OC-Checksum header should not be there
*
* @return void
* @throws \Exception
*/
public function theOcChecksumHeaderShouldNotBeThere() {
if ($this->response->hasHeader('OC-Checksum')) {
Expand Down
10 changes: 6 additions & 4 deletions tests/acceptance/features/bootstrap/CommandLine.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ public function findLines($input, $text) {
* @Then /^the command should have been successful$/
*
* @return void
* @throws \Exception
*/
public function theCommandShouldHaveBeenSuccessful() {
$exceptions = $this->findExceptions();
Expand All @@ -153,7 +154,7 @@ public function theCommandShouldHaveBeenSuccessful() {
* @param int $exitCode
*
* @return void
* @throws Exception
* @throws \Exception
*/
public function theCommandFailedWithExitCode($exitCode) {
if ($this->lastCode !== (int)$exitCode) {
Expand All @@ -170,7 +171,7 @@ public function theCommandFailedWithExitCode($exitCode) {
* @param string $exceptionText
*
* @return void
* @throws Exception
* @throws \Exception
*/
public function theCommandFailedWithExceptionText($exceptionText) {
$exceptions = $this->findExceptions();
Expand All @@ -192,7 +193,7 @@ public function theCommandFailedWithExceptionText($exceptionText) {
* @param string $text
*
* @return void
* @throws Exception
* @throws \Exception
*/
public function theCommandOutputContainsTheText($text) {
$lines = $this->findLines($this->lastStdOut, $text);
Expand All @@ -210,7 +211,7 @@ public function theCommandOutputContainsTheText($text) {
* @param string $text
*
* @return void
* @throws Exception
* @throws \Exception
*/
public function theCommandErrorOutputContainsTheText($text) {
$lines = $this->findLines($this->lastStdErr, $text);
Expand Down Expand Up @@ -289,6 +290,7 @@ public function transferringOwnership($user1, $user2) {
* @Given /^the administrator has successfully recreated the encryption masterkey$/
*
* @return void
* @throws \Exception
*/
public function recreateMasterKeyUsingOccCommand() {
$this->runOcc(['encryption:recreate-master-key', '-y']);
Expand Down
Loading

0 comments on commit 6e3b0e4

Please sign in to comment.