diff options
author | Lukas Reschke <lukas@statuscode.ch> | 2016-11-18 11:55:37 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2016-11-21 11:30:00 +0100 |
commit | 8bf41113682f5d41529ff09f400880574e9b9322 (patch) | |
tree | b37cab919bd8e0de52ab57c11bbab98c6cd522e1 /tests | |
parent | 662dff046d7b287c380656a3c0302cd63736e753 (diff) | |
download | nextcloud-server-8bf41113682f5d41529ff09f400880574e9b9322.tar.gz nextcloud-server-8bf41113682f5d41529ff09f400880574e9b9322.zip |
Fix changing display names for subadmins
Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Core/Controller/OCSControllerTest.php | 49 |
1 files changed, 42 insertions, 7 deletions
diff --git a/tests/Core/Controller/OCSControllerTest.php b/tests/Core/Controller/OCSControllerTest.php index 38356483c95..6c47521786f 100644 --- a/tests/Core/Controller/OCSControllerTest.php +++ b/tests/Core/Controller/OCSControllerTest.php @@ -24,6 +24,8 @@ namespace OC\Core\Controller; use OC\CapabilitiesManager; use OC\Security\Bruteforce\Throttler; +use OC\Security\IdentityProof\Key; +use OC\Security\IdentityProof\Manager; use OCP\AppFramework\Http\DataResponse; use OCP\IRequest; use OCP\IUser; @@ -32,22 +34,18 @@ use OCP\IUserSession; use Test\TestCase; class OCSControllerTest extends TestCase { - /** @var IRequest|\PHPUnit_Framework_MockObject_MockObject */ private $request; - /** @var CapabilitiesManager|\PHPUnit_Framework_MockObject_MockObject */ private $capabilitiesManager; - /** @var IUserSession|\PHPUnit_Framework_MockObject_MockObject */ private $userSession; - /** @var IUserManager|\PHPUnit_Framework_MockObject_MockObject */ private $userManager; - /** @var Throttler|\PHPUnit_Framework_MockObject_MockObject */ private $throttler; - + /** @var Manager|\PHPUnit_Framework_MockObject_MockObject */ + private $keyManager; /** @var OCSController */ private $controller; @@ -59,6 +57,7 @@ class OCSControllerTest extends TestCase { $this->userSession = $this->createMock(IUserSession::class); $this->userManager = $this->createMock(IUserManager::class); $this->throttler = $this->createMock(Throttler::class); + $this->keyManager = $this->createMock(Manager::class); $this->controller = new OCSController( 'core', @@ -66,7 +65,8 @@ class OCSControllerTest extends TestCase { $this->capabilitiesManager, $this->userSession, $this->userManager, - $this->throttler + $this->throttler, + $this->keyManager ); } @@ -206,4 +206,39 @@ class OCSControllerTest extends TestCase { $this->assertEquals($expected, $this->controller->personCheck('', '')); } + + public function testGetIdentityProofWithNotExistingUser() { + $this->userManager + ->expects($this->once()) + ->method('get') + ->with('NotExistingUser') + ->willReturn(null); + + $expected = new DataResponse('User not found', 404); + $this->assertEquals($expected, $this->controller->getIdentityProof('NotExistingUser')); + } + + public function testGetIdentityProof() { + $user = $this->createMock(IUser::class); + $key = $this->createMock(Key::class); + $this->userManager + ->expects($this->once()) + ->method('get') + ->with('ExistingUser') + ->willReturn($user); + $this->keyManager + ->expects($this->once()) + ->method('getKey') + ->with($user) + ->willReturn($key); + $key + ->expects($this->once()) + ->method('getPublic') + ->willReturn('Existing Users public key'); + + $expected = new DataResponse([ + 'public' => 'Existing Users public key', + ]); + $this->assertEquals($expected, $this->controller->getIdentityProof('ExistingUser')); + } } |