diff --git a/tests/acceptance/features/apiCapabilities/capabilities.feature b/tests/acceptance/features/apiCapabilities/capabilities.feature index 5b85b17ff723..a9ff81abd7d9 100644 --- a/tests/acceptance/features/apiCapabilities/capabilities.feature +++ b/tests/acceptance/features/apiCapabilities/capabilities.feature @@ -3,7 +3,6 @@ Feature: capabilities Background: Given using OCS API version "1" - And as user "%admin%" @smokeTest Scenario: Check that the sharing API can be enabled @@ -34,11 +33,15 @@ Feature: capabilities @smokeTest Scenario: getting capabilities with admin user - When the user retrieves the capabilities using the capabilities API + When the administrator retrieves the capabilities using the capabilities API Then the capabilities should contain | capability | path_to_element | value | | core | pollinterval | 60 | | core | webdav-root | remote.php/webdav | + | core | status@@@edition | %edition% | + | core | status@@@productname | %productname% | + | core | status@@@version | %version% | + | core | status@@@versionstring | %versionstring% | | files_sharing | api_enabled | 1 | | files_sharing | can_share | 1 | | files_sharing | public@@@enabled | 1 | @@ -58,7 +61,7 @@ Feature: capabilities Scenario: Changing public upload Given parameter "shareapi_allow_public_upload" of app "core" has been set to "no" - When the user retrieves the capabilities using the capabilities API + When the administrator retrieves the capabilities using the capabilities API Then the capabilities should contain | capability | path_to_element | value | | core | pollinterval | 60 | @@ -82,7 +85,7 @@ Feature: capabilities Scenario: Disabling share api Given parameter "shareapi_enabled" of app "core" has been set to "no" - When the user retrieves the capabilities using the capabilities API + When the administrator retrieves the capabilities using the capabilities API Then the capabilities should contain | capability | path_to_element | value | | core | pollinterval | 60 | @@ -100,7 +103,7 @@ Feature: capabilities Scenario: Disabling public links Given parameter "shareapi_allow_links" of app "core" has been set to "no" - When the user retrieves the capabilities using the capabilities API + When the administrator retrieves the capabilities using the capabilities API Then the capabilities should contain | capability | path_to_element | value | | core | pollinterval | 60 | @@ -122,7 +125,7 @@ Feature: capabilities Scenario: Changing resharing Given parameter "shareapi_allow_resharing" of app "core" has been set to "no" - When the user retrieves the capabilities using the capabilities API + When the administrator retrieves the capabilities using the capabilities API Then the capabilities should contain | capability | path_to_element | value | | core | pollinterval | 60 | @@ -146,7 +149,7 @@ Feature: capabilities Scenario: Changing federation outgoing Given parameter "outgoing_server2server_share_enabled" of app "files_sharing" has been set to "no" - When the user retrieves the capabilities using the capabilities API + When the administrator retrieves the capabilities using the capabilities API Then the capabilities should contain | capability | path_to_element | value | | core | pollinterval | 60 | @@ -170,7 +173,7 @@ Feature: capabilities Scenario: Changing federation incoming Given parameter "incoming_server2server_share_enabled" of app "files_sharing" has been set to "no" - When the user retrieves the capabilities using the capabilities API + When the administrator retrieves the capabilities using the capabilities API Then the capabilities should contain | capability | path_to_element | value | | core | pollinterval | 60 | @@ -194,7 +197,7 @@ Feature: capabilities Scenario: Changing "password enforced for read-only public link shares" Given parameter "shareapi_enforce_links_password_read_only" of app "core" has been set to "yes" - When the user retrieves the capabilities using the capabilities API + When the administrator retrieves the capabilities using the capabilities API Then the capabilities should contain | capability | path_to_element | value | | core | pollinterval | 60 | @@ -221,7 +224,7 @@ Feature: capabilities Scenario: Changing "password enforced for read-write public link shares" Given parameter "shareapi_enforce_links_password_read_write" of app "core" has been set to "yes" - When the user retrieves the capabilities using the capabilities API + When the administrator retrieves the capabilities using the capabilities API Then the capabilities should contain | capability | path_to_element | value | | core | pollinterval | 60 | @@ -248,7 +251,7 @@ Feature: capabilities Scenario: Changing "password enforced for write-only public link shares" Given parameter "shareapi_enforce_links_password_write_only" of app "core" has been set to "yes" - When the user retrieves the capabilities using the capabilities API + When the administrator retrieves the capabilities using the capabilities API Then the capabilities should contain | capability | path_to_element | value | | core | pollinterval | 60 | @@ -275,7 +278,7 @@ Feature: capabilities Scenario: Changing public notifications Given parameter "shareapi_allow_public_notification" of app "core" has been set to "yes" - When the user retrieves the capabilities using the capabilities API + When the administrator retrieves the capabilities using the capabilities API Then the capabilities should contain | capability | path_to_element | value | | core | pollinterval | 60 | @@ -299,7 +302,7 @@ Feature: capabilities Scenario: Changing public social share Given parameter "shareapi_allow_social_share" of app "core" has been set to "no" - When the user retrieves the capabilities using the capabilities API + When the administrator retrieves the capabilities using the capabilities API Then the capabilities should contain | capability | path_to_element | value | | core | pollinterval | 60 | @@ -323,7 +326,7 @@ Feature: capabilities Scenario: Changing expire date Given parameter "shareapi_default_expire_date" of app "core" has been set to "yes" - When the user retrieves the capabilities using the capabilities API + When the administrator retrieves the capabilities using the capabilities API Then the capabilities should contain | capability | path_to_element | value | | core | pollinterval | 60 | @@ -349,7 +352,7 @@ Feature: capabilities Scenario: Changing expire date enforcing Given parameter "shareapi_default_expire_date" of app "core" has been set to "yes" And parameter "shareapi_enforce_expire_date" of app "core" has been set to "yes" - When the user retrieves the capabilities using the capabilities API + When the administrator retrieves the capabilities using the capabilities API Then the capabilities should contain | capability | path_to_element | value | | core | pollinterval | 60 | @@ -375,7 +378,7 @@ Feature: capabilities Scenario: Changing group sharing allowed Given parameter "shareapi_allow_group_sharing" of app "core" has been set to "no" - When the user retrieves the capabilities using the capabilities API + When the administrator retrieves the capabilities using the capabilities API Then the capabilities should contain | capability | path_to_element | value | | core | pollinterval | 60 | @@ -399,7 +402,7 @@ Feature: capabilities Scenario: Changing only share with group member Given parameter "shareapi_only_share_with_group_members" of app "core" has been set to "yes" - When the user retrieves the capabilities using the capabilities API + When the administrator retrieves the capabilities using the capabilities API Then the capabilities should contain | capability | path_to_element | value | | core | pollinterval | 60 | @@ -423,7 +426,7 @@ Feature: capabilities Scenario: Changing allow share dialog user enumeration Given parameter "shareapi_allow_share_dialog_user_enumeration" of app "core" has been set to "no" - When the user retrieves the capabilities using the capabilities API + When the administrator retrieves the capabilities using the capabilities API Then the capabilities should contain | capability | path_to_element | value | | core | pollinterval | 60 | @@ -446,7 +449,7 @@ Feature: capabilities Scenario: Changing allow share dialog user enumeration for group members only Given parameter "shareapi_share_dialog_user_enumeration_group_members" of app "core" has been set to "yes" - When the user retrieves the capabilities using the capabilities API + When the administrator retrieves the capabilities using the capabilities API Then the capabilities should contain | capability | path_to_element | value | | core | pollinterval | 60 | @@ -474,7 +477,7 @@ Feature: capabilities And group "hash#group" has been created And group "group-3" has been created And parameter "shareapi_exclude_groups_list" of app "core" has been set to '["grp1","hash#group","group-3"]' - When the user retrieves the capabilities using the capabilities API + When the administrator retrieves the capabilities using the capabilities API Then the capabilities should contain | capability | path_to_element | value | | core | pollinterval | 60 | @@ -505,8 +508,7 @@ Feature: capabilities And group "ordinary-group" has been created And user "user0" has been added to group "hash#group" And parameter "shareapi_exclude_groups_list" of app "core" has been set to '["grp1","hash#group","group-3"]' - And as user "user0" - When the user retrieves the capabilities using the capabilities API + When user "user0" retrieves the capabilities using the capabilities API Then the capabilities should contain | capability | path_to_element | value | | core | pollinterval | 60 | @@ -537,8 +539,7 @@ Feature: capabilities And group "ordinary-group" has been created And user "user0" has been added to group "ordinary-group" And parameter "shareapi_exclude_groups_list" of app "core" has been set to '["grp1","hash#group","group-3"]' - And as user "user0" - When the user retrieves the capabilities using the capabilities API + When user "user0" retrieves the capabilities using the capabilities API Then the capabilities should contain | capability | path_to_element | value | | core | pollinterval | 60 | @@ -570,8 +571,7 @@ Feature: capabilities And user "user0" has been added to group "hash#group" And user "user0" has been added to group "ordinary-group" And parameter "shareapi_exclude_groups_list" of app "core" has been set to '["grp1","hash#group","group-3"]' - And as user "user0" - When the user retrieves the capabilities using the capabilities API + When user "user0" retrieves the capabilities using the capabilities API Then the capabilities should contain | capability | path_to_element | value | | core | pollinterval | 60 | diff --git a/tests/acceptance/features/apiMain/status.feature b/tests/acceptance/features/apiMain/status.feature index 5ea02388b3a6..e24e3ad02783 100644 --- a/tests/acceptance/features/apiMain/status.feature +++ b/tests/acceptance/features/apiMain/status.feature @@ -1,9 +1,10 @@ @api Feature: Status + @smokeTest Scenario: Status.php is correct When the administrator requests status.php Then the status.php response should match with """ - {"installed":true,"maintenance":false,"needsDbUpgrade":false,"version":"$CURRENT_VERSION","versionstring":"$CURRENT_VERSION_STRING","edition":"Community","productname":"ownCloud"} + {"installed":true,"maintenance":false,"needsDbUpgrade":false,"version":"$CURRENT_VERSION","versionstring":"$CURRENT_VERSION_STRING","edition":"$EDITION","productname":"$PRODUCTNAME"} """ diff --git a/tests/acceptance/features/apiWebdavOperations/refuseAccess.feature b/tests/acceptance/features/apiWebdavOperations/refuseAccess.feature index 4c80406546d7..d6620934981b 100644 --- a/tests/acceptance/features/apiWebdavOperations/refuseAccess.feature +++ b/tests/acceptance/features/apiWebdavOperations/refuseAccess.feature @@ -14,7 +14,7 @@ Feature: refuse access Then the HTTP status code should be "401" And there should be no duplicate headers And the following headers should be set - | WWW-Authenticate | Basic realm="ownCloud", charset="UTF-8" | + | WWW-Authenticate | Basic realm="%productname%", charset="UTF-8" | Examples: | dav_version | | old | diff --git a/tests/acceptance/features/bootstrap/AppConfiguration.php b/tests/acceptance/features/bootstrap/AppConfiguration.php index 031e056505d2..bd5289e58b7f 100644 --- a/tests/acceptance/features/bootstrap/AppConfiguration.php +++ b/tests/acceptance/features/bootstrap/AppConfiguration.php @@ -127,7 +127,7 @@ public function serverParameterHasBeenSetTo($parameter, $app, $value) { public function theCapabilitiesSettingOfAppParameterShouldBe( $capabilitiesApp, $capabilitiesPath, $expectedValue ) { - $this->getCapabilitiesCheckResponse(); + $this->theAdministratorGetsCapabilitiesCheckResponse(); PHPUnit_Framework_Assert::assertEquals( $expectedValue, @@ -152,17 +152,37 @@ public function getAppParameter($capabilitiesApp, $capabilitiesPath) { } /** - * @When the user retrieves the capabilities using the capabilities API + * @When user :username retrieves the capabilities using the capabilities API + * + * @param string $username * * @return void */ - public function getCapabilitiesCheckResponse() { - $this->theUserSendsToOcsApiEndpoint('GET', '/cloud/capabilities'); + public function userGetsCapabilitiesCheckResponse($username) { + $this->userSendsToOcsApiEndpoint($username, 'GET', '/cloud/capabilities'); PHPUnit_Framework_Assert::assertEquals( 200, $this->response->getStatusCode() ); } + /** + * @When the user retrieves the capabilities using the capabilities API + * + * @return void + */ + public function getCapabilitiesCheckResponse() { + $this->userGetsCapabilitiesCheckResponse($this->getCurrentUser()); + } + + /** + * @When the administrator retrieves the capabilities using the capabilities API + * + * @return void + */ + public function theAdministratorGetsCapabilitiesCheckResponse() { + $this->userGetsCapabilitiesCheckResponse($this->getAdminUsername()); + } + /** * @return string latest retrieved capabilities in XML format */ diff --git a/tests/acceptance/features/bootstrap/BasicStructure.php b/tests/acceptance/features/bootstrap/BasicStructure.php index b9540fd08a26..d59d6ec2b57b 100644 --- a/tests/acceptance/features/bootstrap/BasicStructure.php +++ b/tests/acceptance/features/bootstrap/BasicStructure.php @@ -1606,8 +1606,36 @@ public function jsonRespondedShouldMatch(PyStringNode $jsonExpected) { */ public function statusPhpRespondedShouldMatch(PyStringNode $jsonExpected) { $jsonExpectedDecoded = \json_decode($jsonExpected->getRaw(), true); - $jsonRespondedEncoded - = \json_encode(\json_decode($this->response->getBody(), true)); + $jsonRespondedEncoded = \json_encode($this->getJsonDecodedResponse()); + + $this->theAdministratorGetsCapabilitiesCheckResponse(); + $edition = $this->getParameterValueFromXml( + $this->getCapabilitiesXml(), + 'core', + 'status@@@edition' + ); + + if (!\strlen($edition)) { + PHPUnit_Framework_Assert::fail( + "Cannot get edition from capabilities" + ); + } + + $productName = $this->getParameterValueFromXml( + $this->getCapabilitiesXml(), + 'core', + 'status@@@productname' + ); + + if (!\strlen($edition)) { + PHPUnit_Framework_Assert::fail( + "Cannot get productname from capabilities" + ); + } + + $jsonExpectedDecoded['edition'] = $edition; + $jsonExpectedDecoded['productname'] = $productName; + $runOccStatus = $this->runOcc(['status']); if ($runOccStatus === 0) { $output = \explode("- ", $this->lastStdOut); @@ -1632,6 +1660,63 @@ public function statusPhpRespondedShouldMatch(PyStringNode $jsonExpected) { } } + /** + * @return string|null + */ + public function getJsonDecodedResponse() { + return \json_decode( + $this->getResponse()->getBody(), true + ); + } + + /** + * @return string + */ + public function getEditionFromStatus() { + $this->getStatusPhp(); + $decodedResponse = $this->getJsonDecodedResponse(); + if (isset($decodedResponse['edition'])) { + return $decodedResponse['edition']; + } + return ''; + } + + /** + * @return string|null + */ + public function getProductNameFromStatus() { + $this->getStatusPhp(); + $decodedResponse = $this->getJsonDecodedResponse(); + if (isset($decodedResponse['productname'])) { + return $decodedResponse['productname']; + } + return ''; + } + + /** + * @return string|null + */ + public function getVersionFromStatus() { + $this->getStatusPhp(); + $decodedResponse = $this->getJsonDecodedResponse(); + if (isset($decodedResponse['version'])) { + return $decodedResponse['version']; + } + return ''; + } + + /** + * @return string|null + */ + public function getVersionStringFromStatus() { + $this->getStatusPhp(); + $decodedResponse = $this->getJsonDecodedResponse(); + if (isset($decodedResponse['versionstring'])) { + return $decodedResponse['versionstring']; + } + return ''; + } + /** * substitutes codes like %base_url% with the value * if the given value does not have anything to be substituted diff --git a/tests/acceptance/features/bootstrap/CapabilitiesContext.php b/tests/acceptance/features/bootstrap/CapabilitiesContext.php index b70117e8d147..abdd15470300 100644 --- a/tests/acceptance/features/bootstrap/CapabilitiesContext.php +++ b/tests/acceptance/features/bootstrap/CapabilitiesContext.php @@ -50,6 +50,18 @@ public function checkCapabilitiesResponse(TableNode $formData) { $capabilitiesXML = $this->featureContext->getCapabilitiesXml(); foreach ($formData->getHash() as $row) { + if ($row['value'] === "%edition%") { + $row['value'] = $this->featureContext->getEditionFromStatus(); + } + if ($row['value'] === "%productname%") { + $row['value'] = $this->featureContext->getProductNameFromStatus(); + } + if ($row['value'] === "%version%") { + $row['value'] = $this->featureContext->getVersionFromStatus(); + } + if ($row['value'] === "%versionstring%") { + $row['value'] = $this->featureContext->getVersionStringFromStatus(); + } PHPUnit_Framework_Assert::assertEquals( $row['value'] === "EMPTY" ? '' : $row['value'], $this->featureContext->getParameterValueFromXml( diff --git a/tests/acceptance/features/bootstrap/WebDav.php b/tests/acceptance/features/bootstrap/WebDav.php index 81efdcdfb610..ddf145c171c7 100644 --- a/tests/acceptance/features/bootstrap/WebDav.php +++ b/tests/acceptance/features/bootstrap/WebDav.php @@ -796,6 +796,12 @@ public function theFollowingHeadersShouldBeSet(TableNode $table) { $headerName = $header[0]; $expectedHeaderValue = $header[1]; $returnedHeader = $this->response->getHeader($headerName); + + if (\strpos($expectedHeaderValue, "%productname%") !== false) { + $productName = $this->getProductNameFromStatus(); + $expectedHeaderValue = \str_replace("%productname%", $productName, $expectedHeaderValue); + } + if ($returnedHeader !== $expectedHeaderValue) { throw new \Exception( \sprintf(