refs #812 Applies schemas subnets and hosts in swagger documentation, adds logic y some parameter is missing. Changes tests to check what parameter is missing
testing/og-dhcp-API/pipeline/head There was a failure building this commit
Details
testing/og-dhcp-API/pipeline/head There was a failure building this commit
Details
parent
8e929108af
commit
6de02065a6
|
@ -684,7 +684,11 @@ public function addDhcpSubnet(Request $request): JsonResponse
|
||||||
$bootFileName = htmlspecialchars($input->bootFileName);
|
$bootFileName = htmlspecialchars($input->bootFileName);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$response["message"] = $e->getMessage();
|
$response["message"] = $e->getMessage();
|
||||||
return new JsonResponse(['error' => $response], 400);
|
if (strpos($e->getMessage(), 'Undefined property') !== false) {
|
||||||
|
preg_match('/Undefined property: stdClass::\$(\w+)/', $e->getMessage(), $matches);
|
||||||
|
$paramFaltante = $matches[1] ?? 'desconocido';
|
||||||
|
return new JsonResponse(['error' => "Falta un parámetro requerido: $paramFaltante"], 400);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -769,12 +773,7 @@ public function addDhcpSubnet(Request $request): JsonResponse
|
||||||
* type="object",
|
* type="object",
|
||||||
* @OA\Property(property="success", type="string", example="Hosts obtenidos correctamente"),
|
* @OA\Property(property="success", type="string", example="Hosts obtenidos correctamente"),
|
||||||
* @OA\Property(property="message", type="array",
|
* @OA\Property(property="message", type="array",
|
||||||
* @OA\Items(
|
* @OA\Items(ref="#/components/schemas/Host")
|
||||||
* type="object",
|
|
||||||
* @OA\Property(property="ip-address", type="string", example="192.168.1.20"),
|
|
||||||
* @OA\Property(property="hw-address", type="string", example="00:0c:29:6b:5e:71"),
|
|
||||||
* @OA\Property(property="hostname", type="string", example="pc11")
|
|
||||||
* )
|
|
||||||
* )
|
* )
|
||||||
* )
|
* )
|
||||||
* ),
|
* ),
|
||||||
|
@ -864,11 +863,7 @@ public function getHosts($subnetId): JsonResponse
|
||||||
* @OA\JsonContent(
|
* @OA\JsonContent(
|
||||||
* type="object",
|
* type="object",
|
||||||
* @OA\Property(property="success", type="string", example="Host added successfully"),
|
* @OA\Property(property="success", type="string", example="Host added successfully"),
|
||||||
* @OA\Property(property="newHost", type="object",
|
* @OA\Property(property="message", ref="#/components/schemas/Host")
|
||||||
* @OA\Property(property="hostname", type="string", example="pc11"),
|
|
||||||
* @OA\Property(property="hw-address", type="string", example="56:6f:c7:4f:00:4f"),
|
|
||||||
* @OA\Property(property="ip-address", type="string", example="172.30.4.11")
|
|
||||||
* )
|
|
||||||
* )
|
* )
|
||||||
* ),
|
* ),
|
||||||
* @OA\Response(
|
* @OA\Response(
|
||||||
|
@ -1211,11 +1206,7 @@ public function deleteDhcpHost(Request $request, $subnetId): JsonResponse
|
||||||
* @OA\JsonContent(
|
* @OA\JsonContent(
|
||||||
* type="object",
|
* type="object",
|
||||||
* @OA\Property(property="success", type="string", example="Host updated successfully"),
|
* @OA\Property(property="success", type="string", example="Host updated successfully"),
|
||||||
* @OA\Property(property="message", type="object",
|
* @OA\Property(property="message", ref="#/components/schemas/Host")
|
||||||
* @OA\Property(property="hostname", type="string", example="PC11"),
|
|
||||||
* @OA\Property(property="macAddress", type="string", example="56:6f:c7:4f:01:01"),
|
|
||||||
* @OA\Property(property="ipAddress", type="string", example="192.168.1.12")
|
|
||||||
* )
|
|
||||||
* )
|
* )
|
||||||
* ),
|
* ),
|
||||||
* @OA\Response(
|
* @OA\Response(
|
||||||
|
@ -1335,35 +1326,16 @@ public function updateDhcpHost(Request $request, $subnetId): JsonResponse
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @OA\Get(
|
* @OA\Get(
|
||||||
* path="/ogdhcp/v1/subnets/backup",
|
* path="/ogdhcp/v1/backup",
|
||||||
* summary="Get the latest backup configuration of Kea DHCP (only subnet4)",
|
* summary="Get the latest backup configuration of Kea DHCP (only subnet4)",
|
||||||
* @OA\Response(
|
* @OA\Response(
|
||||||
* response=200,
|
* response=200,
|
||||||
* description="Latest backup configuration of Kea DHCP",
|
* description="Latest backup configuration of Kea DHCP",
|
||||||
* @OA\JsonContent(
|
* @OA\JsonContent(
|
||||||
* type="object",
|
* type="object",
|
||||||
* @OA\Property(property="success", type="string", example="Backup configuration retrieved successfully"),
|
* @OA\Property(property="success", type="string", example="Backup obtenido con exito),
|
||||||
* @OA\Property(property="message", type="object",
|
* @OA\Property(property="message", type="array",
|
||||||
* @OA\Property(property="subnet4", type="array",
|
* @OA\Items(ref="#/components/schemas/Host")
|
||||||
* @OA\Items(
|
|
||||||
* type="object",
|
|
||||||
* @OA\Property(property="id", type="integer", example=1),
|
|
||||||
* @OA\Property(property="subnet", type="string", example="192.168.1.0/24"),
|
|
||||||
* @OA\Property(property="pools", type="array",
|
|
||||||
* @OA\Items(
|
|
||||||
* type="object",
|
|
||||||
* @OA\Property(property="pool", type="string", example="192.168.1.10-192.168.1.100")
|
|
||||||
* )
|
|
||||||
* ),
|
|
||||||
* @OA\Property(property="reservations", type="array",
|
|
||||||
* @OA\Items(
|
|
||||||
* type="object",
|
|
||||||
* @OA\Property(property="ip-address", type="string", example="192.168.1.20"),
|
|
||||||
* @OA\Property(property="hw-address", type="string", example="00:0c:29:6b:5e:71")
|
|
||||||
* )
|
|
||||||
* )
|
|
||||||
* )
|
|
||||||
* )
|
|
||||||
* )
|
* )
|
||||||
* )
|
* )
|
||||||
* ),
|
* ),
|
||||||
|
@ -1376,7 +1348,7 @@ public function updateDhcpHost(Request $request, $subnetId): JsonResponse
|
||||||
* )
|
* )
|
||||||
* )
|
* )
|
||||||
* )
|
* )
|
||||||
* @Route("/ogdhcp/v1/subnets/backup", methods={"GET"})
|
* @Route("/ogdhcp/v1/backup", methods={"GET"})
|
||||||
*/
|
*/
|
||||||
public function getLatestBackupConfiguration(): JsonResponse
|
public function getLatestBackupConfiguration(): JsonResponse
|
||||||
{
|
{
|
||||||
|
@ -1414,7 +1386,7 @@ public function getLatestBackupConfiguration(): JsonResponse
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @OA\Post(
|
* @OA\Post(
|
||||||
* path="/ogdhcp/v1/backup/restore",
|
* path="/ogdhcp/v1/backup",
|
||||||
* summary="Restore the latest DHCP configuration from backup",
|
* summary="Restore the latest DHCP configuration from backup",
|
||||||
* description="This endpoint restores the last saved DHCP configuration from a backup file and applies it to the Kea DHCP server, returning all currently loaded subnets.",
|
* description="This endpoint restores the last saved DHCP configuration from a backup file and applies it to the Kea DHCP server, returning all currently loaded subnets.",
|
||||||
* @OA\Response(
|
* @OA\Response(
|
||||||
|
@ -1423,25 +1395,8 @@ public function getLatestBackupConfiguration(): JsonResponse
|
||||||
* @OA\JsonContent(
|
* @OA\JsonContent(
|
||||||
* type="object",
|
* type="object",
|
||||||
* @OA\Property(property="success", type="string", example="Configuración cargada correctamente"),
|
* @OA\Property(property="success", type="string", example="Configuración cargada correctamente"),
|
||||||
* @OA\Property(property="subnets", type="array",
|
* @OA\Property(property="message", type="array",
|
||||||
* @OA\Items(
|
* @OA\Items(ref="#/components/schemas/Host")
|
||||||
* type="object",
|
|
||||||
* @OA\Property(property="id", type="integer", example=1),
|
|
||||||
* @OA\Property(property="subnet", type="string", example="192.168.1.0/24"),
|
|
||||||
* @OA\Property(property="pools", type="array",
|
|
||||||
* @OA\Items(
|
|
||||||
* type="object",
|
|
||||||
* @OA\Property(property="pool", type="string", example="192.168.1.10-192.168.1.100")
|
|
||||||
* )
|
|
||||||
* ),
|
|
||||||
* @OA\Property(property="reservations", type="array",
|
|
||||||
* @OA\Items(
|
|
||||||
* type="object",
|
|
||||||
* @OA\Property(property="ip-address", type="string", example="192.168.1.20"),
|
|
||||||
* @OA\Property(property="hw-address", type="string", example="00:0c:29:6b:5e:71")
|
|
||||||
* )
|
|
||||||
* )
|
|
||||||
* )
|
|
||||||
* )
|
* )
|
||||||
* )
|
* )
|
||||||
* ),
|
* ),
|
||||||
|
@ -1486,7 +1441,7 @@ public function getLatestBackupConfiguration(): JsonResponse
|
||||||
* )
|
* )
|
||||||
* )
|
* )
|
||||||
* )
|
* )
|
||||||
* @Route("/ogdhcp/v1/backup/restore", methods={"POST"})
|
* @Route("/ogdhcp/v1/backup", methods={"POST"})
|
||||||
*/
|
*/
|
||||||
public function restoreDhcpConfiguration(): JsonResponse
|
public function restoreDhcpConfiguration(): JsonResponse
|
||||||
{
|
{
|
||||||
|
|
|
@ -167,7 +167,7 @@ Modify subnet with invalid configuration address without netmask
|
||||||
${json}= Convert To Dictionary ${response.json()}
|
${json}= Convert To Dictionary ${response.json()}
|
||||||
|
|
||||||
# Verificar que la respuesta contiene el error esperado
|
# Verificar que la respuesta contiene el error esperado
|
||||||
Should Be Equal ${json['error']} La máscara de red es requerida con el parametro 'address'
|
Should Be Equal ${json['error']} Falta un parámetro requerido: mask
|
||||||
|
|
||||||
Modify subnet with invalid configuration netmask without address
|
Modify subnet with invalid configuration netmask without address
|
||||||
[Documentation] Este test verifica que la modificación falla cuando hay un error en la configuración de Kea DHCP.
|
[Documentation] Este test verifica que la modificación falla cuando hay un error en la configuración de Kea DHCP.
|
||||||
|
@ -183,7 +183,7 @@ Modify subnet with invalid configuration netmask without address
|
||||||
${json}= Convert To Dictionary ${response.json()}
|
${json}= Convert To Dictionary ${response.json()}
|
||||||
|
|
||||||
# Verificar que la respuesta contiene el error esperado
|
# Verificar que la respuesta contiene el error esperado
|
||||||
Should Be Equal ${json['error']} La dirección de red es requerida con el parametro 'mask'
|
Should Be Equal ${json['error']} Falta un parámetro requerido: address
|
||||||
|
|
||||||
Delete subnet by id
|
Delete subnet by id
|
||||||
[Documentation] Este test verifica que la subred se elimina correctamente con el código 200.
|
[Documentation] Este test verifica que la subred se elimina correctamente con el código 200.
|
||||||
|
|
Loading…
Reference in New Issue