From 5d2fdfe0b5214bd35bc9842cb6aa53f70aff125d Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Mon, 8 Oct 2018 10:22:27 +0200 Subject: Rename admin security section Signed-off-by: Christoph Wurst --- tests/lib/Settings/Admin/EncryptionTest.php | 138 ---------------------------- tests/lib/Settings/Admin/SecurityTest.php | 138 ++++++++++++++++++++++++++++ 2 files changed, 138 insertions(+), 138 deletions(-) delete mode 100644 tests/lib/Settings/Admin/EncryptionTest.php create mode 100644 tests/lib/Settings/Admin/SecurityTest.php (limited to 'tests') diff --git a/tests/lib/Settings/Admin/EncryptionTest.php b/tests/lib/Settings/Admin/EncryptionTest.php deleted file mode 100644 index 9be2a3f46d9..00000000000 --- a/tests/lib/Settings/Admin/EncryptionTest.php +++ /dev/null @@ -1,138 +0,0 @@ - - * - * @author Lukas Reschke - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * 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 - * along with this program. If not, see . - * - */ - -namespace Test\Settings\Admin; - -use OC\Encryption\Manager; -use OC\Settings\Admin\Encryption; -use OCP\AppFramework\Http\TemplateResponse; -use OCP\IUserManager; -use Test\TestCase; - -class EncryptionTest extends TestCase { - /** @var Encryption */ - private $admin; - /** @var Manager */ - private $manager; - /** @var IUserManager */ - private $userManager; - - public function setUp() { - parent::setUp(); - $this->manager = $this->getMockBuilder('\OC\Encryption\Manager')->disableOriginalConstructor()->getMock(); - $this->userManager = $this->getMockBuilder(IUserManager::class)->getMock(); - - $this->admin = new Encryption( - $this->manager, - $this->userManager - ); - } - - /** - * @return array - */ - public function encryptionSettingsProvider() { - return [ - [true], - [false], - ]; - } - - /** - * @dataProvider encryptionSettingsProvider - * @param bool $enabled - */ - public function testGetFormWithOnlyOneBackend($enabled) { - $this->manager - ->expects($this->once()) - ->method('isEnabled') - ->willReturn($enabled); - $this->manager - ->expects($this->once()) - ->method('isReady') - ->willReturn($enabled); - $this->manager - ->expects($this->once()) - ->method('getEncryptionModules') - ->willReturn([]); - $this->userManager - ->expects($this->once()) - ->method('getBackends') - ->willReturn(['entry']); - $expected = new TemplateResponse( - 'settings', - 'settings/admin/encryption', - [ - 'encryptionEnabled' => $enabled, - 'encryptionReady' => $enabled, - 'externalBackendsEnabled' => false, - 'encryptionModules' => [] - ], - '' - ); - $this->assertEquals($expected, $this->admin->getForm()); - } - - /** - * @dataProvider encryptionSettingsProvider - * @param bool $enabled - */ - public function testGetFormWithMultipleBackends($enabled) { - $this->manager - ->expects($this->once()) - ->method('isEnabled') - ->willReturn($enabled); - $this->manager - ->expects($this->once()) - ->method('isReady') - ->willReturn($enabled); - $this->manager - ->expects($this->once()) - ->method('getEncryptionModules') - ->willReturn([]); - $this->userManager - ->expects($this->once()) - ->method('getBackends') - ->willReturn(['entry', 'entry']); - $expected = new TemplateResponse( - 'settings', - 'settings/admin/encryption', - [ - 'encryptionEnabled' => $enabled, - 'encryptionReady' => $enabled, - 'externalBackendsEnabled' => true, - 'encryptionModules' => [] - ], - '' - ); - $this->assertEquals($expected, $this->admin->getForm()); - } - - public function testGetSection() { - $this->assertSame('security', $this->admin->getSection()); - } - - public function testGetPriority() { - $this->assertSame(10, $this->admin->getPriority()); - } -} diff --git a/tests/lib/Settings/Admin/SecurityTest.php b/tests/lib/Settings/Admin/SecurityTest.php new file mode 100644 index 00000000000..4ad98227297 --- /dev/null +++ b/tests/lib/Settings/Admin/SecurityTest.php @@ -0,0 +1,138 @@ + + * + * @author Lukas Reschke + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * 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 + * along with this program. If not, see . + * + */ + +namespace Test\Settings\Admin; + +use OC\Encryption\Manager; +use OC\Settings\Admin\Security; +use OCP\AppFramework\Http\TemplateResponse; +use OCP\IUserManager; +use Test\TestCase; + +class SecurityTest extends TestCase { + /** @var Security */ + private $admin; + /** @var Manager */ + private $manager; + /** @var IUserManager */ + private $userManager; + + public function setUp() { + parent::setUp(); + $this->manager = $this->getMockBuilder('\OC\Encryption\Manager')->disableOriginalConstructor()->getMock(); + $this->userManager = $this->getMockBuilder(IUserManager::class)->getMock(); + + $this->admin = new Security( + $this->manager, + $this->userManager + ); + } + + /** + * @return array + */ + public function encryptionSettingsProvider() { + return [ + [true], + [false], + ]; + } + + /** + * @dataProvider encryptionSettingsProvider + * @param bool $enabled + */ + public function testGetFormWithOnlyOneBackend($enabled) { + $this->manager + ->expects($this->once()) + ->method('isEnabled') + ->willReturn($enabled); + $this->manager + ->expects($this->once()) + ->method('isReady') + ->willReturn($enabled); + $this->manager + ->expects($this->once()) + ->method('getEncryptionModules') + ->willReturn([]); + $this->userManager + ->expects($this->once()) + ->method('getBackends') + ->willReturn(['entry']); + $expected = new TemplateResponse( + 'settings', + 'settings/admin/encryption', + [ + 'encryptionEnabled' => $enabled, + 'encryptionReady' => $enabled, + 'externalBackendsEnabled' => false, + 'encryptionModules' => [] + ], + '' + ); + $this->assertEquals($expected, $this->admin->getForm()); + } + + /** + * @dataProvider encryptionSettingsProvider + * @param bool $enabled + */ + public function testGetFormWithMultipleBackends($enabled) { + $this->manager + ->expects($this->once()) + ->method('isEnabled') + ->willReturn($enabled); + $this->manager + ->expects($this->once()) + ->method('isReady') + ->willReturn($enabled); + $this->manager + ->expects($this->once()) + ->method('getEncryptionModules') + ->willReturn([]); + $this->userManager + ->expects($this->once()) + ->method('getBackends') + ->willReturn(['entry', 'entry']); + $expected = new TemplateResponse( + 'settings', + 'settings/admin/encryption', + [ + 'encryptionEnabled' => $enabled, + 'encryptionReady' => $enabled, + 'externalBackendsEnabled' => true, + 'encryptionModules' => [] + ], + '' + ); + $this->assertEquals($expected, $this->admin->getForm()); + } + + public function testGetSection() { + $this->assertSame('security', $this->admin->getSection()); + } + + public function testGetPriority() { + $this->assertSame(10, $this->admin->getPriority()); + } +} -- cgit v1.2.3 From b1b43aa7bc3c4d5ffe4973cf12644c1e60305530 Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Mon, 8 Oct 2018 11:27:22 +0200 Subject: Fix reference to template in tests Signed-off-by: Christoph Wurst --- tests/lib/Settings/Admin/SecurityTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/lib/Settings/Admin/SecurityTest.php b/tests/lib/Settings/Admin/SecurityTest.php index 4ad98227297..a7c56f697b0 100644 --- a/tests/lib/Settings/Admin/SecurityTest.php +++ b/tests/lib/Settings/Admin/SecurityTest.php @@ -81,7 +81,7 @@ class SecurityTest extends TestCase { ->willReturn(['entry']); $expected = new TemplateResponse( 'settings', - 'settings/admin/encryption', + 'settings/admin/security', [ 'encryptionEnabled' => $enabled, 'encryptionReady' => $enabled, @@ -116,7 +116,7 @@ class SecurityTest extends TestCase { ->willReturn(['entry', 'entry']); $expected = new TemplateResponse( 'settings', - 'settings/admin/encryption', + 'settings/admin/security', [ 'encryptionEnabled' => $enabled, 'encryptionReady' => $enabled, -- cgit v1.2.3