Allow to decrypt user '0' files only
This commit is contained in:
parent
60e15e934c
commit
4f27c2c433
|
@ -111,7 +111,8 @@ class DecryptAll extends Command {
|
||||||
$this->addArgument(
|
$this->addArgument(
|
||||||
'user',
|
'user',
|
||||||
InputArgument::OPTIONAL,
|
InputArgument::OPTIONAL,
|
||||||
'user for which you want to decrypt all files (optional)'
|
'user for which you want to decrypt all files (optional)',
|
||||||
|
''
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,7 @@ class DecryptAll {
|
||||||
$this->input = $input;
|
$this->input = $input;
|
||||||
$this->output = $output;
|
$this->output = $output;
|
||||||
|
|
||||||
if (!empty($user) && $this->userManager->userExists($user) === false) {
|
if ($user !== '' && $this->userManager->userExists($user) === false) {
|
||||||
$this->output->writeln('User "' . $user . '" does not exist. Please check the username and try again');
|
$this->output->writeln('User "' . $user . '" does not exist. Please check the username and try again');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -141,7 +141,7 @@ class DecryptAll {
|
||||||
$this->output->writeln("\n");
|
$this->output->writeln("\n");
|
||||||
|
|
||||||
$userList = [];
|
$userList = [];
|
||||||
if (empty($user)) {
|
if ($user === '') {
|
||||||
|
|
||||||
$fetchUsersProgress = new ProgressBar($this->output);
|
$fetchUsersProgress = new ProgressBar($this->output);
|
||||||
$fetchUsersProgress->setFormat(" %message% \n [%bar%]");
|
$fetchUsersProgress->setFormat(" %message% \n [%bar%]");
|
||||||
|
|
|
@ -86,13 +86,25 @@ class DecryptAllTest extends TestCase {
|
||||||
$this->invokePrivate($this->instance, 'output', [$this->outputInterface]);
|
$this->invokePrivate($this->instance, 'output', [$this->outputInterface]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function dataDecryptAll() {
|
||||||
* @dataProvider dataTrueFalse
|
return [
|
||||||
* @param bool $prepareResult
|
[true, 'user1', true],
|
||||||
*/
|
[false, 'user1', true],
|
||||||
public function testDecryptAll($prepareResult, $user) {
|
[true, '0', true],
|
||||||
|
[false, '0', true],
|
||||||
|
[true, '', false],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($user)) {
|
/**
|
||||||
|
* @dataProvider dataDecryptAll
|
||||||
|
* @param bool $prepareResult
|
||||||
|
* @param string $user
|
||||||
|
* @param bool $userExistsChecked
|
||||||
|
*/
|
||||||
|
public function testDecryptAll($prepareResult, $user, $userExistsChecked) {
|
||||||
|
|
||||||
|
if ($userExistsChecked) {
|
||||||
$this->userManager->expects($this->once())->method('userExists')->willReturn(true);
|
$this->userManager->expects($this->once())->method('userExists')->willReturn(true);
|
||||||
} else {
|
} else {
|
||||||
$this->userManager->expects($this->never())->method('userExists');
|
$this->userManager->expects($this->never())->method('userExists');
|
||||||
|
@ -125,15 +137,6 @@ class DecryptAllTest extends TestCase {
|
||||||
$instance->decryptAll($this->inputInterface, $this->outputInterface, $user);
|
$instance->decryptAll($this->inputInterface, $this->outputInterface, $user);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function dataTrueFalse() {
|
|
||||||
return [
|
|
||||||
[true, 'user1'],
|
|
||||||
[false, 'user1'],
|
|
||||||
[true, ''],
|
|
||||||
[true, null]
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test decrypt all call with a user who doesn't exists
|
* test decrypt all call with a user who doesn't exists
|
||||||
*/
|
*/
|
||||||
|
@ -147,8 +150,16 @@ class DecryptAllTest extends TestCase {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function dataTrueFalse() {
|
||||||
|
return [
|
||||||
|
[true],
|
||||||
|
[false],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider dataTrueFalse
|
* @dataProvider dataTrueFalse
|
||||||
|
* @param bool $success
|
||||||
*/
|
*/
|
||||||
public function testPrepareEncryptionModules($success) {
|
public function testPrepareEncryptionModules($success) {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue