Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions changelog/unreleased/40702
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Change: Do not auto-enable user-key ecryption

Executing occ encryption:encrypt-all will no longer auto-enable user-key encryption.

https://github.com/owncloud/core/pull/40702
https://github.com/owncloud/enterprise/issues/4939
https://doc.owncloud.com/docs/next/server_release_notes.html#deprecation-note-for-user-key-storage-encryption
5 changes: 1 addition & 4 deletions core/Command/Encryption/EncryptAll.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,7 @@ protected function execute(InputInterface $input, OutputInterface $output) {
$masterKeyEnabled = $this->config->getAppValue('encryption', 'useMasterKey', '');
$userKeyEnabled = $this->config->getAppValue('encryption', 'userSpecificKey', '');
if (($masterKeyEnabled === '') && ($userKeyEnabled === '')) {
/**
* Enable user specific encryption if nothing is enabled.
*/
$this->config->setAppValue('encryption', 'userSpecificKey', '1');
throw new \Exception('None of the encryption modules is enabled');
}

$output->writeln("\n");
Expand Down
27 changes: 21 additions & 6 deletions tests/Core/Command/Encryption/EncryptAllTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ protected function setUp(): void {
$this->consoleOutput = $this->createMock('Symfony\Component\Console\Output\OutputInterface');
}

public function testEncryptAll() {
public function testSingleUserAndTrashbin() {
// trash bin needs to be disabled in order to avoid adding dummy files to the users
// trash bin which gets deleted during the encryption process
$this->appManager->expects($this->once())->method('disableApp')->with('files_trashbin');
Expand Down Expand Up @@ -99,12 +99,11 @@ public function testExecute($answer, $askResult) {
$this->config->expects($this->any())
->method('getAppValue')
->willReturnMap([
['encryption', 'useMasterKey', '', ''],
['encryption', 'useMasterKey', '', '1'], // enabled
['encryption', 'userSpecificKey', '', '']
]);
$this->config->expects($this->once())
->method('setAppValue')
->willReturn(null);
$this->config->expects($this->never())
->method('setAppValue');

if ($answer === 'Y' || $answer === 'y') {
$this->encryptionManager->expects($this->once())
Expand All @@ -127,7 +126,7 @@ public function dataTestExecute() {

/**
*/
public function testExecuteException() {
public function testExecuteEncryptionNotEnabled() {
$this->expectException(\Exception::class);

$command = new EncryptAll($this->encryptionManager, $this->appManager, $this->config, $this->questionHelper);
Expand All @@ -136,4 +135,20 @@ public function testExecuteException() {
$this->encryptionModule->expects($this->never())->method('encryptAll');
$this->invokePrivate($command, 'execute', [$this->consoleInput, $this->consoleOutput]);
}

/**
*/
public function testExecuteEncryptionModuleNotEnabled() {
$this->expectException(\Exception::class);

$command = new EncryptAll($this->encryptionManager, $this->appManager, $this->config, $this->questionHelper);
$this->encryptionManager->expects($this->once())->method('isEnabled')->willReturn(true);
$this->config->expects($this->any())
->method('getAppValue')
->willReturnMap([
['encryption', 'useMasterKey', '', ''],
['encryption', 'userSpecificKey', '', '']
]);
$this->invokePrivate($command, 'execute', [$this->consoleInput, $this->consoleOutput]);
}
}