diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Core/Controller/AppPasswordControllerTest.php | 14 | ||||
-rw-r--r-- | tests/Core/Controller/ClientFlowLoginControllerTest.php | 20 |
2 files changed, 32 insertions, 2 deletions
diff --git a/tests/Core/Controller/AppPasswordControllerTest.php b/tests/Core/Controller/AppPasswordControllerTest.php index f0c223ccc1d..a66bcb3fc26 100644 --- a/tests/Core/Controller/AppPasswordControllerTest.php +++ b/tests/Core/Controller/AppPasswordControllerTest.php @@ -36,6 +36,7 @@ use OCP\IRequest; use OCP\ISession; use OCP\Security\ISecureRandom; use PHPUnit\Framework\MockObject\MockObject; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Test\TestCase; class AppPasswordControllerTest extends TestCase { @@ -55,6 +56,9 @@ class AppPasswordControllerTest extends TestCase { /** @var IRequest|MockObject */ private $request; + /** @var EventDispatcherInterface|\PHPUnit_Framework_MockObject_MockObject */ + private $eventDispatcher; + /** @var AppPasswordController */ private $controller; @@ -66,6 +70,7 @@ class AppPasswordControllerTest extends TestCase { $this->tokenProvider = $this->createMock(IProvider::class); $this->credentialStore = $this->createMock(IStore::class); $this->request = $this->createMock(IRequest::class); + $this->eventDispatcher = $this->createMock(EventDispatcherInterface::class); $this->controller = new AppPasswordController( 'core', @@ -73,7 +78,8 @@ class AppPasswordControllerTest extends TestCase { $this->session, $this->random, $this->tokenProvider, - $this->credentialStore + $this->credentialStore, + $this->eventDispatcher ); } @@ -134,6 +140,9 @@ class AppPasswordControllerTest extends TestCase { IToken::DO_NOT_REMEMBER ); + $this->eventDispatcher->expects($this->once()) + ->method('dispatch'); + $this->controller->getAppPassword(); } @@ -172,6 +181,9 @@ class AppPasswordControllerTest extends TestCase { IToken::DO_NOT_REMEMBER ); + $this->eventDispatcher->expects($this->once()) + ->method('dispatch'); + $this->controller->getAppPassword(); } diff --git a/tests/Core/Controller/ClientFlowLoginControllerTest.php b/tests/Core/Controller/ClientFlowLoginControllerTest.php index eddcc1bbdb9..73b8118a876 100644 --- a/tests/Core/Controller/ClientFlowLoginControllerTest.php +++ b/tests/Core/Controller/ClientFlowLoginControllerTest.php @@ -41,6 +41,7 @@ use OCP\IUserSession; use OCP\Security\ICrypto; use OCP\Security\ISecureRandom; use OCP\Session\Exceptions\SessionNotAvailableException; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Test\TestCase; class ClientFlowLoginControllerTest extends TestCase { @@ -66,6 +67,9 @@ class ClientFlowLoginControllerTest extends TestCase { private $accessTokenMapper; /** @var ICrypto|\PHPUnit_Framework_MockObject_MockObject */ private $crypto; + /** @var EventDispatcherInterface|\PHPUnit_Framework_MockObject_MockObject */ + private $eventDispatcher; + /** @var ClientFlowLoginController */ private $clientFlowLoginController; @@ -90,6 +94,7 @@ class ClientFlowLoginControllerTest extends TestCase { $this->clientMapper = $this->createMock(ClientMapper::class); $this->accessTokenMapper = $this->createMock(AccessTokenMapper::class); $this->crypto = $this->createMock(ICrypto::class); + $this->eventDispatcher = $this->createMock(EventDispatcherInterface::class); $this->clientFlowLoginController = new ClientFlowLoginController( 'core', @@ -103,7 +108,8 @@ class ClientFlowLoginControllerTest extends TestCase { $this->urlGenerator, $this->clientMapper, $this->accessTokenMapper, - $this->crypto + $this->crypto, + $this->eventDispatcher ); } @@ -378,6 +384,9 @@ class ClientFlowLoginControllerTest extends TestCase { ->method('getHeader') ->willReturn(''); + $this->eventDispatcher->expects($this->once()) + ->method('dispatch'); + $expected = new Http\RedirectResponse('nc://login/server:http://example.com&user:MyLoginName&password:MyGeneratedToken'); $this->assertEquals($expected, $this->clientFlowLoginController->generateAppPassword('MyStateToken')); } @@ -462,6 +471,9 @@ class ClientFlowLoginControllerTest extends TestCase { ->with('MyClientIdentifier') ->willReturn($client); + $this->eventDispatcher->expects($this->once()) + ->method('dispatch'); + $expected = new Http\RedirectResponse('https://example.com/redirect.php?state=MyOauthState&code=MyAccessCode'); $this->assertEquals($expected, $this->clientFlowLoginController->generateAppPassword('MyStateToken', 'MyClientIdentifier')); } @@ -534,6 +546,9 @@ class ClientFlowLoginControllerTest extends TestCase { ->method('getHeader') ->willReturn(''); + $this->eventDispatcher->expects($this->once()) + ->method('dispatch'); + $expected = new Http\RedirectResponse('nc://login/server:http://example.com&user:MyLoginName&password:MyGeneratedToken'); $this->assertEquals($expected, $this->clientFlowLoginController->generateAppPassword('MyStateToken')); } @@ -662,6 +677,9 @@ class ClientFlowLoginControllerTest extends TestCase { ->method('getHeader') ->willReturnMap($headers); + $this->eventDispatcher->expects($this->once()) + ->method('dispatch'); + $expected = new Http\RedirectResponse('nc://login/server:' . $expected . '://example.com&user:MyLoginName&password:MyGeneratedToken'); $this->assertEquals($expected, $this->clientFlowLoginController->generateAppPassword('MyStateToken')); } |