diff --git a/app/modules/api/Controllers/ControllerBase.php b/app/modules/api/Controllers/ControllerBase.php
index e92a706d..26c489b0 100644
--- a/app/modules/api/Controllers/ControllerBase.php
+++ b/app/modules/api/Controllers/ControllerBase.php
@@ -29,7 +29,6 @@ use Klein\Klein;
use SP\Core\Context\StatelessContext;
use SP\Core\Events\EventDispatcher;
use SP\Core\Exceptions\SPException;
-use SP\Services\Api\ApiRequest;
use SP\Services\Api\ApiResponse;
use SP\Services\Api\ApiService;
use SP\Services\Api\JsonRpcResponse;
@@ -78,20 +77,19 @@ abstract class ControllerBase
/**
* Constructor
*
- * @param Container $container
- * @param string $actionName
- * @param ApiRequest $apiRequest
+ * @param Container $container
+ * @param string $actionName
+ *
* @throws \DI\DependencyException
* @throws \DI\NotFoundException
*/
- public final function __construct(Container $container, $actionName, ApiRequest $apiRequest)
+ public final function __construct(Container $container, $actionName)
{
$this->dic = $container;
$this->context = $container->get(StatelessContext::class);
$this->eventDispatcher = $container->get(EventDispatcher::class);
$this->router = $container->get(Klein::class);
-
- $this->apiService = $container->get(ApiService::class)->setApiRequest($apiRequest);
+ $this->apiService = $container->get(ApiService::class);
$this->controllerName = $this->getControllerName();
$this->actionName = $actionName;
@@ -121,6 +119,7 @@ abstract class ControllerBase
/**
* @param int $actionId
+ *
* @throws \Exception
* @throws \SP\Services\ServiceException
*/
@@ -137,6 +136,7 @@ abstract class ControllerBase
* {"jsonrpc": "2.0", "result": 19, "id": 3}
*
* @param \SP\Services\Api\ApiResponse $apiResponse
+ *
* @return string La cadena en formato JSON
*/
final protected function returnResponse(ApiResponse $apiResponse)
@@ -159,6 +159,7 @@ abstract class ControllerBase
/**
* @param \Exception $e
+ *
* @return string
*/
final protected function returnResponseException(\Exception $e)
diff --git a/lib/SP/Bootstrap.php b/lib/SP/Bootstrap.php
index fa96bfb0..e40ad99a 100644
--- a/lib/SP/Bootstrap.php
+++ b/lib/SP/Bootstrap.php
@@ -118,6 +118,7 @@ class Bootstrap
* Bootstrap constructor.
*
* @param Container $container
+ *
* @throws \DI\DependencyException
* @throws \DI\NotFoundException
*/
@@ -158,7 +159,7 @@ class Bootstrap
'@/api\.php',
function ($request, $response, $service) use ($oops) {
try {
- $apiRequest = (new ApiRequest())->getRequestData();
+ $apiRequest = self::$container->get(ApiRequest::class);
list($controller, $action) = explode('/', $apiRequest->getMethod());
@@ -429,6 +430,7 @@ class Bootstrap
/**
* @param Container $container
* @param string $module
+ *
* @throws InitializationException
* @throws \DI\DependencyException
* @throws \DI\NotFoundException
diff --git a/lib/SP/Http/Request.php b/lib/SP/Http/Request.php
index c9ef73d1..62d85aea 100644
--- a/lib/SP/Http/Request.php
+++ b/lib/SP/Http/Request.php
@@ -25,7 +25,6 @@
namespace SP\Http;
use Klein\Klein;
-use phpseclib\Crypt\RSA;
use SP\Bootstrap;
use SP\Core\Crypt\CryptPKI;
use SP\Html\Html;
@@ -47,6 +46,7 @@ class Request
* Devolver las cabeceras enviadas desde el cliente.
*
* @param string $header nombre de la cabecera a devolver
+ *
* @return array|string
*/
public static function getRequestHeaders($header = '')
@@ -89,6 +89,7 @@ class Request
* Analizar un valor encriptado y devolverlo desencriptado
*
* @param $param
+ *
* @return string
*/
public static function analyzeEncrypted($param)
@@ -100,25 +101,29 @@ class Request
}
try {
- // FIXME: DIC???
// Desencriptar con la clave RSA
- if (($clearData = (new CryptPKI(Bootstrap::getContainer()->get(RSA::class)))->decryptRSA(base64_decode($encryptedData))) === false) {
+ $clearData = Bootstrap::getContainer()->get(CryptPKI::class)
+ ->decryptRSA(base64_decode($encryptedData));
+
+ // Desencriptar con la clave RSA
+ if ($clearData === false) {
debugLog('No RSA encrypted data from request');
return $encryptedData;
}
+
+ return $clearData;
} catch (\Exception $e) {
processException($e);
return $encryptedData;
}
-
- return $clearData;
}
/**
* @param $param
* @param $default
+ *
* @return string
*/
public static function analyzeString($param, $default = null)
@@ -133,6 +138,7 @@ class Request
/**
* @param $param
* @param $default
+ *
* @return string
*/
public static function analyzeEmail($param, $default = null)
@@ -153,6 +159,7 @@ class Request
* @param bool $check comprobar si el parámetro está presente
* @param mixed $force valor devuelto si el parámeto está definido
* @param bool $sanitize escapar/eliminar carácteres especiales
+ *
* @return mixed si está presente el parámeto en la petición devuelve bool. Si lo está, devuelve el valor.
* @deprecated
*/
@@ -179,6 +186,7 @@ class Request
* @param $value mixed valor a analizar
* @param $default mixed tipo por defecto a devolver
* @param $sanitize bool limpiar una cadena de caracteres
+ *
* @return mixed
* @deprecated
*/
@@ -210,6 +218,7 @@ class Request
* @param string $param
* @param callable|null $mapper
* @param mixed $default
+ *
* @return mixed
*/
public static function analyzeArray($param, callable $mapper = null, $default = null)
@@ -234,6 +243,7 @@ class Request
/**
* @param $param
* @param $default
+ *
* @return int
*/
public static function analyzeInt($param, $default = null)
@@ -248,6 +258,7 @@ class Request
/**
* @param $param
* @param $default
+ *
* @return bool
*/
public static function analyzeBool($param, $default = null)
@@ -262,6 +273,7 @@ class Request
/**
* @param $param
* @param $default
+ *
* @return string
*/
public static function analyzePassword($param, $default = '')
@@ -277,6 +289,7 @@ class Request
* Comprobar si se realiza una recarga de la página
*
* @param Klein $router
+ *
* @return bool
*/
public static function checkReload(Klein $router)
@@ -308,6 +321,7 @@ class Request
*
* @param $file
* @param null $base
+ *
* @return string
*/
public static function getSecureAppFile($file, $base = null)
@@ -320,6 +334,7 @@ class Request
*
* @param $path
* @param string $base
+ *
* @return string
*/
public static function getSecureAppPath($path, $base = null)
diff --git a/lib/SP/Services/Api/ApiRequest.php b/lib/SP/Services/Api/ApiRequest.php
index d65453b5..13f70925 100644
--- a/lib/SP/Services/Api/ApiRequest.php
+++ b/lib/SP/Services/Api/ApiRequest.php
@@ -24,15 +24,12 @@
namespace SP\Services\Api;
-use SP\Core\DataCollection;
-use SP\Services\ServiceException;
-
/**
* Class ApiRequest
*
* @package SP\Services\Api
*/
-class ApiRequest extends DataCollection
+class ApiRequest
{
/**
* @var string
@@ -42,6 +39,107 @@ class ApiRequest extends DataCollection
* @var int
*/
protected $id;
+ /**
+ * @var ApiRequestData
+ */
+ protected $data;
+
+ /**
+ * ApiRequest constructor.
+ *
+ * @param string $request
+ *
+ * @throws ApiRequestException
+ */
+ public function __construct($request = null)
+ {
+ if ($request === null) {
+ $this->getRequestJsonData($this->getRequestContent());
+ } else {
+ $this->getRequestJsonData($request);
+ }
+ }
+
+ /**
+ * Obtener los datos de la petición
+ *
+ * Comprueba que el JSON esté bien formado
+ *
+ * @param null $request
+ *
+ * @return ApiRequest
+ * @throws ApiRequestException
+ */
+ public function getRequestJsonData($request)
+ {
+ $data = json_decode($request, true);
+
+ if ($data === null) {
+ throw new ApiRequestException(
+ __u('Datos inválidos'),
+ ApiRequestException::ERROR,
+ json_last_error_msg(),
+ -32700
+ );
+ }
+
+ if (!isset($data['jsonrpc'], $data['method'], $data['params'], $data['id'], $data['params']['authToken'])) {
+ throw new ApiRequestException(
+ __u('Fomato incorrecto'),
+ ApiRequestException::ERROR,
+ null,
+ -32600
+ );
+ }
+
+ $this->method = preg_replace('#[^a-z/]+#i', '', $data['method']);
+ $this->id = filter_var($data['id'], FILTER_VALIDATE_INT) ?: 1;
+ $this->data = new ApiRequestData();
+ $this->data->replace($data['params']);
+
+ return $this;
+ }
+
+ /**
+ * @return string
+ * @throws ApiRequestException
+ */
+ public function getRequestContent()
+ {
+ $content = file_get_contents('php://input');
+
+ if ($content === false || empty($content)) {
+ throw new ApiRequestException(
+ __u('Datos inválidos'),
+ ApiRequestException::ERROR,
+ null,
+ -32700
+ );
+ }
+
+ return $content;
+ }
+
+ /**
+ * @param string $key
+ * @param mixed $default
+ *
+ * @return mixed
+ */
+ public function get(string $key, $default = null)
+ {
+ return $this->data->get($key, $default);
+ }
+
+ /**
+ * @param string $key
+ *
+ * @return bool
+ */
+ public function exists(string $key)
+ {
+ return $this->data->exists($key);
+ }
/**
* @return string
@@ -58,40 +156,4 @@ class ApiRequest extends DataCollection
{
return $this->id;
}
-
- /**
- * Obtener los datos de la petición
- *
- * Comprueba que el JSON esté bien formado
- *
- * @throws ServiceException
- */
- public function getRequestData()
- {
- if (($request = file_get_contents('php://input')) === false
- || ($data = json_decode($request, true)) === null
- ) {
- throw new ServiceException(
- __u('Datos inválidos'),
- ServiceException::ERROR,
- null,
- -32700
- );
- }
-
- if (!isset($data['jsonrpc'], $data['method'], $data['params'], $data['id'], $data['params']['authToken'])) {
- throw new ServiceException(
- __u('Fomato incorrecto'),
- ServiceException::ERROR,
- null,
- -32600
- );
- }
-
- $this->method = preg_replace('#[^a-z/]+#i', '', $data['method']);
- $this->id = filter_var($data['id'], FILTER_VALIDATE_INT);
- $this->attributes = $data['params'];
-
- return $this;
- }
}
\ No newline at end of file
diff --git a/lib/SP/Services/Api/ApiRequestData.php b/lib/SP/Services/Api/ApiRequestData.php
new file mode 100644
index 00000000..dc7c5043
--- /dev/null
+++ b/lib/SP/Services/Api/ApiRequestData.php
@@ -0,0 +1,38 @@
+.
+ */
+
+namespace SP\Services\Api;
+
+
+use SP\Core\DataCollection;
+
+/**
+ * Class ApiData
+ *
+ * @package SP\Services\Api
+ */
+class ApiRequestData extends DataCollection
+{
+
+}
\ No newline at end of file
diff --git a/lib/SP/Services/Api/ApiRequestException.php b/lib/SP/Services/Api/ApiRequestException.php
new file mode 100644
index 00000000..207fac44
--- /dev/null
+++ b/lib/SP/Services/Api/ApiRequestException.php
@@ -0,0 +1,37 @@
+.
+ */
+
+namespace SP\Services\Api;
+
+use SP\Core\Exceptions\SPException;
+
+/**
+ * Class ApiRequestException
+ *
+ * @package SP\Services\Api
+ */
+class ApiRequestException extends SPException
+{
+
+}
\ No newline at end of file
diff --git a/lib/SP/Services/Api/ApiService.php b/lib/SP/Services/Api/ApiService.php
index fe58cb05..7d98e153 100644
--- a/lib/SP/Services/Api/ApiService.php
+++ b/lib/SP/Services/Api/ApiService.php
@@ -175,7 +175,7 @@ class ApiService extends Service
'text' => __('Texto a buscar'),
'count' => __('Número de resultados a mostrar'),
'categoryId' => __('Id de categoría a filtrar'),
- 'customerId' => __('Id de cliente a filtrar')
+ 'clientId' => __('Id de cliente a filtrar')
]
],
'account/view' => [
@@ -414,5 +414,6 @@ class ApiService extends Service
$this->authTokenService = $this->dic->get(AuthTokenService::class);
$this->trackService = $this->dic->get(TrackService::class);
$this->trackRequest = TrackService::getTrackRequest('api');
+ $this->apiRequest = $this->dic->get(ApiRequest::class);
}
}
\ No newline at end of file
diff --git a/tests/Services/AccountAclServiceTest.php b/tests/Services/Account/AccountAclServiceTest.php
similarity index 99%
rename from tests/Services/AccountAclServiceTest.php
rename to tests/Services/Account/AccountAclServiceTest.php
index 0872a8ed..60d097c4 100644
--- a/tests/Services/AccountAclServiceTest.php
+++ b/tests/Services/Account/AccountAclServiceTest.php
@@ -2,8 +2,8 @@
/**
* sysPass
*
- * @author nuxsmin
- * @link https://syspass.org
+ * @author nuxsmin
+ * @link https://syspass.org
* @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
@@ -22,7 +22,7 @@
* along with sysPass. If not, see .
*/
-namespace SP\Tests\Services;
+namespace SP\Tests\Services\Account;
use SP\Account\AccountAcl;
use SP\Core\Acl\Acl;
diff --git a/tests/Services/AccountCryptServiceTest.php b/tests/Services/Account/AccountCryptServiceTest.php
similarity index 98%
rename from tests/Services/AccountCryptServiceTest.php
rename to tests/Services/Account/AccountCryptServiceTest.php
index b572d111..6168a466 100644
--- a/tests/Services/AccountCryptServiceTest.php
+++ b/tests/Services/Account/AccountCryptServiceTest.php
@@ -2,8 +2,8 @@
/**
* sysPass
*
- * @author nuxsmin
- * @link https://syspass.org
+ * @author nuxsmin
+ * @link https://syspass.org
* @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
@@ -22,7 +22,7 @@
* along with sysPass. If not, see .
*/
-namespace SP\Tests\Services;
+namespace SP\Tests\Services\Account;
use Defuse\Crypto\Exception\CryptoException;
use SP\Core\Crypt\Crypt;
diff --git a/tests/Services/AccountFileServiceTest.php b/tests/Services/Account/AccountFileServiceTest.php
similarity index 99%
rename from tests/Services/AccountFileServiceTest.php
rename to tests/Services/Account/AccountFileServiceTest.php
index fbef6195..4ecdd208 100644
--- a/tests/Services/AccountFileServiceTest.php
+++ b/tests/Services/Account/AccountFileServiceTest.php
@@ -2,8 +2,8 @@
/**
* sysPass
*
- * @author nuxsmin
- * @link https://syspass.org
+ * @author nuxsmin
+ * @link https://syspass.org
* @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
@@ -22,7 +22,7 @@
* along with sysPass. If not, see .
*/
-namespace SP\Tests\Services;
+namespace SP\Tests\Services\Account;
use SP\Core\Exceptions\InvalidImageException;
use SP\DataModel\FileData;
diff --git a/tests/Services/AccountHistoryServiceTest.php b/tests/Services/Account/AccountHistoryServiceTest.php
similarity index 99%
rename from tests/Services/AccountHistoryServiceTest.php
rename to tests/Services/Account/AccountHistoryServiceTest.php
index 227658dd..4a412496 100644
--- a/tests/Services/AccountHistoryServiceTest.php
+++ b/tests/Services/Account/AccountHistoryServiceTest.php
@@ -2,8 +2,8 @@
/**
* sysPass
*
- * @author nuxsmin
- * @link https://syspass.org
+ * @author nuxsmin
+ * @link https://syspass.org
* @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
@@ -22,7 +22,7 @@
* along with sysPass. If not, see .
*/
-namespace SP\Tests\Services;
+namespace SP\Tests\Services\Account;
use SP\DataModel\AccountHistoryData;
use SP\DataModel\Dto\AccountHistoryCreateDto;
diff --git a/tests/Services/AccountSearchServiceTest.php b/tests/Services/Account/AccountSearchServiceTest.php
similarity index 99%
rename from tests/Services/AccountSearchServiceTest.php
rename to tests/Services/Account/AccountSearchServiceTest.php
index 4bc5d427..bfc22f8b 100644
--- a/tests/Services/AccountSearchServiceTest.php
+++ b/tests/Services/Account/AccountSearchServiceTest.php
@@ -2,8 +2,8 @@
/**
* sysPass
*
- * @author nuxsmin
- * @link https://syspass.org
+ * @author nuxsmin
+ * @link https://syspass.org
* @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
@@ -22,7 +22,7 @@
* along with sysPass. If not, see .
*/
-namespace SP\Tests\Services;
+namespace SP\Tests\Services\Account;
use SP\Account\AccountSearchFilter;
use SP\Account\AccountSearchItem;
diff --git a/tests/Services/AccountServiceTest.php b/tests/Services/Account/AccountServiceTest.php
similarity index 99%
rename from tests/Services/AccountServiceTest.php
rename to tests/Services/Account/AccountServiceTest.php
index 028f9f19..eb18aae7 100644
--- a/tests/Services/AccountServiceTest.php
+++ b/tests/Services/Account/AccountServiceTest.php
@@ -2,8 +2,8 @@
/**
* sysPass
*
- * @author nuxsmin
- * @link https://syspass.org
+ * @author nuxsmin
+ * @link https://syspass.org
* @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
@@ -22,7 +22,7 @@
* along with sysPass. If not, see .
*/
-namespace SP\Tests\Services;
+namespace SP\Tests\Services\Account;
use SP\Account\AccountRequest;
use SP\Account\AccountSearchFilter;
diff --git a/tests/Services/AccountToFavoriteServiceTest.php b/tests/Services/Account/AccountToFavoriteServiceTest.php
similarity index 97%
rename from tests/Services/AccountToFavoriteServiceTest.php
rename to tests/Services/Account/AccountToFavoriteServiceTest.php
index d8128b50..8a385d28 100644
--- a/tests/Services/AccountToFavoriteServiceTest.php
+++ b/tests/Services/Account/AccountToFavoriteServiceTest.php
@@ -2,8 +2,8 @@
/**
* sysPass
*
- * @author nuxsmin
- * @link https://syspass.org
+ * @author nuxsmin
+ * @link https://syspass.org
* @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
@@ -22,7 +22,7 @@
* along with sysPass. If not, see .
*/
-namespace SP\Tests\Services;
+namespace SP\Tests\Services\Account;
use SP\Core\Exceptions\ConstraintException;
use SP\Services\Account\AccountToFavoriteService;
diff --git a/tests/Services/AccountToTagServiceTest.php b/tests/Services/Account/AccountToTagServiceTest.php
similarity index 95%
rename from tests/Services/AccountToTagServiceTest.php
rename to tests/Services/Account/AccountToTagServiceTest.php
index 924b4901..07967604 100644
--- a/tests/Services/AccountToTagServiceTest.php
+++ b/tests/Services/Account/AccountToTagServiceTest.php
@@ -2,8 +2,8 @@
/**
* sysPass
*
- * @author nuxsmin
- * @link https://syspass.org
+ * @author nuxsmin
+ * @link https://syspass.org
* @copyright 2012-2018, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
@@ -22,7 +22,7 @@
* along with sysPass. If not, see .
*/
-namespace SP\Tests\Services;
+namespace SP\Tests\Services\Account;
use SP\Services\Account\AccountToTagService;
use SP\Storage\Database\DatabaseConnectionData;
diff --git a/tests/Services/Api/ApiRequestTest.php b/tests/Services/Api/ApiRequestTest.php
new file mode 100644
index 00000000..266dcfa7
--- /dev/null
+++ b/tests/Services/Api/ApiRequestTest.php
@@ -0,0 +1,109 @@
+.
+ */
+
+namespace SP\Tests\Services\Api;
+
+use PHPUnit\Framework\TestCase;
+use SP\Services\Api\ApiRequest;
+use SP\Services\Api\ApiRequestException;
+use function SP\Tests\getResource;
+
+/**
+ * Class ApiRequestTest
+ *
+ * @package SP\Tests\Services\Api
+ */
+class ApiRequestTest extends TestCase
+{
+ /**
+ * @throws \SP\Services\Api\ApiRequestException
+ */
+ public function testGetRequestJsonData()
+ {
+ $apiRequest = new ApiRequest(getResource('json', 'account_search.json'));
+ $this->assertEquals(10, $apiRequest->getId());
+ $this->assertEquals('account/search', $apiRequest->getMethod());
+ $this->assertEquals('ce4e5f2e5700d9032b0cbb0769a6d7cf8557484da492d3c32626a74bb28fb44b', $apiRequest->get('authToken'));
+ $this->assertEquals('API', $apiRequest->get('text'));
+ $this->assertEquals(5, $apiRequest->get('count'));
+ $this->assertEquals(1, $apiRequest->get('clientId'));
+ $this->assertEquals(1, $apiRequest->get('categoryId'));
+
+ }
+
+ /**
+ * @throws ApiRequestException
+ */
+ public function testWrongJson()
+ {
+ $this->expectException(ApiRequestException::class);
+ $this->expectExceptionCode(-32700);
+
+ $wrongJson = '{abc}';
+ new ApiRequest($wrongJson);
+ }
+
+ /**
+ * testWrongJsonParams
+ */
+ public function testWrongJsonParams()
+ {
+ $this->checkJsonException('{"a": 1}');
+ $this->checkJsonException('{"jsonrpc": 2.0}');
+ $this->checkJsonException('{"jsonrpc": 2.0, "method": "account/search"}');
+ $this->checkJsonException('{"jsonrpc": 2.0, "method": "account/search", "params": {}}');
+ $this->checkJsonException('{"jsonrpc": 2.0, "method": "account/search", "params": {"authToken": "1"}}');
+ }
+
+ /**
+ * @throws ApiRequestException
+ */
+ public function testFilterData()
+ {
+ $json = '{"jsonrpc": 2.0, "method": "&account/$(search)?!%()=?¿", "params": {"authToken": "1"}, "id": "10"}';
+
+ $apiRequest = new ApiRequest($json);
+ $this->assertEquals(10, $apiRequest->getId());
+ $this->assertEquals('account/search', $apiRequest->getMethod());
+ }
+
+ /**
+ * @param $json
+ */
+ private function checkJsonException($json)
+ {
+ try {
+ new ApiRequest($json);
+
+ $this->fail('No exception thrown');
+ } catch (ApiRequestException $e) {
+ $this->assertEquals(-32600, $e->getCode());
+ }
+ }
+
+ public function testGetRequestContent()
+ {
+ $this->markTestSkipped('Should be an HTTP test');
+ }
+}
diff --git a/tests/Services/Api/ApiServiceTest.php b/tests/Services/Api/ApiServiceTest.php
new file mode 100644
index 00000000..b5dcf03e
--- /dev/null
+++ b/tests/Services/Api/ApiServiceTest.php
@@ -0,0 +1,120 @@
+.
+ */
+
+namespace SP\Tests\Services\Api;
+
+use SP\Core\Acl\ActionsInterface;
+use SP\Services\Api\ApiService;
+use SP\Storage\Database\DatabaseConnectionData;
+use SP\Tests\DatabaseTestCase;
+use function SP\Tests\setupContext;
+
+/**
+ * Class ApiServiceTest
+ *
+ * @package SP\Tests\Services
+ */
+class ApiServiceTest extends DatabaseTestCase
+{
+ /**
+ * @var ApiService
+ */
+ private static $service;
+
+ /**
+ * @throws \DI\NotFoundException
+ * @throws \SP\Core\Context\ContextException
+ * @throws \DI\DependencyException
+ */
+ public static function setUpBeforeClass()
+ {
+ $dic = setupContext();
+
+ self::$dataset = 'syspass_account.xml';
+
+ // Datos de conexión a la BBDD
+ self::$databaseConnectionData = $dic->get(DatabaseConnectionData::class);
+
+ // Inicializar el servicio
+ self::$service = $dic->get(ApiService::class);
+ }
+
+ /**
+ * @throws \SP\Services\ServiceException
+ */
+ public function testSetup()
+ {
+ self::$service->setup(ActionsInterface::ACCOUNT_SEARCH);
+ }
+
+ public function testGetParam()
+ {
+
+ }
+
+ public function testGetHelp()
+ {
+
+ }
+
+ public function testGetParamInt()
+ {
+
+ }
+
+ public function testGetParamEmail()
+ {
+
+ }
+
+ public function testSetApiRequest()
+ {
+
+ }
+
+ public function testGetActions()
+ {
+
+ }
+
+ public function testGetParamString()
+ {
+
+ }
+
+ public function testGetParamRaw()
+ {
+
+ }
+
+ public function testGetRequestId()
+ {
+
+ }
+
+ public function testGetMasterPass()
+ {
+
+ }
+}
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index cc8e4d3f..e5738992 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -107,4 +107,15 @@ function setupContext()
$dic->set(DatabaseConnectionData::class, $databaseConnectionData);
return $dic;
+}
+
+/**
+ * @param $dir
+ * @param $file
+ *
+ * @return string
+ */
+function getResource($dir, $file)
+{
+ return file_get_contents(RESOURCE_DIR . DIRECTORY_SEPARATOR . $dir . DIRECTORY_SEPARATOR . $file) ?: '';
}
\ No newline at end of file
diff --git a/tests/res/json/account_add.json b/tests/res/json/account_add.json
new file mode 100644
index 00000000..e903f4b0
--- /dev/null
+++ b/tests/res/json/account_add.json
@@ -0,0 +1,23 @@
+{
+ "jsonrpc" : 2.0,
+ "method": "account/search",
+ "params":
+ {
+ "authToken": "ce4e5f2e5700d9032b0cbb0769a6d7cf8557484da492d3c32626a74bb28fb44b",
+ "tokenPass": "1234",
+ "id": "10",
+ "text": "API",
+ "name": "API Test",
+ "clientId": "1",
+ "categoryId": "4",
+ "login": "toor",
+ "url": "http://www.google.com",
+ "notes": "bla bla bla\nbla bla",
+ "private": "0",
+ "privateGroup": "0",
+ "expireDate": "0",
+ "parentId": "0",
+ "pass": "erfwerfreqfgqer%&/()=?="
+ },
+ "id": 1
+}
\ No newline at end of file
diff --git a/tests/res/json/account_search.json b/tests/res/json/account_search.json
new file mode 100644
index 00000000..9be5014b
--- /dev/null
+++ b/tests/res/json/account_search.json
@@ -0,0 +1,13 @@
+{
+ "jsonrpc" : 2.0,
+ "method": "account/search",
+ "params":
+ {
+ "authToken": "ce4e5f2e5700d9032b0cbb0769a6d7cf8557484da492d3c32626a74bb28fb44b",
+ "text": "API",
+ "count": 5,
+ "categoryId": 1,
+ "clientId": 1
+ },
+ "id": 10
+}
\ No newline at end of file