Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable10] Install app when enabling via provisioning api #32214

Merged
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
9 changes: 9 additions & 0 deletions lib/private/App/AppManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,11 @@ public function enableApp($appId) {
if ($this->getAppPath($appId) === false) {
throw new \Exception("$appId can't be enabled since it is not installed.");
}

if (!Installer::isInstalled($appId)) {
Installer::installShippedApp($appId);
}

$this->canEnableTheme($appId);

$this->installedAppsCache[$appId] = 'yes';
Expand Down Expand Up @@ -289,6 +294,10 @@ public function enableAppForGroups($appId, $groups) {
}
}

if (!Installer::isInstalled($appId)) {
Installer::installShippedApp($appId);
}

$groupIds = \array_map(function ($group) {
/** @var \OCP\IGroup $group */
return $group->getGID();
Expand Down
4 changes: 0 additions & 4 deletions lib/private/legacy/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -398,10 +398,6 @@ public static function enable($app, $groups = null) {

self::checkAppDependencies($config, $l, $info);

if (!Installer::isInstalled($app)) {
Installer::installShippedApp($app);
}

$appManager = \OC::$server->getAppManager();
if ($groups !== null) {
$groupManager = \OC::$server->getGroupManager();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ So that I can use the app features again
Then the OCS status code should be "100"
And the HTTP status code should be "200"
And app "comments" should be enabled
And the information for app "comments" should have a valid version

Scenario: subadmin tries to enable an app
Given user "subadmin" has been created
Expand Down
43 changes: 43 additions & 0 deletions tests/acceptance/features/bootstrap/Provisioning.php
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,20 @@ public function getArrayOfSubadminsResponded($resp) {
return $extractedElementsArray;
}

/**
* Parses the xml answer to get the array of app info returned for an app.
*
* @param ResponseInterface $resp
*
* @return array
*/
public function getArrayOfAppInfoResponded($resp) {
$listCheckedElements = $resp->xml()->data[0];
$extractedElementsArray
= \json_decode(\json_encode($listCheckedElements), 1);
return $extractedElementsArray;
}

/**
* @Then /^app "([^"]*)" should be disabled$/
*
Expand Down Expand Up @@ -1489,6 +1503,35 @@ public function appShouldBeEnabled($app) {
);
}

/**
* @Then /^the information for app "([^"]*)" should have a valid version$/
*
* @param string $app
*
* @return void
*/
public function theInformationForAppShouldHaveAValidVersion($app) {
$fullUrl = $this->getBaseUrl() . "/ocs/v2.php/cloud/apps/$app";
$client = new Client();
$options = [];
$options['auth'] = $this->getAuthOptionForAdmin();

$this->response = $client->get($fullUrl, $options);
PHPUnit_Framework_Assert::assertEquals(
200, $this->response->getStatusCode()
);
$respondedArray = $this->getArrayOfAppInfoResponded($this->response);
PHPUnit_Framework_Assert::assertArrayHasKey(
'version',
$respondedArray,
"app info returned for $app app does not have a version");
$appVersion = $respondedArray['version'];
PHPUnit_Framework_Assert::assertTrue(
\substr_count($appVersion, '.') > 1,
"app version '$appVersion' returned in app info is not a valid version string"
);
}

/**
* @Then /^user "([^"]*)" should be disabled$/
*
Expand Down