Merge pull request #23264 from owncloud/fix_22907_9.0

allow group shares, even if not all public keys are available
This commit is contained in:
Thomas Müller 2016-03-16 11:18:51 +01:00
commit d54106dada
2 changed files with 42 additions and 2 deletions

View File

@ -390,7 +390,11 @@ class Encryption implements IEncryptionModule {
$publicKeys[$this->keyManager->getMasterKeyId()] = $this->keyManager->getPublicMasterKey();
} else {
foreach ($accessList['users'] as $user) {
try {
$publicKeys[$user] = $this->keyManager->getPublicKey($user);
} catch (PublicKeyMissingException $e) {
$this->logger->warning('Could not encrypt file for ' . $user . ': ' . $e->getMessage());
}
}
}

View File

@ -304,7 +304,6 @@ class EncryptionTest extends TestCase {
$this->assertSame($expected,
$this->instance->update('path', 'user1', ['users' => ['user1']])
);
}
public function dataTestUpdate() {
@ -330,6 +329,43 @@ class EncryptionTest extends TestCase {
$this->instance->update('path', 'user1', []);
}
/**
* 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