From 0074cc8d6c10131712c88f6dfbf4f24502523c85 Mon Sep 17 00:00:00 2001 From: Enrico Zini Date: Tue, 21 Apr 2020 12:54:27 +0200 Subject: [PATCH 1/2] Reproduced in test suite. refs: #4 --- wizard/tests/test_advocate.py | 2 +- wizard/tests/test_whoami.py | 42 +++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 wizard/tests/test_whoami.py diff --git a/wizard/tests/test_advocate.py b/wizard/tests/test_advocate.py index d76133a..a24e3b3 100644 --- a/wizard/tests/test_advocate.py +++ b/wizard/tests/test_advocate.py @@ -5,7 +5,7 @@ from backend import const from backend.unittest import PersonFixtureMixin -class PersonPageTestCase(PersonFixtureMixin, TestCase): +class AdvocateTests(PersonFixtureMixin, TestCase): @classmethod def setUpClass(cls): super().setUpClass() diff --git a/wizard/tests/test_whoami.py b/wizard/tests/test_whoami.py new file mode 100644 index 0000000..eb263fc --- /dev/null +++ b/wizard/tests/test_whoami.py @@ -0,0 +1,42 @@ +from __future__ import annotations +from django.test import TestCase +from django.urls import reverse +from backend import const +from backend.unittest import PersonFixtureMixin +from signon.models import Identity + + +class WhoamiTests(PersonFixtureMixin, TestCase): + def test_notlogged(self): + # Check that the new person is listed on the page + client = self.make_test_client(None) + response = client.get(reverse('wizard_home')) + self.assertEqual(response.status_code, 200) + self.assertContains(response, "You are not currently logged in.") + self.assertNotContains(response, "but not mapped to any person in the site.") + self.assertNotContains(response, "You are currently logged in, and recognized as") + + def test_active_unbound(self): + # Check that the new person is listed on the page + identity = Identity.objects.create( + issuer="debsso", subject="test@debian.org", + username="test@debian.org", audit_skip=True) + client = self.make_test_client(None, [identity]) + response = client.get(reverse('wizard_home')) + self.assertEqual(response.status_code, 200) + self.assertNotContains(response, "You are not currently logged in.") + self.assertContains(response, "but not mapped to any person in the site.") + self.assertNotContains(response, "You are currently logged in, and recognized as") + + def test_active_bound(self): + # Check that the new person is listed on the page + identity = Identity.objects.create( + person=self.persons.dc, + issuer="debsso", subject="test@debian.org", + username="test@debian.org", audit_skip=True) + client = self.make_test_client(self.persons.dc, [identity]) + response = client.get(reverse('wizard_home')) + self.assertEqual(response.status_code, 200) + self.assertNotContains(response, "You are not currently logged in.") + self.assertNotContains(response, "but not mapped to any person in the site.") + self.assertContains(response, "You are currently logged in, and recognized as") -- GitLab From 1f4dea0baf9043d69a9ffa07ec2b4338740f39bc Mon Sep 17 00:00:00 2001 From: Enrico Zini Date: Tue, 21 Apr 2020 12:54:48 +0200 Subject: [PATCH 2/2] Ported whoami template to signon. refs: #4 --- wizard/templates/wizard/whoami.html | 41 +++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/wizard/templates/wizard/whoami.html b/wizard/templates/wizard/whoami.html index 3c3935b..05eb78f 100644 --- a/wizard/templates/wizard/whoami.html +++ b/wizard/templates/wizard/whoami.html @@ -2,25 +2,50 @@
- {% if request.sso_username %} + {% if request.signon_identities %} {% if visitor %} -{% blocktrans with request_user_username=request.user.username visitor_a_link=visitor.a_link %}You -are currently logged in with -SSO username -{{request_user_username}}, and recognized as {{visitor_a_link}}.{% endblocktrans %} + +{% blocktrans with visitor_a_link=visitor.a_link %} +You are currently logged in, and recognized as {{visitor_a_link}}. +{% endblocktrans %} + {% else %} + {% url 'dm_claim' as dm_claim_url %} {% blocktrans with request_user_username=request.user.username %}You -are currently logged in with -SSO username -{{request_user_username}}, but not mapped to any person in the site. +are currently logged in, but not mapped to any person in the site. If you are a Debian Maintainer, you can try to correct the situation using the claim interface.{% endblocktrans %} + +

{% trans "You are logged in as:" %}

+ + + {% endif %} + {% else %} {% blocktrans %}You are not currently logged in. See the Single Sign-On page for details.{% endblocktrans %} + {% endif %}
-- GitLab