allow group shares, even if not all public keys are available
This commit is contained in:
parent
f8180579d0
commit
9de4a8338e
|
@ -390,7 +390,11 @@ class Encryption implements IEncryptionModule {
|
||||||
$publicKeys[$this->keyManager->getMasterKeyId()] = $this->keyManager->getPublicMasterKey();
|
$publicKeys[$this->keyManager->getMasterKeyId()] = $this->keyManager->getPublicMasterKey();
|
||||||
} else {
|
} else {
|
||||||
foreach ($accessList['users'] as $user) {
|
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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -304,7 +304,6 @@ class EncryptionTest extends TestCase {
|
||||||
$this->assertSame($expected,
|
$this->assertSame($expected,
|
||||||
$this->instance->update('path', 'user1', ['users' => ['user1']])
|
$this->instance->update('path', 'user1', ['users' => ['user1']])
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function dataTestUpdate() {
|
public function dataTestUpdate() {
|
||||||
|
@ -330,6 +329,43 @@ class EncryptionTest extends TestCase {
|
||||||
$this->instance->update('path', 'user1', []);
|
$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
|
* by default the encryption module should encrypt regular files, files in
|
||||||
* files_versions and files in files_trashbin
|
* files_versions and files in files_trashbin
|
||||||
|
|
Loading…
Reference in New Issue