mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-23 15:56:45 -04:00
Merge pull request #1081 from alphagov/ip-fix
don't store non-strings to os.environ
This commit is contained in:
@@ -43,7 +43,7 @@ def extract_notify_config(notify_config):
|
|||||||
os.environ['SECRET_KEY'] = notify_config['credentials']['secret_key']
|
os.environ['SECRET_KEY'] = notify_config['credentials']['secret_key']
|
||||||
os.environ['DANGEROUS_SALT'] = notify_config['credentials']['dangerous_salt']
|
os.environ['DANGEROUS_SALT'] = notify_config['credentials']['dangerous_salt']
|
||||||
os.environ['PERFORMANCE_PLATFORM_TOKEN'] = notify_config['credentials'].get('performance_platform_token', '')
|
os.environ['PERFORMANCE_PLATFORM_TOKEN'] = notify_config['credentials'].get('performance_platform_token', '')
|
||||||
os.environ['SMS_INBOUND_WHITELIST'] = notify_config['credentials']['allow_ip_inbound_sms']
|
os.environ['SMS_INBOUND_WHITELIST'] = json.dumps(notify_config['credentials']['allow_ip_inbound_sms'])
|
||||||
|
|
||||||
|
|
||||||
def extract_notify_aws_config(aws_config):
|
def extract_notify_aws_config(aws_config):
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import os
|
import os
|
||||||
|
import json
|
||||||
|
|
||||||
from celery.schedules import crontab
|
from celery.schedules import crontab
|
||||||
from kombu import Exchange, Queue
|
from kombu import Exchange, Queue
|
||||||
@@ -262,7 +263,7 @@ class Config(object):
|
|||||||
|
|
||||||
FREE_SMS_TIER_FRAGMENT_COUNT = 250000
|
FREE_SMS_TIER_FRAGMENT_COUNT = 250000
|
||||||
|
|
||||||
SMS_INBOUND_WHITELIST = os.environ.get('SMS_INBOUND_WHITELIST', [])
|
SMS_INBOUND_WHITELIST = json.loads(os.environ.get('SMS_INBOUND_WHITELIST', '[]'))
|
||||||
|
|
||||||
|
|
||||||
######################
|
######################
|
||||||
|
|||||||
@@ -204,4 +204,4 @@ def test_redis_config():
|
|||||||
def test_sms_inbound_config():
|
def test_sms_inbound_config():
|
||||||
extract_cloudfoundry_config()
|
extract_cloudfoundry_config()
|
||||||
|
|
||||||
assert os.environ['SMS_INBOUND_WHITELIST'] == ['111.111.111.111', '100.100.100.100']
|
assert os.environ['SMS_INBOUND_WHITELIST'] == json.dumps(['111.111.111.111', '100.100.100.100'])
|
||||||
|
|||||||
@@ -90,7 +90,13 @@ def os_environ():
|
|||||||
"""
|
"""
|
||||||
# for use whenever you expect code to edit environment variables
|
# for use whenever you expect code to edit environment variables
|
||||||
old_env = os.environ.copy()
|
old_env = os.environ.copy()
|
||||||
os.environ = {}
|
|
||||||
|
class EnvironDict(dict):
|
||||||
|
def __setitem__(self, key, value):
|
||||||
|
assert type(value) == str
|
||||||
|
super().__setitem__(key, value)
|
||||||
|
|
||||||
|
os.environ = EnvironDict()
|
||||||
yield
|
yield
|
||||||
os.environ = old_env
|
os.environ = old_env
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user