summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2015-09-24 14:51:38 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2015-09-24 14:51:38 +0200
commit383f381489c58a309cfd37405aa71ecb192a6f91 (patch)
tree1174626e6276998f531556b331618a04a6df501a
parent594a31d260451d237a864f9f679c14c17d183ad4 (diff)
parentd697ea58a42920518d5dbe30d41098cdd3f4b7d7 (diff)
downloadnextcloud-server-383f381489c58a309cfd37405aa71ecb192a6f91.tar.gz
nextcloud-server-383f381489c58a309cfd37405aa71ecb192a6f91.zip
Merge pull request #19340 from owncloud/enc_fix_user_check
only check if the user exists if a user was added as parameter
-rw-r--r--lib/private/encryption/decryptall.php2
-rw-r--r--tests/lib/encryption/decryptalltest.php16
2 files changed, 11 insertions, 7 deletions
diff --git a/lib/private/encryption/decryptall.php b/lib/private/encryption/decryptall.php
index 1ff9c74ef84..c1875f16abd 100644
--- a/lib/private/encryption/decryptall.php
+++ b/lib/private/encryption/decryptall.php
@@ -80,7 +80,7 @@ class DecryptAll {
$this->input = $input;
$this->output = $output;
- if ($user !== '' && $this->userManager->userExists($user) === false) {
+ if (!empty($user) && $this->userManager->userExists($user) === false) {
$this->output->writeln('User "' . $user . '" does not exist. Please check the username and try again');
return false;
}
diff --git a/tests/lib/encryption/decryptalltest.php b/tests/lib/encryption/decryptalltest.php
index c2a0711c0a0..ce5bcf1e5ae 100644
--- a/tests/lib/encryption/decryptalltest.php
+++ b/tests/lib/encryption/decryptalltest.php
@@ -82,11 +82,13 @@ class DecryptAllTest extends TestCase {
* @dataProvider dataTrueFalse
* @param bool $prepareResult
*/
- public function testDecryptAll($prepareResult) {
+ public function testDecryptAll($prepareResult, $user) {
- $user = 'user1';
-
- $this->userManager->expects($this->once())->method('userExists')->willReturn(true);
+ if (!empty($user)) {
+ $this->userManager->expects($this->once())->method('userExists')->willReturn(true);
+ } else {
+ $this->userManager->expects($this->never())->method('userExists');
+ }
/** @var DecryptAll | \PHPUnit_Framework_MockObject_MockObject | $instance */
$instance = $this->getMockBuilder('OC\Encryption\DecryptAll')
->setConstructorArgs(
@@ -117,8 +119,10 @@ class DecryptAllTest extends TestCase {
public function dataTrueFalse() {
return [
- [true],
- [false]
+ [true, 'user1'],
+ [false, 'user1'],
+ [true, ''],
+ [true, null]
];
}