diff options
author | Morris Jobke <hey@morrisjobke.de> | 2017-02-22 23:02:31 -0600 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2017-02-22 23:02:31 -0600 |
commit | 9533f4e5edfded577b67d08f7778a8a1704132f2 (patch) | |
tree | dc3e1741b8e69b0f8be6abf3cf678f499e68bff7 /tests/Core/Command | |
parent | 54317e80c0837cb5efe43086685fc09d6796e1ef (diff) | |
download | nextcloud-server-9533f4e5edfded577b67d08f7778a8a1704132f2.tar.gz nextcloud-server-9533f4e5edfded577b67d08f7778a8a1704132f2.zip |
Clean up single user mode
Single user mode basically disables WebDAV, OCS and cron execution. Since
we heavily rely on WebDAV and OCS also in the web UI it's basically useless.
An admin only sees a broken interface and can't even change any settings nor
sees any files. Also sharing is not possible.
As this is at least the case since Nextcloud 9 and we haven't received any
reports for this it seems that this feature is not used at all so I removed it.
The encryption commands now rely on the well tested maintenance mode.
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'tests/Core/Command')
-rw-r--r-- | tests/Core/Command/Encryption/DecryptAllTest.php | 14 | ||||
-rw-r--r-- | tests/Core/Command/Encryption/EncryptAllTest.php | 10 | ||||
-rw-r--r-- | tests/Core/Command/Maintenance/SingleUserTest.php | 132 |
3 files changed, 12 insertions, 144 deletions
diff --git a/tests/Core/Command/Encryption/DecryptAllTest.php b/tests/Core/Command/Encryption/DecryptAllTest.php index 8f674aa5b44..1b01231ac57 100644 --- a/tests/Core/Command/Encryption/DecryptAllTest.php +++ b/tests/Core/Command/Encryption/DecryptAllTest.php @@ -77,7 +77,7 @@ class DecryptAllTest extends TestCase { $this->config->expects($this->any()) ->method('getSystemValue') - ->with('singleuser', false) + ->with('maintenance', false) ->willReturn(false); $this->appManager->expects($this->any()) ->method('isEnabledForUser') @@ -85,12 +85,12 @@ class DecryptAllTest extends TestCase { } - public function testSingleUserAndTrashbin() { + public function testMaintenanceAndTrashbin() { // on construct we enable single-user-mode and disable the trash bin $this->config->expects($this->at(1)) ->method('setSystemValue') - ->with('singleuser', true); + ->with('maintenance', true); $this->appManager->expects($this->once()) ->method('disableApp') ->with('files_trashbin'); @@ -98,7 +98,7 @@ class DecryptAllTest extends TestCase { // on destruct wi disable single-user-mode again and enable the trash bin $this->config->expects($this->at(2)) ->method('setSystemValue') - ->with('singleuser', false); + ->with('maintenance', false); $this->appManager->expects($this->once()) ->method('enableApp') ->with('files_trashbin'); @@ -110,16 +110,16 @@ class DecryptAllTest extends TestCase { $this->decryptAll, $this->questionHelper ); - $this->invokePrivate($instance, 'forceSingleUserAndTrashbin'); + $this->invokePrivate($instance, 'forceMaintenanceAndTrashbin'); $this->assertTrue( $this->invokePrivate($instance, 'wasTrashbinEnabled') ); $this->assertFalse( - $this->invokePrivate($instance, 'wasSingleUserModeEnabled') + $this->invokePrivate($instance, 'wasMaintenanceModeEnabled') ); - $this->invokePrivate($instance, 'resetSingleUserAndTrashbin'); + $this->invokePrivate($instance, 'resetMaintenanceAndTrashbin'); } /** diff --git a/tests/Core/Command/Encryption/EncryptAllTest.php b/tests/Core/Command/Encryption/EncryptAllTest.php index 00895541782..554560a35b7 100644 --- a/tests/Core/Command/Encryption/EncryptAllTest.php +++ b/tests/Core/Command/Encryption/EncryptAllTest.php @@ -88,13 +88,13 @@ class EncryptAllTest extends TestCase { $this->appManager->expects($this->once())->method('disableApp')->with('files_trashbin'); // enable single user mode to avoid that other user login during encryption // destructor should disable the single user mode again - $this->config->expects($this->once())->method('getSystemValue')->with('singleuser', false)->willReturn(false); - $this->config->expects($this->at(1))->method('setSystemValue')->with('singleuser', true); - $this->config->expects($this->at(2))->method('setSystemValue')->with('singleuser', false); + $this->config->expects($this->once())->method('getSystemValue')->with('maintenance', false)->willReturn(false); + $this->config->expects($this->at(1))->method('setSystemValue')->with('maintenance', true); + $this->config->expects($this->at(2))->method('setSystemValue')->with('maintenance', false); $instance = new EncryptAll($this->encryptionManager, $this->appManager, $this->config, $this->questionHelper); - $this->invokePrivate($instance, 'forceSingleUserAndTrashbin'); - $this->invokePrivate($instance, 'resetSingleUserAndTrashbin'); + $this->invokePrivate($instance, 'forceMaintenanceAndTrashbin'); + $this->invokePrivate($instance, 'resetMaintenanceAndTrashbin'); } /** diff --git a/tests/Core/Command/Maintenance/SingleUserTest.php b/tests/Core/Command/Maintenance/SingleUserTest.php deleted file mode 100644 index 13efebacb0a..00000000000 --- a/tests/Core/Command/Maintenance/SingleUserTest.php +++ /dev/null @@ -1,132 +0,0 @@ -<?php -/** - * @author Morris Jobke <hey@morrisjobke.de> - * - * @copyright Copyright (c) 2015, ownCloud, Inc. - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * - */ - -namespace Tests\Core\Command\Maintenance; - - -use OC\Core\Command\Maintenance\SingleUser; -use OCP\IConfig; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; -use Test\TestCase; - -class SingleUserTest extends TestCase { - /** @var \PHPUnit_Framework_MockObject_MockObject */ - protected $config; - /** @var \PHPUnit_Framework_MockObject_MockObject */ - protected $consoleInput; - /** @var \PHPUnit_Framework_MockObject_MockObject */ - protected $consoleOutput; - - /** @var \Symfony\Component\Console\Command\Command */ - protected $command; - - protected function setUp() { - parent::setUp(); - - $config = $this->config = $this->getMockBuilder(IConfig::class) - ->disableOriginalConstructor() - ->getMock(); - $this->consoleInput = $this->getMockBuilder(InputInterface::class)->getMock(); - $this->consoleOutput = $this->getMockBuilder(OutputInterface::class)->getMock(); - - /** @var \OCP\IConfig $config */ - $this->command = new SingleUser($config); - } - - public function testChangeStateToOn() { - - $this->consoleInput->expects($this->once()) - ->method('getOption') - ->with('on') - ->willReturn(true); - - $this->config->expects($this->once()) - ->method('setSystemValue') - ->with('singleuser', true); - - $this->consoleOutput->expects($this->once()) - ->method('writeln') - ->with('Single user mode enabled'); - - self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]); - } - - public function testChangeStateToOff() { - - $this->consoleInput->expects($this->at(0)) - ->method('getOption') - ->with('on') - ->willReturn(false); - - $this->consoleInput->expects($this->at(1)) - ->method('getOption') - ->with('off') - ->willReturn(true); - - $this->config->expects($this->once()) - ->method('setSystemValue') - ->with('singleuser', false); - - $this->consoleOutput->expects($this->once()) - ->method('writeln') - ->with('Single user mode disabled'); - - self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]); - } - - public function stateData() { - return [ - [ true, 'Single user mode is currently enabled' ], - [ false, 'Single user mode is currently disabled' ], - ]; - } - - /** - * @dataProvider stateData - * - * @param $state - * @param $expectedOutput - */ - public function testState($state, $expectedOutput) { - - $this->consoleInput->expects($this->at(0)) - ->method('getOption') - ->with('on') - ->willReturn(false); - - $this->consoleInput->expects($this->at(1)) - ->method('getOption') - ->with('off') - ->willReturn(false); - - $this->config->expects($this->once()) - ->method('getSystemValue') - ->with('singleuser', false) - ->willReturn($state); - - $this->consoleOutput->expects($this->once()) - ->method('writeln') - ->with($expectedOutput); - - self::invokePrivate($this->command, 'execute', [$this->consoleInput, $this->consoleOutput]); - } -} |