Browse Source

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
pull/11792/merge
Morris Jobke 8 years ago
committed by GitHub
parent
commit
e36d4a990d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      core/Command/Encryption/DecryptAll.php
  2. 8
      core/Command/Encryption/EncryptAll.php
  3. 3
      tests/Core/Command/Encryption/DecryptAllTest.php
  4. 3
      tests/Core/Command/Encryption/EncryptAllTest.php

8
core/Command/Encryption/DecryptAll.php

@ -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) {

8
core/Command/Encryption/EncryptAll.php

@ -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');

3
tests/Core/Command/Encryption/DecryptAllTest.php

@ -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())

3
tests/Core/Command/Encryption/EncryptAllTest.php

@ -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();
}

Loading…
Cancel
Save