aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/encryption/appinfo/application.php3
-rw-r--r--apps/encryption/lib/crypto/encryption.php12
-rw-r--r--apps/encryption/tests/lib/crypto/encryptionTest.php20
3 files changed, 31 insertions, 4 deletions
diff --git a/apps/encryption/appinfo/application.php b/apps/encryption/appinfo/application.php
index 79b2ad3abaf..10ad610cd4a 100644
--- a/apps/encryption/appinfo/application.php
+++ b/apps/encryption/appinfo/application.php
@@ -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())
);
});
diff --git a/apps/encryption/lib/crypto/encryption.php b/apps/encryption/lib/crypto/encryption.php
index c060bb04e53..df3f9a0997e 100644
--- a/apps/encryption/lib/crypto/encryption.php
+++ b/apps/encryption/lib/crypto/encryption.php
@@ -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)) {
diff --git a/apps/encryption/tests/lib/crypto/encryptionTest.php b/apps/encryption/tests/lib/crypto/encryptionTest.php
index 960ed112488..d33aff877bf 100644
--- a/apps/encryption/tests/lib/crypto/encryptionTest.php
+++ b/apps/encryption/tests/lib/crypto/encryptionTest.php
@@ -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');
+ }
}