Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kesselberg <mail@danielkesselberg.de>2020-03-15 13:52:06 +0300
committerDaniel Kesselberg <mail@danielkesselberg.de>2020-03-15 13:55:07 +0300
commit509af24bc94ec18a57b922d65bdcc484144db736 (patch)
tree66ba8ebd97ce53e7dc7ae04165c572a9e6200f87 /apps/oauth2/tests
parentd1a5490b2db8da9f2159a34eecd6a3bba041d0f5 (diff)
Fix invalid instantiation of TemplateResponse if client not found
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
Diffstat (limited to 'apps/oauth2/tests')
-rw-r--r--apps/oauth2/tests/Controller/LoginRedirectorControllerTest.php22
1 files changed, 21 insertions, 1 deletions
diff --git a/apps/oauth2/tests/Controller/LoginRedirectorControllerTest.php b/apps/oauth2/tests/Controller/LoginRedirectorControllerTest.php
index a2dfd048dda..9bea0b328cb 100644
--- a/apps/oauth2/tests/Controller/LoginRedirectorControllerTest.php
+++ b/apps/oauth2/tests/Controller/LoginRedirectorControllerTest.php
@@ -24,15 +24,17 @@
namespace OCA\OAuth2\Tests\Controller;
-use OCA\Files_Sharing\Tests\TestCase;
use OCA\OAuth2\Controller\LoginRedirectorController;
use OCA\OAuth2\Db\Client;
use OCA\OAuth2\Db\ClientMapper;
+use OCA\OAuth2\Exceptions\ClientNotFoundException;
use OCP\AppFramework\Http\RedirectResponse;
+use OCP\AppFramework\Http\TemplateResponse;
use OCP\IL10N;
use OCP\IRequest;
use OCP\ISession;
use OCP\IURLGenerator;
+use Test\TestCase;
/**
* @group DB
@@ -114,4 +116,22 @@ class LoginRedirectorControllerTest extends TestCase {
$expected = new RedirectResponse('http://foo.bar?error=unsupported_response_type&state=MyState');
$this->assertEquals($expected, $this->loginRedirectorController->authorize('MyClientId', 'MyState', 'wrongcode'));
}
+
+ public function testClientNotFound() {
+ $clientNotFound = new ClientNotFoundException('could not find client test123', 0);
+ $this->clientMapper
+ ->expects($this->once())
+ ->method('getByIdentifier')
+ ->willThrowException($clientNotFound);
+ $this->session
+ ->expects($this->never())
+ ->method('set');
+
+ $response = $this->loginRedirectorController->authorize('MyClientId', 'MyState', 'wrongcode');
+ $this->assertInstanceOf(TemplateResponse::class, $response);
+
+ /** @var TemplateResponse $response */
+ $this->assertEquals('404', $response->getTemplateName());
+ $this->assertEquals('guest', $response->getRenderAs());
+ }
}