First test added
parent
ba57508041
commit
59e70be134
|
@ -0,0 +1,82 @@
|
|||
*** Settings ***
|
||||
Documentation This is a basic skeleton for a Robot Framework test suite.
|
||||
Library Collections
|
||||
Library RequestsLibrary
|
||||
Library JSONLibrary
|
||||
Library BuiltIn
|
||||
|
||||
|
||||
*** Variables ***
|
||||
${BASE_URL} http://localhost:8005/ogdhcp/v1
|
||||
${headers} Create Dictionary Content-Type application/json
|
||||
${new_subnet} Create Dictionary subnetId=2 mask=255.255.255.0 address=192.168.1.0 nextServer=192.168.1.1 bootFileName=pxelinux.0
|
||||
${modified_subnet} Create Dictionary mask=255.255.192.0 address=192.168.1.0 nextServer=192.168.1.1 bootFileName=pxelinux.0
|
||||
*** Test Cases ***
|
||||
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
|
||||
# Convertir la respuesta a JSON usando ${response.json()}
|
||||
${json}= Set Variable ${response.json()}
|
||||
# Validar el estado de los servicios
|
||||
Should Be Equal ${json["services_status"]["tftpboot"]} active
|
||||
Should Be Equal ${json["services_status"]["nginx"]} active
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
Loading…
Reference in New Issue