]> source.dussan.org Git - nextcloud-server.git/commitdiff
fixing unit test execution
authorThomas Müller <thomas.mueller@tmit.eu>
Thu, 2 Apr 2015 08:26:40 +0000 (10:26 +0200)
committerThomas Müller <thomas.mueller@tmit.eu>
Tue, 7 Apr 2015 11:30:30 +0000 (13:30 +0200)
apps/encryption/lib/keymanager.php
apps/encryption/tests/lib/KeyManagerTest.php
apps/encryption/tests/lib/SessionTest.php

index d2659f55a77d9a85199abec8bb3bb224c5ecaa59..1f71a891e81f9b18dae741c46f9cdbb5037e15a7 100644 (file)
@@ -192,7 +192,6 @@ class KeyManager {
         * @param string $password
         * @param array $keyPair
         * @return bool
-        * @internal param string $uid
         */
        public function setRecoveryKey($password, $keyPair) {
                // Save Public Key
index 040390e827fc6b3a230cef69c7d5cbd7cdcc7b21..5a85007aa57531023746ca8d958316b4efa94883 100644 (file)
@@ -14,18 +14,10 @@ use OCA\Encryption\KeyManager;
 use Test\TestCase;
 
 class KeyManagerTest extends TestCase {
-       /**
-        * @var bool
-        */
-       private static $trashbinState;
        /**
         * @var KeyManager
         */
        private $instance;
-       /**
-        * @var string
-        */
-       private static $testUser = 'test-keyManager-user.dot';
        /**
         * @var string
         */
@@ -55,27 +47,6 @@ class KeyManagerTest extends TestCase {
        /** @var \PHPUnit_Framework_MockObject_MockObject */
        private $configMock;
 
-       /**
-        *
-        */
-       public static function setUpBeforeClass() {
-               parent::setUpBeforeClass();
-
-               // Remember files_trashbin state
-               self::$trashbinState = \OC_App::isEnabled('files_trashbin');
-
-               // We dont want tests with app files_trashbin enabled
-               \OC_App::disable('files_trashbin');
-
-               $userManager = \OC::$server->getUserManager();
-               $userManager->get(self::$testUser)->delete();
-               $userManager->createUser(self::$testUser,
-                       self::$testUser);
-
-               // Create test user
-               parent::loginAsUser(self::$testUser);
-       }
-
        public function setUp() {
                parent::setUp();
                $this->userId = 'user1';
@@ -118,7 +89,6 @@ class KeyManagerTest extends TestCase {
                );
        }
 
-
        public function testGetPrivateKey() {
                $this->keyStorageMock->expects($this->any())
                        ->method('getUserKey')
@@ -153,9 +123,6 @@ class KeyManagerTest extends TestCase {
                $this->assertTrue($this->instance->recoveryKeyExists());
        }
 
-       /**
-        *
-        */
        public function testCheckRecoveryKeyPassword() {
                $this->keyStorageMock->expects($this->any())
                        ->method('getSystemUserKey')
@@ -165,12 +132,10 @@ class KeyManagerTest extends TestCase {
                        ->method('decryptPrivateKey')
                        ->with($this->equalTo('recoveryKey'), $this->equalTo('pass'))
                        ->willReturn('decryptedRecoveryKey');
-               
 
                $this->assertTrue($this->instance->checkRecoveryPassword('pass'));
        }
 
-
        public function testSetPublicKey() {
                $this->keyStorageMock->expects($this->any())
                        ->method('setUserKey')
@@ -184,7 +149,6 @@ class KeyManagerTest extends TestCase {
                $this->assertTrue(
                        $this->instance->setPublicKey($this->userId, 'key')
                );
-
        }
 
        public function testSetPrivateKey() {
@@ -214,9 +178,6 @@ class KeyManagerTest extends TestCase {
                );
        }
 
-       /**
-        *
-        */
        public function testInit() {
                $this->keyStorageMock->expects($this->any())
                        ->method('getUserKey')
@@ -249,7 +210,7 @@ class KeyManagerTest extends TestCase {
                );
        }
 
-       public function setSystemPrivateKey() {
+       public function testSetSystemPrivateKey() {
                $this->keyStorageMock->expects($this->exactly(1))
                        ->method('setSystemUserKey')
                        ->with($this->equalTo('keyId.privateKey'), $this->equalTo('key'))
@@ -261,9 +222,9 @@ class KeyManagerTest extends TestCase {
                );
        }
 
-       public function getSystemPrivateKey() {
+       public function testGetSystemPrivateKey() {
                $this->keyStorageMock->expects($this->exactly(1))
-                       ->method('setSystemUserKey')
+                       ->method('getSystemUserKey')
                        ->with($this->equalTo('keyId.privateKey'))
                        ->willReturn('systemPrivateKey');
                
@@ -272,6 +233,4 @@ class KeyManagerTest extends TestCase {
                        $this->instance->getSystemPrivateKey('keyId')
                );
        }
-
-
 }
index dbf3ecc45a12652fa1e5b13fb4e3ff70414dfa4d..f7e026808f0e7b077929788a8eca966023bb2f7b 100644 (file)
@@ -35,10 +35,10 @@ class SessionTest extends TestCase {
        private $sessionMock;
 
        /**
-        * @throws \OCA\Encryption\Exceptions\PrivateKeyMissingException
+        * @expectedException \OCA\Encryption\Exceptions\PrivateKeyMissingException
+        * @expectedExceptionMessage Private Key missing for user: please try to log-out and log-in again
         */
        public function testThatGetPrivateKeyThrowsExceptionWhenNotSet() {
-               $this->setExpectedException('OCA\Encryption\Exceptions\PrivateKeyMissingException', 'no private key stored in session');
                $this->instance->getPrivateKey();
        }