Skip to content

Commit

Permalink
Merge pull request #33036 from owncloud/test-edition
Browse files Browse the repository at this point in the history
Abstract edition productname version in API tests
  • Loading branch information
paurakhsharma authored Oct 8, 2018
2 parents a8655e9 + 466c34e commit 7f43ba6
Show file tree
Hide file tree
Showing 7 changed files with 158 additions and 34 deletions.
52 changes: 26 additions & 26 deletions tests/acceptance/features/apiCapabilities/capabilities.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 |
Expand All @@ -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 |
Expand All @@ -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 |
Expand All @@ -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 |
Expand All @@ -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 |
Expand All @@ -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 |
Expand All @@ -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 |
Expand All @@ -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 |
Expand All @@ -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 |
Expand All @@ -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 |
Expand All @@ -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 |
Expand All @@ -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 |
Expand All @@ -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 |
Expand All @@ -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 |
Expand All @@ -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 |
Expand All @@ -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 |
Expand All @@ -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 |
Expand All @@ -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 |
Expand Down Expand Up @@ -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 |
Expand Down Expand Up @@ -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 |
Expand Down Expand Up @@ -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 |
Expand Down Expand Up @@ -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 |
Expand Down
3 changes: 2 additions & 1 deletion tests/acceptance/features/apiMain/status.feature
Original file line number Diff line number Diff line change
@@ -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"}
"""
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
28 changes: 24 additions & 4 deletions tests/acceptance/features/bootstrap/AppConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
*/
Expand Down
89 changes: 87 additions & 2 deletions tests/acceptance/features/bootstrap/BasicStructure.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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
Expand Down
Loading

0 comments on commit 7f43ba6

Please sign in to comment.