Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS has been phased out. To see alternatives please check here

Skip to content
Snippets Groups Projects
Commit 4130c2e8 authored by Diego MENDEZ's avatar Diego MENDEZ
Browse files

Repair robot bug with authentification.

parent 930c8cfe
No related branches found
No related tags found
5 merge requests!133Draft: Rebase v4 firewall,!131Draft: Rebase v4.1,!129Draft: Rebase v4,!128Repair robot bug with authentification.,!127Develop
Pipeline #227146 passed
# Testing the plugin
## End to end
Prepare a python environment to execute the E2E tests suite
## Prepare a Python environment for E2E and Robot tests
```shell
python3 -m venv venv
source venv/bin/activate
pip install -r tests/requirements.e2e.txt
pip install -r tests/requirements.robot.txt
```
## E2E, End to end
```shell
python -m unittest discover tests/e2e
```
or
```shell
env HOST=<host_to_connect> PORT=8080 API_TOKEN=<netbox_token> python -m unittest discover tests/e2e
```
## Run Robot Framework tests
......@@ -21,12 +29,13 @@ python -m unittest discover tests/e2e
###
3. Go to the test folder and change the value of the variable `PORT` in the varibales.yaml file to the correct port number used by netbox
###
4. Prepare a python environment, install aditional settings and run the tests:
4. Run the tests:
```
python3 -m venv venv
source ./venv/bin/activate
pip install robotframework robotframework-requests pyyaml
robot ./tests/robot/
```
or
```
robot -v HOST:<host_to_connect> -v PORT:8080 -v API_TOKEN:<netbox_token> ./tests/robot
```
###
5. Open the file `report.html` in the browser to check the test results.
robotframework
robotframework-requests
pyyaml
......@@ -8,19 +8,16 @@ ${TOKEN} Token ${API_TOKEN}
*** Test Cases ***
TC03 Check Metrics Page
${auth}= Evaluate ("${USER_API}", "${PASSWORD_API}")
&{HEADERS} Create Dictionary Authorization=${TOKEN} Content-Type=${CONTENT_TYPE}
Create Session robot_test_session ${BASE_URL} headers=${HEADERS}
${response}= GET On session robot_test_session /${PAGE} headers=${HEADERS} auth=${auth} expected_status=200
Check Metrics Page
${response}= GET ${BASE_URL}/metrics expected_status=200
Log to console ${\n}
Check metrics response status "${response.ok}" "${PAGE}"
Check metrics response status "${response.ok}" "metrics"
Log to console ${\n}
TC03.1 Check Nonexistent Page
${auth}= Evaluate ("${USER_API}", "${PASSWORD_API}")
&{HEADERS} Create Dictionary Authorization=${TOKEN} Content-Type=${CONTENT_TYPE}
${response}= GET On session robot_test_session /api/plugins/nonexistent_plugin auth=${auth} headers=${HEADERS} expected_status=404
Check Nonexistent Page
${HEADERS} Create Dictionary Content-Type application/json Authorization ${TOKEN}
Log to console ${\n}
${response}= GET ${BASE_URL}/nonexisting_page headers=${HEADERS} expected_status=404
Log to console ${\n}
Check metrics response status "${response.ok}" "nonexistent"
Log to console ${\n}
......
......@@ -8,21 +8,20 @@ ${TOKEN} Token ${API_TOKEN}
*** Test Cases ***
TC02 Check installed plugins
${auth}= Evaluate ("${USER_API}", "${PASSWORD_API}")
&{HEADERS} Create Dictionary Authorization=${TOKEN} Content-Type=${CONTENT_TYPE}
Create Session robot_test_session ${BASE_URL} headers=${HEADERS}
Check installed plugins
${HEADERS} Create Dictionary Content-Type application/json Authorization ${TOKEN}
Log to console ${\n}
FOR ${item} IN @{PLUGINS}
${response}= GET On session robot_test_session /api/plugins/${item}/ auth=${auth} headers=${HEADERS} expected_status=200
${response}= GET ${BASE_URL}/api/plugins/${item}/ headers=${HEADERS} expected_status=200
Check plugins response status "${response.ok}" "${item}"
END
Log to console ${\n}
TC02.1 Check Nonexistent Plugin
${auth}= Evaluate ("${USER_API}", "${PASSWORD_API}")
&{HEADERS} Create Dictionary Authorization=${TOKEN} Content-Type=${CONTENT_TYPE}
${response}= GET On session robot_test_session /api/plugins/nonexistent_plugin headers=${HEADERS} expected_status=404
Check Nonexistent Plugin
${HEADERS} Create Dictionary Content-Type application/json Authorization ${TOKEN}
Log to console ${\n}
${response}= GET ${BASE_URL}/api/plugins/nonexistent_plugin/ headers=${HEADERS} expected_status=404
Check plugins response status "${response.ok}" "nonexistent"
......
HOST: "localhost"
PORT: 8080
USER_API: "admin"
PASSWORD_API: "thisisagoodpassword"
API_TOKEN: "only4testingpurpose"
CONTENT_TYPE: "application/json"
PAGE: "metrics"
PLUGINS: ["rps", "netbox-dns", "cert", "prometheus-sd", "docker", "mac-address"]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment