Merge pull request #10439 from eugulixes/improve-encrypt-all-and-decrypt-all-commands

Check if TTY is invalid in encryption:encrypt-all and encryption:decrypt-all
This commit is contained in:
Morris Jobke 2018-10-15 09:15:58 +02:00 committed by GitHub
commit e36d4a990d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 0 deletions

View File

@ -123,6 +123,14 @@ class DecryptAll extends Command {
}
protected function execute(InputInterface $input, OutputInterface $output) {
if ( !$input->isInteractive() ) {
$output->writeln('Invalid TTY.');
$output->writeln('If you are trying to execute the command in a Docker ');
$output->writeln("container, do not forget to execute 'docker exec' with");
$output->writeln("the '-i' and '-t' options.");
$output->writeln('');
return;
}
try {
if ($this->encryptionManager->isEnabled() === true) {

View File

@ -105,6 +105,14 @@ class EncryptAll extends Command {
}
protected function execute(InputInterface $input, OutputInterface $output) {
if ( !$input->isInteractive() ) {
$output->writeln('Invalid TTY.');
$output->writeln('If you are trying to execute the command in a Docker ');
$output->writeln("container, do not forget to execute 'docker exec' with");
$output->writeln("the '-i' and '-t' options.");
$output->writeln('');
return;
}
if ($this->encryptionManager->isEnabled() === false) {
throw new \Exception('Server side encryption is not enabled');

View File

@ -73,6 +73,9 @@ class DecryptAllTest extends TestCase {
$this->decryptAll = $this->getMockBuilder(\OC\Encryption\DecryptAll::class)
->disableOriginalConstructor()->getMock();
$this->consoleInput = $this->getMockBuilder(InputInterface::class)->getMock();
$this->consoleInput->expects($this->any())
->method('isInteractive')
->willReturn(true);
$this->consoleOutput = $this->getMockBuilder(OutputInterface::class)->getMock();
$this->config->expects($this->any())

View File

@ -78,6 +78,9 @@ class EncryptAllTest extends TestCase {
->disableOriginalConstructor()
->getMock();
$this->consoleInput = $this->getMockBuilder(InputInterface::class)->getMock();
$this->consoleInput->expects($this->any())
->method('isInteractive')
->willReturn(true);
$this->consoleOutput = $this->getMockBuilder(OutputInterface::class)->getMock();
}