Skip to content

Commit

Permalink
test: Fix encryption test
Browse files Browse the repository at this point in the history
Signed-off-by: Louis Chemineau <louis@chmn.me>
  • Loading branch information
artonge committed Jun 6, 2024
1 parent 885604c commit 01e3921
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions apps/encryption/tests/Crypto/EncryptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ protected function setUp(): void {
* 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();
}
Expand All @@ -112,6 +116,10 @@ public function testEndUser1() {
*
*/
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']]);
Expand Down Expand Up @@ -238,6 +246,9 @@ public function testBeginDecryptAll() {
$decryptAllKey = 'decryptAllKey';
$fileKey = 'fileKey';

$this->sessionMock->expects($this->once())
->method('decryptAllModeActivated')
->willReturn(false);
$this->sessionMock->expects($this->once())
->method('decryptAllModeActivated')
->willReturn(true);
Expand Down Expand Up @@ -275,6 +286,10 @@ public function testBeginDecryptAll() {
* 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);
Expand Down

0 comments on commit 01e3921

Please sign in to comment.