summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/files/filesystem.php22
-rw-r--r--tests/lib/files/mapper.php9
-rw-r--r--tests/lib/files/view.php22
3 files changed, 53 insertions, 0 deletions
diff --git a/tests/lib/files/filesystem.php b/tests/lib/files/filesystem.php
index 888690adb0e..7bf59315d77 100644
--- a/tests/lib/files/filesystem.php
+++ b/tests/lib/files/filesystem.php
@@ -187,6 +187,28 @@ class Filesystem extends \Test\TestCase {
$this->assertSame($expected, \OC\Files\Filesystem::isValidPath($path));
}
+ public function isFileBlacklistedData() {
+ return array(
+ array('/etc/foo/bar/foo.txt', false),
+ array('\etc\foo/bar\foo.txt', false),
+ array('.htaccess', true),
+ array('.htaccess/', true),
+ array('.htaccess\\', true),
+ array('/etc/foo\bar/.htaccess\\', true),
+ array('/etc/foo\bar/.htaccess/', true),
+ array('/etc/foo\bar/.htaccess/foo', false),
+ array('//foo//bar/\.htaccess/', true),
+ array('\foo\bar\.HTAccess', true),
+ );
+ }
+
+ /**
+ * @dataProvider isFileBlacklistedData
+ */
+ public function testIsFileBlacklisted($path, $expected) {
+ $this->assertSame($expected, \OC\Files\Filesystem::isFileBlacklisted($path));
+ }
+
public function normalizePathWindowsAbsolutePathData() {
return array(
array('C:/', 'C:\\'),
diff --git a/tests/lib/files/mapper.php b/tests/lib/files/mapper.php
index 18161734b60..cd35d4f8fc3 100644
--- a/tests/lib/files/mapper.php
+++ b/tests/lib/files/mapper.php
@@ -68,6 +68,15 @@ class Mapper extends \Test\TestCase {
*/
array('D:/' . md5('ありがとう'), 'D:/ありがとう'),
array('D:/' . md5('ありがとう') . '/issue6722.txt', 'D:/ありがとう/issue6722.txt'),
+ array('D:/' . md5('.htaccess'), 'D:/.htaccess'),
+ array('D:/' . md5('.htaccess.'), 'D:/.htaccess.'),
+ array('D:/' . md5('.htAccess'), 'D:/.htAccess'),
+ array('D:/' . md5('.htAccess\\…\\') . '/a', 'D:/.htAccess\…\/とa'),
+ array('D:/' . md5('.htaccess-'), 'D:/.htaccess-'),
+ array('D:/' . md5('.htaあccess'), 'D:/.htaあccess'),
+ array('D:/' . md5(' .htaccess'), 'D:/ .htaccess'),
+ array('D:/' . md5('.htaccess '), 'D:/.htaccess '),
+ array('D:/' . md5(' .htaccess '), 'D:/ .htaccess '),
);
}
diff --git a/tests/lib/files/view.php b/tests/lib/files/view.php
index 9ddc9c80475..f6af59d52be 100644
--- a/tests/lib/files/view.php
+++ b/tests/lib/files/view.php
@@ -729,6 +729,28 @@ class View extends \Test\TestCase {
);
}
+ /**
+ * @dataProvider relativePathProvider
+ */
+ function testGetRelativePath($absolutePath, $expectedPath) {
+ $view = new \OC\Files\View('/files');
+ // simulate a external storage mount point which has a trailing slash
+ $view->chroot('/files/');
+ $this->assertEquals($expectedPath, $view->getRelativePath($absolutePath));
+ }
+
+ function relativePathProvider() {
+ return array(
+ array('/files/', '/'),
+ array('/files', '/'),
+ array('/files/0', '0'),
+ array('/files/false', 'false'),
+ array('/files/true', 'true'),
+ array('/files/test', 'test'),
+ array('/files/test/foo', 'test/foo'),
+ );
+ }
+
public function testFileView() {
$storage = new Temporary(array());
$scanner = $storage->getScanner();