adding recoverFileTest
This commit is contained in:
parent
c7c3caedf5
commit
28c8017928
|
@ -28,6 +28,10 @@ use Test\TestCase;
|
||||||
|
|
||||||
class RecoveryTest extends TestCase {
|
class RecoveryTest extends TestCase {
|
||||||
private static $tempStorage = [];
|
private static $tempStorage = [];
|
||||||
|
/**
|
||||||
|
* @var \PHPUnit_Framework_MockObject_MockObject
|
||||||
|
*/
|
||||||
|
private $fileMock;
|
||||||
/**
|
/**
|
||||||
* @var \PHPUnit_Framework_MockObject_MockObject
|
* @var \PHPUnit_Framework_MockObject_MockObject
|
||||||
*/
|
*/
|
||||||
|
@ -143,6 +147,43 @@ class RecoveryTest extends TestCase {
|
||||||
'admin'));
|
'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() {
|
protected function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
|
@ -170,7 +211,7 @@ class RecoveryTest extends TestCase {
|
||||||
$this->keyManagerMock = $this->getMockBuilder('OCA\Encryption\KeyManager')->disableOriginalConstructor()->getMock();
|
$this->keyManagerMock = $this->getMockBuilder('OCA\Encryption\KeyManager')->disableOriginalConstructor()->getMock();
|
||||||
$this->configMock = $this->getMock('OCP\IConfig');
|
$this->configMock = $this->getMock('OCP\IConfig');
|
||||||
$keyStorageMock = $this->getMock('OCP\Encryption\Keys\IStorage');
|
$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->viewMock = $this->getMock('OC\Files\View');
|
||||||
|
|
||||||
$this->configMock->expects($this->any())
|
$this->configMock->expects($this->any())
|
||||||
|
@ -187,7 +228,7 @@ class RecoveryTest extends TestCase {
|
||||||
$this->keyManagerMock,
|
$this->keyManagerMock,
|
||||||
$this->configMock,
|
$this->configMock,
|
||||||
$keyStorageMock,
|
$keyStorageMock,
|
||||||
$fileMock,
|
$this->fileMock,
|
||||||
$this->viewMock);
|
$this->viewMock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue