diff options
author | Thomas Müller <DeepDiver1975@users.noreply.github.com> | 2016-07-01 11:30:39 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-01 11:30:39 +0200 |
commit | 4ac256ea6cd14f531dad0841ce7a9c5f5ffdeb51 (patch) | |
tree | ac79e6d294c44e0cbfc4a96001c87fb240f1ff15 /tests | |
parent | 4a4103b92375b191700b9e0f52fe363d3fe989ff (diff) | |
download | nextcloud-server-4ac256ea6cd14f531dad0841ce7a9c5f5ffdeb51.tar.gz nextcloud-server-4ac256ea6cd14f531dad0841ce7a9c5f5ffdeb51.zip |
[stable9] Fix decrypt message stable9 (#25188)
* Fix Decrypt message via occ
* Comments fixed
* Fixed reviews
* Originally:
commit 2304e4bda027e61ff1302c55c2f70f8e4c8f47d0
Author: Joas Schilling <nickvergessen@owncloud.com>
Date: Tue Jun 7 09:13:11 2016 +0200
Allow to decrypt user '0' files only
* Fix uid comparison
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/encryption/decryptalltest.php | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/tests/lib/encryption/decryptalltest.php b/tests/lib/encryption/decryptalltest.php index 85fbe3e0ed9..d7cf2fb7baf 100644 --- a/tests/lib/encryption/decryptalltest.php +++ b/tests/lib/encryption/decryptalltest.php @@ -26,6 +26,7 @@ namespace Test\Encryption; use OC\Encryption\DecryptAll; use OC\Encryption\Exceptions\DecryptionFailedException; use OC\Encryption\Manager; +use OC\Files\FileInfo; use OC\Files\View; use OCP\IUserManager; use Test\TestCase; @@ -85,13 +86,25 @@ class DecryptAllTest extends TestCase { $this->invokePrivate($this->instance, 'output', [$this->outputInterface]); } + public function dataDecryptAll() { + return [ + [true, 'user1', true], + [false, 'user1', true], + [true, '0', true], + [false, '0', true], + [true, '', false], + ]; + } + /** - * @dataProvider dataTrueFalse + * @dataProvider dataDecryptAll * @param bool $prepareResult + * @param string $user + * @param bool $userExistsChecked */ - public function testDecryptAll($prepareResult, $user) { + public function testDecryptAll($prepareResult, $user, $userExistsChecked) { - if (!empty($user)) { + if ($userExistsChecked) { $this->userManager->expects($this->once())->method('userExists')->willReturn(true); } else { $this->userManager->expects($this->never())->method('userExists'); @@ -124,15 +137,6 @@ class DecryptAllTest extends TestCase { $instance->decryptAll($this->inputInterface, $this->outputInterface, $user); } - public function dataTrueFalse() { - return [ - [true, 'user1'], - [false, 'user1'], - [true, ''], - [true, null] - ]; - } - /** * test decrypt all call with a user who doesn't exists */ @@ -146,8 +150,16 @@ class DecryptAllTest extends TestCase { ); } + public function dataTrueFalse() { + return [ + [true], + [false], + ]; + } + /** * @dataProvider dataTrueFalse + * @param bool $success */ public function testPrepareEncryptionModules($success) { @@ -242,15 +254,15 @@ class DecryptAllTest extends TestCase { $this->view->expects($this->at(0))->method('getDirectoryContent') ->with('/user1/files')->willReturn( [ - ['name' => 'foo', 'type'=>'dir'], - ['name' => 'bar', 'type'=>'file'], + new FileInfo('path', null, 'intPath', ['name' => 'foo', 'type'=>'dir'], null), + new FileInfo('path', null, 'intPath', ['name' => 'bar', 'type'=>'file', 'encrypted'=>true], null) ] ); $this->view->expects($this->at(3))->method('getDirectoryContent') ->with('/user1/files/foo')->willReturn( [ - ['name' => 'subfile', 'type'=>'file'] + new FileInfo('path', null, 'intPath', ['name' => 'subfile', 'type'=>'file', 'encrypted'=>true], null) ] ); |