]> source.dussan.org Git - nextcloud-server.git/commitdiff
Use function parameters 988/head
authorRoeland Jago Douma <roeland@famdouma.nl>
Fri, 19 Aug 2016 19:41:55 +0000 (21:41 +0200)
committerRoeland Jago Douma <roeland@famdouma.nl>
Sun, 28 Aug 2016 09:40:58 +0000 (11:40 +0200)
apps/federation/lib/Controller/OCSAuthAPIController.php
apps/federation/tests/Controller/OCSAuthAPIControllerTest.php

index 68e0f8b271eeedc9e8e3fd28dfc39e5e8c64f9e1..6cd3b1890efb66789cabffc214558820d7cc8f78 100644 (file)
@@ -96,14 +96,12 @@ class OCSAuthAPIController extends OCSController{
         *
         * request received to ask remote server for a shared secret
         *
+        * @param string $url
+        * @param string $token
         * @return Http\DataResponse
         * @throws OCSForbiddenException
         */
-       public function requestSharedSecret() {
-
-               $url = $this->request->getParam('url');
-               $token = $this->request->getParam('token');
-
+       public function requestSharedSecret($url, $token) {
                if ($this->trustedServers->isTrustedServer($url) === false) {
                        $this->logger->error('remote server not trusted (' . $url . ') while requesting shared secret', ['app' => 'federation']);
                        throw new OCSForbiddenException();
@@ -146,14 +144,12 @@ class OCSAuthAPIController extends OCSController{
         *
         * create shared secret and return it
         *
+        * @param string $url
+        * @param string $token
         * @return Http\DataResponse
         * @throws OCSForbiddenException
         */
-       public function getSharedSecret() {
-
-               $url = $this->request->getParam('url');
-               $token = $this->request->getParam('token');
-
+       public function getSharedSecret($url, $token) {
                if ($this->trustedServers->isTrustedServer($url) === false) {
                        $this->logger->error('remote server not trusted (' . $url . ') while getting shared secret', ['app' => 'federation']);
                        throw new OCSForbiddenException();
index ba10ce57c3093aa2aad81eb2f04f4cb469aa9344..2b231b4fca0b9e1d70fc27676432eadc4cd3312a 100644 (file)
@@ -97,8 +97,6 @@ class OCSAuthAPIControllerTest extends TestCase {
 
                $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
                        ->expects($this->once())
                        ->method('isTrustedServer')->with($url)->willReturn($isTrustedServer);
@@ -116,7 +114,7 @@ class OCSAuthAPIControllerTest extends TestCase {
                }
 
                try {
-                       $result = $this->ocsAuthApi->requestSharedSecret();
+                       $this->ocsAuthApi->requestSharedSecret($url, $token);
                        $this->assertTrue($ok);
                } catch (OCSForbiddenException $e) {
                        $this->assertFalse($ok);
@@ -143,9 +141,6 @@ class OCSAuthAPIControllerTest extends TestCase {
                $url = 'url';
                $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 */
                $ocsAuthApi = $this->getMockBuilder('OCA\Federation\Controller\OCSAuthAPIController')
                        ->setConstructorArgs(
@@ -181,7 +176,7 @@ class OCSAuthAPIControllerTest extends TestCase {
                }
 
                try {
-                       $result = $ocsAuthApi->getSharedSecret();
+                       $result = $ocsAuthApi->getSharedSecret($url, $token);
                        $this->assertTrue($ok);
                        $data =  $result->getData();
                        $this->assertSame('secret', $data['sharedSecret']);