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:
authorRoeland Jago Douma <roeland@famdouma.nl>2018-06-26 16:27:20 +0300
committerRoeland Jago Douma <roeland@famdouma.nl>2018-06-26 17:15:53 +0300
commit555de27567183861a5dce77029f499a10b28ee05 (patch)
tree1e898fd64128039e2277d7a319a7972cdd523322 /apps/oauth2/tests
parent43f7ea5852db6375efe1fd2f309eb919e3e97feb (diff)
Validate OAuth2 redirect uri
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps/oauth2/tests')
-rw-r--r--apps/oauth2/tests/Controller/SettingsControllerTest.php15
1 files changed, 14 insertions, 1 deletions
diff --git a/apps/oauth2/tests/Controller/SettingsControllerTest.php b/apps/oauth2/tests/Controller/SettingsControllerTest.php
index 5dddbc65e4c..942aa5c481b 100644
--- a/apps/oauth2/tests/Controller/SettingsControllerTest.php
+++ b/apps/oauth2/tests/Controller/SettingsControllerTest.php
@@ -26,7 +26,9 @@ use OCA\OAuth2\Controller\SettingsController;
use OCA\OAuth2\Db\AccessTokenMapper;
use OCA\OAuth2\Db\Client;
use OCA\OAuth2\Db\ClientMapper;
+use OCP\AppFramework\Http;
use OCP\AppFramework\Http\JSONResponse;
+use OCP\IL10N;
use OCP\IRequest;
use OCP\Security\ISecureRandom;
use Test\TestCase;
@@ -53,6 +55,9 @@ class SettingsControllerTest extends TestCase {
$this->secureRandom = $this->createMock(ISecureRandom::class);
$this->accessTokenMapper = $this->createMock(AccessTokenMapper::class);
$this->defaultTokenMapper = $this->createMock(DefaultTokenMapper::class);
+ $l = $this->createMock(IL10N::class);
+ $l->method('t')
+ ->willReturnArgument(0);
$this->settingsController = new SettingsController(
'oauth2',
@@ -60,7 +65,8 @@ class SettingsControllerTest extends TestCase {
$this->clientMapper,
$this->secureRandom,
$this->accessTokenMapper,
- $this->defaultTokenMapper
+ $this->defaultTokenMapper,
+ $l
);
}
@@ -178,4 +184,11 @@ class SettingsControllerTest extends TestCase {
],
], $data);
}
+
+ public function testInvalidRedirectUri() {
+ $result = $this->settingsController->addClient('test', 'invalidurl');
+
+ $this->assertEquals(Http::STATUS_BAD_REQUEST, $result->getStatus());
+ $this->assertSame(['message' => 'Your redirect url needs to be a full url for example: https://yourdomain.com/path'], $result->getData());
+ }
}