allow group shares, even if not all public keys are available

This commit is contained in:
Bjoern Schiessle 2016-03-15 11:23:49 +01:00
parent 5a6b2956d8
commit 0f372a2a8c
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) {
$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());
}
}
}

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