summaryrefslogtreecommitdiffstats
path: root/tests/lib/Files/FilesystemTest.php
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2016-10-04 12:28:41 +0200
committerLukas Reschke <lukas@statuscode.ch>2016-11-02 22:21:46 +0100
commitf737426eca338dbc65db6210a09f3034d372701b (patch)
tree10fbeb022517900955aff8a69e571652ee48d073 /tests/lib/Files/FilesystemTest.php
parentc1feae1684934bb52b1edaa67d33d01b377b875a (diff)
downloadnextcloud-server-f737426eca338dbc65db6210a09f3034d372701b.tar.gz
nextcloud-server-f737426eca338dbc65db6210a09f3034d372701b.zip
Add using casing check/fix for initMountPoints
Diffstat (limited to 'tests/lib/Files/FilesystemTest.php')
-rw-r--r--tests/lib/Files/FilesystemTest.php35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/lib/Files/FilesystemTest.php b/tests/lib/Files/FilesystemTest.php
index 210ce4edc69..fb9dee15051 100644
--- a/tests/lib/Files/FilesystemTest.php
+++ b/tests/lib/Files/FilesystemTest.php
@@ -79,6 +79,7 @@ class FilesystemTest extends \Test\TestCase {
protected function setUp() {
parent::setUp();
+ \OC_User::clearBackends();
$userBackend = new \Test\Util\User\Dummy();
$userBackend->createUser(self::TEST_FILESYSTEM_USER1, self::TEST_FILESYSTEM_USER1);
$userBackend->createUser(self::TEST_FILESYSTEM_USER2, self::TEST_FILESYSTEM_USER2);
@@ -93,6 +94,7 @@ class FilesystemTest extends \Test\TestCase {
$this->logout();
$this->invokePrivate('\OC\Files\Filesystem', 'normalizedPathCache', [null]);
+ \OC_User::clearBackends();
parent::tearDown();
}
@@ -368,6 +370,39 @@ class FilesystemTest extends \Test\TestCase {
$this->assertEquals(2, $thrown);
}
+ public function testUserNameCasing() {
+ $this->logout();
+ $userId = $this->getUniqueID('user_');
+
+ \OC_User::clearBackends();
+ // needed for loginName2UserName mapping
+ $userBackend = $this->getMock('\OC\User\Database');
+ \OC::$server->getUserManager()->registerBackend($userBackend);
+
+ $userBackend->expects($this->once())
+ ->method('userExists')
+ ->with(strtoupper($userId))
+ ->will($this->returnValue(true));
+ $userBackend->expects($this->once())
+ ->method('loginName2UserName')
+ ->with(strtoupper($userId))
+ ->will($this->returnValue($userId));
+
+ $view = new \OC\Files\View();
+ $this->assertFalse($view->file_exists('/' . $userId));
+
+ \OC\Files\Filesystem::initMountPoints(strtoupper($userId));
+
+ list($storage1, $path1) = $view->resolvePath('/' . $userId);
+ list($storage2, $path2) = $view->resolvePath('/' . strtoupper($userId));
+
+ $this->assertTrue($storage1->instanceOfStorage('\OCP\Files\IHomeStorage'));
+ $this->assertEquals('', $path1);
+
+ // not mounted, still on the local root storage
+ $this->assertEquals(strtoupper($userId), $path2);
+ }
+
/**
* Tests that the home storage is used for the user's mount point
*/