]> source.dussan.org Git - nextcloud-server.git/commitdiff
adding recoverFileTest
authorClark Tomlinson <fallen013@gmail.com>
Mon, 6 Apr 2015 15:49:18 +0000 (11:49 -0400)
committerThomas Müller <thomas.mueller@tmit.eu>
Tue, 7 Apr 2015 11:30:31 +0000 (13:30 +0200)
apps/encryption/tests/lib/RecoveryTest.php

index 406c8167026ae0fa11a219e0d6fd64777ab51dbd..701762b56d6a1070ff174c013c2ba9d2efc2eff9 100644 (file)
@@ -28,6 +28,10 @@ use Test\TestCase;
 
 class RecoveryTest extends TestCase {
        private static $tempStorage = [];
+       /**
+        * @var \PHPUnit_Framework_MockObject_MockObject
+        */
+       private $fileMock;
        /**
         * @var \PHPUnit_Framework_MockObject_MockObject
         */
@@ -143,6 +147,43 @@ class RecoveryTest extends TestCase {
                        'admin'));
        }
 
+       public function testRecoverFile() {
+               $this->keyManagerMock->expects($this->once())
+                       ->method('getEncryptedFileKey')
+                       ->willReturn(true);
+
+               $this->keyManagerMock->expects($this->once())
+                       ->method('getShareKey')
+                       ->willReturn(true);
+
+               $this->cryptMock->expects($this->once())
+                       ->method('multiKeyDecrypt')
+                       ->willReturn(true);
+
+               $this->fileMock->expects($this->once())
+                       ->method('getAccessList')
+                       ->willReturn(['users' => ['admin']]);
+
+               $this->keyManagerMock->expects($this->once())
+                       ->method('getPublicKey')
+                       ->willReturn('publicKey');
+
+               $this->keyManagerMock->expects($this->once())
+                       ->method('addSystemKeys')
+                       ->willReturn(['admin' => 'publicKey']);
+
+
+               $this->cryptMock->expects($this->once())
+                       ->method('multiKeyEncrypt');
+
+               $this->keyManagerMock->expects($this->once())
+                       ->method('setAllFileKeys');
+
+               $this->assertNull(\Test_Helper::invokePrivate($this->instance,
+                       'recoverFile',
+                       ['/', 'testkey']));
+       }
+
        protected function setUp() {
                parent::setUp();
 
@@ -170,7 +211,7 @@ class RecoveryTest extends TestCase {
                $this->keyManagerMock = $this->getMockBuilder('OCA\Encryption\KeyManager')->disableOriginalConstructor()->getMock();
                $this->configMock = $this->getMock('OCP\IConfig');
                $keyStorageMock = $this->getMock('OCP\Encryption\Keys\IStorage');
-               $fileMock = $this->getMock('OCP\Encryption\IFile');
+               $this->fileMock = $this->getMock('OCP\Encryption\IFile');
                $this->viewMock = $this->getMock('OC\Files\View');
 
                $this->configMock->expects($this->any())
@@ -187,7 +228,7 @@ class RecoveryTest extends TestCase {
                        $this->keyManagerMock,
                        $this->configMock,
                        $keyStorageMock,
-                       $fileMock,
+                       $this->fileMock,
                        $this->viewMock);
        }