mirror of
https://github.com/nextcloud/server.git
synced 2026-04-15 22:11:17 -04:00
test: Fix encryption test
Signed-off-by: Louis Chemineau <louis@chmn.me>
This commit is contained in:
parent
885604ce2d
commit
f244261e85
1 changed files with 14 additions and 21 deletions
|
|
@ -103,6 +103,10 @@ class EncryptionTest extends TestCase {
|
|||
* test if public key from one of the recipients is missing
|
||||
*/
|
||||
public function testEndUser1() {
|
||||
$this->sessionMock->expects($this->once())
|
||||
->method('decryptAllModeActivated')
|
||||
->willReturn(false);
|
||||
|
||||
$this->instance->begin('/foo/bar', 'user1', 'r', [], ['users' => ['user1', 'user2', 'user3']]);
|
||||
$this->endTest();
|
||||
}
|
||||
|
|
@ -112,6 +116,10 @@ class EncryptionTest extends TestCase {
|
|||
*
|
||||
*/
|
||||
public function testEndUser2() {
|
||||
$this->sessionMock->expects($this->once())
|
||||
->method('decryptAllModeActivated')
|
||||
->willReturn(false);
|
||||
|
||||
$this->expectException(\OCA\Encryption\Exceptions\PublicKeyMissingException::class);
|
||||
|
||||
$this->instance->begin('/foo/bar', 'user2', 'r', [], ['users' => ['user1', 'user2', 'user3']]);
|
||||
|
|
@ -233,35 +241,16 @@ class EncryptionTest extends TestCase {
|
|||
*/
|
||||
public function testBeginDecryptAll() {
|
||||
$path = '/user/files/foo.txt';
|
||||
$recoveryKeyId = 'recoveryKeyId';
|
||||
$recoveryShareKey = 'recoveryShareKey';
|
||||
$decryptAllKey = 'decryptAllKey';
|
||||
$fileKey = 'fileKey';
|
||||
|
||||
$this->sessionMock->expects($this->once())
|
||||
->method('decryptAllModeActivated')
|
||||
->willReturn(true);
|
||||
$this->sessionMock->expects($this->once())
|
||||
->method('getDecryptAllUid')
|
||||
->willReturn($recoveryKeyId);
|
||||
$this->sessionMock->expects($this->once())
|
||||
->method('getDecryptAllKey')
|
||||
->willReturn($decryptAllKey);
|
||||
|
||||
$this->keyManagerMock->expects($this->once())
|
||||
->method('getEncryptedFileKey')
|
||||
->willReturn('encryptedFileKey');
|
||||
$this->keyManagerMock->expects($this->once())
|
||||
->method('getShareKey')
|
||||
->with($path, $recoveryKeyId)
|
||||
->willReturn($recoveryShareKey);
|
||||
$this->cryptMock->expects($this->once())
|
||||
->method('multiKeyDecryptLegacy')
|
||||
->with('encryptedFileKey', $recoveryShareKey, $decryptAllKey)
|
||||
->method('getFileKey')
|
||||
->with($path, 'user', null, true)
|
||||
->willReturn($fileKey);
|
||||
|
||||
$this->keyManagerMock->expects($this->never())->method('getFileKey');
|
||||
|
||||
$this->instance->begin($path, 'user', 'r', [], []);
|
||||
|
||||
$this->assertSame($fileKey,
|
||||
|
|
@ -275,6 +264,10 @@ class EncryptionTest extends TestCase {
|
|||
* and continue
|
||||
*/
|
||||
public function testBeginInitMasterKey() {
|
||||
$this->sessionMock->expects($this->once())
|
||||
->method('decryptAllModeActivated')
|
||||
->willReturn(false);
|
||||
|
||||
$this->sessionMock->expects($this->once())->method('isReady')->willReturn(false);
|
||||
$this->utilMock->expects($this->once())->method('isMasterKeyEnabled')
|
||||
->willReturn(true);
|
||||
|
|
|
|||
Loading…
Reference in a new issue