Skip to content
Snippets Groups Projects
Verified Commit f6603554 authored by Damien's avatar Damien
Browse files

FEAT #13671 TIME 1:25 Installer db + url fixes + unit tests

parent 82a44e4c
No related branches found
No related tags found
No related merge requests found
......@@ -105,7 +105,7 @@ class InstallerController
return $response->withStatus(400)->withJson(['errors' => 'QueryParams name is empty or not a string']);
} elseif (!Validator::length(1, 50)->validate($queryParams['name'])) {
return $response->withStatus(400)->withJson(['errors' => 'QueryParams name length is not valid']);
} elseif (strpbrk($queryParams['name'], '"; ') !== false) {
} elseif (strpbrk($queryParams['name'], '"; \\') !== false) {
return $response->withStatus(400)->withJson(['errors' => 'QueryParams name is not valid']);
}
......@@ -288,7 +288,7 @@ class InstallerController
return $response->withStatus(400)->withJson(['errors' => 'Body name is empty or not a string']);
} elseif (!Validator::length(1, 50)->validate($body['name'])) {
return $response->withStatus(400)->withJson(['errors' => 'Body name length is not valid']);
} elseif (strpbrk($body['name'], '"; ') !== false) {
} elseif (strpbrk($body['name'], '"; \\') !== false) {
return $response->withStatus(400)->withJson(['errors' => 'Body name is not valid']);
} elseif (!Validator::stringType()->notEmpty()->validate($body['customId'])) {
return $response->withStatus(400)->withJson(['errors' => 'Body customId is empty or not a string']);
......@@ -579,12 +579,14 @@ class InstallerController
$explodedUrl = explode('/', rtrim($url, '/'));
$lastPart = $explodedUrl[count($explodedUrl) - 1];
$jsonFile = file_get_contents('custom/custom.json');
if (!empty($jsonFile)) {
$jsonFile = json_decode($jsonFile, true);
foreach ($jsonFile as $value) {
if (!empty($value['path']) && $value['path'] == $lastPart) {
$url = str_replace("/{$lastPart}", '', $url);
if (is_file('custom/custom.json')) {
$jsonFile = file_get_contents('custom/custom.json');
if (!empty($jsonFile)) {
$jsonFile = json_decode($jsonFile, true);
foreach ($jsonFile as $value) {
if (!empty($value['path']) && $value['path'] == $lastPart) {
$url = str_replace("/{$lastPart}", '', $url);
}
}
}
}
......
......@@ -505,6 +505,8 @@ class EntityControllerTest extends TestCase
$response = $entityController->create($fullRequest, new \Slim\Http\Response());
$this->assertSame(200, $response->getStatusCode());
\User\models\UserEntityModel::deleteUserEntity(['id' => $GLOBALS['id'], 'entityId' => 'R2-D2']);
$environment = \Slim\Http\Environment::mock(['REQUEST_METHOD' => 'PUT']);
$request = \Slim\Http\Request::createFromEnvironment($environment);
$response = $entityController->reassignEntity($request, new \Slim\Http\Response(), ['id' => 'R2-D2', 'newEntityId' => 'TEST-ENTITY123']);
......
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