mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-30 14:31:57 -05:00
Remove cloudfoundry config parsing logic
By replacing user-provided services with manifest environment variables we avoid the need to set the application environment variables from the service data. Most of the variable names already match the service JSON keys, but we need to rename the ones that don't (eg MMG and Firetext `api_key`) this is done in a separate credentials PR.
This commit is contained in:
@@ -6,70 +6,6 @@ import pytest
|
||||
from app.cloudfoundry_config import extract_cloudfoundry_config, set_config_env_vars
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def notify_config():
|
||||
return {
|
||||
'name': 'notify-config',
|
||||
'credentials': {
|
||||
'admin_base_url': 'admin base url',
|
||||
'api_host_name': 'api host name',
|
||||
'admin_client_secret': 'admin client secret',
|
||||
'secret_key': 'secret key',
|
||||
'dangerous_salt': 'dangerous salt',
|
||||
'allow_ip_inbound_sms': ['111.111.111.111', '100.100.100.100'],
|
||||
'firetext_inbound_sms_auth': ['testkey'],
|
||||
'mmg_inbound_sms_auth': ['testkey'],
|
||||
'mmg_inbound_sms_username': ['username'],
|
||||
'route_secret_key_1': "key_1",
|
||||
'route_secret_key_2': ""
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def aws_config():
|
||||
return {
|
||||
'name': 'notify-aws',
|
||||
'credentials': {
|
||||
'sqs_queue_prefix': 'sqs queue prefix',
|
||||
'aws_access_key_id': 'aws access key id',
|
||||
'aws_secret_access_key': 'aws secret access key',
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def hosted_graphite_config():
|
||||
return {
|
||||
'name': 'hosted-graphite',
|
||||
'credentials': {
|
||||
'statsd_prefix': 'statsd prefix'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mmg_config():
|
||||
return {
|
||||
'name': 'mmg',
|
||||
'credentials': {
|
||||
'api_url': 'mmg api url',
|
||||
'api_key': 'mmg api key'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def firetext_config():
|
||||
return {
|
||||
'name': 'firetext',
|
||||
'credentials': {
|
||||
'api_key': 'firetext api key',
|
||||
'loadtesting_api_key': 'loadtesting api key'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def postgres_config():
|
||||
return [
|
||||
@@ -82,62 +18,10 @@ def postgres_config():
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def redis_config():
|
||||
return {
|
||||
'name': 'redis',
|
||||
'credentials': {
|
||||
'redis_enabled': '1',
|
||||
'redis_url': 'redis url'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def performance_platform_config():
|
||||
return {
|
||||
'name': 'performance-platform',
|
||||
'credentials': {
|
||||
'foo': 'my_token',
|
||||
'bar': 'other_token'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def template_preview_config():
|
||||
return {
|
||||
'name': 'notify-template-preview',
|
||||
'credentials': {
|
||||
'api_host': 'template-preview api host',
|
||||
'api_key': 'template-preview api key'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def cloudfoundry_config(
|
||||
postgres_config,
|
||||
notify_config,
|
||||
aws_config,
|
||||
hosted_graphite_config,
|
||||
mmg_config,
|
||||
firetext_config,
|
||||
redis_config,
|
||||
performance_platform_config,
|
||||
template_preview_config
|
||||
):
|
||||
def cloudfoundry_config(postgres_config):
|
||||
return {
|
||||
'postgres': postgres_config,
|
||||
'user-provided': [
|
||||
notify_config,
|
||||
aws_config,
|
||||
hosted_graphite_config,
|
||||
mmg_config,
|
||||
firetext_config,
|
||||
redis_config,
|
||||
performance_platform_config,
|
||||
template_preview_config
|
||||
]
|
||||
'user-provided': []
|
||||
}
|
||||
|
||||
|
||||
@@ -167,100 +51,3 @@ def test_set_config_env_vars_ignores_unknown_configs(cloudfoundry_config):
|
||||
|
||||
assert 'foo' not in os.environ
|
||||
assert 'bar' not in os.environ
|
||||
|
||||
|
||||
@pytest.mark.usefixtures('os_environ', 'cloudfoundry_environ')
|
||||
def test_notify_config():
|
||||
extract_cloudfoundry_config()
|
||||
|
||||
assert os.environ['ADMIN_BASE_URL'] == 'admin base url'
|
||||
assert os.environ['API_HOST_NAME'] == 'api host name'
|
||||
assert os.environ['ADMIN_CLIENT_SECRET'] == 'admin client secret'
|
||||
assert os.environ['SECRET_KEY'] == 'secret key'
|
||||
assert os.environ['DANGEROUS_SALT'] == 'dangerous salt'
|
||||
|
||||
|
||||
@pytest.mark.usefixtures('os_environ', 'cloudfoundry_environ')
|
||||
def test_aws_config():
|
||||
extract_cloudfoundry_config()
|
||||
|
||||
assert os.environ['NOTIFICATION_QUEUE_PREFIX'] == 'sqs queue prefix'
|
||||
assert os.environ['AWS_ACCESS_KEY_ID'] == 'aws access key id'
|
||||
assert os.environ['AWS_SECRET_ACCESS_KEY'] == 'aws secret access key'
|
||||
|
||||
|
||||
@pytest.mark.usefixtures('os_environ', 'cloudfoundry_environ')
|
||||
def test_hosted_graphite_config():
|
||||
extract_cloudfoundry_config()
|
||||
|
||||
assert os.environ['STATSD_PREFIX'] == 'statsd prefix'
|
||||
|
||||
|
||||
@pytest.mark.usefixtures('os_environ', 'cloudfoundry_environ')
|
||||
def test_mmg_config():
|
||||
extract_cloudfoundry_config()
|
||||
|
||||
assert os.environ['MMG_URL'] == 'mmg api url'
|
||||
assert os.environ['MMG_API_KEY'] == 'mmg api key'
|
||||
|
||||
|
||||
@pytest.mark.usefixtures('os_environ', 'cloudfoundry_environ')
|
||||
def test_firetext_config():
|
||||
extract_cloudfoundry_config()
|
||||
|
||||
assert os.environ['FIRETEXT_API_KEY'] == 'firetext api key'
|
||||
assert os.environ['LOADTESTING_API_KEY'] == 'loadtesting api key'
|
||||
|
||||
|
||||
@pytest.mark.usefixtures('os_environ', 'cloudfoundry_environ')
|
||||
def test_redis_config():
|
||||
extract_cloudfoundry_config()
|
||||
|
||||
assert os.environ['REDIS_ENABLED'] == '1'
|
||||
assert os.environ['REDIS_URL'] == 'redis url'
|
||||
|
||||
|
||||
@pytest.mark.usefixtures('os_environ', 'cloudfoundry_environ')
|
||||
def test_sms_inbound_config():
|
||||
extract_cloudfoundry_config()
|
||||
|
||||
assert os.environ['SMS_INBOUND_WHITELIST'] == json.dumps(['111.111.111.111', '100.100.100.100'])
|
||||
|
||||
|
||||
@pytest.mark.usefixtures('os_environ', 'cloudfoundry_environ')
|
||||
def test_firetext_inbound_sms_auth_config():
|
||||
extract_cloudfoundry_config()
|
||||
|
||||
assert os.environ['FIRETEXT_INBOUND_SMS_AUTH'] == json.dumps(['testkey'])
|
||||
|
||||
|
||||
@pytest.mark.usefixtures('os_environ', 'cloudfoundry_environ')
|
||||
def test_mmg_inbound_sms_auth_config():
|
||||
extract_cloudfoundry_config()
|
||||
|
||||
assert os.environ['MMG_INBOUND_SMS_AUTH'] == json.dumps(['testkey'])
|
||||
|
||||
|
||||
@pytest.mark.usefixtures('os_environ', 'cloudfoundry_environ')
|
||||
def test_mmg_inbound_sms_username_config():
|
||||
extract_cloudfoundry_config()
|
||||
|
||||
assert os.environ['MMG_INBOUND_SMS_USERNAME'] == json.dumps(['username'])
|
||||
|
||||
|
||||
@pytest.mark.usefixtures('os_environ', 'cloudfoundry_environ')
|
||||
def test_performance_platform_config():
|
||||
extract_cloudfoundry_config()
|
||||
|
||||
assert json.loads(os.environ['PERFORMANCE_PLATFORM_ENDPOINTS']) == {
|
||||
'foo': 'my_token',
|
||||
'bar': 'other_token'
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.usefixtures('os_environ', 'cloudfoundry_environ')
|
||||
def test_template_preview_config():
|
||||
extract_cloudfoundry_config()
|
||||
|
||||
assert os.environ['TEMPLATE_PREVIEW_API_HOST'] == 'template-preview api host'
|
||||
assert os.environ['TEMPLATE_PREVIEW_API_KEY'] == 'template-preview api key'
|
||||
|
||||
Reference in New Issue
Block a user