summaryrefslogtreecommitdiffstats
path: root/apps/federation/lib/Controller
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2017-08-01 11:23:40 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2017-08-01 11:23:40 +0200
commitbc54e6ff7cf6bb587feb5bf93b24b023a07a4123 (patch)
treead5a45004bfc52b59b274f350abd76fd29fe5645 /apps/federation/lib/Controller
parent3ffff08819365e6a38e0c7d381343f59bc2fc89c (diff)
downloadnextcloud-server-bc54e6ff7cf6bb587feb5bf93b24b023a07a4123.tar.gz
nextcloud-server-bc54e6ff7cf6bb587feb5bf93b24b023a07a4123.zip
Use ITimeFactory
* Inject the timefacotry so we can mock it properly in the tests. * Extended unit tests to cover the new paths Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps/federation/lib/Controller')
-rw-r--r--apps/federation/lib/Controller/OCSAuthAPIController.php16
1 files changed, 9 insertions, 7 deletions
diff --git a/apps/federation/lib/Controller/OCSAuthAPIController.php b/apps/federation/lib/Controller/OCSAuthAPIController.php
index f09f0807bd4..b0594877b23 100644
--- a/apps/federation/lib/Controller/OCSAuthAPIController.php
+++ b/apps/federation/lib/Controller/OCSAuthAPIController.php
@@ -32,6 +32,7 @@ use OCA\Federation\TrustedServers;
use OCP\AppFramework\Http;
use OCP\AppFramework\OCS\OCSForbiddenException;
use OCP\AppFramework\OCSController;
+use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\IJobList;
use OCP\ILogger;
use OCP\IRequest;
@@ -61,6 +62,9 @@ class OCSAuthAPIController extends OCSController{
/** @var ILogger */
private $logger;
+ /** @var ITimeFactory */
+ private $timeFactory;
+
/**
* OCSAuthAPI constructor.
*
@@ -71,6 +75,7 @@ class OCSAuthAPIController extends OCSController{
* @param TrustedServers $trustedServers
* @param DbHandler $dbHandler
* @param ILogger $logger
+ * @param ITimeFactory $timeFactory
*/
public function __construct(
$appName,
@@ -79,7 +84,8 @@ class OCSAuthAPIController extends OCSController{
IJobList $jobList,
TrustedServers $trustedServers,
DbHandler $dbHandler,
- ILogger $logger
+ ILogger $logger,
+ ITimeFactory $timeFactory
) {
parent::__construct($appName, $request);
@@ -88,6 +94,7 @@ class OCSAuthAPIController extends OCSController{
$this->trustedServers = $trustedServers;
$this->dbHandler = $dbHandler;
$this->logger = $logger;
+ $this->timeFactory = $timeFactory;
}
/**
@@ -154,7 +161,7 @@ class OCSAuthAPIController extends OCSController{
[
'url' => $url,
'token' => $token,
- 'created' => $this->getTimestamp()
+ 'created' => $this->timeFactory->getTime()
]
);
@@ -202,9 +209,4 @@ class OCSAuthAPIController extends OCSController{
$storedToken = $this->dbHandler->getToken($url);
return hash_equals($storedToken, $token);
}
-
- protected function getTimestamp() {
- return time();
- }
-
}