Merge pull request #16405 from owncloud/enc_add_missing_parameter
add missing parameter to constructor
This commit is contained in:
commit
b085f58553
|
@ -104,7 +104,8 @@ class Application extends \OCP\AppFramework\App {
|
||||||
$container->query('Crypt'),
|
$container->query('Crypt'),
|
||||||
$container->query('KeyManager'),
|
$container->query('KeyManager'),
|
||||||
$container->query('Util'),
|
$container->query('Util'),
|
||||||
$container->getServer()->getLogger()
|
$container->getServer()->getLogger(),
|
||||||
|
$container->getServer()->getL10N($container->getAppName())
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -25,10 +25,12 @@
|
||||||
namespace OCA\Encryption\Crypto;
|
namespace OCA\Encryption\Crypto;
|
||||||
|
|
||||||
|
|
||||||
|
use OC\Encryption\Exceptions\DecryptionFailedException;
|
||||||
use OCA\Encryption\Exceptions\PublicKeyMissingException;
|
use OCA\Encryption\Exceptions\PublicKeyMissingException;
|
||||||
use OCA\Encryption\Util;
|
use OCA\Encryption\Util;
|
||||||
use OCP\Encryption\IEncryptionModule;
|
use OCP\Encryption\IEncryptionModule;
|
||||||
use OCA\Encryption\KeyManager;
|
use OCA\Encryption\KeyManager;
|
||||||
|
use OCP\IL10N;
|
||||||
use OCP\ILogger;
|
use OCP\ILogger;
|
||||||
|
|
||||||
class Encryption implements IEncryptionModule {
|
class Encryption implements IEncryptionModule {
|
||||||
|
@ -68,25 +70,30 @@ class Encryption implements IEncryptionModule {
|
||||||
/** @var Util */
|
/** @var Util */
|
||||||
private $util;
|
private $util;
|
||||||
|
|
||||||
|
|
||||||
/** @var ILogger */
|
/** @var ILogger */
|
||||||
private $logger;
|
private $logger;
|
||||||
|
|
||||||
|
/** @var IL10N */
|
||||||
|
private $l;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param Crypt $crypt
|
* @param Crypt $crypt
|
||||||
* @param KeyManager $keyManager
|
* @param KeyManager $keyManager
|
||||||
* @param Util $util
|
* @param Util $util
|
||||||
* @param ILogger $logger
|
* @param ILogger $logger
|
||||||
|
* @param IL10N $il10n
|
||||||
*/
|
*/
|
||||||
public function __construct(Crypt $crypt,
|
public function __construct(Crypt $crypt,
|
||||||
KeyManager $keyManager,
|
KeyManager $keyManager,
|
||||||
Util $util,
|
Util $util,
|
||||||
ILogger $logger) {
|
ILogger $logger,
|
||||||
|
IL10N $il10n) {
|
||||||
$this->crypt = $crypt;
|
$this->crypt = $crypt;
|
||||||
$this->keyManager = $keyManager;
|
$this->keyManager = $keyManager;
|
||||||
$this->util = $util;
|
$this->util = $util;
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
|
$this->l = $il10n;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -268,6 +275,7 @@ class Encryption implements IEncryptionModule {
|
||||||
*
|
*
|
||||||
* @param string $data you want to decrypt
|
* @param string $data you want to decrypt
|
||||||
* @return mixed decrypted data
|
* @return mixed decrypted data
|
||||||
|
* @throws DecryptionFailedException
|
||||||
*/
|
*/
|
||||||
public function decrypt($data) {
|
public function decrypt($data) {
|
||||||
if (empty($this->fileKey)) {
|
if (empty($this->fileKey)) {
|
||||||
|
|
|
@ -42,6 +42,9 @@ class EncryptionTest extends TestCase {
|
||||||
/** @var \PHPUnit_Framework_MockObject_MockObject */
|
/** @var \PHPUnit_Framework_MockObject_MockObject */
|
||||||
private $loggerMock;
|
private $loggerMock;
|
||||||
|
|
||||||
|
/** @var \PHPUnit_Framework_MockObject_MockObject */
|
||||||
|
private $l10nMock;
|
||||||
|
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
|
@ -57,12 +60,20 @@ class EncryptionTest extends TestCase {
|
||||||
$this->loggerMock = $this->getMockBuilder('OCP\ILogger')
|
$this->loggerMock = $this->getMockBuilder('OCP\ILogger')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->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->instance = new Encryption(
|
||||||
$this->cryptMock,
|
$this->cryptMock,
|
||||||
$this->keyManagerMock,
|
$this->keyManagerMock,
|
||||||
$this->utilMock,
|
$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');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue