summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2018-01-08 21:10:11 +0100
committerGitHub <noreply@github.com>2018-01-08 21:10:11 +0100
commit1f875eca3c5729f6ca207284d5ca238cf0a0b774 (patch)
tree7e8acc68b015c570174fe9b13922a75789dcc35e /tests
parente23491dc4202b0f6b357fb9df09d42357e63d6cb (diff)
parent32597f896602c891a3e4f0164e2d0468e67290db (diff)
downloadnextcloud-server-1f875eca3c5729f6ca207284d5ca238cf0a0b774.tar.gz
nextcloud-server-1f875eca3c5729f6ca207284d5ca238cf0a0b774.zip
Merge pull request #7694 from nextcloud/stable12-7611
[stable12] Don't attempt to translate login names to uids when uids are provided
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Files/FilesystemTest.php33
-rw-r--r--tests/lib/User/ManagerTest.php28
-rw-r--r--tests/lib/Util/User/Dummy.php7
3 files changed, 35 insertions, 33 deletions
diff --git a/tests/lib/Files/FilesystemTest.php b/tests/lib/Files/FilesystemTest.php
index 1eb6c4fc54b..a98af220ba1 100644
--- a/tests/lib/Files/FilesystemTest.php
+++ b/tests/lib/Files/FilesystemTest.php
@@ -368,39 +368,6 @@ 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->createMock(\OC\User\Database::class);
- \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
*/
diff --git a/tests/lib/User/ManagerTest.php b/tests/lib/User/ManagerTest.php
index cf725aae671..badcfb551b7 100644
--- a/tests/lib/User/ManagerTest.php
+++ b/tests/lib/User/ManagerTest.php
@@ -184,6 +184,8 @@ class ManagerTest extends TestCase {
->method('userExists')
->with($this->equalTo('foo'))
->will($this->returnValue(true));
+ $backend->expects($this->never())
+ ->method('loginName2UserName');
$manager = new \OC\User\Manager($this->config);
$manager->registerBackend($backend);
@@ -207,6 +209,24 @@ class ManagerTest extends TestCase {
$this->assertEquals(null, $manager->get('foo'));
}
+ public function testGetOneBackendDoNotTranslateLoginNames() {
+ /**
+ * @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend
+ */
+ $backend = $this->createMock(\Test\Util\User\Dummy::class);
+ $backend->expects($this->once())
+ ->method('userExists')
+ ->with($this->equalTo('bLeNdEr'))
+ ->will($this->returnValue(true));
+ $backend->expects($this->never())
+ ->method('loginName2UserName');
+
+ $manager = new \OC\User\Manager($this->config);
+ $manager->registerBackend($backend);
+
+ $this->assertEquals('bLeNdEr', $manager->get('bLeNdEr')->getUID());
+ }
+
public function testSearchOneBackend() {
/**
* @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend
@@ -216,6 +236,8 @@ class ManagerTest extends TestCase {
->method('getUsers')
->with($this->equalTo('fo'))
->will($this->returnValue(array('foo', 'afoo')));
+ $backend->expects($this->never())
+ ->method('loginName2UserName');
$manager = new \OC\User\Manager($this->config);
$manager->registerBackend($backend);
@@ -235,6 +257,8 @@ class ManagerTest extends TestCase {
->method('getUsers')
->with($this->equalTo('fo'), $this->equalTo(3), $this->equalTo(1))
->will($this->returnValue(array('foo1', 'foo2')));
+ $backend1->expects($this->never())
+ ->method('loginName2UserName');
/**
* @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend2
@@ -244,6 +268,8 @@ class ManagerTest extends TestCase {
->method('getUsers')
->with($this->equalTo('fo'), $this->equalTo(3), $this->equalTo(1))
->will($this->returnValue(array('foo3')));
+ $backend2->expects($this->never())
+ ->method('loginName2UserName');
$manager = new \OC\User\Manager($this->config);
$manager->registerBackend($backend1);
@@ -324,6 +350,8 @@ class ManagerTest extends TestCase {
->method('userExists')
->with($this->equalTo('foo'))
->will($this->returnValue(false));
+ $backend->expects($this->never())
+ ->method('loginName2UserName');
$manager = new \OC\User\Manager($this->config);
$manager->registerBackend($backend);
diff --git a/tests/lib/Util/User/Dummy.php b/tests/lib/Util/User/Dummy.php
index ea47f5d7d15..375a5f4b8e6 100644
--- a/tests/lib/Util/User/Dummy.php
+++ b/tests/lib/Util/User/Dummy.php
@@ -108,6 +108,13 @@ class Dummy extends Backend implements \OCP\IUserBackend {
}
}
+ public function loginName2UserName($loginName) {
+ if(isset($this->users[strtolower($loginName)])) {
+ return strtolower($loginName);
+ }
+ return false;
+ }
+
/**
* Get a list of all users
*