From 0d2adfcce21dd2efb5d781babec3e6b03464b6d5 Mon Sep 17 00:00:00 2001 From: Athanasios Voutsadakis Date: Tue, 14 Nov 2017 15:26:03 +0000 Subject: [PATCH] Add basic tests --- tests/app/main/test_request_header.py | 33 +++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tests/app/main/test_request_header.py diff --git a/tests/app/main/test_request_header.py b/tests/app/main/test_request_header.py new file mode 100644 index 000000000..6111c6f26 --- /dev/null +++ b/tests/app/main/test_request_header.py @@ -0,0 +1,33 @@ +from tests.conftest import set_config_values + + +def test_route_correct_secret_key(app_, client): + with set_config_values(app_, { + 'ROUTE_SECRET_KEY_1': 'key_1', + 'ROUTE_SECRET_KEY_2': '', + 'DEBUG': False, + }): + + response = client.get( + path='/_status', + headers=[ + ('X-Custom-forwarder', 'key_1'), + ] + ) + assert response.status_code == 200 + + +def test_route_incorrect_secret_key(app_, client): + with set_config_values(app_, { + 'ROUTE_SECRET_KEY_1': 'key_1', + 'ROUTE_SECRET_KEY_2': '', + 'DEBUG': False, + }): + + response = client.get( + path='/_status', + headers=[ + ('X-Custom-forwarder', 'wrong_key'), + ] + ) + assert response.status_code == 403