Ensure all service route have permission decorators

We accidentally miss these sometimes. This code adds a test which
inspects the code to automatically check that any function which:
- handles a route
- accepts a service_id

For each function it checks that each of these routes have the
permissions decorator we’d expect.

Most of the introspection/AST code is adapted from here:
https://mvdwoord.github.io/exploration/2017/08/18/ast_explore.html
This commit is contained in:
Chris Hill-Scott
2019-06-27 14:23:03 +01:00
parent 14e9d763f1
commit 91f2da8b68
8 changed files with 87 additions and 3 deletions

View File

@@ -23,6 +23,7 @@ def agreement():
@main.route('/services/<uuid:service_id>/agreement')
@login_required
@user_has_permissions('manage_service')
def service_agreement(service_id):
return render_template(
'views/agreement/service-{}.html'.format(current_service.organisation.as_jinja_template),
@@ -41,6 +42,7 @@ def service_download_agreement(service_id):
@main.route('/services/<uuid:service_id>/agreement/accept', methods=['GET', 'POST'])
@login_required
@user_has_permissions('manage_service')
def service_accept_agreement(service_id):
if not current_service.organisation:
@@ -64,6 +66,7 @@ def service_accept_agreement(service_id):
@main.route('/services/<uuid:service_id>/agreement/confirm', methods=['GET', 'POST'])
@login_required
@user_has_permissions('manage_service')
def service_confirm_agreement(service_id):
if (