Updating test cases
testing/og-dhcp-API/pipeline/head There was a failure building this commit Details

nginx_conf
Nicolas Arenas 2024-10-02 13:19:48 +02:00
parent 7ac1d486fd
commit 2d391cdd34
1 changed files with 90 additions and 59 deletions

View File

@ -14,72 +14,103 @@ ${modified_subnet} Create Dictionary mask=255.255.192.0 address=192.1
Get Status of the DHCP server
[Documentation] Get status of the dhcp server and check services status
[Tags] status
${response}= GET ${BASE_URL}/status
Status Should Be 200
${response}= GET ${BASE_URL}/status
Status Should Be 200 ${response}
# Convertir la respuesta a JSON usando ${response.json()}
${json}= Set Variable ${response.json()}
# Validar el estado de los servicios
Should Contain ${response.json()} success
Should Contain ${response.json()} message
${json}= Convert to Dictionary ${response.json()}
Dictionary Should Contain Key ${json} success
Dictionary Should Contain Key ${json} message
Should Contain ${response.json()['message']} disk_usage
Should Contain ${response.json()['message']} subnets
Should Contain ${response.json()['message']['disk_usage']} total
# Get all subnets
# [Documentation] Get all subnets
# [Tags] subnets
# ${response}= GET ${BASE_URL}/subnets
# Status Should Be 200
# # Convertir la respuesta a JSON usando ${response.json()}
# ${json}= Set Variable ${response.json()}
# # Obtener la longitud del arreglo JSON
# ${num_elements}= Get Length ${json}
# # Validar el número de elementos
# Should Be Equal As Numbers ${num_elements} 1
Get all subnets
[Documentation] Get all subnets
[Tags] subnets
${response}= GET ${BASE_URL}/subnets
Status Should Be 200 ${response}
# Convertir la respuesta a JSON usando ${response.json()}
${json}= Convert to Dictionary ${response.json()}
Dictionary Should Contain Key ${json} success
Dictionary Should Contain Key ${json} message
${subnets}= Set Variable False
FOR ${subred} IN @{json_response['message']}
Run Keyword If '${subred['id']}' == '1' Set Variable ${subred_encontrada} True
END
Should Be True ${subred_encontrada}
# Post a new subnet
# [Documentation] Post a new subnet
# [Tags] subnets
# ${headers}= Create Dictionary Content-Type=application/json
# ${response}= POST ${BASE_URL}/subnets json=${new_subnet} headers=${headers}
# Status Should Be 200
# ${json}= Set Variable ${response.json()}
# Should Be Equal ${json["status"]} success
# Should Be Equal ${json["message"]} Subred creada correctamente
# Should Be Equal ${json["subnetId"]} 2
# Modify a new subnet by id
# [Documentation] Modify a subnet by id
# [Tags] subnets
# # Modificar la subred con id=2
# ${response}= PUT ${BASE_URL}/subnets/2 json=${modified_subnet} headers=${headers}
# Status Should Be 200
# # Verificar la respuesta del PUT
# ${json}= Set Variable ${response.json()}
# Should Be Equal ${json["status"]} success
# Should Be Equal ${json["message"]} Subred modificada correctamente
# Should Be Equal ${json["subnetId"]} 2
# # Obtener todas las subredes y verificar si la subred fue modificada
# ${response_all}= GET ${BASE_URL}/subnets
# Status Should Be 200
# ${json_all}= Set Variable ${response_all.json()}
# # Iterar sobre todas las subredes para encontrar la subred con id=2 y verificar su máscara
# FOR ${subnet} IN @{json_all}
# Run Keyword If '${subnet["id"]}' == '2' Should Be Equal ${subnet["mask"]} 255.255.192.0
# END
Post a new subnet
[Documentation] Post a new subnet
[Tags] subnets
${headers}= Create Dictionary Content-Type=application/json
${response}= POST ${BASE_URL}/subnets json=${new_subnet} headers=${headers} expected_status=200
Status Should Be 200 ${response}
${json}= Convert to Dictionary ${response.json()}
Dictionary Should Contain Key ${json} success
Dictionary Should Contain Key ${json} message
Should Contain ${json["success"]} Subnet agregada correctamente
Should Be Equal As Numbers ${json["message"]["id"]} 2
Should Be Equal ${json["message"]["mask"]} ${new_subnet["mask"]}
Should Be Equal ${json["message"]["address"]} ${new_subnet["address"]}
Should Be Equal ${json["message"]["nextServer"]} ${new_subnet["nextServer"]}
Should Be Equal ${json["message"]["bootFileName"]} ${new_subnet["bootFileName"]}
# Delete a new subnet by id
# [Documentation] Delete a subnet by id
# [Tags] subnets
# ${response}= DELETE ${BASE_URL}/subnets/2 headers=${headers}
# Status Should Be 200
# ${json}= Set Variable ${response.json()}
# Should Be Equal ${json["status"]} success
# Should Be Equal ${json["message"]} Subred eliminada correctamente
# Should Be Equal ${json["subnetId"]} 2
Post a new subnet with existing id
[Documentation] Post a new subnet with invalid data
[Tags] subnets
${headers}= Create Dictionary Content-Type=application/json
${response}= POST ${BASE_URL}/subnets json=${new_subnet} headers=${headers} expected_status=400
Status Should Be 400 ${response}
${json}= Convert to Dictionary ${response.json()}
Dictionary Should Contain Key ${json} error
Should Contain ${response.json()['error']} Subnet con id 2 ya existe
Post a new subnet with existing address
[Documentation] Post a new subnet with invalid data
[Tags] subnets
${headers}= Create Dictionary Content-Type=application/json
${new_subnet_invalid}= Create Dictionary subnetId=3 mask=255.255.255.0 address=192.168.1.0 nextServer=192.168.1.1 bootFileName=pxelinux.0
${response}= POST ${BASE_URL}/subnets json=${new_subnet_invalid} headers=${headers} expected_status=400
Status Should Be 400 ${response}
${json}= Convert to Dictionary ${response.json()}
Dictionary Should Contain Key ${json} error
Should Contain ${response.json()['error']} Error: La subred el subnet '192.168.1.0/24' ya existe en las subredes
Modify an existing subnet by id
[Documentation] Modify a subnet by id
[Tags] subnets
# Modificar la subred con id=2
${response}= PUT ${BASE_URL}/subnets/2 json=${modified_subnet} headers=${headers} expected_status=200
Status Should Be 200
# Verificar la respuesta del PUT
${json}= Set Variable ${response.json()}
Should Be Equal ${json["status"]} success
Should Be Equal ${json["message"]} Subred modificada correctamente
Should Be Equal ${json["subnetId"]} 2
# Obtener todas las subredes y verificar si la subred fue modificada
${response_all}= GET ${BASE_URL}/subnets
Status Should Be 200
${json_all}= Set Variable ${response_all.json()}
# Iterar sobre todas las subredes para encontrar la subred con id=2 y verificar su máscara
FOR ${subnet} IN @{json_all}
Run Keyword If '${subnet["id"]}' == '2' Should Be Equal ${subnet["mask"]} 255.255.192.0
END
Delete a new subnet by id
[Documentation] Delete a subnet by id
[Tags] subnets
${response}= DELETE ${BASE_URL}/subnets/2 headers=${headers}
Status Should Be 200
${json}= Set Variable ${response.json()}
Should Be Equal ${json["status"]} success
Should Be Equal ${json["message"]} Subred eliminada correctamente
Should Be Equal ${json["subnetId"]} 2