Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Nextcloud
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Nextcloud
Commits
509af24b
Unverified
Commit
509af24b
authored
5 years ago
by
Daniel Kesselberg
Browse files
Options
Downloads
Patches
Plain Diff
Fix invalid instantiation of TemplateResponse if client not found
Signed-off-by:
Daniel Kesselberg
<
mail@danielkesselberg.de
>
parent
d1a5490b
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
apps/oauth2/lib/Controller/LoginRedirectorController.php
+3
-4
3 additions, 4 deletions
apps/oauth2/lib/Controller/LoginRedirectorController.php
apps/oauth2/tests/Controller/LoginRedirectorControllerTest.php
+21
-1
21 additions, 1 deletion
...oauth2/tests/Controller/LoginRedirectorControllerTest.php
with
24 additions
and
5 deletions
apps/oauth2/lib/Controller/LoginRedirectorController.php
+
3
−
4
View file @
509af24b
...
@@ -85,11 +85,10 @@ class LoginRedirectorController extends Controller {
...
@@ -85,11 +85,10 @@ class LoginRedirectorController extends Controller {
try
{
try
{
$client
=
$this
->
clientMapper
->
getByIdentifier
(
$client_id
);
$client
=
$this
->
clientMapper
->
getByIdentifier
(
$client_id
);
}
catch
(
ClientNotFoundException
$e
)
{
}
catch
(
ClientNotFoundException
$e
)
{
$response
=
new
TemplateResponse
(
'core'
,
'404'
,
'guest'
);
$params
=
[
$response
->
setParams
([
'content'
=>
$this
->
l
->
t
(
'Your client is not authorized to connect. Please inform the administrator of your client.'
),
'content'
=>
$this
->
l
->
t
(
'Your client is not authorized to connect. Please inform the administrator of your client.'
),
]
)
;
];
return
$response
;
return
new
TemplateResponse
(
'core'
,
'404'
,
$params
,
'guest'
)
;
}
}
if
(
$response_type
!==
'code'
)
{
if
(
$response_type
!==
'code'
)
{
...
...
This diff is collapsed.
Click to expand it.
apps/oauth2/tests/Controller/LoginRedirectorControllerTest.php
+
21
−
1
View file @
509af24b
...
@@ -24,15 +24,17 @@
...
@@ -24,15 +24,17 @@
namespace
OCA\OAuth2\Tests\Controller
;
namespace
OCA\OAuth2\Tests\Controller
;
use
OCA\Files_Sharing
\Tests\TestCase
;
use
OCA\OAuth2\Controller\LoginRedirectorController
;
use
OCA\OAuth2\Controller\LoginRedirectorController
;
use
OCA\OAuth2\Db\Client
;
use
OCA\OAuth2\Db\Client
;
use
OCA\OAuth2\Db\ClientMapper
;
use
OCA\OAuth2\Db\ClientMapper
;
use
OCA\OAuth2\Exceptions\ClientNotFoundException
;
use
OCP\AppFramework\Http\RedirectResponse
;
use
OCP\AppFramework\Http\RedirectResponse
;
use
OCP\AppFramework\Http\TemplateResponse
;
use
OCP\IL10N
;
use
OCP\IL10N
;
use
OCP\IRequest
;
use
OCP\IRequest
;
use
OCP\ISession
;
use
OCP\ISession
;
use
OCP\IURLGenerator
;
use
OCP\IURLGenerator
;
use
Test\TestCase
;
/**
/**
* @group DB
* @group DB
...
@@ -114,4 +116,22 @@ class LoginRedirectorControllerTest extends TestCase {
...
@@ -114,4 +116,22 @@ class LoginRedirectorControllerTest extends TestCase {
$expected
=
new
RedirectResponse
(
'http://foo.bar?error=unsupported_response_type&state=MyState'
);
$expected
=
new
RedirectResponse
(
'http://foo.bar?error=unsupported_response_type&state=MyState'
);
$this
->
assertEquals
(
$expected
,
$this
->
loginRedirectorController
->
authorize
(
'MyClientId'
,
'MyState'
,
'wrongcode'
));
$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
());
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment