summaryrefslogtreecommitdiffstats
path: root/tests/lib/Encryption
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2022-06-20 10:53:06 +0200
committerCôme Chilliet <come.chilliet@nextcloud.com>2022-06-20 10:53:06 +0200
commit6a1510f8ee48494a19dc1239fd2584dc2188e18d (patch)
tree44268aa4e7afce7531cddb4cf91f3a72bbca4c13 /tests/lib/Encryption
parentc7e1c36362a7e4de5a7d074ab43f97c2559e06ea (diff)
downloadnextcloud-server-6a1510f8ee48494a19dc1239fd2584dc2188e18d.tar.gz
nextcloud-server-6a1510f8ee48494a19dc1239fd2584dc2188e18d.zip
Remove some more at matchers in tests/lib
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'tests/lib/Encryption')
-rw-r--r--tests/lib/Encryption/DecryptAllTest.php35
-rw-r--r--tests/lib/Encryption/Keys/StorageTest.php30
2 files changed, 36 insertions, 29 deletions
diff --git a/tests/lib/Encryption/DecryptAllTest.php b/tests/lib/Encryption/DecryptAllTest.php
index 90ff045a9b9..92ed2dcd701 100644
--- a/tests/lib/Encryption/DecryptAllTest.php
+++ b/tests/lib/Encryption/DecryptAllTest.php
@@ -224,12 +224,12 @@ class DecryptAllTest extends TestCase {
$this->userInterface->expects($this->any())
->method('getUsers')
->willReturn(['user1', 'user2']);
- $instance->expects($this->at(0))
+ $instance->expects($this->exactly(2))
->method('decryptUsersFiles')
- ->with('user1');
- $instance->expects($this->at(1))
- ->method('decryptUsersFiles')
- ->with('user2');
+ ->withConsecutive(
+ ['user1'],
+ ['user2'],
+ );
} else {
$instance->expects($this->once())
->method('decryptUsersFiles')
@@ -269,17 +269,18 @@ class DecryptAllTest extends TestCase {
$sharedStorage->expects($this->once())->method('instanceOfStorage')
->with('OCA\Files_Sharing\SharedStorage')->willReturn(true);
- $this->view->expects($this->at(0))->method('getDirectoryContent')
- ->with('/user1/files')->willReturn(
+ $this->view->expects($this->exactly(2))
+ ->method('getDirectoryContent')
+ ->withConsecutive(
+ ['/user1/files'],
+ ['/user1/files/foo']
+ )
+ ->willReturnOnConsecutiveCalls(
[
new FileInfo('path', $storage, 'intPath', ['name' => 'foo', 'type' => 'dir'], null),
new FileInfo('path', $storage, 'intPath', ['name' => 'bar', 'type' => 'file', 'encrypted' => true], null),
new FileInfo('path', $sharedStorage, 'intPath', ['name' => 'shared', 'type' => 'file', 'encrypted' => true], null),
- ]
- );
-
- $this->view->expects($this->at(3))->method('getDirectoryContent')
- ->with('/user1/files/foo')->willReturn(
+ ],
[
new FileInfo('path', $storage, 'intPath', ['name' => 'subfile', 'type' => 'file', 'encrypted' => true], null)
]
@@ -295,12 +296,12 @@ class DecryptAllTest extends TestCase {
}
);
- $instance->expects($this->at(0))
- ->method('decryptFile')
- ->with('/user1/files/bar');
- $instance->expects($this->at(1))
+ $instance->expects($this->exactly(2))
->method('decryptFile')
- ->with('/user1/files/foo/subfile');
+ ->withConsecutive(
+ ['/user1/files/bar'],
+ ['/user1/files/foo/subfile'],
+ );
/* We need format method to return a string */
diff --git a/tests/lib/Encryption/Keys/StorageTest.php b/tests/lib/Encryption/Keys/StorageTest.php
index 30680646f73..bb7bbbcd7c1 100644
--- a/tests/lib/Encryption/Keys/StorageTest.php
+++ b/tests/lib/Encryption/Keys/StorageTest.php
@@ -162,21 +162,21 @@ class StorageTest extends TestCase {
->method('isSystemWideMountPoint')
->willReturn(false);
- $this->view->expects($this->at(0))
- ->method('file_exists')
- ->with($this->equalTo('/user1/files_encryption/keys' . $strippedPartialName . '/encModule/fileKey'))
- ->willReturn($originalKeyExists);
-
$this->crypto->method('decrypt')
->willReturnCallback(function ($data, $pass) {
return $data;
});
if (!$originalKeyExists) {
- $this->view->expects($this->at(1))
+ $this->view->expects($this->exactly(2))
->method('file_exists')
- ->with($this->equalTo('/user1/files_encryption/keys' . $path . '/encModule/fileKey'))
- ->willReturn(true);
+ ->withConsecutive(
+ [$this->equalTo('/user1/files_encryption/keys' . $strippedPartialName . '/encModule/fileKey')],
+ [$this->equalTo('/user1/files_encryption/keys' . $path . '/encModule/fileKey')],
+ )->willReturnOnConsecutiveCalls(
+ $originalKeyExists,
+ true,
+ );
$this->view->expects($this->once())
->method('file_get_contents')
@@ -184,6 +184,11 @@ class StorageTest extends TestCase {
->willReturn(json_encode(['key' => base64_encode('key2')]));
} else {
$this->view->expects($this->once())
+ ->method('file_exists')
+ ->with($this->equalTo('/user1/files_encryption/keys' . $strippedPartialName . '/encModule/fileKey'))
+ ->willReturn($originalKeyExists);
+
+ $this->view->expects($this->once())
->method('file_get_contents')
->with($this->equalTo('/user1/files_encryption/keys' . $strippedPartialName . '/encModule/fileKey'))
->willReturn(json_encode(['key' => base64_encode('key')]));
@@ -627,10 +632,11 @@ class StorageTest extends TestCase {
->with('user1/files_encryption/backup')->willReturn(!$createBackupDir);
if ($createBackupDir) {
- $this->view->expects($this->at(1))->method('mkdir')
- ->with('user1/files_encryption/backup');
- $this->view->expects($this->at(2))->method('mkdir')
- ->with('user1/files_encryption/backup/test.encryptionModule.1234567');
+ $this->view->expects($this->exactly(2))->method('mkdir')
+ ->withConsecutive(
+ ['user1/files_encryption/backup'],
+ ['user1/files_encryption/backup/test.encryptionModule.1234567'],
+ );
} else {
$this->view->expects($this->once())->method('mkdir')
->with('user1/files_encryption/backup/test.encryptionModule.1234567');