Exemplo n.º 1
0
 def test_to_super(self):
     UserFactory()
     UserFactory(is_staff=True)
     user2 = UserFactory(is_superuser=True)
     ACLRuleFactory(slug='page', permissions=['change_page'], apply_to=ACLRule.TO_SUPERUSERS)
     users = ACLRule.get_users_for(['change_page'], 'page')
     self.assertEqual(set(users), {user2})
Exemplo n.º 2
0
 def test_simple_user_for_multiples_perms(self):
     user1 = UserFactory()
     user2 = UserFactory()
     ACLRuleFactory(
         slug='page', permissions=['view_page'], users=[user1, user2])
     ACLRuleFactory(slug='page', permissions=['change_page'], users=[user1])
     users = ACLRule.get_users_for(['view_page', 'change_page'], 'page')
     self.assertEqual(set(users), {user1})
Exemplo n.º 3
0
 def test_to_staff(self):
     UserFactory()
     user2 = UserFactory(is_staff=True)
     ACLRuleFactory(slug='page',
                    permissions=['view_page'],
                    apply_to=ACLRule.TO_STAFF)
     users = ACLRule.get_users_for(['view_page'], 'page')
     self.assertEqual(set(users), {user2})
Exemplo n.º 4
0
 def test_any_logged_user(self):
     user1 = UserFactory()
     ACLRuleFactory(slug='page',
                    permissions=['view_page'],
                    apply_to=ACLRule.TO_LOGGED)
     users = ACLRule.get_users_for(['view_page'], 'page')
     self.assertNotIn(AnonymousUser(), users)
     self.assertIn(user1, users)
Exemplo n.º 5
0
 def test_is_distinct(self):
     user = UserFactory()
     group1_users = [user]
     group1 = GroupFactory(users=group1_users)
     ACLRuleFactory(slug='page', permissions=['view_page'],
                    groups=[group1], users=[user])
     users = ACLRule.get_users_for('view_page', 'page')
     self.assertEqual(users.count(), 1)
     self.assertEqual(set(users), set(group1_users))
Exemplo n.º 6
0
 def test_to_super(self):
     UserFactory()
     UserFactory(is_staff=True)
     user2 = UserFactory(is_superuser=True)
     ACLRuleFactory(slug='page',
                    permissions=['change_page'],
                    apply_to=ACLRule.TO_SUPERUSERS)
     users = ACLRule.get_users_for(['change_page'], 'page')
     self.assertEqual(set(users), {user2})
Exemplo n.º 7
0
 def test_mixing_group_and_users(self):
     user = UserFactory()
     group1_users = [UserFactory(), UserFactory()]
     group2_users = [UserFactory(), UserFactory()]
     group1 = GroupFactory(users=group1_users)
     group2 = GroupFactory(users=group2_users)
     ACLRuleFactory(slug='page', permissions=['view_page'],
                    groups=[group1, group2], users=[user])
     users = ACLRule.get_users_for('view_page', 'page')
     self.assertEqual(set(users), set(group1_users + group2_users + [user]))
Exemplo n.º 8
0
 def test_simple_user_for_multiples_perms(self):
     user1 = UserFactory()
     user2 = UserFactory()
     ACLRuleFactory(slug='page',
                    permissions=['view_page'],
                    users=[user1, user2])
     ACLRuleFactory(slug='page',
                    permissions=['view_page', 'change_page'],
                    users=[user1])
     users = ACLRule.get_users_for(['view_page', 'change_page'], 'page')
     self.assertEqual(set(users), {user1})
Exemplo n.º 9
0
 def test_is_distinct(self):
     user = UserFactory()
     group1_users = [user]
     group1 = GroupFactory(users=group1_users)
     ACLRuleFactory(slug='page',
                    permissions=['view_page'],
                    groups=[group1],
                    users=[user])
     users = ACLRule.get_users_for('view_page', 'page')
     self.assertEqual(users.count(), 1)
     self.assertEqual(set(users), set(group1_users))
Exemplo n.º 10
0
 def test_mixing_group_and_users(self):
     user = UserFactory()
     group1_users = [UserFactory(), UserFactory()]
     group2_users = [UserFactory(), UserFactory()]
     group1 = GroupFactory(users=group1_users)
     group2 = GroupFactory(users=group2_users)
     ACLRuleFactory(slug='page',
                    permissions=['view_page'],
                    groups=[group1, group2],
                    users=[user])
     users = ACLRule.get_users_for('view_page', 'page')
     self.assertEqual(set(users), set(group1_users + group2_users + [user]))
Exemplo n.º 11
0
 def test_simple_user(self):
     user = UserFactory()
     ACLRuleFactory(slug='page', permissions=['view_page'], users=[user])
     users = ACLRule.get_users_for('view_page', 'page')
     self.assertEqual(set(users), {user})
Exemplo n.º 12
0
 def test_simple_group(self):
     group_users = [UserFactory(), UserFactory()]
     group = GroupFactory(users=group_users)
     ACLRuleFactory(slug='page', permissions=['view_page'], groups=[group])
     users = ACLRule.get_users_for('view_page', 'page')
     self.assertEqual(set(users), set(group_users))
Exemplo n.º 13
0
 def test_simple_group(self):
     group_users = [UserFactory(), UserFactory()]
     group = GroupFactory(users=group_users)
     ACLRuleFactory(slug='page', permissions=['view_page'], groups=[group])
     users = ACLRule.get_users_for('view_page', 'page')
     self.assertEqual(set(users), set(group_users))
Exemplo n.º 14
0
 def test_simple_user(self):
     user = UserFactory()
     ACLRuleFactory(slug='page', permissions=['view_page'], users=[user])
     users = ACLRule.get_users_for('view_page', 'page')
     self.assertEqual(set(users), {user})
Exemplo n.º 15
0
 def test_to_staff(self):
     UserFactory()
     user2 = UserFactory(is_staff=True)
     ACLRuleFactory(slug='page', permissions=['view_page'], apply_to=ACLRule.TO_STAFF)
     users = ACLRule.get_users_for(['view_page'], 'page')
     self.assertEqual(set(users), {user2})
Exemplo n.º 16
0
 def test_any_logged_user(self):
     user1 = UserFactory()
     ACLRuleFactory(slug='page', permissions=['view_page'], apply_to=ACLRule.TO_LOGGED)
     users = ACLRule.get_users_for(['view_page'], 'page')
     self.assertNotIn(AnonymousUser(), users)
     self.assertIn(user1, users)