summaryrefslogtreecommitdiffstats
path: root/apps/encryption/tests
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2015-04-24 13:02:06 +0200
committerBjoern Schiessle <schiessle@owncloud.com>2015-04-27 13:01:18 +0200
commit27683f944289e7b37f20ec7d877ed295d5ca66a3 (patch)
tree83c7f72931cbdc6549816030bf8333a0ca9eef2d /apps/encryption/tests
parente58029f8ad9ed4ddb1a68ea91e76e6a8d749fe27 (diff)
downloadnextcloud-server-27683f944289e7b37f20ec7d877ed295d5ca66a3.tar.gz
nextcloud-server-27683f944289e7b37f20ec7d877ed295d5ca66a3.zip
fall back to the ownCloud default encryption module and aes128 if we read a encrypted file without a header
Diffstat (limited to 'apps/encryption/tests')
-rw-r--r--apps/encryption/tests/lib/crypto/encryptionTest.php27
1 files changed, 27 insertions, 0 deletions
diff --git a/apps/encryption/tests/lib/crypto/encryptionTest.php b/apps/encryption/tests/lib/crypto/encryptionTest.php
index 9e14a70ebb0..500433c77d4 100644
--- a/apps/encryption/tests/lib/crypto/encryptionTest.php
+++ b/apps/encryption/tests/lib/crypto/encryptionTest.php
@@ -72,5 +72,32 @@ class EncryptionTest extends TestCase {
);
}
+ /**
+ * @dataProvider dataTestBegin
+ */
+ public function testBegin($mode, $header, $legacyCipher, $defaultCipher, $expected) {
+
+ $this->cryptMock->expects($this->any())
+ ->method('getCipher')
+ ->willReturn($defaultCipher);
+ $this->cryptMock->expects($this->any())
+ ->method('getLegacyCipher')
+ ->willReturn($legacyCipher);
+
+ $result = $this->instance->begin('/user/files/foo.txt', 'user', $mode, $header, []);
+
+ $this->assertArrayHasKey('cipher', $result);
+ $this->assertSame($expected, $result['cipher']);
+ }
+
+ public function dataTestBegin() {
+ return array(
+ array('w', ['cipher' => 'myCipher'], 'legacyCipher', 'defaultCipher', 'myCipher'),
+ array('r', ['cipher' => 'myCipher'], 'legacyCipher', 'defaultCipher', 'myCipher'),
+ array('w', [], 'legacyCipher', 'defaultCipher', 'defaultCipher'),
+ array('r', [], 'legacyCipher', 'defaultCipher', 'legacyCipher'),
+ );
+ }
+
} \ No newline at end of file