summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2015-09-21 16:06:43 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2015-09-21 16:06:43 +0200
commitd8901cf7cd822b5c4323618527aafc687ee6c341 (patch)
treedd952ade1291d46bf3cb60fd55df82e0728b7e80
parentb23a5e6886e75a2d5b1a058b91c4ee2e89bb2635 (diff)
parentd2e90b6050d1c26cb365c81e987ccc1577ae56d0 (diff)
downloadnextcloud-server-d8901cf7cd822b5c4323618527aafc687ee6c341.tar.gz
nextcloud-server-d8901cf7cd822b5c4323618527aafc687ee6c341.zip
Merge pull request #19221 from owncloud/improved_error_messages
decrypt-all: improved error message if user doesn't exists
-rw-r--r--lib/private/encryption/decryptall.php5
-rw-r--r--tests/lib/encryption/decryptalltest.php15
2 files changed, 20 insertions, 0 deletions
diff --git a/lib/private/encryption/decryptall.php b/lib/private/encryption/decryptall.php
index e59be17886d..1ff9c74ef84 100644
--- a/lib/private/encryption/decryptall.php
+++ b/lib/private/encryption/decryptall.php
@@ -80,6 +80,11 @@ class DecryptAll {
$this->input = $input;
$this->output = $output;
+ if ($user !== '' && $this->userManager->userExists($user) === false) {
+ $this->output->writeln('User "' . $user . '" does not exist. Please check the username and try again');
+ return false;
+ }
+
$this->output->writeln('prepare encryption modules...');
if ($this->prepareEncryptionModules($user) === false) {
return false;
diff --git a/tests/lib/encryption/decryptalltest.php b/tests/lib/encryption/decryptalltest.php
index eb3bc721f86..c2a0711c0a0 100644
--- a/tests/lib/encryption/decryptalltest.php
+++ b/tests/lib/encryption/decryptalltest.php
@@ -80,11 +80,13 @@ class DecryptAllTest extends TestCase {
/**
* @dataProvider dataTrueFalse
+ * @param bool $prepareResult
*/
public function testDecryptAll($prepareResult) {
$user = 'user1';
+ $this->userManager->expects($this->once())->method('userExists')->willReturn(true);
/** @var DecryptAll | \PHPUnit_Framework_MockObject_MockObject | $instance */
$instance = $this->getMockBuilder('OC\Encryption\DecryptAll')
->setConstructorArgs(
@@ -121,6 +123,19 @@ class DecryptAllTest extends TestCase {
}
/**
+ * test decrypt all call with a user who doesn't exists
+ */
+ public function testDecryptAllWrongUser() {
+ $this->userManager->expects($this->once())->method('userExists')->willReturn(false);
+ $this->outputInterface->expects($this->once())->method('writeln')
+ ->with('User "user1" does not exist. Please check the username and try again');
+
+ $this->assertFalse(
+ $this->instance->decryptAll($this->inputInterface, $this->outputInterface, 'user1')
+ );
+ }
+
+ /**
* @dataProvider dataTrueFalse
*/
public function testPrepareEncryptionModules($success) {