Merge pull request #16405 from owncloud/enc_add_missing_parameter

add missing parameter to constructor
This commit is contained in:
Joas Schilling 2015-05-18 17:12:48 +02:00
commit b085f58553
3 changed files with 31 additions and 4 deletions

View File

@ -104,7 +104,8 @@ class Application extends \OCP\AppFramework\App {
$container->query('Crypt'),
$container->query('KeyManager'),
$container->query('Util'),
$container->getServer()->getLogger()
$container->getServer()->getLogger(),
$container->getServer()->getL10N($container->getAppName())
);
});

View File

@ -25,10 +25,12 @@
namespace OCA\Encryption\Crypto;
use OC\Encryption\Exceptions\DecryptionFailedException;
use OCA\Encryption\Exceptions\PublicKeyMissingException;
use OCA\Encryption\Util;
use OCP\Encryption\IEncryptionModule;
use OCA\Encryption\KeyManager;
use OCP\IL10N;
use OCP\ILogger;
class Encryption implements IEncryptionModule {
@ -68,25 +70,30 @@ class Encryption implements IEncryptionModule {
/** @var Util */
private $util;
/** @var ILogger */
private $logger;
/** @var IL10N */
private $l;
/**
*
* @param Crypt $crypt
* @param KeyManager $keyManager
* @param Util $util
* @param ILogger $logger
* @param IL10N $il10n
*/
public function __construct(Crypt $crypt,
KeyManager $keyManager,
Util $util,
ILogger $logger) {
ILogger $logger,
IL10N $il10n) {
$this->crypt = $crypt;
$this->keyManager = $keyManager;
$this->util = $util;
$this->logger = $logger;
$this->l = $il10n;
}
/**
@ -268,6 +275,7 @@ class Encryption implements IEncryptionModule {
*
* @param string $data you want to decrypt
* @return mixed decrypted data
* @throws DecryptionFailedException
*/
public function decrypt($data) {
if (empty($this->fileKey)) {

View File

@ -42,6 +42,9 @@ class EncryptionTest extends TestCase {
/** @var \PHPUnit_Framework_MockObject_MockObject */
private $loggerMock;
/** @var \PHPUnit_Framework_MockObject_MockObject */
private $l10nMock;
public function setUp() {
parent::setUp();
@ -57,12 +60,20 @@ class EncryptionTest extends TestCase {
$this->loggerMock = $this->getMockBuilder('OCP\ILogger')
->disableOriginalConstructor()
->getMock();
$this->l10nMock = $this->getMockBuilder('OCP\IL10N')
->disableOriginalConstructor()
->getMock();
$this->l10nMock->expects($this->any())
->method('t')
->with($this->anything())
->willReturnArgument(0);
$this->instance = new Encryption(
$this->cryptMock,
$this->keyManagerMock,
$this->utilMock,
$this->loggerMock
$this->loggerMock,
$this->l10nMock
);
}
@ -245,4 +256,11 @@ class EncryptionTest extends TestCase {
);
}
/**
* @expectedException \OC\Encryption\Exceptions\DecryptionFailedException
* @expectedExceptionMessage Can not decrypt this file, probably this is a shared file. Please ask the file owner to reshare the file with you.
*/
public function testDecrypt() {
$this->instance->decrypt('abc');
}
}