From 326a73827c11301fab22077ff2ae292223274762 Mon Sep 17 00:00:00 2001 From: Sujith H Date: Thu, 21 Feb 2019 14:07:14 +0530 Subject: [PATCH] Add re-login information after successfully recreating masterkey After successful re-creation of masterkey, its always better to let user know that one needs to re-login. Signed-off-by: Sujith H --- lib/Command/RecreateMasterKey.php | 1 + tests/unit/Command/RecreateMasterKeyTest.php | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/Command/RecreateMasterKey.php b/lib/Command/RecreateMasterKey.php index b9890895..c499433c 100644 --- a/lib/Command/RecreateMasterKey.php +++ b/lib/Command/RecreateMasterKey.php @@ -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("\nNote: All users are required to relogin.\n"); } else { $output->writeln("The process is abandoned"); } diff --git a/tests/unit/Command/RecreateMasterKeyTest.php b/tests/unit/Command/RecreateMasterKeyTest.php index ead060b3..5bdce689 100644 --- a/tests/unit/Command/RecreateMasterKeyTest.php +++ b/tests/unit/Command/RecreateMasterKeyTest.php @@ -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("\nNote: All users are required to relogin.\n", $reloginText); $outputText=""; } else { $this->recreateMasterKey = $this->getMockBuilder('OCA\Encryption\Command\RecreateMasterKey')