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 2014/02/13 18:58:36 UTC

[1/3] git commit: [#6677] add comment, and positive test

Updated Branches:
  refs/heads/master cab6cfa74 -> 63514760c


[#6677] add comment, and positive test


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/87259aa0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/87259aa0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/87259aa0

Branch: refs/heads/master
Commit: 87259aa02afc635d8f2d41ae88a3a7ace66760df
Parents: 6939145
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Thu Feb 13 17:33:13 2014 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Feb 13 17:33:17 2014 +0000

----------------------------------------------------------------------
 Allura/allura/model/auth.py            | 1 +
 Allura/allura/tests/model/test_auth.py | 6 ++++--
 2 files changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/87259aa0/Allura/allura/model/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/auth.py b/Allura/allura/model/auth.py
index aa8e5dc..0a68146 100644
--- a/Allura/allura/model/auth.py
+++ b/Allura/allura/model/auth.py
@@ -747,6 +747,7 @@ class User(MappedClass, ActivityNode, ActivityObject):
         if self.is_anonymous():
             return
         roles = g.credentials.user_roles(user_id=self._id)
+        # filter out projects to which the user belongs to no named groups (i.e., role['roles'] is empty)
         projects = [r['project_id'] for r in roles if r['roles']]
         from .project import Project
         return Project.query.find({'_id': {'$in': projects}, 'deleted': False})

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/87259aa0/Allura/allura/tests/model/test_auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/model/test_auth.py b/Allura/allura/tests/model/test_auth.py
index 606b3e2..475b74a 100644
--- a/Allura/allura/tests/model/test_auth.py
+++ b/Allura/allura/tests/model/test_auth.py
@@ -20,7 +20,7 @@
 """
 Model tests for auth
 """
-from nose.tools import with_setup, assert_equal, assert_not_in
+from nose.tools import with_setup, assert_equal, assert_not_in, assert_in
 from pylons import tmpl_context as c, app_globals as g
 from webob import Request
 from mock import patch
@@ -268,7 +268,9 @@ def test_user_projects_unnamed():
         user_id=c.user._id,
         project_id=sub1._id)
     ThreadLocalORMSession.flush_all()
-    assert_not_in('test/sub1', [p.shortname for p in c.user.my_projects()])
+    project_names = [p.shortname for p in c.user.my_projects()]
+    assert_not_in('test/sub1', project_names)
+    assert_in('test', project_names)
 
 
 @patch.object(g, 'user_message_max_messages', 3)


[3/3] git commit: Merge branch 'cj/6677'

Posted by br...@apache.org.
Merge branch 'cj/6677'


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/63514760
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/63514760
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/63514760

Branch: refs/heads/master
Commit: 63514760cd02d037278d10a87ae0087bd523338b
Parents: cab6cfa 87259aa
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Thu Feb 13 17:33:36 2014 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Feb 13 17:33:36 2014 +0000

----------------------------------------------------------------------
 Allura/allura/model/auth.py            |  3 ++-
 Allura/allura/tests/model/test_auth.py | 20 +++++++++++++++++++-
 2 files changed, 21 insertions(+), 2 deletions(-)
----------------------------------------------------------------------



[2/3] git commit: [#6677] Account for spurious ProjectRoles for non-members in User.my_projects

Posted by br...@apache.org.
[#6677] Account for spurious ProjectRoles for non-members in User.my_projects

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/6939145e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/6939145e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/6939145e

Branch: refs/heads/master
Commit: 6939145ef8a12894d2dce613989cb50c649537fc
Parents: bbba5f7
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Wed Feb 12 23:03:49 2014 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Feb 13 17:33:17 2014 +0000

----------------------------------------------------------------------
 Allura/allura/model/auth.py            |  2 +-
 Allura/allura/tests/model/test_auth.py | 18 +++++++++++++++++-
 2 files changed, 18 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/6939145e/Allura/allura/model/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/auth.py b/Allura/allura/model/auth.py
index dfbfc32..aa8e5dc 100644
--- a/Allura/allura/model/auth.py
+++ b/Allura/allura/model/auth.py
@@ -747,7 +747,7 @@ class User(MappedClass, ActivityNode, ActivityObject):
         if self.is_anonymous():
             return
         roles = g.credentials.user_roles(user_id=self._id)
-        projects = [r['project_id'] for r in roles]
+        projects = [r['project_id'] for r in roles if r['roles']]
         from .project import Project
         return Project.query.find({'_id': {'$in': projects}, 'deleted': False})
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/6939145e/Allura/allura/tests/model/test_auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/model/test_auth.py b/Allura/allura/tests/model/test_auth.py
index 5119f68..606b3e2 100644
--- a/Allura/allura/tests/model/test_auth.py
+++ b/Allura/allura/tests/model/test_auth.py
@@ -20,7 +20,7 @@
 """
 Model tests for auth
 """
-from nose.tools import with_setup, assert_equal
+from nose.tools import with_setup, assert_equal, assert_not_in
 from pylons import tmpl_context as c, app_globals as g
 from webob import Request
 from mock import patch
@@ -255,6 +255,22 @@ def test_user_projects_by_role():
                  set(['test', 'u/test-admin', 'adobe-1', '--init--']))
 
 
+@td.with_user_project('test-admin')
+@with_setup(setUp)
+def test_user_projects_unnamed():
+    """
+    Confirm that spurious ProjectRoles associating a user with
+    a project to which they do not belong to any named group
+    don't cause the user to count as a member of the project.
+    """
+    sub1 = M.Project.query.get(shortname='test/sub1')
+    M.ProjectRole(
+        user_id=c.user._id,
+        project_id=sub1._id)
+    ThreadLocalORMSession.flush_all()
+    assert_not_in('test/sub1', [p.shortname for p in c.user.my_projects()])
+
+
 @patch.object(g, 'user_message_max_messages', 3)
 def test_check_sent_user_message_times():
     user1 = M.User.register(dict(username='test-user'), make_project=False)