Make it easy to see API keys for broadcast service

This made it easier to debug a problem with the functional tests
due to the fixtures not working correctly [^1]. It's a platform
admin only convenience over knowing the page URL.

We may want to expose the top-level "/api-integration" page but
that will require more work to show which broadcasts were sent with
which key - currently it's oriented around "messages". For now I
think it's useful to see what keys a service has.

[^1]: https://github.com/alphagov/notifications-functional-tests/pull/411#pullrequestreview-920069799
This commit is contained in:
Ben Thorner
2022-03-24 12:29:14 +00:00
parent dd85cf076d
commit b6bc598e8c
2 changed files with 35 additions and 2 deletions

View File

@@ -25,8 +25,12 @@
{% if current_user.has_permissions('manage_api_keys', 'manage_service') %}
<li><a class="govuk-link govuk-link--no-visited-state{{ main_navigation.is_selected('settings') }}" href="{{ url_for('.service_settings', service_id=current_service.id) }}">Settings</a></li>
{% endif %}
{% if current_user.has_permissions('manage_api_keys') and not current_service.has_permission('broadcast') %}
<li><a class="govuk-link govuk-link--no-visited-state{{ main_navigation.is_selected('api-integration') }}" href="{{ url_for('.api_integration', service_id=current_service.id) }}">API integration</a></li>
{% if current_user.has_permissions('manage_api_keys') %}
{% if current_service.has_permission('broadcast') %}
<li><a class="govuk-link govuk-link--no-visited-state{{ main_navigation.is_selected('api-integration') }}" href="{{ url_for('.api_keys', service_id=current_service.id) }}">API integration</a></li>
{% else %}
<li><a class="govuk-link govuk-link--no-visited-state{{ main_navigation.is_selected('api-integration') }}" href="{{ url_for('.api_integration', service_id=current_service.id) }}">API integration</a></li>
{% endif %}
{% endif %}
{% elif current_user.has_permissions(allow_org_user=True) %}
<li><a class="govuk-link govuk-link--no-visited-state{{ main_navigation.is_selected('usage') }}" href="{{ url_for('.usage', service_id=current_service.id) }}">Usage</a></li>

View File

@@ -547,6 +547,35 @@ def test_navigation_for_services_with_broadcast_permission(
]
def test_navigation_for_services_with_broadcast_permission_platform_admin(
mocker,
client_request,
service_one,
mock_get_service_templates,
mock_get_template_folders,
mock_get_api_keys,
platform_admin_user,
):
service_one['permissions'] += ['broadcast']
mocker.patch(
'app.user_api_client.get_user',
return_value=platform_admin_user,
)
page = client_request.get('main.choose_template', service_id=SERVICE_ONE_ID)
assert [
a['href'] for a in page.select('.navigation a')
] == [
'/services/{}/current-alerts'.format(SERVICE_ONE_ID),
'/services/{}/past-alerts'.format(SERVICE_ONE_ID),
'/services/{}/rejected-alerts'.format(SERVICE_ONE_ID),
'/services/{}/templates'.format(SERVICE_ONE_ID),
'/services/{}/users'.format(SERVICE_ONE_ID),
'/services/{}/service-settings'.format(SERVICE_ONE_ID),
'/services/{}/api/keys'.format(SERVICE_ONE_ID),
]
def test_caseworkers_get_caseworking_navigation(
client_request,
mocker,