Files
notifications-admin/tests/app/main/test_request_header.py

27 lines
801 B
Python
Raw Normal View History

2017-11-16 16:34:10 +00:00
import pytest
2017-11-16 16:34:10 +00:00
from tests.conftest import set_config_values
2017-11-14 15:26:03 +00:00
2017-11-16 16:34:10 +00:00
@pytest.mark.parametrize('check_proxy_header,header_value,expected_code', [
(True, 'key_1', 200),
(True, 'wrong_key', 403),
(False, 'wrong_key', 200),
(False, 'key_1', 200),
])
def test_route_correct_secret_key(app_, check_proxy_header, header_value, expected_code):
2017-11-14 15:26:03 +00:00
with set_config_values(app_, {
'ROUTE_SECRET_KEY_1': 'key_1',
'ROUTE_SECRET_KEY_2': '',
2017-11-16 16:34:10 +00:00
'CHECK_PROXY_HEADER': check_proxy_header,
2017-11-14 15:26:03 +00:00
}):
2017-11-16 17:02:38 +00:00
with app_.test_client() as client:
response = client.get(
path='/_status?elb=True',
headers=[
('X-Custom-forwarder', header_value),
]
)
2017-11-16 16:34:10 +00:00
assert response.status_code == expected_code