diff options
author | Bjoern Schiessle <schiessle@owncloud.com> | 2016-03-15 11:23:49 +0100 |
---|---|---|
committer | Bjoern Schiessle <schiessle@owncloud.com> | 2016-03-15 11:33:19 +0100 |
commit | 9de4a8338ec2e850c87a7404e5093e7b29ebf6f6 (patch) | |
tree | 07e93372b08950b7d72375d57dd17814e5ee0e61 /apps/encryption/tests | |
parent | f8180579d03fcd10ab8f92f1ecb27899436c7653 (diff) | |
download | nextcloud-server-9de4a8338ec2e850c87a7404e5093e7b29ebf6f6.tar.gz nextcloud-server-9de4a8338ec2e850c87a7404e5093e7b29ebf6f6.zip |
allow group shares, even if not all public keys are available
Diffstat (limited to 'apps/encryption/tests')
-rw-r--r-- | apps/encryption/tests/lib/crypto/encryptionTest.php | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/apps/encryption/tests/lib/crypto/encryptionTest.php b/apps/encryption/tests/lib/crypto/encryptionTest.php index 0ce1a2cb76a..8a228c2c215 100644 --- a/apps/encryption/tests/lib/crypto/encryptionTest.php +++ b/apps/encryption/tests/lib/crypto/encryptionTest.php @@ -304,7 +304,6 @@ class EncryptionTest extends TestCase { $this->assertSame($expected, $this->instance->update('path', 'user1', ['users' => ['user1']]) ); - } public function dataTestUpdate() { @@ -331,6 +330,43 @@ class EncryptionTest extends TestCase { } /** + * Test case if the public key is missing. ownCloud should still encrypt + * the file for the remaining users + */ + public function testUpdateMissingPublicKey() { + $this->keyManagerMock->expects($this->once()) + ->method('getFileKey')->willReturn('fileKey'); + + $this->keyManagerMock->expects($this->any()) + ->method('getPublicKey')->willReturnCallback( + function($user) { + throw new PublicKeyMissingException($user); + } + ); + + $this->keyManagerMock->expects($this->any()) + ->method('addSystemKeys') + ->willReturnCallback(function($accessList, $publicKeys) { + return $publicKeys; + }); + + $this->cryptMock->expects($this->once())->method('multiKeyEncrypt') + ->willReturnCallback( + function($fileKey, $publicKeys) { + $this->assertEmpty($publicKeys); + $this->assertSame('fileKey', $fileKey); + } + ); + + $this->keyManagerMock->expects($this->never())->method('getVersion'); + $this->keyManagerMock->expects($this->never())->method('setVersion'); + + $this->assertTrue( + $this->instance->update('path', 'user1', ['users' => ['user1']]) + ); + } + + /** * by default the encryption module should encrypt regular files, files in * files_versions and files in files_trashbin * |