manage: display relevant info on apiclient detail page (#81333) #130

Merged
pmarillonnet merged 1 commits from wip/81333-api-client-recap-missing-info into main 2023-09-20 10:52:43 +02:00
2 changed files with 25 additions and 5 deletions

View File

@ -21,16 +21,32 @@
<div class="bo-block">
<h3>{% trans "Parameters" %}</h3>
<ul>
<li>{% trans "Identifier" %}{% trans ":" %} {{api_client.identifier}}</li>
<li>{% trans "Password" %}{% trans ":" %} {{api_client.password}}</li>
<li>{% trans "Organizational unit" %}{% trans ":" %} {{ api_client.ou.name }}</li>
{% if api_client.restrict_to_anonymised_data %}<li>{% trans "Restricted to anonymised data" %}</li>{% endif %}
{% if api_client.description %}<li>{% blocktrans with description=api_client.description %}Description: {{ description }}{% endblocktrans %}</li>{% endif %}
<li>{% blocktrans with identifier=api_client.identifier %}Identifier: {{ identifier }}{% endblocktrans %}</li>
<li>{% blocktrans with password=api_client.password %}Password: {{ password }}{% endblocktrans %}</li>
<li>{% blocktrans with ou=api_client.ou.name %}Organizational unit: {{ ou }}{% endblocktrans %}</li>
{% if api_client.apiclient_roles.count %}
<li>{% trans "Roles:" %}
<ul>
{% for role in api_client.apiclient_roles.all %}<li>{{ role.name }}</li>{% endfor %}
</ul>
</li>
{% else %}
<li>{% trans "No role assigned to this client yet." %}</li>
{% endif %}
{% if api_client.restrict_to_anonymised_data %}
<li>{% trans "Restricted to anonymised data" %}</li>
{% else %}
<li>{% trans "No restriction to anonymised-only data." %}</li>
{% endif %}
{% if api_client.allowed_user_attributes.count %}
<li>{% trans "Allowed user attributes:" %}
<ul>
{% for attr in api_client.allowed_user_attributes.all %}<li>{{ attr.name }}</li>{% endfor %}
</ul>
</li>
{% else %}
<li>{% trans "Unrestricted access to user profile attributes." %}
{% endif %}
</ul>
</div>

View File

@ -227,7 +227,7 @@ def test_add_description_non_mandatory(superuser, app):
assert urlparse(response.request.url).path == api_client.get_absolute_url()
def test_detail(superuser, app):
def test_detail(superuser, app, phone_activated_authn):
role_1 = Role.objects.create(name='role-1')
role_2 = Role.objects.create(name='role-2')
api_client = APIClient.objects.create(
@ -238,13 +238,17 @@ def test_detail(superuser, app):
restrict_to_anonymised_data=True,
)
api_client.apiclient_roles.add(role_1, role_2)
api_client.allowed_user_attributes.add(phone_activated_authn.phone_identifier_field)
resp = login(app, superuser, api_client.get_absolute_url())
assert 'Description: foo-description' in resp.text
assert 'Identifier: foo-identifier' in resp.text
assert 'Password: foo-password' in resp.text
assert 'foo-description' in resp.text
assert 'Restricted to anonymised data' in resp.text
assert 'role-1' in resp.text
assert 'role-2' in resp.text
assert 'Allowed user attributes' in resp.text
assert 'phone' in resp.text
edit_button = resp.pyquery(
'span.actions a[href="%s"]' % reverse('a2-manager-api-client-edit', kwargs={'pk': api_client.pk})