diff options
author | Daniel Kesselberg <mail@danielkesselberg.de> | 2019-02-17 23:49:54 +0100 |
---|---|---|
committer | Daniel Kesselberg <mail@danielkesselberg.de> | 2019-02-17 23:49:54 +0100 |
commit | 149a98edf69558ade2176467fd1d78919ee0b8c7 (patch) | |
tree | e54ebd5c68b293c445b97d63201d015d464b93ad /tests | |
parent | 2ade2bef8c7c030258943b680401aec64bcdb9a2 (diff) | |
download | nextcloud-server-149a98edf69558ade2176467fd1d78919ee0b8c7.tar.gz nextcloud-server-149a98edf69558ade2176467fd1d78919ee0b8c7.zip |
Publish activity for app token created by client login flow
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Core/Controller/ClientFlowLoginControllerTest.php | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/tests/Core/Controller/ClientFlowLoginControllerTest.php b/tests/Core/Controller/ClientFlowLoginControllerTest.php index eddcc1bbdb9..ed84d456de1 100644 --- a/tests/Core/Controller/ClientFlowLoginControllerTest.php +++ b/tests/Core/Controller/ClientFlowLoginControllerTest.php @@ -29,10 +29,13 @@ use OC\Core\Controller\ClientFlowLoginController; use OCA\OAuth2\Db\AccessTokenMapper; use OCA\OAuth2\Db\Client; use OCA\OAuth2\Db\ClientMapper; +use OCP\Activity\IEvent; +use OCP\Activity\IManager as IActivityManager; use OCP\AppFramework\Http; use OCP\AppFramework\Http\StandaloneTemplateResponse; use OCP\Defaults; use OCP\IL10N; +use OCP\ILogger; use OCP\IRequest; use OCP\ISession; use OCP\IURLGenerator; @@ -66,6 +69,8 @@ class ClientFlowLoginControllerTest extends TestCase { private $accessTokenMapper; /** @var ICrypto|\PHPUnit_Framework_MockObject_MockObject */ private $crypto; + /** @var IActivityManager|\PHPUnit_Framework_MockObject_MockObject */ + private $activityManager; /** @var ClientFlowLoginController */ private $clientFlowLoginController; @@ -90,6 +95,9 @@ class ClientFlowLoginControllerTest extends TestCase { $this->clientMapper = $this->createMock(ClientMapper::class); $this->accessTokenMapper = $this->createMock(AccessTokenMapper::class); $this->crypto = $this->createMock(ICrypto::class); + $this->activityManager = $this->createMock(IActivityManager::class); + /** @var ILogger|\PHPUnit_Framework_MockObject_MockObject $logger */ + $logger = $this->createMock(ILogger::class); $this->clientFlowLoginController = new ClientFlowLoginController( 'core', @@ -103,7 +111,9 @@ class ClientFlowLoginControllerTest extends TestCase { $this->urlGenerator, $this->clientMapper, $this->accessTokenMapper, - $this->crypto + $this->crypto, + $this->activityManager, + $logger ); } @@ -378,6 +388,12 @@ class ClientFlowLoginControllerTest extends TestCase { ->method('getHeader') ->willReturn(''); + $this->activityManager->expects($this->once()) + ->method('generateEvent') + ->willReturn($this->createMock(IEvent::class)); + $this->activityManager->expects($this->once()) + ->method('publish'); + $expected = new Http\RedirectResponse('nc://login/server:http://example.com&user:MyLoginName&password:MyGeneratedToken'); $this->assertEquals($expected, $this->clientFlowLoginController->generateAppPassword('MyStateToken')); } @@ -462,6 +478,12 @@ class ClientFlowLoginControllerTest extends TestCase { ->with('MyClientIdentifier') ->willReturn($client); + $this->activityManager->expects($this->once()) + ->method('generateEvent') + ->willReturn($this->createMock(IEvent::class)); + $this->activityManager->expects($this->once()) + ->method('publish'); + $expected = new Http\RedirectResponse('https://example.com/redirect.php?state=MyOauthState&code=MyAccessCode'); $this->assertEquals($expected, $this->clientFlowLoginController->generateAppPassword('MyStateToken', 'MyClientIdentifier')); } @@ -534,6 +556,12 @@ class ClientFlowLoginControllerTest extends TestCase { ->method('getHeader') ->willReturn(''); + $this->activityManager->expects($this->once()) + ->method('generateEvent') + ->willReturn($this->createMock(IEvent::class)); + $this->activityManager->expects($this->once()) + ->method('publish'); + $expected = new Http\RedirectResponse('nc://login/server:http://example.com&user:MyLoginName&password:MyGeneratedToken'); $this->assertEquals($expected, $this->clientFlowLoginController->generateAppPassword('MyStateToken')); } @@ -662,6 +690,12 @@ class ClientFlowLoginControllerTest extends TestCase { ->method('getHeader') ->willReturnMap($headers); + $this->activityManager->expects($this->once()) + ->method('generateEvent') + ->willReturn($this->createMock(IEvent::class)); + $this->activityManager->expects($this->once()) + ->method('publish'); + $expected = new Http\RedirectResponse('nc://login/server:' . $expected . '://example.com&user:MyLoginName&password:MyGeneratedToken'); $this->assertEquals($expected, $this->clientFlowLoginController->generateAppPassword('MyStateToken')); } |