Files
notifications-admin/tests/app/test_webauthn_server.py
Ben Thorner fd6329b92e Fix app config leaking between tests
We need to re-initialise the webauthn_server module with original
app config, since this state is global across all tests. Since the
behaviour of the original fixture wasn't specific to verifying the
origin, I've renamed the fixture as part of making it global.

In order to keep the fixture simple, I've rewritten the test for
the webauthn_server module, so they don't touch the app fixture.
2021-05-17 12:18:28 +01:00

39 lines
875 B
Python

import pytest
from app import webauthn_server
@pytest.fixture
def app_with_mock_config(mocker):
app = mocker.Mock()
app.config = {
'ADMIN_BASE_URL': 'https://www.notify.works',
'NOTIFY_ENVIRONMENT': 'development'
}
return app
@pytest.mark.parametrize(('environment, allowed'), [
('development', True),
('production', False)
])
def test_server_origin_verification(
app_with_mock_config,
environment,
allowed
):
app_with_mock_config.config['NOTIFY_ENVIRONMENT'] = environment
webauthn_server.init_app(app_with_mock_config)
assert app_with_mock_config.webauthn_server._verify('fake-domain') == allowed
def test_server_relying_party_id(
app_with_mock_config,
mocker,
):
webauthn_server.init_app(app_with_mock_config)
assert app_with_mock_config.webauthn_server.rp.id == 'www.notify.works'