From 85bb7e5b0b39f41f40ca919d7d33352b729ea74d Mon Sep 17 00:00:00 2001 From: Jens Diemer Date: Sun, 25 Aug 2024 20:16:19 +0200 Subject: [PATCH] Bugfix Django user permissions A staff user can't see/change anything ;) --- conf/setup_user.py | 1 + for_runners_ynh/tests/test_django_project.py | 8 +- ...roject_create_unknown_user_1.snapshot.html | 208 +++++++++++++++++- 3 files changed, 210 insertions(+), 7 deletions(-) diff --git a/conf/setup_user.py b/conf/setup_user.py index d838d3e..26abbc3 100644 --- a/conf/setup_user.py +++ b/conf/setup_user.py @@ -4,5 +4,6 @@ def setup_project_user(user): Called from django_yunohost_integration.sso_auth """ user.is_staff = True + user.is_superuser = True user.save() return user diff --git a/for_runners_ynh/tests/test_django_project.py b/for_runners_ynh/tests/test_django_project.py index 5fdc416..30400e0 100644 --- a/for_runners_ynh/tests/test_django_project.py +++ b/for_runners_ynh/tests/test_django_project.py @@ -81,7 +81,7 @@ class DjangoYnhTestCase(HtmlAssertionMixin, TestCase): assert user.username == 'test' assert user.is_active is True assert user.is_staff is True # Set by: conf.setup_user.setup_project_user - assert user.is_superuser is False + assert user.is_superuser is True # Set by: conf.setup_user.setup_project_user self.assert_html_parts( response, @@ -111,7 +111,7 @@ class DjangoYnhTestCase(HtmlAssertionMixin, TestCase): assert user.username == 'test' assert user.is_active is True assert user.is_staff is True # Set by: conf.setup_user.setup_project_user - assert user.is_superuser is False + assert user.is_superuser is True # Set by: conf.setup_user.setup_project_user assert AccessLog.objects.count() == 1 @@ -136,7 +136,7 @@ class DjangoYnhTestCase(HtmlAssertionMixin, TestCase): assert user.username == 'test' assert user.is_active is True assert user.is_staff is True # Set by: conf.setup_user.setup_project_user - assert user.is_superuser is False + assert user.is_superuser is True # Set by: conf.setup_user.setup_project_user assert AccessLog.objects.count() == 1 @@ -163,7 +163,7 @@ class DjangoYnhTestCase(HtmlAssertionMixin, TestCase): assert user.username == 'test' assert user.is_active is True assert user.is_staff is True # Set by: conf.setup_user.setup_project_user - assert user.is_superuser is False + assert user.is_superuser is True # Set by: conf.setup_user.setup_project_user assert AccessLog.objects.count() == 1 diff --git a/for_runners_ynh/tests/test_django_project_create_unknown_user_1.snapshot.html b/for_runners_ynh/tests/test_django_project_create_unknown_user_1.snapshot.html index 84f96ea..05b2cde 100644 --- a/for_runners_ynh/tests/test_django_project_create_unknown_user_1.snapshot.html +++ b/for_runners_ynh/tests/test_django_project_create_unknown_user_1.snapshot.html @@ -6,9 +6,211 @@ Site administration
-

- You don’t have permission to view or edit anything. -

+ + +