mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-07 03:43:48 -05:00
This naming was introduced in 2016 without explanation [1]. I find it confusing because: - It's reminiscent of "_app", which is a Python convention indicating the variable is internal, so maybe avoid using it. - It suggests there's some other "app" fixture I should be using (there isn't, though). The Python style guide describes using an underscore suffix to avoid clashes with inbuilt names [1], which is sort of applicable if we need to import the "app" module [2]. However, we can also avoid clashes by choosing a different name, without the strange underscore. [1]:3b1d521c10[2]:78824f54fd/tests/app/main/views/test_forgot_password.py (L5)
27 lines
825 B
Python
27 lines
825 B
Python
import pytest
|
|
|
|
from tests.conftest import set_config_values
|
|
|
|
|
|
@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(notify_admin, check_proxy_header, header_value, expected_code):
|
|
with set_config_values(notify_admin, {
|
|
'ROUTE_SECRET_KEY_1': 'key_1',
|
|
'ROUTE_SECRET_KEY_2': '',
|
|
'CHECK_PROXY_HEADER': check_proxy_header,
|
|
}):
|
|
|
|
with notify_admin.test_client() as client:
|
|
response = client.get(
|
|
path='/_status?elb=True',
|
|
headers=[
|
|
('X-Custom-forwarder', header_value),
|
|
]
|
|
)
|
|
assert response.status_code == expected_code
|