Skip to content

Commit 6f3e02d

Browse files
author
Wout Feys
committed
Add e2e test
1 parent d2dd2d2 commit 6f3e02d

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

.github/workflows/end2end.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ jobs:
3333
working-directory: ./sample-apps/flask-postgres
3434
run: |
3535
docker compose -f docker-compose.yml -f docker-compose.benchmark.yml up --build -d
36+
- name: Start flask-postgres-xml
37+
working-directory: ./sample-apps/flask-postgres-xml
38+
run: |
39+
docker compose -f docker-compose.yml -f docker-compose.benchmark.yml up --build -d
3640
3741
- name: Set up Python ${{ matrix.python-version }}
3842
uses: actions/setup-python@v2

end2end/flask_postgres_xml_test.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import pytest
2+
import requests
3+
# e2e tests for flask_postgres sample app
4+
post_url_fw = "http://localhost:8092/xml_post"
5+
post_url_nofw = "http://localhost:8093/xml_post"
6+
7+
def test_safe_response_with_firewall():
8+
xml_data = '<dogs><dog dog_name="Bobby" /></dogs>'
9+
res = requests.post(post_url_fw, data=xml_data)
10+
assert res.status_code == 200
11+
12+
13+
def test_safe_response_without_firewall():
14+
xml_data = '<dogs><dog dog_name="Bobby" /></dogs>'
15+
res = requests.post(post_url_nofw, data=xml_data)
16+
assert res.status_code == 200
17+
18+
19+
def test_dangerous_response_with_firewall():
20+
xml_data = '<dogs><dog dog_name="Malicious dog\', TRUE); -- " /></dogs>'
21+
res = requests.post(post_url_fw, data=xml_data)
22+
assert res.status_code == 500
23+
24+
def test_dangerous_response_without_firewall():
25+
xml_data = '<dogs><dog dog_name="Malicious dog\', TRUE); -- " /></dogs>'
26+
res = requests.post(post_url_nofw, data=xml_data)
27+
assert res.status_code == 200
28+

0 commit comments

Comments
 (0)