Skip to content

Commit

Permalink
Add e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
Wout Feys committed Aug 22, 2024
1 parent d2dd2d2 commit 6f3e02d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/end2end.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ jobs:
working-directory: ./sample-apps/flask-postgres
run: |
docker compose -f docker-compose.yml -f docker-compose.benchmark.yml up --build -d
- name: Start flask-postgres-xml
working-directory: ./sample-apps/flask-postgres-xml
run: |
docker compose -f docker-compose.yml -f docker-compose.benchmark.yml up --build -d
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
Expand Down
28 changes: 28 additions & 0 deletions end2end/flask_postgres_xml_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import pytest
import requests
# e2e tests for flask_postgres sample app
post_url_fw = "http://localhost:8092/xml_post"
post_url_nofw = "http://localhost:8093/xml_post"

def test_safe_response_with_firewall():
xml_data = '<dogs><dog dog_name="Bobby" /></dogs>'
res = requests.post(post_url_fw, data=xml_data)
assert res.status_code == 200


def test_safe_response_without_firewall():
xml_data = '<dogs><dog dog_name="Bobby" /></dogs>'
res = requests.post(post_url_nofw, data=xml_data)
assert res.status_code == 200


def test_dangerous_response_with_firewall():
xml_data = '<dogs><dog dog_name="Malicious dog\', TRUE); -- " /></dogs>'
res = requests.post(post_url_fw, data=xml_data)
assert res.status_code == 500

def test_dangerous_response_without_firewall():
xml_data = '<dogs><dog dog_name="Malicious dog\', TRUE); -- " /></dogs>'
res = requests.post(post_url_nofw, data=xml_data)
assert res.status_code == 200

0 comments on commit 6f3e02d

Please sign in to comment.