aboutsummaryrefslogtreecommitdiffstats
path: root/apps/encryption/tests/Crypto/CryptTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/encryption/tests/Crypto/CryptTest.php')
-rw-r--r--apps/encryption/tests/Crypto/CryptTest.php23
1 files changed, 14 insertions, 9 deletions
diff --git a/apps/encryption/tests/Crypto/CryptTest.php b/apps/encryption/tests/Crypto/CryptTest.php
index 60548a0f1dc..ef4e46085a4 100644
--- a/apps/encryption/tests/Crypto/CryptTest.php
+++ b/apps/encryption/tests/Crypto/CryptTest.php
@@ -139,9 +139,9 @@ class CryptTest extends TestCase {
*/
public function dataTestGenerateHeader() {
return [
- [null, 'HBEGIN:cipher:AES-128-CFB:keyFormat:hash:HEND'],
- ['password', 'HBEGIN:cipher:AES-128-CFB:keyFormat:password:HEND'],
- ['hash', 'HBEGIN:cipher:AES-128-CFB:keyFormat:hash:HEND']
+ [null, 'HBEGIN:cipher:AES-128-CFB:keyFormat:hash:encoding:binary:HEND'],
+ ['password', 'HBEGIN:cipher:AES-128-CFB:keyFormat:password:encoding:binary:HEND'],
+ ['hash', 'HBEGIN:cipher:AES-128-CFB:keyFormat:hash:encoding:binary:HEND']
];
}
@@ -305,15 +305,17 @@ class CryptTest extends TestCase {
* test parseHeader()
*/
public function testParseHeader() {
- $header = 'HBEGIN:foo:bar:cipher:AES-256-CFB:HEND';
+ $header = 'HBEGIN:foo:bar:cipher:AES-256-CFB:encoding:binary:HEND';
$result = self::invokePrivate($this->crypt, 'parseHeader', [$header]);
$this->assertTrue(is_array($result));
- $this->assertSame(2, count($result));
+ $this->assertSame(3, count($result));
$this->assertArrayHasKey('foo', $result);
$this->assertArrayHasKey('cipher', $result);
+ $this->assertArrayHasKey('encoding', $result);
$this->assertSame('bar', $result['foo']);
$this->assertSame('AES-256-CFB', $result['cipher']);
+ $this->assertSame('binary', $result['encoding']);
}
/**
@@ -324,18 +326,20 @@ class CryptTest extends TestCase {
public function testEncrypt() {
$decrypted = 'content';
$password = 'password';
+ $cipher = 'AES-256-CTR';
$iv = self::invokePrivate($this->crypt, 'generateIv');
$this->assertTrue(is_string($iv));
$this->assertSame(16, strlen($iv));
- $result = self::invokePrivate($this->crypt, 'encrypt', [$decrypted, $iv, $password]);
+ $result = self::invokePrivate($this->crypt, 'encrypt', [$decrypted, $iv, $password, $cipher]);
$this->assertTrue(is_string($result));
return [
'password' => $password,
'iv' => $iv,
+ 'cipher' => $cipher,
'encrypted' => $result,
'decrypted' => $decrypted];
}
@@ -349,7 +353,7 @@ class CryptTest extends TestCase {
$result = self::invokePrivate(
$this->crypt,
'decrypt',
- [$data['encrypted'], $data['iv'], $data['password']]);
+ [$data['encrypted'], $data['iv'], $data['password'], $data['cipher'], true]);
$this->assertSame($data['decrypted'], $result);
}
@@ -391,8 +395,9 @@ class CryptTest extends TestCase {
*/
public function testDecryptPrivateKey($header, $privateKey, $expectedCipher, $isValidKey, $expected) {
$this->config->method('getSystemValueBool')
- ->with('encryption.legacy_format_support', false)
- ->willReturn(true);
+ ->withConsecutive(['encryption.legacy_format_support', false],
+ ['encryption.use_legacy_base64_encoding', false])
+ ->willReturnOnConsecutiveCalls(true, false);
/** @var \OCA\Encryption\Crypto\Crypt | \PHPUnit\Framework\MockObject\MockObject $crypt */
$crypt = $this->getMockBuilder(Crypt::class)