aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorLouis Chemineau <louis@chmn.me>2024-06-06 18:02:32 +0200
committerLouis Chemineau <louis@chmn.me>2024-06-11 11:53:57 +0200
commit71188dc3f2b4eebf0e85356ebe7c6715ba752417 (patch)
treef66d28a726c07d9f77a098d1e123cdc4d6497e93 /apps
parent9026c98243a97ea1c9952865cf390d8c2cd56b4e (diff)
downloadnextcloud-server-71188dc3f2b4eebf0e85356ebe7c6715ba752417.tar.gz
nextcloud-server-71188dc3f2b4eebf0e85356ebe7c6715ba752417.zip
test: Fix encryption test
Signed-off-by: Louis Chemineau <louis@chmn.me>
Diffstat (limited to 'apps')
-rw-r--r--apps/encryption/tests/Crypto/EncryptionTest.php35
1 files changed, 14 insertions, 21 deletions
diff --git a/apps/encryption/tests/Crypto/EncryptionTest.php b/apps/encryption/tests/Crypto/EncryptionTest.php
index 115b9054278..427421def9c 100644
--- a/apps/encryption/tests/Crypto/EncryptionTest.php
+++ b/apps/encryption/tests/Crypto/EncryptionTest.php
@@ -122,6 +122,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();
}
@@ -131,6 +135,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']]);
@@ -252,35 +260,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,
@@ -294,6 +283,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);