Ejemplo n.º 1
0
    def test_membership_signals(self):
        moderator = User.objects.create_user(
            username="******",
            email="*****@*****.**",
            is_superuser=True,
            is_staff=True
        )

        attendee = User.objects.create_user(
            username="******",
            email="*****@*****.**",
            is_superuser=True,
            is_staff=True
        )

        outsider = User.objects.create_user(
            username="******",
            email="*****@*****.**",
            is_superuser=True,
            is_staff=True
        )

        group = CosinnusGroup(name="BBB Test")
        group.save()

        membership1 = CosinnusGroupMembership(group=group, user=moderator, status=2)
        membership1.save()

        membership2 = CosinnusGroupMembership(group=group, user=attendee, status=1)
        membership2.save()

        room = BBBRoom.create(
            name="SIGNAL TEST",
            meeting_id="signal-test",
            meeting_welcome="meant to be end",
        )

        time.sleep(2)
        room.join_group_members(group)

        membership1.status = 1

        membership1.save()
        self.assertEqual(len(room.moderators.all()), 1)

        membership2.delete()
        self.assertEqual(len(room.attendees.all()), 1)
Ejemplo n.º 2
0
    def test_creation(self):
        room = BBBRoom.create(
            name="TestName",
            meeting_id="MeetingID",
            meeting_welcome="Welcome Test",
        )

        self.assertEqual(room.name, "TestName")
        self.assertEqual(room.meeting_id, "MeetingID")
        self.assertEqual(room.welcome_message, "Welcome Test")

        time.sleep(2)

        room_info = self.bbb_api.meeting_info(room.meeting_id, room.moderator_password)
        self.assertNotEqual(room_info, None)
        self.assertEqual(room_info['moderatorPW'], room.moderator_password)
        self.assertEqual(room_info['attendeePW'], room.attendee_password)

        room_info = self.bbb_api.meeting_info(room.meeting_id, room.moderator_password)
Ejemplo n.º 3
0
            def create_room():
                max_participants = None
                if event.type == event.TYPE_COFFEE_TABLE and event.max_participants:
                    max_participants = event.max_participants
                # determine BBBRoom type from event type
                room_type = event.BBB_ROOM_ROOM_TYPE_MAP.get(
                    event.type, settings.BBB_ROOM_TYPE_DEFAULT)
                presentation_url = event.presentation_file.url if event.presentation_file else None

                from cosinnus.models.bbb_room import BBBRoom
                bbb_room = BBBRoom.create(
                    name=event.title,
                    meeting_id=f'{portal.slug}-{event.group.id}-{event.id}',
                    max_participants=max_participants,
                    room_type=room_type,
                    presentation_url=presentation_url,
                    source_object=self,
                )
                event.media_tag.bbb_room = bbb_room
                event.media_tag.save()
                # sync all bb users
                event.sync_bbb_members()
Ejemplo n.º 4
0
    def test_join_view(self):
        factory = RequestFactory()

        room = BBBRoom.create(
            name="VIEW TEST",
            meeting_id="view-test",
            meeting_welcome="join via url",
        )

        time.sleep(2)
        room.join_group_members(self.group)

        request = factory.get(reverse("cosinnus:bbb-room", kwargs={"room_id": room.id}))
        request.user = self.moderator

        response = BBBRoomMeetingView.as_view()(request, **{"room_id": room.id})

        self.assertNotEqual(response.status_code, 404)
        self.assertNotEqual(response.status_code, 403)
        self.assertEqual(response.status_code, 302)

        first_token = response.url

        self.assertTrue(first_token.startswith(self.bbb_api.api_auth_url))

        # another request with another user
        request = factory.get(reverse("cosinnus:bbb-room", kwargs={"room_id": room.id}))
        request.user = self.attendee

        response = BBBRoomMeetingView.as_view()(request, **{"room_id": room.id})

        self.assertNotEqual(response.status_code, 404)
        self.assertNotEqual(response.status_code, 403)
        self.assertEqual(response.status_code, 302)

        second_token = response.url

        self.assertNotEqual(first_token, second_token)
        self.assertTrue(second_token.startswith(self.bbb_api.api_auth_url))

        # third request as anonymous user should result in a 403
        request = factory.get(reverse("cosinnus:bbb-room", kwargs={"room_id": room.id}))
        request.user = self.outsider

        with self.assertRaises(PermissionDenied):
            BBBRoomMeetingView.as_view()(request, **{"room_id": room.id})

        # test view with superuser permissions
        superuser = User.objects.create_user(
            username="******",
            email="*****@*****.**",
            is_superuser=True,
            is_staff=True
        )
        request = factory.get(reverse("cosinnus:bbb-room", kwargs={"room_id": room.id}))
        request.user = superuser

        response = BBBRoomMeetingView.as_view()(request, **{"room_id": room.id})

        self.assertNotEqual(response.status_code, 404)
        self.assertNotEqual(response.status_code, 403)
        self.assertEqual(response.status_code, 302)

        second_token = response.url

        self.assertNotEqual(first_token, second_token)
        self.assertTrue(second_token.startswith(self.bbb_api.api_auth_url))