|
24 | 24 |
|
25 | 25 | namespace OCA\OAuth2\Tests\Controller; |
26 | 26 |
|
27 | | -use OCA\Files_Sharing\Tests\TestCase; |
28 | 27 | use OCA\OAuth2\Controller\LoginRedirectorController; |
29 | 28 | use OCA\OAuth2\Db\Client; |
30 | 29 | use OCA\OAuth2\Db\ClientMapper; |
| 30 | +use OCA\OAuth2\Exceptions\ClientNotFoundException; |
31 | 31 | use OCP\AppFramework\Http\RedirectResponse; |
| 32 | +use OCP\AppFramework\Http\TemplateResponse; |
32 | 33 | use OCP\IL10N; |
33 | 34 | use OCP\IRequest; |
34 | 35 | use OCP\ISession; |
35 | 36 | use OCP\IURLGenerator; |
| 37 | +use Test\TestCase; |
36 | 38 |
|
37 | 39 | /** |
38 | 40 | * @group DB |
@@ -114,4 +116,22 @@ public function testAuthorizeWrongResponseType() { |
114 | 116 | $expected = new RedirectResponse('http://foo.bar?error=unsupported_response_type&state=MyState'); |
115 | 117 | $this->assertEquals($expected, $this->loginRedirectorController->authorize('MyClientId', 'MyState', 'wrongcode')); |
116 | 118 | } |
| 119 | + |
| 120 | + public function testClientNotFound() { |
| 121 | + $clientNotFound = new ClientNotFoundException('could not find client test123', 0); |
| 122 | + $this->clientMapper |
| 123 | + ->expects($this->once()) |
| 124 | + ->method('getByIdentifier') |
| 125 | + ->willThrowException($clientNotFound); |
| 126 | + $this->session |
| 127 | + ->expects($this->never()) |
| 128 | + ->method('set'); |
| 129 | + |
| 130 | + $response = $this->loginRedirectorController->authorize('MyClientId', 'MyState', 'wrongcode'); |
| 131 | + $this->assertInstanceOf(TemplateResponse::class, $response); |
| 132 | + |
| 133 | + /** @var TemplateResponse $response */ |
| 134 | + $this->assertEquals('404', $response->getTemplateName()); |
| 135 | + $this->assertEquals('guest', $response->getRenderAs()); |
| 136 | + } |
117 | 137 | } |
0 commit comments