summaryrefslogtreecommitdiffstats
path: root/apps/oauth2/lib
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2017-05-18 19:09:59 +0200
committerLukas Reschke <lukas@statuscode.ch>2017-05-18 20:49:10 +0200
commit691646bdaedca81dc7100337f48a384ca80b5950 (patch)
tree82957278fa20c4fcaba459c5542f01c003babe85 /apps/oauth2/lib
parent59e968977c64e95fea7a7a96a77a892de5a23d7d (diff)
downloadnextcloud-server-691646bdaedca81dc7100337f48a384ca80b5950.tar.gz
nextcloud-server-691646bdaedca81dc7100337f48a384ca80b5950.zip
Add tests for OAuth2 app
Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
Diffstat (limited to 'apps/oauth2/lib')
-rw-r--r--apps/oauth2/lib/Db/AccessTokenMapper.php5
-rw-r--r--apps/oauth2/lib/Db/ClientMapper.php15
2 files changed, 12 insertions, 8 deletions
diff --git a/apps/oauth2/lib/Db/AccessTokenMapper.php b/apps/oauth2/lib/Db/AccessTokenMapper.php
index 51b97bf8d7a..2661c853372 100644
--- a/apps/oauth2/lib/Db/AccessTokenMapper.php
+++ b/apps/oauth2/lib/Db/AccessTokenMapper.php
@@ -21,6 +21,7 @@
namespace OCA\OAuth2\Db;
+use OCA\OAuth2\Exceptions\AccessTokenNotFoundException;
use OCP\AppFramework\Db\Mapper;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
@@ -37,6 +38,7 @@ class AccessTokenMapper extends Mapper {
/**
* @param string $code
* @return AccessToken
+ * @throws AccessTokenNotFoundException
*/
public function getByCode($code) {
$qb = $this->db->getQueryBuilder();
@@ -47,6 +49,9 @@ class AccessTokenMapper extends Mapper {
$result = $qb->execute();
$row = $result->fetch();
$result->closeCursor();
+ if($row === false) {
+ throw new AccessTokenNotFoundException();
+ }
return AccessToken::fromRow($row);
}
diff --git a/apps/oauth2/lib/Db/ClientMapper.php b/apps/oauth2/lib/Db/ClientMapper.php
index cf00afacb70..9df07e2789f 100644
--- a/apps/oauth2/lib/Db/ClientMapper.php
+++ b/apps/oauth2/lib/Db/ClientMapper.php
@@ -21,6 +21,7 @@
namespace OCA\OAuth2\Db;
+use OCA\OAuth2\Exceptions\ClientNotFoundException;
use OCP\AppFramework\Db\Mapper;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
@@ -37,6 +38,7 @@ class ClientMapper extends Mapper {
/**
* @param string $clientIdentifier
* @return Client
+ * @throws ClientNotFoundException
*/
public function getByIdentifier($clientIdentifier) {
$qb = $this->db->getQueryBuilder();
@@ -47,17 +49,16 @@ class ClientMapper extends Mapper {
$result = $qb->execute();
$row = $result->fetch();
$result->closeCursor();
-
- if (!is_array($row)) {
- $row = [];
+ if($row === false) {
+ throw new ClientNotFoundException();
}
-
return Client::fromRow($row);
}
/**
* @param string $uid internal uid of the client
* @return Client
+ * @throws ClientNotFoundException
*/
public function getByUid($uid) {
$qb = $this->db->getQueryBuilder();
@@ -68,11 +69,9 @@ class ClientMapper extends Mapper {
$result = $qb->execute();
$row = $result->fetch();
$result->closeCursor();
-
- if (!is_array($row)) {
- $row = [];
+ if($row === false) {
+ throw new ClientNotFoundException();
}
-
return Client::fromRow($row);
}