Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog/unreleased/39851
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Enhancement: Add product to version in capabilities response

https://github.com/owncloud/core/pull/39851
2 changes: 2 additions & 0 deletions core/Controller/CloudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@ public function __construct($appName, IRequest $request) {
*/
public function getCapabilities() {
$result = [];
$defaults = new \OCP\Defaults();
list($major, $minor, $micro) = \OCP\Util::getVersion();
$result['version'] = [
'major' => $major,
'minor' => $minor,
'micro' => $micro,
'string' => \OC_Util::getVersionString(),
'edition' => \OC_Util::getEditionString(),
'product' => $defaults->getName(),
];

$result['capabilities'] = \OC::$server->getCapabilitiesManager()->getCapabilities();
Expand Down
8 changes: 5 additions & 3 deletions lib/public/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class Util {
public static function getVersion() {
return(\OC_Util::getVersion());
}

/**
* Set current update channel
* @param string $channel
Expand All @@ -85,7 +85,7 @@ public static function setChannel($channel) {
\OC::$server->getSession()->set('OC_Version_Timestamp', 0);
\OC::$server->getAppConfig()->setValue('core', 'OC_Channel', $channel);
}

/**
* Get current update channel
* @return string
Expand Down Expand Up @@ -760,14 +760,16 @@ public static function getStatusInfo($includeVersion = false, $serverHide = fals
'version' => '',
'versionstring' => '',
'edition' => '',
'productname' => ''];
'productname' => '', // deprecated
'product' => ''];

// expose version and servername details
if ($includeVersion || (bool) $systemConfig->getValue('version.hide', false) === false) {
$values['version'] = \implode('.', self::getVersion());
$values['versionstring'] = \OC_Util::getVersionString();
$values['edition'] = \OC_Util::getEditionString();
$values['productname'] = $defaults->getName();
$values['product'] = $defaults->getName();
// expose the servername only if allowed via version, but never when called via status.php
if ($serverHide === false) {
$hostname = \gethostname();
Expand Down
18 changes: 18 additions & 0 deletions tests/acceptance/features/apiCapabilities/capabilities.feature
Original file line number Diff line number Diff line change
Expand Up @@ -953,3 +953,21 @@ Feature: capabilities
| capability | path_to_element | value |
| files | blacklisted_files_regex | \.(part\|filepart)$ |

@smokeTest
@skipOnOcV10.7 @skipOnOcV10.8 @skipOnOcV10.9.0 @skipOnOcV10.9.1
# This is a new capability after 10.9.1
Scenario: getting default capabilities with admin user
When the administrator retrieves the capabilities using the capabilities API
Then the capabilities should contain
| capability | path_to_element | value |
| core | status@@@edition | %edition% |
| core | status@@@product | %productname% |
| core | status@@@productname | %productname% |
| core | status@@@version | %version% |
| core | status@@@versionstring | %versionstring% |
And the version data in the response should contain
| name | value |
| string | %versionstring% |
| edition | %edition% |
| product | %productname% |
And the major-minor-micro version data in the response should match the version string
4 changes: 2 additions & 2 deletions tests/acceptance/features/apiMain/status.feature
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
@api @issue-ocis-reva-65 @issue-ocis-reva-97
Feature: Status

@smokeTest
@smokeTest @skipOnOcV10.7 @skipOnOcV10.8 @skipOnOcV10.9.0 @skipOnOcV10.9.1
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":"$EDITION","productname":"$PRODUCTNAME"}
{"installed":true,"maintenance":false,"needsDbUpgrade":false,"version":"$CURRENT_VERSION","versionstring":"$CURRENT_VERSION_STRING","edition":"$EDITION","productname":"$PRODUCTNAME","product":"$PRODUCT"}
"""
12 changes: 12 additions & 0 deletions tests/acceptance/features/bootstrap/AppConfigurationContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,18 @@ public function getCapabilitiesXml(string $exceptionText = ''): SimpleXMLElement
return $this->featureContext->getResponseXml(null, $exceptionText)->data->capabilities;
}

/**
* @param string $exceptionText text to put at the front of exception messages
*
* @return SimpleXMLElement latest retrieved version data in XML format
*/
public function getVersionXml(string $exceptionText = ''): SimpleXMLElement {
if ($exceptionText === '') {
$exceptionText = __METHOD__;
}
return $this->featureContext->getResponseXml(null, $exceptionText)->data->version;
}

/**
* @param SimpleXMLElement $xml of the capabilities
* @param string $capabilitiesApp the "app" name in the capabilities response
Expand Down
73 changes: 73 additions & 0 deletions tests/acceptance/features/bootstrap/CapabilitiesContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,79 @@ public function checkCapabilitiesResponse(TableNode $formData):void {
);
}

/**
* @Then the version data in the response should contain
*
* @param TableNode|null $formData
*
* @return void
* @throws Exception
*/
public function checkVersionResponse(TableNode $formData):void {
$versionXML = $this->featureContext->appConfigurationContext->getVersionXml(__METHOD__);
$assertedSomething = false;

$this->featureContext->verifyTableNodeColumns($formData, ['name', 'value']);

foreach ($formData->getHash() as $row) {
$row['value'] = $this->featureContext->substituteInLineCodes($row['value']);
$actualValue = $versionXML->{$row['name']};

Assert::assertEquals(
$row['value'] === "EMPTY" ? '' : $row['value'],
$actualValue,
"Failed field {$row['name']}"
);
$assertedSomething = true;
}

Assert::assertTrue(
$assertedSomething,
'there was nothing in the table of expected version data'
);
}

/**
* @Then the major-minor-micro version data in the response should match the version string
*
* @return void
* @throws Exception
*/
public function checkVersionMajorMinorMicroResponse():void {
$versionXML = $this->featureContext->appConfigurationContext->getVersionXml(__METHOD__);
$versionString = (string) $versionXML->string;
// We expect that versionString will be in a format like "10.9.2 beta" or "10.9.2-alpha" or "10.9.2"
$result = \preg_match('/^[0-9]+\.[0-9]+\.[0-9]+/', $versionString, $matches);
Assert::assertSame(
1,
$result,
__METHOD__ . " version string '$versionString' does not start with a semver version"
);
// semVerParts should have an array with the 3 semver components of the version, e.g. "1", "9" and "2".
$semVerParts = \explode('.', $matches[0]);
$expectedMajor = $semVerParts[0];
$expectedMinor = $semVerParts[1];
$expectedMicro = $semVerParts[2];
$actualMajor = (string) $versionXML->major;
$actualMinor = (string) $versionXML->minor;
$actualMicro = (string) $versionXML->micro;
Assert::assertSame(
$expectedMajor,
$actualMajor,
__METHOD__ . "'major' data item does not match with major version in string '$versionString'"
);
Assert::assertSame(
$expectedMinor,
$actualMinor,
__METHOD__ . "'minor' data item does not match with minor version in string '$versionString'"
);
Assert::assertSame(
$expectedMicro,
$actualMicro,
__METHOD__ . "'micro' data item does not match with micro (patch) version in string '$versionString'"
);
}

/**
* @Then the :pathToElement capability of files sharing app should be :value
*
Expand Down
1 change: 1 addition & 0 deletions tests/acceptance/features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -2640,6 +2640,7 @@ public function statusPhpRespondedShouldMatch(PyStringNode $jsonExpected):void {
}

$jsonExpectedDecoded['edition'] = $edition;
$jsonExpectedDecoded['product'] = $productName;
$jsonExpectedDecoded['productname'] = $productName;

if (OcisHelper::isTestingOnOc10()) {
Expand Down