Require IDs to be UUIDs in URLS

We mostly rely on the API returning a 404 to generate 404s for trying
to get things with non-UUID IDs. This is fine, except our tests often
mock these API calls. So it could look like everything is working fine,
except the thing your passing in might never be a valid UUID, and thus
would 404 in a non-test environment.

So this commit:
1. uses the `uuid` URL converter everywhere there’s something that looks
   like an ID in a URL parameter
2.  adds a test which automates checking for 1.
This commit is contained in:
Chris Hill-Scott
2019-11-04 11:07:55 +00:00
parent 554a852e2d
commit ef335e7601
26 changed files with 283 additions and 233 deletions

View File

@@ -38,7 +38,7 @@ def add_monthly_traffic(domestic_sms_providers):
provider['monthly_traffic'] = round(percentage)
@main.route("/provider/<provider_id>/edit", methods=['GET', 'POST'])
@main.route("/provider/<uuid:provider_id>/edit", methods=['GET', 'POST'])
@user_is_platform_admin
def edit_provider(provider_id):
provider = provider_client.get_provider_by_id(provider_id)['provider_details']
@@ -51,7 +51,7 @@ def edit_provider(provider_id):
return render_template('views/providers/edit-provider.html', form=form, provider=provider)
@main.route("/provider/<provider_id>")
@main.route("/provider/<uuid:provider_id>")
@user_is_platform_admin
def view_provider(provider_id):
versions = provider_client.get_provider_versions(provider_id)