Skip to content
Snippets Groups Projects
Unverified Commit b6520827 authored by Roeland Jago Douma's avatar Roeland Jago Douma
Browse files

Use function parameters

parent 16ff2074
No related branches found
No related tags found
No related merge requests found
...@@ -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();
......
...@@ -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']);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment