Files
notifications-admin/tests/app/test_webauthn_server.py
T

39 lines
875 B
Python
Raw Normal View History

2021-05-07 18:10:07 +01:00
import pytest
from app import webauthn_server
2021-05-17 11:37:47 +01:00
@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
2021-05-07 18:10:07 +01:00
@pytest.mark.parametrize(('environment, allowed'), [
('development', True),
('production', False)
])
def test_server_origin_verification(
2021-05-17 11:37:47 +01:00
app_with_mock_config,
2021-05-07 18:10:07 +01:00
environment,
allowed
):
2021-05-17 11:37:47 +01:00
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
2021-05-07 18:10:07 +01:00
def test_server_relying_party_id(
2021-05-17 11:37:47 +01:00
app_with_mock_config,
2021-05-07 18:10:07 +01:00
mocker,
):
2021-05-17 11:37:47 +01:00
webauthn_server.init_app(app_with_mock_config)
assert app_with_mock_config.webauthn_server.rp.id == 'www.notify.works'