From 0a79c4ded178029a85b5113fec104415d3e3bf75 Mon Sep 17 00:00:00 2001
From: Serghei Mihai <smihai@entrouvert.com>
Date: Mon, 9 May 2022 15:10:57 +0200
Subject: [PATCH] idp_oidc: display service info on authorization page (#64672)

---
 .../locale/fr/LC_MESSAGES/django.po                |  7 +++----
 .../authentic2_idp_oidc/authorization.html         |  6 +++++-
 tests/idp_oidc/test_misc.py                        | 14 +++++++++++++-
 3 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/src/authentic2_idp_oidc/locale/fr/LC_MESSAGES/django.po b/src/authentic2_idp_oidc/locale/fr/LC_MESSAGES/django.po
index d79e54d7c..723ab1d3b 100644
--- a/src/authentic2_idp_oidc/locale/fr/LC_MESSAGES/django.po
+++ b/src/authentic2_idp_oidc/locale/fr/LC_MESSAGES/django.po
@@ -7,7 +7,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: Authentic\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2022-04-06 10:46+0200\n"
+"POT-Creation-Date: 2022-05-09 14:18+0200\n"
 "PO-Revision-Date: 2022-04-06 10:49+0200\n"
 "Last-Translator: Benjamin Dauvergne <bdauvergne@entrouvert.com>\n"
 "Language-Team: None\n"
@@ -232,9 +232,8 @@ msgid "Authentication access check"
 msgstr "Vérification d’autorisation d’accès"
 
 #: src/authentic2_idp_oidc/templates/authentic2_idp_oidc/authorization.html
-#, python-format
-msgid "Do you want to be authenticated on service %(client_name)s ?"
-msgstr "Souhaitez-vous être authentifié sur le service %(client_name)s ?"
+msgid "Do you want to be authenticated on this service ?"
+msgstr "Souhaitez-vous être authentifié sur ce service ?"
 
 #: src/authentic2_idp_oidc/templates/authentic2_idp_oidc/authorization.html
 msgid "The following informations will be sent to the service:"
diff --git a/src/authentic2_idp_oidc/templates/authentic2_idp_oidc/authorization.html b/src/authentic2_idp_oidc/templates/authentic2_idp_oidc/authorization.html
index 85f246f74..d4cf40d67 100644
--- a/src/authentic2_idp_oidc/templates/authentic2_idp_oidc/authorization.html
+++ b/src/authentic2_idp_oidc/templates/authentic2_idp_oidc/authorization.html
@@ -6,10 +6,14 @@
 <link rel="stylesheet" type="text/css" href="{% static 'authentic2_idp_oidc/css/style.css' %}"></link>
 {% endblock %}
 
+{% block beforecontent %}
+{% include "authentic2/service_info_fragment.html" %}
+{% endblock %}
+
 {% block content %}
 <h2>{% trans "Authentication access check" %}</h2>
 <form method="post" id="a2-oidc-authorization-form">
-    <p>{% blocktrans with client_name=client.name %}Do you want to be authenticated on service {{ client_name }} ?{% endblocktrans %}</p>
+    <p>{% trans "Do you want to be authenticated on this service ?" %}</p>
     {% if needs_scope_validation %}
       <p>{% trans "The following informations will be sent to the service:" %}</p>
       <ul>
diff --git a/tests/idp_oidc/test_misc.py b/tests/idp_oidc/test_misc.py
index 1779739f7..3f7f11882 100644
--- a/tests/idp_oidc/test_misc.py
+++ b/tests/idp_oidc/test_misc.py
@@ -130,7 +130,7 @@ def test_admin(other_attributes, app, superuser, oidc_settings):
     assert OIDCClient.objects.count() == 1
 
 
-def test_login_from_client_with_home_url(oidc_client, app):
+def test_login_from_client_with_home_url(oidc_client, app, simple_user):
     redirect_uri = oidc_client.redirect_uris.split()[0]
     params = {
         'client_id': oidc_client.client_id,
@@ -185,6 +185,18 @@ def test_login_from_client_with_home_url(oidc_client, app):
         == '/media/services/logos/201x201.jpg'
     )
 
+    # check authorization page
+    response = utils.login(app, simple_user)
+    response = app.get(authorize_url)
+    assert response.pyquery.find('.service-message')
+    assert response.pyquery.find('a.service-message--link')
+    assert (
+        response.pyquery.find('img.service-message--logo')[0].attrib['src']
+        == '/media/services/logos/201x201.jpg'
+    )
+    link = response.pyquery.find('a.service-message--link')[0]
+    assert link.attrib['href'] == 'https://service.example.net'
+
 
 @pytest.mark.parametrize('oidc_client', OIDC_CLIENT_PARAMS, indirect=True)
 @pytest.mark.parametrize('do_not_ask_again', [(True,), (False,)])
-- 
2.36.0

