summaryrefslogtreecommitdiffstats
path: root/apps/encryption/tests
diff options
context:
space:
mode:
authorClark Tomlinson <fallen013@gmail.com>2015-04-06 11:49:18 -0400
committerThomas Müller <thomas.mueller@tmit.eu>2015-04-07 13:30:31 +0200
commit28c801792857efa539720ba7702c24f4df3b9ddd (patch)
tree0d4dfb7b2587bc1ab9d2ab98fdb18f17127feeea /apps/encryption/tests
parentc7c3caedf5a66b5b179978bd54a2539eb632bc54 (diff)
downloadnextcloud-server-28c801792857efa539720ba7702c24f4df3b9ddd.tar.gz
nextcloud-server-28c801792857efa539720ba7702c24f4df3b9ddd.zip
adding recoverFileTest
Diffstat (limited to 'apps/encryption/tests')
-rw-r--r--apps/encryption/tests/lib/RecoveryTest.php45
1 files changed, 43 insertions, 2 deletions
diff --git a/apps/encryption/tests/lib/RecoveryTest.php b/apps/encryption/tests/lib/RecoveryTest.php
index 406c8167026..701762b56d6 100644
--- a/apps/encryption/tests/lib/RecoveryTest.php
+++ b/apps/encryption/tests/lib/RecoveryTest.php
@@ -31,6 +31,10 @@ class RecoveryTest extends TestCase {
/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
+ private $fileMock;
+ /**
+ * @var \PHPUnit_Framework_MockObject_MockObject
+ */
private $viewMock;
/**
* @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);
}