summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-03-15 16:00:47 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2016-03-15 16:00:47 +0100
commit8feb42c22eebe6ee70aca55f3dae38d67689b74f (patch)
tree02d0639fa1bf2c47b0a7a885bdcc783c006ecbb6 /apps
parentad9a0804f3a40123ce931f6f7f365758fe8a0933 (diff)
parent9de4a8338ec2e850c87a7404e5093e7b29ebf6f6 (diff)
downloadnextcloud-server-8feb42c22eebe6ee70aca55f3dae38d67689b74f.tar.gz
nextcloud-server-8feb42c22eebe6ee70aca55f3dae38d67689b74f.zip
Merge pull request #23251 from owncloud/fix_22907
allow group shares, even if not all public keys are available
Diffstat (limited to 'apps')
-rw-r--r--apps/encryption/lib/crypto/encryption.php6
-rw-r--r--apps/encryption/tests/lib/crypto/encryptionTest.php38
2 files changed, 42 insertions, 2 deletions
diff --git a/apps/encryption/lib/crypto/encryption.php b/apps/encryption/lib/crypto/encryption.php
index 10c8c4a290a..907a6437f5b 100644
--- a/apps/encryption/lib/crypto/encryption.php
+++ b/apps/encryption/lib/crypto/encryption.php
@@ -390,7 +390,11 @@ class Encryption implements IEncryptionModule {
$publicKeys[$this->keyManager->getMasterKeyId()] = $this->keyManager->getPublicMasterKey();
} else {
foreach ($accessList['users'] as $user) {
- $publicKeys[$user] = $this->keyManager->getPublicKey($user);
+ try {
+ $publicKeys[$user] = $this->keyManager->getPublicKey($user);
+ } catch (PublicKeyMissingException $e) {
+ $this->logger->warning('Could not encrypt file for ' . $user . ': ' . $e->getMessage());
+ }
}
}
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
*