diff --git a/lib/Controller/WizardController.php b/lib/Controller/WizardController.php index d232e8bf0..2213bb49a 100644 --- a/lib/Controller/WizardController.php +++ b/lib/Controller/WizardController.php @@ -25,9 +25,9 @@ use OCP\AppFramework\Controller; use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\Http\JSONResponse; -use OCP\AppFramework\Http\TemplateResponse; use OCP\Defaults; use OCP\IConfig; +use OCP\IGroupManager; use OCP\IRequest; class WizardController extends Controller { @@ -41,6 +41,9 @@ class WizardController extends Controller { /** @var Defaults */ protected $theming; + /** @var IGroupManager */ + protected $groupManager; + /** * @param string $appName * @param IRequest $request @@ -48,12 +51,13 @@ class WizardController extends Controller { * @param string $userId * @param Defaults $theming */ - public function __construct($appName, IRequest $request, IConfig $config, $userId, Defaults $theming) { + public function __construct($appName, IRequest $request, IConfig $config, $userId, Defaults $theming, IGroupManager $groupManager) { parent::__construct($appName, $request); $this->config = $config; $this->userId = $userId; $this->theming = $theming; + $this->groupManager = $groupManager; } /** @@ -81,11 +85,14 @@ public function show() { $slides = [ $this->staticSlide('page.intro', $data), - $this->staticSlide('page.values', $data), - $this->staticSlide('page.apps', $data), - $this->staticSlide('page.clients', $data), - $this->staticSlide('page.final', $data) + $this->staticSlide('page.values', $data) ]; + if ($this->groupManager->isAdmin($this->userId)) { + $slides[] = $this->staticSlide('page.apps', $data); + } + $slides[] = $this->staticSlide('page.clients', $data); + $slides[] = $this->staticSlide('page.final', $data); + return new JSONResponse($slides); } diff --git a/tests/Controller/WizardControllerTest.php b/tests/Controller/WizardControllerTest.php index 687bfd244..2319471e4 100644 --- a/tests/Controller/WizardControllerTest.php +++ b/tests/Controller/WizardControllerTest.php @@ -30,6 +30,7 @@ use OCP\AppFramework\Http\JSONResponse; use OCP\Defaults; use OCP\IConfig; +use OCP\IGroupManager; use OCP\IRequest; use Test\TestCase; @@ -42,10 +43,13 @@ class WizardControllerTest extends TestCase { /** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */ protected $config; + private $groupManager; protected function setUp() { parent::setUp(); $this->config = $this->createMock(IConfig::class); + $this->groupManager = $this->createMock(IGroupManager::class); + } /** @@ -58,7 +62,8 @@ protected function getController($user = 'test') { $this->createMock(IRequest::class), $this->config, $user, - \OC::$server->query(Defaults::class) + \OC::$server->query(Defaults::class), + $this->groupManager ); } @@ -87,9 +92,31 @@ public function testDisable($user) { } - public function testShow() { + public function testShowUser() { + $controller = $this->getController(); + + $this->config->expects($this->exactly(4)) + ->method('getSystemValue') + ->willReturnMap([ + ['customclient_desktop', 'https://nextcloud.com/install/#install-clients', 'https://nextcloud.com/install/#install-clients'], + ['customclient_android', 'https://play.google.com/store/apps/details?id=com.nextcloud.client', 'https://nextcloud.com/install/#install-clients'], + ['customclient_ios', 'https://geo.itunes.apple.com/us/app/nextcloud/id1125420102?mt=8', 'https://nextcloud.com/install/#install-clients'], + ['appstoreenabled', true, true] + ]); + + $response = $controller->show(); + + $this->assertInstanceOf(JSONResponse::class, $response); + $this->assertSame(Http::STATUS_OK, $response->getStatus()); + $this->assertEquals(4, count($response->getData())); + } + + public function testShowAdmin() { $controller = $this->getController(); + $this->groupManager->expects($this->once()) + ->method('isAdmin') + ->willReturn(true); $this->config->expects($this->exactly(4)) ->method('getSystemValue') ->willReturnMap([