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

@@ -33,6 +33,7 @@ from app.utils import (
generate_next_dict,
generate_previous_dict,
get_page_from_request,
user_has_permissions,
user_is_platform_admin,
)
@@ -339,6 +340,7 @@ def platform_admin_letter_validation_preview():
@main.route("/services/<service_id>/letter-validation-preview", methods=["GET", "POST"])
@login_required
@user_has_permissions()
def service_letter_validation_preview(service_id):
return letter_validation_preview(from_platform_admin=False)