diff options
author | Bjoern Schiessle <schiessle@owncloud.com> | 2014-10-02 12:55:46 +0200 |
---|---|---|
committer | Bjoern Schiessle <schiessle@owncloud.com> | 2014-10-06 12:02:08 +0200 |
commit | 9147219377d6fec5666a03943be1892253750871 (patch) | |
tree | 6a415f052231554fb2a120f69a1a00e7db5e8089 /apps/files_encryption/tests | |
parent | 537f046e66b16aa98c7b9fcf60e767e9f861f342 (diff) | |
download | nextcloud-server-9147219377d6fec5666a03943be1892253750871.tar.gz nextcloud-server-9147219377d6fec5666a03943be1892253750871.zip |
we also encrypt/decrypt files in the versions folder for previews and if encryption is enabled/disabled
Diffstat (limited to 'apps/files_encryption/tests')
-rw-r--r-- | apps/files_encryption/tests/proxy.php | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/apps/files_encryption/tests/proxy.php b/apps/files_encryption/tests/proxy.php index 9ec1f940edd..42637a52e04 100644 --- a/apps/files_encryption/tests/proxy.php +++ b/apps/files_encryption/tests/proxy.php @@ -136,4 +136,42 @@ class Test_Encryption_Proxy extends \PHPUnit_Framework_TestCase { } + /** + * @dataProvider isExcludedPathProvider + */ + function testIsExcludedPath($path, $expected) { + $this->view->mkdir(dirname($path)); + $this->view->file_put_contents($path, "test"); + + $testClass = new DummyProxy(); + + $result = $testClass->isExcludedPathTesting($path, $this->userId); + $this->assertSame($expected, $result); + + $this->view->deleteAll(dirname($path)); + + } + + public function isExcludedPathProvider() { + return array( + array ('/' . \Test_Encryption_Proxy::TEST_ENCRYPTION_PROXY_USER1 . '/files/test.txt', false), + array (\Test_Encryption_Proxy::TEST_ENCRYPTION_PROXY_USER1 . '/files/test.txt', false), + array ('/files/test.txt', true), + array ('/' . \Test_Encryption_Proxy::TEST_ENCRYPTION_PROXY_USER1 . '/files/versions/test.txt', false), + array ('/' . \Test_Encryption_Proxy::TEST_ENCRYPTION_PROXY_USER1 . '/files_versions/test.txt', false), + array ('/' . \Test_Encryption_Proxy::TEST_ENCRYPTION_PROXY_USER1 . '/files_trashbin/test.txt', true), + array ('/' . \Test_Encryption_Proxy::TEST_ENCRYPTION_PROXY_USER1 . '/file/test.txt', true), + ); + } + +} + + +/** + * Dummy class to make protected methods available for testing + */ +class DummyProxy extends \OCA\Encryption\Proxy { + public function isExcludedPathTesting($path, $uid) { + return $this->isExcludedPath($path, $uid); + } } |