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
b6520827
Unverified
Commit
b6520827
authored
8 years ago
by
Roeland Jago Douma
Browse files
Options
Downloads
Patches
Plain Diff
Use function parameters
parent
16ff2074
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
apps/federation/lib/Controller/OCSAuthAPIController.php
+6
-10
6 additions, 10 deletions
apps/federation/lib/Controller/OCSAuthAPIController.php
apps/federation/tests/Controller/OCSAuthAPIControllerTest.php
+2
-7
2 additions, 7 deletions
.../federation/tests/Controller/OCSAuthAPIControllerTest.php
with
8 additions
and
17 deletions
apps/federation/lib/Controller/OCSAuthAPIController.php
+
6
−
10
View file @
b6520827
...
@@ -96,14 +96,12 @@ class OCSAuthAPIController extends OCSController{
...
@@ -96,14 +96,12 @@ class OCSAuthAPIController extends OCSController{
*
*
* request received to ask remote server for a shared secret
* request received to ask remote server for a shared secret
*
*
* @param string $url
* @param string $token
* @return Http\DataResponse
* @return Http\DataResponse
* @throws OCSForbiddenException
* @throws OCSForbiddenException
*/
*/
public
function
requestSharedSecret
()
{
public
function
requestSharedSecret
(
$url
,
$token
)
{
$url
=
$this
->
request
->
getParam
(
'url'
);
$token
=
$this
->
request
->
getParam
(
'token'
);
if
(
$this
->
trustedServers
->
isTrustedServer
(
$url
)
===
false
)
{
if
(
$this
->
trustedServers
->
isTrustedServer
(
$url
)
===
false
)
{
$this
->
logger
->
error
(
'remote server not trusted ('
.
$url
.
') while requesting shared secret'
,
[
'app'
=>
'federation'
]);
$this
->
logger
->
error
(
'remote server not trusted ('
.
$url
.
') while requesting shared secret'
,
[
'app'
=>
'federation'
]);
throw
new
OCSForbiddenException
();
throw
new
OCSForbiddenException
();
...
@@ -146,14 +144,12 @@ class OCSAuthAPIController extends OCSController{
...
@@ -146,14 +144,12 @@ class OCSAuthAPIController extends OCSController{
*
*
* create shared secret and return it
* create shared secret and return it
*
*
* @param string $url
* @param string $token
* @return Http\DataResponse
* @return Http\DataResponse
* @throws OCSForbiddenException
* @throws OCSForbiddenException
*/
*/
public
function
getSharedSecret
()
{
public
function
getSharedSecret
(
$url
,
$token
)
{
$url
=
$this
->
request
->
getParam
(
'url'
);
$token
=
$this
->
request
->
getParam
(
'token'
);
if
(
$this
->
trustedServers
->
isTrustedServer
(
$url
)
===
false
)
{
if
(
$this
->
trustedServers
->
isTrustedServer
(
$url
)
===
false
)
{
$this
->
logger
->
error
(
'remote server not trusted ('
.
$url
.
') while getting shared secret'
,
[
'app'
=>
'federation'
]);
$this
->
logger
->
error
(
'remote server not trusted ('
.
$url
.
') while getting shared secret'
,
[
'app'
=>
'federation'
]);
throw
new
OCSForbiddenException
();
throw
new
OCSForbiddenException
();
...
...
This diff is collapsed.
Click to expand it.
apps/federation/tests/Controller/OCSAuthAPIControllerTest.php
+
2
−
7
View file @
b6520827
...
@@ -97,8 +97,6 @@ class OCSAuthAPIControllerTest extends TestCase {
...
@@ -97,8 +97,6 @@ class OCSAuthAPIControllerTest extends TestCase {
$url
=
'url'
;
$url
=
'url'
;
$this
->
request
->
expects
(
$this
->
at
(
0
))
->
method
(
'getParam'
)
->
with
(
'url'
)
->
willReturn
(
$url
);
$this
->
request
->
expects
(
$this
->
at
(
1
))
->
method
(
'getParam'
)
->
with
(
'token'
)
->
willReturn
(
$token
);
$this
->
trustedServers
$this
->
trustedServers
->
expects
(
$this
->
once
())
->
expects
(
$this
->
once
())
->
method
(
'isTrustedServer'
)
->
with
(
$url
)
->
willReturn
(
$isTrustedServer
);
->
method
(
'isTrustedServer'
)
->
with
(
$url
)
->
willReturn
(
$isTrustedServer
);
...
@@ -116,7 +114,7 @@ class OCSAuthAPIControllerTest extends TestCase {
...
@@ -116,7 +114,7 @@ class OCSAuthAPIControllerTest extends TestCase {
}
}
try
{
try
{
$result
=
$this
->
ocsAuthApi
->
requestSharedSecret
();
$this
->
ocsAuthApi
->
requestSharedSecret
(
$url
,
$token
);
$this
->
assertTrue
(
$ok
);
$this
->
assertTrue
(
$ok
);
}
catch
(
OCSForbiddenException
$e
)
{
}
catch
(
OCSForbiddenException
$e
)
{
$this
->
assertFalse
(
$ok
);
$this
->
assertFalse
(
$ok
);
...
@@ -143,9 +141,6 @@ class OCSAuthAPIControllerTest extends TestCase {
...
@@ -143,9 +141,6 @@ class OCSAuthAPIControllerTest extends TestCase {
$url
=
'url'
;
$url
=
'url'
;
$token
=
'token'
;
$token
=
'token'
;
$this
->
request
->
expects
(
$this
->
at
(
0
))
->
method
(
'getParam'
)
->
with
(
'url'
)
->
willReturn
(
$url
);
$this
->
request
->
expects
(
$this
->
at
(
1
))
->
method
(
'getParam'
)
->
with
(
'token'
)
->
willReturn
(
$token
);
/** @var OCSAuthAPIController | \PHPUnit_Framework_MockObject_MockObject $ocsAuthApi */
/** @var OCSAuthAPIController | \PHPUnit_Framework_MockObject_MockObject $ocsAuthApi */
$ocsAuthApi
=
$this
->
getMockBuilder
(
'OCA\Federation\Controller\OCSAuthAPIController'
)
$ocsAuthApi
=
$this
->
getMockBuilder
(
'OCA\Federation\Controller\OCSAuthAPIController'
)
->
setConstructorArgs
(
->
setConstructorArgs
(
...
@@ -181,7 +176,7 @@ class OCSAuthAPIControllerTest extends TestCase {
...
@@ -181,7 +176,7 @@ class OCSAuthAPIControllerTest extends TestCase {
}
}
try
{
try
{
$result
=
$ocsAuthApi
->
getSharedSecret
();
$result
=
$ocsAuthApi
->
getSharedSecret
(
$url
,
$token
);
$this
->
assertTrue
(
$ok
);
$this
->
assertTrue
(
$ok
);
$data
=
$result
->
getData
();
$data
=
$result
->
getData
();
$this
->
assertSame
(
'secret'
,
$data
[
'sharedSecret'
]);
$this
->
assertSame
(
'secret'
,
$data
[
'sharedSecret'
]);
...
...
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