Skip to content

Commit c8d6f4f

Browse files
author
Wout Feys
committed
Add flask_postgres, django_mysql and django_mysql_gunicorn e2e tests
1 parent a1adb84 commit c8d6f4f

File tree

3 files changed

+84
-0
lines changed

3 files changed

+84
-0
lines changed

end2end/django_mysql_gunicorn_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 django_mysql_gunicorn sample app
4+
post_url_fw = "http://localhost:8082/app/create/"
5+
post_url_nofw = "http://localhost:8083/app/create/"
6+
7+
def test_safe_response_with_firewall():
8+
dog_name = "Bobby Tables"
9+
res = requests.post(post_url_fw, data={'dog_name': dog_name})
10+
assert res.status_code == 200
11+
12+
13+
def test_safe_response_without_firewall():
14+
dog_name = "Bobby Tables"
15+
res = requests.post(post_url_nofw, data={'dog_name': dog_name})
16+
assert res.status_code == 200
17+
18+
19+
def test_dangerous_response_with_firewall():
20+
dog_name = 'Dangerous bobby", 1); -- '
21+
res = requests.post(post_url_fw, data={'dog_name': dog_name})
22+
assert res.status_code == 500
23+
24+
def test_dangerous_response_without_firewall():
25+
dog_name = 'Dangerous bobby", 1); -- '
26+
res = requests.post(post_url_nofw, data={'dog_name': dog_name})
27+
assert res.status_code == 200
28+

end2end/django_mysql_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 django_mysql sample app
4+
post_url_fw = "http://localhost:8080/app/create"
5+
post_url_nofw = "http://localhost:8081/app/create"
6+
7+
def test_safe_response_with_firewall():
8+
dog_name = "Bobby Tables"
9+
res = requests.post(post_url_fw, data={'dog_name': dog_name})
10+
assert res.status_code == 200
11+
12+
13+
def test_safe_response_without_firewall():
14+
dog_name = "Bobby Tables"
15+
res = requests.post(post_url_nofw, data={'dog_name': dog_name})
16+
assert res.status_code == 200
17+
18+
19+
def test_dangerous_response_with_firewall():
20+
dog_name = 'Dangerous bobby", 1); -- '
21+
res = requests.post(post_url_fw, data={'dog_name': dog_name})
22+
assert res.status_code == 500
23+
24+
def test_dangerous_response_without_firewall():
25+
dog_name = 'Dangerous bobby", 1); -- '
26+
res = requests.post(post_url_nofw, data={'dog_name': dog_name})
27+
assert res.status_code == 200
28+

end2end/flask_postgres_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:8090/create"
5+
post_url_nofw = "http://localhost:8091/create"
6+
7+
def test_safe_response_with_firewall():
8+
dog_name = "Bobby Tables"
9+
res = requests.post(post_url_fw, data={'dog_name': dog_name})
10+
assert res.status_code == 200
11+
12+
13+
def test_safe_response_without_firewall():
14+
dog_name = "Bobby Tables"
15+
res = requests.post(post_url_nofw, data={'dog_name': dog_name})
16+
assert res.status_code == 200
17+
18+
19+
def test_dangerous_response_with_firewall():
20+
dog_name = "Dangerous Bobby', TRUE); -- "
21+
res = requests.post(post_url_fw, data={'dog_name': dog_name})
22+
assert res.status_code == 500
23+
24+
def test_dangerous_response_without_firewall():
25+
dog_name = "Dangerous Bobby', TRUE); -- "
26+
res = requests.post(post_url_nofw, data={'dog_name': dog_name})
27+
assert res.status_code == 200
28+

0 commit comments

Comments
 (0)