You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2022/03/08 22:39:07 UTC

[allura] branch master updated (9fcb470 -> 6874494)

This is an automated email from the ASF dual-hosted git repository.

brondsem pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git.


    from 9fcb470  8417 fix for failing test
     new 4ac5e5a  [#8391] Unsubscribe from a project when a user is removed from Admin group
     new 438459b  [#8391] Unsubscribe from a project when a user is removed from Admin group - added a test case
     new 6874494  [#8391] update test case to use /remove_user endpoint.  Also re-use existing test since it does a lot of similar steps

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 Allura/allura/app.py                         | 11 +++++++++++
 Allura/allura/ext/admin/admin_main.py        |  3 +++
 Allura/allura/tests/functional/test_admin.py | 12 ++++++++++++
 3 files changed, 26 insertions(+)

[allura] 02/03: [#8391] Unsubscribe from a project when a user is removed from Admin group - added a test case

Posted by br...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

brondsem pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git

commit 438459b6cd68f02b0c33def285899df7c5627be2
Author: Vrinda A <vr...@in.bosch.com>
AuthorDate: Fri Feb 25 17:12:53 2022 +0530

    [#8391] Unsubscribe from a project when a user is removed from Admin group - added a test case
---
 Allura/allura/tests/functional/test_admin.py | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/Allura/allura/tests/functional/test_admin.py b/Allura/allura/tests/functional/test_admin.py
index 8ab03d1..1dbe6d1 100644
--- a/Allura/allura/tests/functional/test_admin.py
+++ b/Allura/allura/tests/functional/test_admin.py
@@ -666,6 +666,30 @@ class TestProjectAdmin(TestController):
                 user_id=uid, project_id=p._id, app_config_id=ac._id)
             assert sub, 'New admin not subscribed to app %s' % ac
 
+    def test_admin_unsubscriptions(self):
+        """
+        When user is removed from admins group then user must be unsubscribed
+        from all the tools in the project
+        """
+        r = self.app.get('/admin/groups/')
+        admin_holder = r.html.find(
+            'table', {'id': 'usergroup_admin'}).findAll('tr')[1]
+        admin_id = admin_holder['data-group']
+        with audits('add user test-user to Admin'):
+            self.app.post('/admin/groups/add_user', params={
+                'role_id': admin_id,
+                'username': 'test-user'})
+        p_nbhd = M.Neighborhood.query.get(name='Projects')
+        p = M.Project.query.get(shortname='test', neighborhood_id=p_nbhd._id)
+        uid = M.User.by_username('test-user')._id
+        for ac in p.app_configs:
+            M.Mailbox.unsubscribe(
+                user_id=uid, project_id=p._id, app_config_id=ac._id
+            )
+            sub = M.Mailbox.subscribed(
+                user_id=uid, project_id=p._id, app_config_id=ac._id)
+        assert not sub, 'New admin not unsubscribed to app %s' % ac
+
     def test_new_user_subscriptions(self):
         """Newly added user must not be subscribed to all the tools in the project if he is not admin"""
         r = self.app.get('/admin/groups/')

[allura] 01/03: [#8391] Unsubscribe from a project when a user is removed from Admin group

Posted by br...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

brondsem pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git

commit 4ac5e5ac8a30afc0a61d96f0c187e64f60914261
Author: Vrinda A <vr...@in.bosch.com>
AuthorDate: Wed Dec 1 19:22:54 2021 +0530

    [#8391] Unsubscribe from a project when a user is removed from Admin group
---
 Allura/allura/app.py                  | 11 +++++++++++
 Allura/allura/ext/admin/admin_main.py |  3 +++
 2 files changed, 14 insertions(+)

diff --git a/Allura/allura/app.py b/Allura/allura/app.py
index 9f50c18..e2e34db 100644
--- a/Allura/allura/app.py
+++ b/Allura/allura/app.py
@@ -519,6 +519,17 @@ class Application:
                 project_id=self.project._id,
                 app_config_id=self.config._id)
 
+    def unsubscribe(self, user):
+        """Unsubscribe :class:`user <allura.model.auth.User>` to the
+        :class:`allura.model.notification.Mailbox` for this Application.
+
+        """
+        if user and user != model.User.anonymous():
+            model.Mailbox.unsubscribe(
+                user_id=user._id,
+                project_id=self.project._id,
+                app_config_id=self.config._id)
+
     @classmethod
     def default_options(cls):
         """Return a ``(name, default value)`` mapping of this Application's
diff --git a/Allura/allura/ext/admin/admin_main.py b/Allura/allura/ext/admin/admin_main.py
index 43cacf3..f3466d9 100644
--- a/Allura/allura/ext/admin/admin_main.py
+++ b/Allura/allura/ext/admin/admin_main.py
@@ -1175,6 +1175,9 @@ class GroupsController(BaseController):
         if len(user_role.roles) == 0:
             # user has no roles in this project any more, so don't leave a useless doc around
             user_role.delete()
+        if group.name == 'Admin':
+            for ac in c.project.app_configs:
+                c.project.app_instance(ac).unsubscribe(user)
         g.post_event('project_updated')
         return dict()
 

[allura] 03/03: [#8391] update test case to use /remove_user endpoint. Also re-use existing test since it does a lot of similar steps

Posted by br...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

brondsem pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git

commit 6874494864dbfa69eed7bf8bd369c8722d3c9389
Author: Dave Brondsema <db...@slashdotmedia.com>
AuthorDate: Tue Mar 8 22:08:03 2022 +0000

    [#8391] update test case to use /remove_user endpoint.  Also re-use existing test since it does a lot of similar steps
---
 Allura/allura/tests/functional/test_admin.py | 20 ++++----------------
 1 file changed, 4 insertions(+), 16 deletions(-)

diff --git a/Allura/allura/tests/functional/test_admin.py b/Allura/allura/tests/functional/test_admin.py
index 1dbe6d1..3a300e8 100644
--- a/Allura/allura/tests/functional/test_admin.py
+++ b/Allura/allura/tests/functional/test_admin.py
@@ -666,29 +666,17 @@ class TestProjectAdmin(TestController):
                 user_id=uid, project_id=p._id, app_config_id=ac._id)
             assert sub, 'New admin not subscribed to app %s' % ac
 
-    def test_admin_unsubscriptions(self):
         """
         When user is removed from admins group then user must be unsubscribed
         from all the tools in the project
         """
-        r = self.app.get('/admin/groups/')
-        admin_holder = r.html.find(
-            'table', {'id': 'usergroup_admin'}).findAll('tr')[1]
-        admin_id = admin_holder['data-group']
-        with audits('add user test-user to Admin'):
-            self.app.post('/admin/groups/add_user', params={
-                'role_id': admin_id,
-                'username': 'test-user'})
-        p_nbhd = M.Neighborhood.query.get(name='Projects')
-        p = M.Project.query.get(shortname='test', neighborhood_id=p_nbhd._id)
-        uid = M.User.by_username('test-user')._id
+        self.app.post('/admin/groups/remove_user', params={
+            'role_id': admin_id,
+            'username': 'test-user'})
         for ac in p.app_configs:
-            M.Mailbox.unsubscribe(
-                user_id=uid, project_id=p._id, app_config_id=ac._id
-            )
             sub = M.Mailbox.subscribed(
                 user_id=uid, project_id=p._id, app_config_id=ac._id)
-        assert not sub, 'New admin not unsubscribed to app %s' % ac
+            assert not sub, 'New admin not unsubscribed to app %s' % ac
 
     def test_new_user_subscriptions(self):
         """Newly added user must not be subscribed to all the tools in the project if he is not admin"""