diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2017-12-22 17:22:49 +0300 |
---|---|---|
committer | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2018-01-04 13:47:31 +0300 |
commit | 776d9e6805a8c100fd746c577a6442ff0bcffb57 (patch) | |
tree | 3f7aa4f77128a801c944269b2254047b8f5e7435 /tests | |
parent | c94c2c48a613d3ca4f77fb3b77b7d453ee3eea46 (diff) |
never translate login names when requiring with a user id
where appropriate, the preLoginNameUsedAsUserName hook should be thrown.
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/User/ManagerTest.php | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/tests/lib/User/ManagerTest.php b/tests/lib/User/ManagerTest.php index 02200b05d05..badcfb551b7 100644 --- a/tests/lib/User/ManagerTest.php +++ b/tests/lib/User/ManagerTest.php @@ -184,9 +184,8 @@ class ManagerTest extends TestCase { ->method('userExists') ->with($this->equalTo('foo')) ->will($this->returnValue(true)); - $backend->expects($this->once()) - ->method('loginName2UserName') - ->willReturn(false); + $backend->expects($this->never()) + ->method('loginName2UserName'); $manager = new \OC\User\Manager($this->config); $manager->registerBackend($backend); @@ -210,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 @@ -219,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); @@ -238,9 +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->exactly(2)) - ->method('loginName2UserName') - ->willReturn(false); + $backend1->expects($this->never()) + ->method('loginName2UserName'); /** * @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend2 @@ -250,9 +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->once()) - ->method('loginName2UserName') - ->willReturn(false); + $backend2->expects($this->never()) + ->method('loginName2UserName'); $manager = new \OC\User\Manager($this->config); $manager->registerBackend($backend1); @@ -333,9 +350,8 @@ class ManagerTest extends TestCase { ->method('userExists') ->with($this->equalTo('foo')) ->will($this->returnValue(false)); - $backend->expects($this->once()) - ->method('loginName2UserName') - ->willReturn(false); + $backend->expects($this->never()) + ->method('loginName2UserName'); $manager = new \OC\User\Manager($this->config); $manager->registerBackend($backend); |