X Tutup
Skip to content

Commit 5fcffe7

Browse files
mrow4aphil-davis
andauthored
occ encryption:encrypt-all should not auto-enable user-key encryption (#40702)
* occ encryption:encrypt-all should not auto-enable user-key encryption * add changelog and tests * Update changelog/unreleased/40702 Co-authored-by: Phil Davis <phil@jankaritech.com> --------- Co-authored-by: Phil Davis <phil@jankaritech.com>
1 parent 8afb5c0 commit 5fcffe7

File tree

3 files changed

+29
-10
lines changed

3 files changed

+29
-10
lines changed

changelog/unreleased/40702

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Change: Do not auto-enable user-key ecryption
2+
3+
Executing occ encryption:encrypt-all will no longer auto-enable user-key encryption.
4+
5+
https://github.com/owncloud/core/pull/40702
6+
https://github.com/owncloud/enterprise/issues/4939
7+
https://doc.owncloud.com/docs/next/server_release_notes.html#deprecation-note-for-user-key-storage-encryption

core/Command/Encryption/EncryptAll.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,7 @@ protected function execute(InputInterface $input, OutputInterface $output) {
115115
$masterKeyEnabled = $this->config->getAppValue('encryption', 'useMasterKey', '');
116116
$userKeyEnabled = $this->config->getAppValue('encryption', 'userSpecificKey', '');
117117
if (($masterKeyEnabled === '') && ($userKeyEnabled === '')) {
118-
/**
119-
* Enable user specific encryption if nothing is enabled.
120-
*/
121-
$this->config->setAppValue('encryption', 'userSpecificKey', '1');
118+
throw new \Exception('None of the encryption modules is enabled');
122119
}
123120

124121
$output->writeln("\n");

tests/Core/Command/Encryption/EncryptAllTest.php

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ protected function setUp(): void {
7171
$this->consoleOutput = $this->createMock('Symfony\Component\Console\Output\OutputInterface');
7272
}
7373

74-
public function testEncryptAll() {
74+
public function testSingleUserAndTrashbin() {
7575
// trash bin needs to be disabled in order to avoid adding dummy files to the users
7676
// trash bin which gets deleted during the encryption process
7777
$this->appManager->expects($this->once())->method('disableApp')->with('files_trashbin');
@@ -99,12 +99,11 @@ public function testExecute($answer, $askResult) {
9999
$this->config->expects($this->any())
100100
->method('getAppValue')
101101
->willReturnMap([
102-
['encryption', 'useMasterKey', '', ''],
102+
['encryption', 'useMasterKey', '', '1'], // enabled
103103
['encryption', 'userSpecificKey', '', '']
104104
]);
105-
$this->config->expects($this->once())
106-
->method('setAppValue')
107-
->willReturn(null);
105+
$this->config->expects($this->never())
106+
->method('setAppValue');
108107

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

128127
/**
129128
*/
130-
public function testExecuteException() {
129+
public function testExecuteEncryptionNotEnabled() {
131130
$this->expectException(\Exception::class);
132131

133132
$command = new EncryptAll($this->encryptionManager, $this->appManager, $this->config, $this->questionHelper);
@@ -136,4 +135,20 @@ public function testExecuteException() {
136135
$this->encryptionModule->expects($this->never())->method('encryptAll');
137136
$this->invokePrivate($command, 'execute', [$this->consoleInput, $this->consoleOutput]);
138137
}
138+
139+
/**
140+
*/
141+
public function testExecuteEncryptionModuleNotEnabled() {
142+
$this->expectException(\Exception::class);
143+
144+
$command = new EncryptAll($this->encryptionManager, $this->appManager, $this->config, $this->questionHelper);
145+
$this->encryptionManager->expects($this->once())->method('isEnabled')->willReturn(true);
146+
$this->config->expects($this->any())
147+
->method('getAppValue')
148+
->willReturnMap([
149+
['encryption', 'useMasterKey', '', ''],
150+
['encryption', 'userSpecificKey', '', '']
151+
]);
152+
$this->invokePrivate($command, 'execute', [$this->consoleInput, $this->consoleOutput]);
153+
}
139154
}

0 commit comments

Comments
 (0)
X Tutup