mirror of
https://github.com/GSA/notifications-api.git
synced 2026-09-09 09:29:50 -04:00
changed name of test fixture
This commit is contained in:
@@ -53,7 +53,7 @@ def restrict_ip_sms():
|
|||||||
ip = ip_list[len(ip_list) - 3]
|
ip = ip_list[len(ip_list) - 3]
|
||||||
current_app.logger.info("Inbound sms ip route list {}".format(ip_route))
|
current_app.logger.info("Inbound sms ip route list {}".format(ip_route))
|
||||||
|
|
||||||
if ip in current_app.config.get('ALLOW_IP_INBOUND_SMS'):
|
if ip in current_app.config.get('SMS_INBOUND_WHITELIST'):
|
||||||
current_app.logger.info("Inbound sms ip addresses {} passed ".format(ip))
|
current_app.logger.info("Inbound sms ip addresses {} passed ".format(ip))
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -262,7 +262,7 @@ class Config(object):
|
|||||||
|
|
||||||
FREE_SMS_TIER_FRAGMENT_COUNT = 250000
|
FREE_SMS_TIER_FRAGMENT_COUNT = 250000
|
||||||
|
|
||||||
ALLOW_IP_INBOUND_SMS = os.environ.get('SMS_INBOUND_WHITELIST', [])
|
SMS_INBOUND_WHITELIST = os.environ.get('SMS_INBOUND_WHITELIST', [])
|
||||||
|
|
||||||
|
|
||||||
######################
|
######################
|
||||||
|
|||||||
@@ -313,8 +313,7 @@ def __create_token(service_id):
|
|||||||
def restrict_ip_sms_app():
|
def restrict_ip_sms_app():
|
||||||
app = flask.Flask(__name__)
|
app = flask.Flask(__name__)
|
||||||
app.config['TESTING'] = True
|
app.config['TESTING'] = True
|
||||||
app.config['ALLOW_IP_INBOUND_SMS'] = ['111.111.111.111', '100.100.100.100']
|
app.config['SMS_INBOUND_WHITELIST'] = ['111.111.111.111', '100.100.100.100']
|
||||||
# app.config['ALLOW_IP_INBOUND_SMS'] = os.environ['SMS_INBOUND_WHITELIST']
|
|
||||||
blueprint = flask.Blueprint('restrict_ip_sms_app', __name__)
|
blueprint = flask.Blueprint('restrict_ip_sms_app', __name__)
|
||||||
|
|
||||||
@blueprint.route('/')
|
@blueprint.route('/')
|
||||||
@@ -350,3 +349,16 @@ def test_reject_invalid_ips(restrict_ip_sms_app):
|
|||||||
)
|
)
|
||||||
|
|
||||||
assert exc_info.value.short_message == 'Unknown source IP address from the SMS provider'
|
assert exc_info.value.short_message == 'Unknown source IP address from the SMS provider'
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.xfail(reason='Currently not blocking invalid IPs', strict=True)
|
||||||
|
def test_illegitimate_ips(restrict_ip_sms_app):
|
||||||
|
with pytest.raises(AuthError) as exc_info:
|
||||||
|
restrict_ip_sms_app.get(
|
||||||
|
path='/',
|
||||||
|
headers=[
|
||||||
|
('X-Forwarded-For', '111.111.111.111, 999.999.999.999, 333.333.333.333, 127.0.0.1')
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
assert exc_info.value.short_message == 'Unknown source IP address from the SMS provider'
|
||||||
|
|||||||
Reference in New Issue
Block a user