mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-23 07:46:23 -04:00
Use service_has_permission decorator on inbox
This proves that the decorator works, because the inbox code is already
tested:
bad1e69cc3/tests/app/main/views/test_dashboard.py (L353-L367)
This commit is contained in:
@@ -33,6 +33,7 @@ from app.utils import (
|
|||||||
generate_next_dict,
|
generate_next_dict,
|
||||||
generate_previous_dict,
|
generate_previous_dict,
|
||||||
get_current_financial_year,
|
get_current_financial_year,
|
||||||
|
service_has_permission,
|
||||||
user_has_permissions,
|
user_has_permissions,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -170,6 +171,7 @@ def monthly(service_id):
|
|||||||
|
|
||||||
@main.route("/services/<uuid:service_id>/inbox")
|
@main.route("/services/<uuid:service_id>/inbox")
|
||||||
@user_has_permissions('view_activity')
|
@user_has_permissions('view_activity')
|
||||||
|
@service_has_permission('inbound_sms')
|
||||||
def inbox(service_id):
|
def inbox(service_id):
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
@@ -181,6 +183,7 @@ def inbox(service_id):
|
|||||||
|
|
||||||
@main.route("/services/<uuid:service_id>/inbox.json")
|
@main.route("/services/<uuid:service_id>/inbox.json")
|
||||||
@user_has_permissions('view_activity')
|
@user_has_permissions('view_activity')
|
||||||
|
@service_has_permission('inbound_sms')
|
||||||
def inbox_updates(service_id):
|
def inbox_updates(service_id):
|
||||||
|
|
||||||
return jsonify(get_inbox_partials(service_id))
|
return jsonify(get_inbox_partials(service_id))
|
||||||
@@ -212,9 +215,6 @@ def inbox_download(service_id):
|
|||||||
|
|
||||||
def get_inbox_partials(service_id):
|
def get_inbox_partials(service_id):
|
||||||
page = int(request.args.get('page', 1))
|
page = int(request.args.get('page', 1))
|
||||||
if not current_service.has_permission('inbound_sms'):
|
|
||||||
abort(403)
|
|
||||||
|
|
||||||
inbound_messages_data = service_api_client.get_most_recent_inbound_sms(service_id, page=page)
|
inbound_messages_data = service_api_client.get_most_recent_inbound_sms(service_id, page=page)
|
||||||
inbound_messages = inbound_messages_data['data']
|
inbound_messages = inbound_messages_data['data']
|
||||||
if not inbound_messages:
|
if not inbound_messages:
|
||||||
|
|||||||
@@ -83,7 +83,9 @@ def user_has_permissions(*permissions, **permission_kwargs):
|
|||||||
|
|
||||||
|
|
||||||
def service_has_permission(permission):
|
def service_has_permission(permission):
|
||||||
|
|
||||||
from app import current_service
|
from app import current_service
|
||||||
|
|
||||||
def wrap(func):
|
def wrap(func):
|
||||||
@wraps(func)
|
@wraps(func)
|
||||||
def wrap_func(*args, **kwargs):
|
def wrap_func(*args, **kwargs):
|
||||||
|
|||||||
@@ -396,6 +396,7 @@ def test_view_inbox_updates(
|
|||||||
mocker,
|
mocker,
|
||||||
mock_get_most_recent_inbound_sms_with_no_messages,
|
mock_get_most_recent_inbound_sms_with_no_messages,
|
||||||
):
|
):
|
||||||
|
service_one['permissions'] += ['inbound_sms']
|
||||||
|
|
||||||
mock_get_partials = mocker.patch(
|
mock_get_partials = mocker.patch(
|
||||||
'app.main.views.dashboard.get_inbox_partials',
|
'app.main.views.dashboard.get_inbox_partials',
|
||||||
|
|||||||
Reference in New Issue
Block a user