Skip to content

Commit

Permalink
Add re-login information after successfully recreating masterkey
Browse files Browse the repository at this point in the history
After successful re-creation of masterkey, its always
better to let user know that one needs to re-login.

Signed-off-by: Sujith H <[email protected]>
  • Loading branch information
sharidas committed Feb 22, 2019
1 parent 09b2b51 commit 326a738
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/Command/RecreateMasterKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ protected function execute(InputInterface $input, OutputInterface $output) {
$this->keyManager->validateMasterKey();
$this->encryptAllUsers($input, $output);
$output->writeln("\nEncryption completed successfully\n");
$output->writeln("\n<info>Note: All users are required to relogin.</info>\n");
} else {
$output->writeln("The process is abandoned");
}
Expand Down
13 changes: 10 additions & 3 deletions tests/unit/Command/RecreateMasterKeyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,17 +193,24 @@ function ($path) {
->with('user1')
->willReturn(true);

global $outputText;
$outputText = '';
$reloginText = '';

$this->output->expects($this->at(16))
->method('writeln')
->willReturnCallback(function ($value) {
global $outputText;
->willReturnCallback(function ($value) use (&$outputText) {
$outputText .= $value . "\n";
});

$this->output->expects($this->at(17))
->method('writeln')
->willReturnCallback(function ($value) use (&$reloginText) {
$reloginText = $value;
});

$this->invokePrivate($this->recreateMasterKey, 'execute', [$this->input, $this->output]);
$this->assertSame("Encryption completed successfully", \trim($outputText, "\n"));
$this->assertEquals("\n<info>Note: All users are required to relogin.</info>\n", $reloginText);
$outputText="";
} else {
$this->recreateMasterKey = $this->getMockBuilder('OCA\Encryption\Command\RecreateMasterKey')
Expand Down

0 comments on commit 326a738

Please sign in to comment.