Exemplo n.º 1
0
    def test_set_groups_superuser(self, crowd_get_groups):
        crowd_get_groups.return_value = self.data
        user = User.objects.create(username="******")
        Group.objects.create(name="admins")
        CrowdBackend().sync_groups(user)

        self.assertEqual(user.groups.count(), 1)
        self.assertEqual(user.is_superuser, True)
Exemplo n.º 2
0
    def test_set_groups_create(self, crowd_get_groups):
        crowd_get_groups.return_value = self.data
        user = User.objects.create(username="******")
        CrowdBackend().sync_groups(user)

        self.assertEqual(user.groups.count(), 2)
        self.assertTrue('admins' in user.groups.values_list('name', flat=True))
        self.assertTrue('users' in user.groups.values_list('name', flat=True))
Exemplo n.º 3
0
    def test_set_groups_map(self, crowd_get_groups):
        crowd_get_groups.return_value = self.data
        user = User.objects.create(username="******")

        gods = Group.objects.create(name="gods")

        CrowdBackend().sync_groups(user)

        self.assertEqual(user.groups.count(), 1)
        self.assertTrue(gods in user.groups.all())
Exemplo n.º 4
0
    def test_sync_user_1(self, crowd_user):
        crowd_user.return_value = self.data
        user = User.objects.create(username="******")

        CrowdBackend().sync_user(user)

        self.assertEqual(user.is_active, False)
        self.assertEqual(user.email, '*****@*****.**')
        self.assertEqual(user.first_name, 'test1')
        self.assertEqual(user.last_name, 'test2')
Exemplo n.º 5
0
    def test_sync_user_2(self, crowd_user):
        crowd_user.return_value = self.data

        user = User.objects.create(username="******")

        CrowdBackend().sync_user(user)

        self.assertEqual(user.is_active, True)
        self.assertEqual(user.email, '')
        self.assertEqual(user.first_name, '')
        self.assertEqual(user.last_name, '')
Exemplo n.º 6
0
    def test_set_groups_1(self, crowd_get_groups):
        crowd_get_groups.return_value = self.data
        user = User.objects.create(username="******")

        users = Group.objects.create(name="users")
        admins = Group.objects.create(name="admins")
        other = Group.objects.create(name="other")

        CrowdBackend().sync_groups(user)

        self.assertEqual(user.groups.count(), 2)
        self.assertTrue(users in user.groups.all())
        self.assertTrue(admins in user.groups.all())
        self.assertTrue(other not in user.groups.all())