Move Encryption app to PSR-4 (#24524)
* Move Encryption to PSR-4 * Move encryption tests to PSR-4 * Fix the tests
This commit is contained in:
parent
c5ae14453a
commit
4a3311f430
|
@ -24,6 +24,7 @@ namespace OCA\Encryption\Tests\Command;
|
|||
|
||||
|
||||
use OCA\Encryption\Command\EnableMasterKey;
|
||||
use OCA\Encryption\Util;
|
||||
use Test\TestCase;
|
||||
|
||||
class TestEnableMasterKey extends TestCase {
|
|
@ -28,47 +28,36 @@ use OCP\AppFramework\Http;
|
|||
use Test\TestCase;
|
||||
|
||||
class RecoveryControllerTest extends TestCase {
|
||||
/**
|
||||
* @var RecoveryController
|
||||
*/
|
||||
/** @var RecoveryController */
|
||||
private $controller;
|
||||
private $appName;
|
||||
/**
|
||||
* @var \PHPUnit_Framework_MockObject_MockObject
|
||||
*/
|
||||
/** @var \OCP\IRequest|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $requestMock;
|
||||
/**
|
||||
* @var \PHPUnit_Framework_MockObject_MockObject
|
||||
*/
|
||||
/** @var \OCP\IConfig|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $configMock;
|
||||
/**
|
||||
* @var \PHPUnit_Framework_MockObject_MockObject
|
||||
*/
|
||||
/** @var \OCP\IL10N|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $l10nMock;
|
||||
/**
|
||||
* @var \PHPUnit_Framework_MockObject_MockObject
|
||||
*/
|
||||
/** @var \OCA\Encryption\Recovery|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $recoveryMock;
|
||||
|
||||
public function adminRecoveryProvider() {
|
||||
return [
|
||||
['test', 'test', '1', 'Recovery key successfully enabled', HTTP::STATUS_OK],
|
||||
['', 'test', '1', 'Missing recovery key password', HTTP::STATUS_BAD_REQUEST],
|
||||
['test', '', '1', 'Please repeat the recovery key password', HTTP::STATUS_BAD_REQUEST],
|
||||
['test', 'soimething that doesn\'t match', '1', 'Repeated recovery key password does not match the provided recovery key password', HTTP::STATUS_BAD_REQUEST],
|
||||
['test', 'test', '0', 'Recovery key successfully disabled', HTTP::STATUS_OK],
|
||||
['test', 'test', '1', 'Recovery key successfully enabled', Http::STATUS_OK],
|
||||
['', 'test', '1', 'Missing recovery key password', Http::STATUS_BAD_REQUEST],
|
||||
['test', '', '1', 'Please repeat the recovery key password', Http::STATUS_BAD_REQUEST],
|
||||
['test', 'soimething that doesn\'t match', '1', 'Repeated recovery key password does not match the provided recovery key password', Http::STATUS_BAD_REQUEST],
|
||||
['test', 'test', '0', 'Recovery key successfully disabled', Http::STATUS_OK],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider adminRecoveryProvider
|
||||
* @param $recoveryPassword
|
||||
* @param $passconfirm
|
||||
* @param $passConfirm
|
||||
* @param $enableRecovery
|
||||
* @param $expectedMessage
|
||||
* @param $expectedStatus
|
||||
*/
|
||||
public function testAdminRecovery($recoveryPassword, $passconfirm, $enableRecovery, $expectedMessage, $expectedStatus) {
|
||||
public function testAdminRecovery($recoveryPassword, $passConfirm, $enableRecovery, $expectedMessage, $expectedStatus) {
|
||||
|
||||
|
||||
$this->recoveryMock->expects($this->any())
|
||||
|
@ -80,7 +69,7 @@ class RecoveryControllerTest extends TestCase {
|
|||
->willReturn(true);
|
||||
|
||||
$response = $this->controller->adminRecovery($recoveryPassword,
|
||||
$passconfirm,
|
||||
$passConfirm,
|
||||
$enableRecovery);
|
||||
|
||||
|
||||
|
@ -92,11 +81,11 @@ class RecoveryControllerTest extends TestCase {
|
|||
|
||||
public function changeRecoveryPasswordProvider() {
|
||||
return [
|
||||
['test', 'test', 'oldtestFail', 'Could not change the password. Maybe the old password was not correct.', HTTP::STATUS_BAD_REQUEST],
|
||||
['test', 'test', 'oldtest', 'Password successfully changed.', HTTP::STATUS_OK],
|
||||
['test', 'notmatch', 'oldtest', 'Repeated recovery key password does not match the provided recovery key password', HTTP::STATUS_BAD_REQUEST],
|
||||
['', 'test', 'oldtest', 'Please provide a new recovery password', HTTP::STATUS_BAD_REQUEST],
|
||||
['test', 'test', '', 'Please provide the old recovery password', HTTP::STATUS_BAD_REQUEST]
|
||||
['test', 'test', 'oldtestFail', 'Could not change the password. Maybe the old password was not correct.', Http::STATUS_BAD_REQUEST],
|
||||
['test', 'test', 'oldtest', 'Password successfully changed.', Http::STATUS_OK],
|
||||
['test', 'notmatch', 'oldtest', 'Repeated recovery key password does not match the provided recovery key password', Http::STATUS_BAD_REQUEST],
|
||||
['', 'test', 'oldtest', 'Please provide a new recovery password', Http::STATUS_BAD_REQUEST],
|
||||
['test', 'test', '', 'Please provide the old recovery password', Http::STATUS_BAD_REQUEST]
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -160,8 +149,7 @@ class RecoveryControllerTest extends TestCase {
|
|||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->appName = 'encryption';
|
||||
$this->requestMock = $this->getMockBuilder('\OCP\IRequest')
|
||||
$this->requestMock = $this->getMockBuilder('OCP\IRequest')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
|
@ -182,7 +170,7 @@ class RecoveryControllerTest extends TestCase {
|
|||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$this->controller = new RecoveryController($this->appName,
|
||||
$this->controller = new RecoveryController('encryption',
|
||||
$this->requestMock,
|
||||
$this->configMock,
|
||||
$this->l10nMock,
|
|
@ -32,31 +32,31 @@ class SettingsControllerTest extends TestCase {
|
|||
/** @var SettingsController */
|
||||
private $controller;
|
||||
|
||||
/** @var \PHPUnit_Framework_MockObject_MockObject */
|
||||
/** @var \OCP\IRequest|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $requestMock;
|
||||
|
||||
/** @var \PHPUnit_Framework_MockObject_MockObject */
|
||||
/** @var \OCP\IL10N|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $l10nMock;
|
||||
|
||||
/** @var \PHPUnit_Framework_MockObject_MockObject */
|
||||
/** @var \OCP\IUserManager|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $userManagerMock;
|
||||
|
||||
/** @var \PHPUnit_Framework_MockObject_MockObject */
|
||||
/** @var \OCP\IUserSession|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $userSessionMock;
|
||||
|
||||
/** @var \PHPUnit_Framework_MockObject_MockObject */
|
||||
/** @var \OCA\Encryption\KeyManager|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $keyManagerMock;
|
||||
|
||||
/** @var \PHPUnit_Framework_MockObject_MockObject */
|
||||
/** @var \OCA\Encryption\Crypto\Crypt|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $cryptMock;
|
||||
|
||||
/** @var \PHPUnit_Framework_MockObject_MockObject */
|
||||
/** @var \OCA\Encryption\Session|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $sessionMock;
|
||||
|
||||
/** @var \PHPUnit_Framework_MockObject_MockObject */
|
||||
/** @var \OCP\ISession|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $ocSessionMock;
|
||||
|
||||
/** @var \PHPUnit_Framework_MockObject_MockObject */
|
||||
/** @var \OCA\Encryption\Util|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $utilMock;
|
||||
|
||||
protected function setUp() {
|
||||
|
@ -96,7 +96,7 @@ class SettingsControllerTest extends TestCase {
|
|||
])
|
||||
->getMock();
|
||||
|
||||
$this->ocSessionMock = $this->getMockBuilder('\OCP\ISession')->disableOriginalConstructor()->getMock();
|
||||
$this->ocSessionMock = $this->getMockBuilder('OCP\ISession')->disableOriginalConstructor()->getMock();
|
||||
|
||||
$this->userSessionMock->expects($this->any())
|
||||
->method('getUID')
|
|
@ -29,11 +29,11 @@ use Test\TestCase;
|
|||
|
||||
class StatusControllerTest extends TestCase {
|
||||
|
||||
/** @var \PHPUnit_Framework_MockObject_MockObject */
|
||||
protected $requestMock;
|
||||
/** @var \OCP\IRequest|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $requestMock;
|
||||
|
||||
/** @var \PHPUnit_Framework_MockObject_MockObject */
|
||||
protected $l10nMock;
|
||||
/** @var \OCP\IL10N|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $l10nMock;
|
||||
|
||||
/** @var \OCA\Encryption\Session | \PHPUnit_Framework_MockObject_MockObject */
|
||||
protected $sessionMock;
|
|
@ -22,29 +22,28 @@
|
|||
*/
|
||||
|
||||
|
||||
namespace OCA\Encryption\Tests\lib\Crypto;
|
||||
namespace OCA\Encryption\Tests\Crypto;
|
||||
|
||||
|
||||
use OCA\Encryption\Crypto\Crypt;
|
||||
use Test\TestCase;
|
||||
|
||||
class cryptTest extends TestCase {
|
||||
class CryptTest extends TestCase {
|
||||
|
||||
|
||||
/** @var \PHPUnit_Framework_MockObject_MockObject */
|
||||
/** @var \OCP\ILogger|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $logger;
|
||||
|
||||
/** @var \PHPUnit_Framework_MockObject_MockObject */
|
||||
/** @var \OCP\IUserSession|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $userSession;
|
||||
|
||||
/** @var \PHPUnit_Framework_MockObject_MockObject */
|
||||
/** @var \OCP\IConfig|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $config;
|
||||
|
||||
|
||||
/** @var \PHPUnit_Framework_MockObject_MockObject */
|
||||
/** @var \OCP\IL10N|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $l;
|
||||
|
||||
/** @var Crypt */
|
||||
/** @var Crypt */
|
||||
private $crypt;
|
||||
|
||||
public function setUp() {
|
|
@ -20,7 +20,7 @@
|
|||
*/
|
||||
|
||||
|
||||
namespace OCA\Encryption\Tests\lib\Crypto;
|
||||
namespace OCA\Encryption\Tests\Crypto;
|
||||
|
||||
|
||||
use OCA\Encryption\Crypto\Crypt;
|
|
@ -20,7 +20,7 @@
|
|||
*/
|
||||
|
||||
|
||||
namespace OCA\Encryption\Tests\lib\Crypto;
|
||||
namespace OCA\Encryption\Tests\Crypto;
|
||||
|
||||
|
||||
use OCA\Encryption\Crypto\EncryptAll;
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
namespace OCA\Encryption\Tests\lib\Crypto;
|
||||
namespace OCA\Encryption\Tests\Crypto;
|
||||
|
||||
use OCA\Encryption\Exceptions\PublicKeyMissingException;
|
||||
use Test\TestCase;
|
||||
|
@ -31,31 +31,31 @@ class EncryptionTest extends TestCase {
|
|||
/** @var Encryption */
|
||||
private $instance;
|
||||
|
||||
/** @var \PHPUnit_Framework_MockObject_MockObject */
|
||||
/** @var \OCA\Encryption\KeyManager|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $keyManagerMock;
|
||||
|
||||
/** @var \PHPUnit_Framework_MockObject_MockObject */
|
||||
/** @var \OCA\Encryption\Crypto\EncryptAll|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $encryptAllMock;
|
||||
|
||||
/** @var \PHPUnit_Framework_MockObject_MockObject */
|
||||
/** @var \OCA\Encryption\Crypto\DecryptAll|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $decryptAllMock;
|
||||
|
||||
/** @var \PHPUnit_Framework_MockObject_MockObject */
|
||||
/** @var \OCA\Encryption\Session|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $sessionMock;
|
||||
|
||||
/** @var \PHPUnit_Framework_MockObject_MockObject */
|
||||
/** @var \OCA\Encryption\Crypto\Crypt|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $cryptMock;
|
||||
|
||||
/** @var \PHPUnit_Framework_MockObject_MockObject */
|
||||
/** @var \OCA\Encryption\Util|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $utilMock;
|
||||
|
||||
/** @var \PHPUnit_Framework_MockObject_MockObject */
|
||||
/** @var \OCP\ILogger|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $loggerMock;
|
||||
|
||||
/** @var \PHPUnit_Framework_MockObject_MockObject */
|
||||
/** @var \OCP\IL10N|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $l10nMock;
|
||||
|
||||
/** @var \PHPUnit_Framework_MockObject_MockObject */
|
||||
/** @var \OCP\Files\Storage|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $storageMock;
|
||||
|
||||
public function setUp() {
|
||||
|
@ -410,7 +410,9 @@ class EncryptionTest extends TestCase {
|
|||
}
|
||||
|
||||
public function testPrepareDecryptAll() {
|
||||
/** @var \Symfony\Component\Console\Input\InputInterface $input */
|
||||
$input = $this->getMock('Symfony\Component\Console\Input\InputInterface');
|
||||
/** @var \Symfony\Component\Console\Output\OutputInterface $output */
|
||||
$output = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
|
||||
|
||||
$this->decryptAllMock->expects($this->once())->method('prepare')
|
|
@ -65,6 +65,7 @@ class HookManagerTest extends TestCase {
|
|||
*/
|
||||
public function testRegisterHooksWithInstance() {
|
||||
$mock = $this->getMockBuilder('OCA\Encryption\Hooks\Contracts\IHook')->disableOriginalConstructor()->getMock();
|
||||
/** @var \OCA\Encryption\Hooks\Contracts\IHook $mock */
|
||||
self::$instance->registerHook($mock);
|
||||
|
||||
$hookInstances = self::invokePrivate(self::$instance, 'hookInstances');
|
|
@ -69,6 +69,10 @@ class UserHooksTest extends TestCase {
|
|||
* @var \PHPUnit_Framework_MockObject_MockObject
|
||||
*/
|
||||
private $cryptMock;
|
||||
/**
|
||||
* @var \PHPUnit_Framework_MockObject_MockObject
|
||||
*/
|
||||
private $loggerMock;
|
||||
/**
|
||||
* @var UserHooks
|
||||
*/
|
||||
|
@ -91,15 +95,16 @@ class UserHooksTest extends TestCase {
|
|||
public function testLogout() {
|
||||
$this->sessionMock->expects($this->once())
|
||||
->method('clear');
|
||||
|
||||
$this->assertNull($this->instance->logout());
|
||||
$this->instance->logout();
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
|
||||
public function testPostCreateUser() {
|
||||
$this->userSetupMock->expects($this->once())
|
||||
->method('setupUser');
|
||||
|
||||
$this->assertNull($this->instance->postCreateUser($this->params));
|
||||
$this->instance->postCreateUser($this->params);
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
|
||||
public function testPostDeleteUser() {
|
||||
|
@ -107,7 +112,8 @@ class UserHooksTest extends TestCase {
|
|||
->method('deletePublicKey')
|
||||
->with('testUser');
|
||||
|
||||
$this->assertNull($this->instance->postDeleteUser($this->params));
|
||||
$this->instance->postDeleteUser($this->params);
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -273,6 +279,7 @@ class UserHooksTest extends TestCase {
|
|||
]
|
||||
)->setMethods(['initMountPoints'])->getMock();
|
||||
|
||||
/** @var \OCA\Encryption\Hooks\UserHooks $userHooks */
|
||||
$this->assertNull($userHooks->setPassphrase($this->params));
|
||||
}
|
||||
|
||||
|
@ -285,7 +292,8 @@ class UserHooksTest extends TestCase {
|
|||
->method('setupUser')
|
||||
->with('testUser', 'password');
|
||||
|
||||
$this->assertNull($this->instance->postPasswordReset($this->params));
|
||||
$this->instance->postPasswordReset($this->params);
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
|
||||
protected function setUp() {
|
|
@ -43,25 +43,25 @@ class KeyManagerTest extends TestCase {
|
|||
/** @var string */
|
||||
private $systemKeyId;
|
||||
|
||||
/** @var \PHPUnit_Framework_MockObject_MockObject */
|
||||
/** @var \OCP\Encryption\Keys\IStorage|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $keyStorageMock;
|
||||
|
||||
/** @var \PHPUnit_Framework_MockObject_MockObject */
|
||||
/** @var \OCA\Encryption\Crypto\Crypt|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $cryptMock;
|
||||
|
||||
/** @var \PHPUnit_Framework_MockObject_MockObject */
|
||||
/** @var \OCP\IUserSession|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $userMock;
|
||||
|
||||
/** @var \PHPUnit_Framework_MockObject_MockObject */
|
||||
/** @var \OCA\Encryption\Session|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $sessionMock;
|
||||
|
||||
/** @var \PHPUnit_Framework_MockObject_MockObject */
|
||||
/** @var \OCP\ILogger|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $logMock;
|
||||
|
||||
/** @var \PHPUnit_Framework_MockObject_MockObject */
|
||||
/** @var \OCA\Encryption\Util|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $utilMock;
|
||||
|
||||
/** @var \PHPUnit_Framework_MockObject_MockObject */
|
||||
/** @var \OCP\IConfig|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $configMock;
|
||||
|
||||
public function setUp() {
|
||||
|
@ -245,6 +245,7 @@ class KeyManagerTest extends TestCase {
|
|||
*/
|
||||
public function testInit($useMasterKey) {
|
||||
|
||||
/** @var \OCA\Encryption\KeyManager|\PHPUnit_Framework_MockObject_MockObject $instance */
|
||||
$instance = $this->getMockBuilder('OCA\Encryption\KeyManager')
|
||||
->setConstructorArgs(
|
||||
[
|
||||
|
@ -588,6 +589,7 @@ class KeyManagerTest extends TestCase {
|
|||
->with('/admin/files/myfile.txt')
|
||||
->willReturn(false);
|
||||
|
||||
/** @var \OC\Files\View $view */
|
||||
$this->assertSame(0, $this->instance->getVersion('/admin/files/myfile.txt', $view));
|
||||
}
|
||||
|
||||
|
@ -604,6 +606,7 @@ class KeyManagerTest extends TestCase {
|
|||
->with('/admin/files/myfile.txt')
|
||||
->willReturn($fileInfo);
|
||||
|
||||
/** @var \OC\Files\View $view */
|
||||
$this->assertSame(1337, $this->instance->getVersion('/admin/files/myfile.txt', $view));
|
||||
}
|
||||
|
||||
|
@ -633,6 +636,7 @@ class KeyManagerTest extends TestCase {
|
|||
->with('/admin/files/myfile.txt')
|
||||
->willReturn($fileInfo);
|
||||
|
||||
/** @var \OC\Files\View $view */
|
||||
$this->instance->setVersion('/admin/files/myfile.txt', 5, $view);
|
||||
}
|
||||
|
||||
|
@ -644,6 +648,7 @@ class KeyManagerTest extends TestCase {
|
|||
->with('/admin/files/myfile.txt')
|
||||
->willReturn(false);
|
||||
|
||||
/** @var \OC\Files\View $view */
|
||||
$this->instance->setVersion('/admin/files/myfile.txt', 5, $view);
|
||||
}
|
||||
|
|
@ -39,7 +39,7 @@ class MigrationTest extends \Test\TestCase {
|
|||
private $recovery_key_id = 'recovery_key_id';
|
||||
private $moduleId;
|
||||
|
||||
/** @var PHPUnit_Framework_MockObject_MockObject | ILogger */
|
||||
/** @var \PHPUnit_Framework_MockObject_MockObject | ILogger */
|
||||
private $logger;
|
||||
|
||||
public static function setUpBeforeClass() {
|
|
@ -32,27 +32,27 @@ use Test\TestCase;
|
|||
class RecoveryTest extends TestCase {
|
||||
private static $tempStorage = [];
|
||||
/**
|
||||
* @var \PHPUnit_Framework_MockObject_MockObject
|
||||
* @var \OCP\Encryption\IFile|\PHPUnit_Framework_MockObject_MockObject
|
||||
*/
|
||||
private $fileMock;
|
||||
/**
|
||||
* @var \PHPUnit_Framework_MockObject_MockObject
|
||||
* @var \OC\Files\View|\PHPUnit_Framework_MockObject_MockObject
|
||||
*/
|
||||
private $viewMock;
|
||||
/**
|
||||
* @var \PHPUnit_Framework_MockObject_MockObject
|
||||
* @var \OCP\IUserSession|\PHPUnit_Framework_MockObject_MockObject
|
||||
*/
|
||||
private $userSessionMock;
|
||||
/**
|
||||
* @var \PHPUnit_Framework_MockObject_MockObject
|
||||
* @var \OCA\Encryption\KeyManager|\PHPUnit_Framework_MockObject_MockObject
|
||||
*/
|
||||
private $keyManagerMock;
|
||||
/**
|
||||
* @var \PHPUnit_Framework_MockObject_MockObject
|
||||
* @var \OCP\IConfig|\PHPUnit_Framework_MockObject_MockObject
|
||||
*/
|
||||
private $configMock;
|
||||
/**
|
||||
* @var \PHPUnit_Framework_MockObject_MockObject
|
||||
* @var \OCA\Encryption\Crypto\Crypt|\PHPUnit_Framework_MockObject_MockObject
|
||||
*/
|
||||
private $cryptMock;
|
||||
/**
|
||||
|
@ -201,7 +201,8 @@ class RecoveryTest extends TestCase {
|
|||
|
||||
$this->cryptMock->expects($this->once())
|
||||
->method('decryptPrivateKey');
|
||||
$this->assertNull($this->instance->recoverUsersFiles('password', 'admin'));
|
||||
$this->instance->recoverUsersFiles('password', 'admin');
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
|
||||
public function testRecoverFile() {
|
||||
|
@ -265,9 +266,11 @@ class RecoveryTest extends TestCase {
|
|||
->will($this->returnSelf());
|
||||
|
||||
$this->cryptMock = $this->getMockBuilder('OCA\Encryption\Crypto\Crypt')->disableOriginalConstructor()->getMock();
|
||||
/** @var \OCP\Security\ISecureRandom $randomMock */
|
||||
$randomMock = $this->getMock('OCP\Security\ISecureRandom');
|
||||
$this->keyManagerMock = $this->getMockBuilder('OCA\Encryption\KeyManager')->disableOriginalConstructor()->getMock();
|
||||
$this->configMock = $this->getMock('OCP\IConfig');
|
||||
/** @var \OCP\Encryption\Keys\IStorage $keyStorageMock */
|
||||
$keyStorageMock = $this->getMock('OCP\Encryption\Keys\IStorage');
|
||||
$this->fileMock = $this->getMock('OCP\Encryption\IFile');
|
||||
$this->viewMock = $this->getMock('OC\Files\View');
|
|
@ -34,6 +34,7 @@ class SessionTest extends TestCase {
|
|||
* @var Session
|
||||
*/
|
||||
private $instance;
|
||||
/** @var \OCP\ISession|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $sessionMock;
|
||||
|
||||
/**
|
|
@ -29,11 +29,11 @@ use Test\TestCase;
|
|||
|
||||
class SetupTest extends TestCase {
|
||||
/**
|
||||
* @var \PHPUnit_Framework_MockObject_MockObject
|
||||
* @var \OCA\Encryption\KeyManager|\PHPUnit_Framework_MockObject_MockObject
|
||||
*/
|
||||
private $keyManagerMock;
|
||||
/**
|
||||
* @var \PHPUnit_Framework_MockObject_MockObject
|
||||
* @var \OCA\Encryption\Crypto\Crypt|\PHPUnit_Framework_MockObject_MockObject
|
||||
*/
|
||||
private $cryptMock;
|
||||
/**
|
||||
|
@ -55,6 +55,8 @@ class SetupTest extends TestCase {
|
|||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
/** @var \OCP\ILogger $logMock */
|
||||
/** @var \OCP\IUserSession $userSessionMock */
|
||||
$this->instance = new Setup($logMock,
|
||||
$userSessionMock,
|
||||
$this->cryptMock,
|
|
@ -30,16 +30,16 @@ use Test\TestCase;
|
|||
class UtilTest extends TestCase {
|
||||
private static $tempStorage = [];
|
||||
|
||||
/** @var \PHPUnit_Framework_MockObject_MockObject */
|
||||
/** @var \OCP\IConfig|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $configMock;
|
||||
|
||||
/** @var \PHPUnit_Framework_MockObject_MockObject */
|
||||
/** @var \OC\Files\View|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $filesMock;
|
||||
|
||||
/** @var \PHPUnit_Framework_MockObject_MockObject */
|
||||
/** @var \OCP\IUserManager|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $userManagerMock;
|
||||
|
||||
/** @var \PHPUnit_Framework_MockObject_MockObject */
|
||||
/** @var \OCP\Files\Mount\IMountPoint|\PHPUnit_Framework_MockObject_MockObject */
|
||||
private $mountMock;
|
||||
|
||||
/** @var Util */
|
||||
|
@ -72,10 +72,13 @@ class UtilTest extends TestCase {
|
|||
$this->filesMock = $this->getMock('OC\Files\View');
|
||||
$this->userManagerMock = $this->getMock('\OCP\IUserManager');
|
||||
|
||||
/** @var \OCA\Encryption\Crypto\Crypt $cryptMock */
|
||||
$cryptMock = $this->getMockBuilder('OCA\Encryption\Crypto\Crypt')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
/** @var \OCP\ILogger $loggerMock */
|
||||
$loggerMock = $this->getMock('OCP\ILogger');
|
||||
/** @var \OCP\IUserSession|\PHPUnit_Framework_MockObject_MockObject $userSessionMock */
|
||||
$userSessionMock = $this->getMockBuilder('OCP\IUserSession')
|
||||
->disableOriginalConstructor()
|
||||
->setMethods([
|
||||
|
@ -97,7 +100,7 @@ class UtilTest extends TestCase {
|
|||
->will($this->returnSelf());
|
||||
|
||||
|
||||
$this->configMock = $configMock = $this->getMock('OCP\IConfig');
|
||||
$this->configMock = $this->getMock('OCP\IConfig');
|
||||
|
||||
$this->configMock->expects($this->any())
|
||||
->method('getUserValue')
|
||||
|
@ -107,7 +110,7 @@ class UtilTest extends TestCase {
|
|||
->method('setUserValue')
|
||||
->will($this->returnCallback([$this, 'setValueTester']));
|
||||
|
||||
$this->instance = new Util($this->filesMock, $cryptMock, $loggerMock, $userSessionMock, $configMock, $this->userManagerMock);
|
||||
$this->instance = new Util($this->filesMock, $cryptMock, $loggerMock, $userSessionMock, $this->configMock, $this->userManagerMock);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -157,8 +160,8 @@ class UtilTest extends TestCase {
|
|||
|
||||
/**
|
||||
* @dataProvider dataTestShouldEncryptHomeStorage
|
||||
* @param $returnValue return value from getAppValue()
|
||||
* @param $expected
|
||||
* @param string $returnValue return value from getAppValue()
|
||||
* @param bool $expected
|
||||
*/
|
||||
public function testShouldEncryptHomeStorage($returnValue, $expected) {
|
||||
$this->configMock->expects($this->once())->method('getAppValue')
|
||||
|
@ -195,12 +198,16 @@ class UtilTest extends TestCase {
|
|||
}
|
||||
|
||||
public function testGetStorage() {
|
||||
$return = $this->getMockBuilder('OC\Files\Storage\Storage')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$path = '/foo/bar.txt';
|
||||
$this->filesMock->expects($this->once())->method('getMount')->with($path)
|
||||
->willReturn($this->mountMock);
|
||||
$this->mountMock->expects($this->once())->method('getStorage')->willReturn(true);
|
||||
$this->mountMock->expects($this->once())->method('getStorage')->willReturn($return);
|
||||
|
||||
$this->assertTrue($this->instance->getStorage($path));
|
||||
$this->assertEquals($return, $this->instance->getStorage($path));
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue