Example #1
0
File: api.py Project: insad/marsha
    def service_create(self, request, *args, **kwargs):
        """Create a Big Blue Button meeting.

        Parameters
        ----------
        request : Type[django.http.request.HttpRequest]
            The request on the API endpoint
        pk: string
            The primary key of the meeting

        Returns
        -------
        Type[rest_framework.response.Response]
            HttpResponse with the serialized meeting.
        """
        # Updating meeting with sent title and welcome text
        self.update(request, *args, **kwargs)

        try:
            response = create(meeting=self.get_object())
            status = 200
        except ApiMeetingException as exception:
            response = {"message": str(exception)}
            status = 400
        return Response(response, status=status)
Example #2
0
    def test_bbb_create_existing_meeting(self):
        """Create a meeting in current meeting related server."""
        meeting = MeetingFactory(
            title="Meeting 001",
            attendee_password="******",
            moderator_password="******",
            meeting_id="7a567d67-29d3-4547-96f3-035733a4dfaa",
        )

        responses.add(
            responses.GET,
            "https://10.7.7.1/bigbluebutton/api/create",
            match=[
                responses.matchers.query_param_matcher(
                    {
                        "attendeePW": "9#R1kuUl3R",
                        "checksum": "08a4c09eb240bcbcfe7a79a3ce864c7070aabd2a",
                        "meetingID": "7a567d67-29d3-4547-96f3-035733a4dfaa",
                        "moderatorPW": "0$C7Aaz0o",
                        "name": "Meeting 001",
                        "welcome": "Welcome!",
                    }
                )
            ],
            body="""
            <response>
                <returncode>FAILED</returncode>
                <messageKey>idNotUnique</messageKey>
                <message>A meeting already exists with that meeting ID.</message>
            </response>
            """,
            status=200,
        )

        with self.assertRaises(ApiMeetingException) as exception:
            create(meeting)
        self.assertEqual(
            str(exception.exception), "A meeting already exists with that meeting ID."
        )
        meeting.refresh_from_db()
        self.assertEqual(meeting.started, False)
Example #3
0
    def test_bbb_create_existing_classroom(self):
        """Create a meeting in current classroom related server."""
        classroom = ClassroomFactory(
            title="Classroom 001",
            attendee_password="******",
            moderator_password="******",
            meeting_id="7a567d67-29d3-4547-96f3-035733a4dfaa",
        )

        responses.add(
            responses.GET,
            "https://10.7.7.1/bigbluebutton/api/create",
            match=[
                responses.matchers.query_param_matcher({
                    "attendeePW": "9#R1kuUl3R",
                    "checksum": "c410b2eaf47efafc9a5ebc0d6d12990069fd78bf",
                    "meetingID": "7a567d67-29d3-4547-96f3-035733a4dfaa",
                    "moderatorPW": "0$C7Aaz0o",
                    "name": "Classroom 001",
                    "welcome": "Welcome!",
                })
            ],
            body="""
            <response>
                <returncode>FAILED</returncode>
                <messageKey>idNotUnique</messageKey>
                <message>A meeting already exists with that meeting ID.</message>
            </response>
            """,
            status=200,
        )

        with self.assertRaises(ApiMeetingException) as exception:
            create(classroom)
        self.assertEqual(str(exception.exception),
                         "A meeting already exists with that meeting ID.")
        classroom.refresh_from_db()
        self.assertEqual(classroom.started, False)
Example #4
0
    def test_bbb_create_new_classroom(self):
        """Create a classroom in current classroom related server."""
        classroom = ClassroomFactory(
            title="Classroom 001",
            attendee_password="******",
            moderator_password="******",
            meeting_id="7a567d67-29d3-4547-96f3-035733a4dfaa",
        )

        responses.add(
            responses.GET,
            "https://10.7.7.1/bigbluebutton/api/create",
            match=[
                responses.matchers.query_param_matcher({
                    "attendeePW": "9#R1kuUl3R",
                    "checksum": "c410b2eaf47efafc9a5ebc0d6d12990069fd78bf",
                    "meetingID": "7a567d67-29d3-4547-96f3-035733a4dfaa",
                    "moderatorPW": "0$C7Aaz0o",
                    "name": "Classroom 001",
                    "welcome": "Welcome!",
                })
            ],
            body=f"""
            <response>
                <returncode>SUCCESS</returncode>
                <meetingID>{classroom.id}</meetingID>
                <internalMeetingID>232a8ab5dbfde4d33a2bd9d5bbc08bd74d04e163-1628693645640</internalMeetingID>
                <parentMeetingID>bbb-none</parentMeetingID>
                <attendeePW>{classroom.attendee_password}</attendeePW>
                <moderatorPW>{classroom.moderator_password}</moderatorPW>
                <createTime>1628693645640</createTime>
                <voiceBridge>83267</voiceBridge>
                <dialNumber>613-555-1234</dialNumber>
                <createDate>Wed Aug 11 14:54:05 UTC 2021</createDate>
                <hasUserJoined>false</hasUserJoined>
                <duration>0</duration>
                <hasBeenForciblyEnded>false</hasBeenForciblyEnded>
                <messageKey></messageKey>
                <message></message>
            </response>
            """,
            status=200,
        )

        api_response = create(classroom)

        self.assertDictEqual(
            {
                "attendeePW": classroom.attendee_password,
                "createDate": "Wed Aug 11 14:54:05 UTC 2021",
                "createTime": "1628693645640",
                "dialNumber": "613-555-1234",
                "duration": "0",
                "hasBeenForciblyEnded": "false",
                "hasUserJoined": "false",
                "internalMeetingID":
                "232a8ab5dbfde4d33a2bd9d5bbc08bd74d04e163-1628693645640",
                "meetingID": str(classroom.id),
                "message": "Meeting created.",
                "messageKey": None,
                "moderatorPW": classroom.moderator_password,
                "parentMeetingID": "bbb-none",
                "returncode": "SUCCESS",
                "voiceBridge": "83267",
            },
            api_response,
        )
        self.assertEqual(classroom.started, True)
        self.assertEqual(classroom.ended, False)
Example #5
0
    def test_bbb_create_new_classroom_no_passwords(self):
        """When starting a classroom, if no passwords exists,
        BBB generates them, and they are stored in classroom instance."""
        classroom = ClassroomFactory(
            title="Classroom 001",
            attendee_password=None,
            moderator_password=None,
            meeting_id="7a567d67-29d3-4547-96f3-035733a4dfaa",
        )
        responses.add(
            responses.GET,
            "https://10.7.7.1/bigbluebutton/api/create",
            match=[
                responses.matchers.query_param_matcher({
                    "checksum": "3d56249a0307871b230c46a64118456262c4f613",
                    "meetingID": "7a567d67-29d3-4547-96f3-035733a4dfaa",
                    "name": "Classroom 001",
                    "welcome": "Welcome!",
                })
            ],
            body=f"""
            <response>
                <returncode>SUCCESS</returncode>
                <meetingID>{classroom.id}</meetingID>
                <internalMeetingID>232a8ab5dbfde4d33a2bd9d5bbc08bd74d04e163-1628693645640</internalMeetingID>
                <parentMeetingID>bbb-none</parentMeetingID>
                <attendeePW>attendee_password</attendeePW>
                <moderatorPW>moderator_password</moderatorPW>
                <createTime>1628693645640</createTime>
                <voiceBridge>83267</voiceBridge>
                <dialNumber>613-555-1234</dialNumber>
                <createDate>Wed Aug 11 14:54:05 UTC 2021</createDate>
                <hasUserJoined>false</hasUserJoined>
                <duration>0</duration>
                <hasBeenForciblyEnded>false</hasBeenForciblyEnded>
                <messageKey></messageKey>
                <message></message>
            </response>
            """,
            status=200,
        )

        api_response = create(classroom)

        self.assertDictEqual(
            {
                "attendeePW": "attendee_password",
                "createDate": "Wed Aug 11 14:54:05 UTC 2021",
                "createTime": "1628693645640",
                "dialNumber": "613-555-1234",
                "duration": "0",
                "hasBeenForciblyEnded": "false",
                "hasUserJoined": "false",
                "internalMeetingID":
                "232a8ab5dbfde4d33a2bd9d5bbc08bd74d04e163-1628693645640",
                "meetingID": str(classroom.id),
                "message": "Meeting created.",
                "messageKey": None,
                "moderatorPW": "moderator_password",
                "parentMeetingID": "bbb-none",
                "returncode": "SUCCESS",
                "voiceBridge": "83267",
            },
            api_response,
        )
        self.assertEqual(classroom.started, True)
        self.assertEqual(classroom.attendee_password, "attendee_password")
        self.assertEqual(classroom.moderator_password, "moderator_password")