diff options
author | Robin Appelman <icewind@owncloud.com> | 2015-12-22 17:42:28 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2016-01-12 12:50:59 +0100 |
commit | c15cab7ed6bf2d3ce9009ca09c7c5f33b252860f (patch) | |
tree | 08d3aefd146ce159b23073958f2fb7e96ace4143 /tests | |
parent | 0c0829fbc73ce10ea1a951989c20973b6b5faa16 (diff) | |
download | nextcloud-server-c15cab7ed6bf2d3ce9009ca09c7c5f33b252860f.tar.gz nextcloud-server-c15cab7ed6bf2d3ce9009ca09c7c5f33b252860f.zip |
Allow admins to add system wide root certificates
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/security/certificatemanager.php | 23 | ||||
-rw-r--r-- | tests/settings/controller/CertificateControllerTest.php | 4 |
2 files changed, 19 insertions, 8 deletions
diff --git a/tests/lib/security/certificatemanager.php b/tests/lib/security/certificatemanager.php index f2e29cab18e..e9ccea39efe 100644 --- a/tests/lib/security/certificatemanager.php +++ b/tests/lib/security/certificatemanager.php @@ -14,6 +14,8 @@ use \OC\Security\CertificateManager; * @group DB */ class CertificateManagerTest extends \Test\TestCase { + use \Test\Traits\UserTrait; + use \Test\Traits\MountProviderTrait; /** @var CertificateManager */ private $certificateManager; @@ -24,7 +26,10 @@ class CertificateManagerTest extends \Test\TestCase { parent::setUp(); $this->username = $this->getUniqueID('', 20); - \OC::$server->getUserManager()->createUser($this->username, $this->getUniqueID('', 20)); + $this->createUser($this->username, ''); + + $storage = new \OC\Files\Storage\Temporary(); + $this->registerMount($this->username, $storage, '/' . $this->username . '/'); \OC_Util::tearDownFS(); \OC_User::setUserId(''); @@ -40,7 +45,9 @@ class CertificateManagerTest extends \Test\TestCase { protected function tearDown() { $user = \OC::$server->getUserManager()->get($this->username); - if ($user !== null) { $user->delete(); } + if ($user !== null) { + $user->delete(); + } parent::tearDown(); } @@ -56,14 +63,14 @@ class CertificateManagerTest extends \Test\TestCase { $this->assertSame(array(), $this->certificateManager->listCertificates()); // Add some certificates - $this->certificateManager->addCertificate(file_get_contents(__DIR__.'/../../data/certificates/goodCertificate.crt'), 'GoodCertificate'); + $this->certificateManager->addCertificate(file_get_contents(__DIR__ . '/../../data/certificates/goodCertificate.crt'), 'GoodCertificate'); $certificateStore = array(); - $certificateStore[] = new \OC\Security\Certificate(file_get_contents(__DIR__.'/../../data/certificates/goodCertificate.crt'), 'GoodCertificate'); + $certificateStore[] = new \OC\Security\Certificate(file_get_contents(__DIR__ . '/../../data/certificates/goodCertificate.crt'), 'GoodCertificate'); $this->assertEqualsArrays($certificateStore, $this->certificateManager->listCertificates()); // Add another certificates - $this->certificateManager->addCertificate(file_get_contents(__DIR__.'/../../data/certificates/expiredCertificate.crt'), 'ExpiredCertificate'); - $certificateStore[] = new \OC\Security\Certificate(file_get_contents(__DIR__.'/../../data/certificates/expiredCertificate.crt'), 'ExpiredCertificate'); + $this->certificateManager->addCertificate(file_get_contents(__DIR__ . '/../../data/certificates/expiredCertificate.crt'), 'ExpiredCertificate'); + $certificateStore[] = new \OC\Security\Certificate(file_get_contents(__DIR__ . '/../../data/certificates/expiredCertificate.crt'), 'ExpiredCertificate'); $this->assertEqualsArrays($certificateStore, $this->certificateManager->listCertificates()); } @@ -93,7 +100,7 @@ class CertificateManagerTest extends \Test\TestCase { * @param string $filename */ function testAddDangerousFile($filename) { - $this->certificateManager->addCertificate(file_get_contents(__DIR__.'/../../data/certificates/expiredCertificate.crt'), $filename); + $this->certificateManager->addCertificate(file_get_contents(__DIR__ . '/../../data/certificates/expiredCertificate.crt'), $filename); } function testRemoveDangerousFile() { @@ -101,7 +108,7 @@ class CertificateManagerTest extends \Test\TestCase { } function testRemoveExistingFile() { - $this->certificateManager->addCertificate(file_get_contents(__DIR__.'/../../data/certificates/goodCertificate.crt'), 'GoodCertificate'); + $this->certificateManager->addCertificate(file_get_contents(__DIR__ . '/../../data/certificates/goodCertificate.crt'), 'GoodCertificate'); $this->assertTrue($this->certificateManager->removeCertificate('GoodCertificate')); } diff --git a/tests/settings/controller/CertificateControllerTest.php b/tests/settings/controller/CertificateControllerTest.php index 023d7753cca..2fdbbb8b0ac 100644 --- a/tests/settings/controller/CertificateControllerTest.php +++ b/tests/settings/controller/CertificateControllerTest.php @@ -44,12 +44,15 @@ class CertificateControllerTest extends \Test\TestCase { private $l10n; /** @var IAppManager */ private $appManager; + /** @var ICertificateManager */ + private $systemCertificateManager; public function setUp() { parent::setUp(); $this->request = $this->getMock('\OCP\IRequest'); $this->certificateManager = $this->getMock('\OCP\ICertificateManager'); + $this->systemCertificateManager = $this->getMock('\OCP\ICertificateManager'); $this->l10n = $this->getMock('\OCP\IL10N'); $this->appManager = $this->getMock('OCP\App\IAppManager'); @@ -59,6 +62,7 @@ class CertificateControllerTest extends \Test\TestCase { 'settings', $this->request, $this->certificateManager, + $this->systemCertificateManager, $this->l10n, $this->appManager ] |