Running Tests for Security Dashboard
Running Tests Through GitHub Actions
Open GitHub Repo https://github.com/openmrs/openmrs-contrib-cvss-scanning
Click
Actionson the top panelIn the
Actionstab, on the left panel underActionsclickSecurity TestsUnder the
Security Testsheader, on the right side, clickRun WorkflowBelow
Use workflow fromselectBranch: mainand select the branch to run the tests onTo test the main branch, leave as
Branch: main
Select
Run WorkflowWait for tests to complete
If running the action on main, the results should be visible at https://security-dashboard.openmrs.org. In-depth Pytest results can be found at the following: https://security-dashboard.openmrs.org/detailed-report.html
If running the action on a branch other than main, follow these steps to view the results
Under
Artifactsdownloadsecurity-dashboardandsecurity-test-report-htmlUnzip each to find the security dashboard page and in-depth Pytest report page respectively.
Local Development
Prerequisites
Download and install Docker Desktop
https://docs.docker.com/desktop/setup/install/windows-install/
First install will reboot your computer
Download and install Python
Execute the following commands in terminal or PowerShell
py -m pip install pytest-html pytest-json-report pytest-playwright python-dotenv pytest pytest_bdd playwright mysql-connector-python requestsplaywright install
Run Tests Locally
Open Docker Desktop
In the terminal:
docker compose up -dTo run a test (or test category), execute this command
py -m pytest tests/ -v -s --headedAdd the flag
--tb=noto hide the details of the errors-vwill show each test-sshows the print statements--headed runs the tests showing the browser
Add
-k “<text>”to run certain tests that have the matching text in their names.
To run all tests with reports, use the following command
py -m pytest tests/ --html=report.html --self-contained-html --json-report --json-report-file=report.json -v -s 2>&1 | tee test_output.log
To turn off docker: docker compose down or stop them in the Docker Desktop app.
Generate the Dashboard Locally
py -m pytest tests/ --html=report.html --self-contained-html --json-report --json-report-file=report.json -v -s 2>&1 | tee test_output.logpy scripts/generate_security_dashboard.pyOpen the generated
report.htmlto see the dashboard.It is recommended to opening this in Live Server Extension in VS Code to update the page whenever the generate script is run.