You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
3.3 KiB
3.3 KiB
Online Class Webhook Smoke Test
This smoke test sends real HTTP requests to the public PlugNMeet webhook endpoint and then verifies the expected database side effects.
It is useful when you want to validate:
- Nginx/public routing to
/api/courses/plugnmeet/webhook/ - signature verification with
PLUGNMEET_API_SECRET - Django webhook processing
CourseLiveSessionupdatesLiveSessionUserjoin/leave updates- moderator auto-close scheduling
Command
Run from the backend project:
python manage.py smoke_test_online_class_webhooks --help
Recommended Safe Mode
Use a disposable live session instead of a real class session:
python manage.py smoke_test_online_class_webhooks \
--create-session \
--course-id 16 \
--base-url https://imamjavad.online \
--include-invalid-signature
What this does:
- creates a temporary active
CourseLiveSession - sends real webhook HTTP requests to the public endpoint
- verifies DB side effects after each webhook
- closes the temporary session at the end
Use an Existing Active Session
If you want to test against a currently active session:
python manage.py smoke_test_online_class_webhooks \
--session-id 123 \
--base-url https://imamjavad.online
Be careful: the final closing webhook will close that session unless you pass --skip-final-close.
Optional User Overrides
By default, the command auto-picks:
- moderator: first professor of the course
- participant: first active participant of the course
You can override them:
python manage.py smoke_test_online_class_webhooks \
--create-session \
--course-id 16 \
--moderator-user-id 279 \
--participant-user-id 315 \
--base-url https://imamjavad.online
Webhooks Covered
The smoke test currently verifies this flow:
participant_joinedfor a studentparticipant_joinedfor a moderatorparticipant_leftfor the moderatorparticipant_joinedfor the moderator againparticipant_leftfor the student- final close event:
room_finishedorsession_ended
Optional:
- invalid signature should return
403
What Each Step Verifies
- participant join creates or updates
LiveSessionUserwithis_online=True - moderator join creates a moderator
LiveSessionUserand clears pending auto-close fields - moderator leave sets
last_moderator_left_atandauto_close_after_moderator_exit_at - participant leave marks the participant offline
- final close sets
ended_atand forces all session users offline
Useful Flags
--include-invalid-signature- sends one bad-signature request and expects HTTP
403
- sends one bad-signature request and expects HTTP
--skip-final-close- skips the final closing webhook
--final-event room_finished- default final close event
--final-event session_ended- use the alternate close event
--timeout 20- set HTTP timeout in seconds
How To Read Results
The command prints one line per step:
[PASS] ...[FAIL] ...
If any step fails, the command exits with a non-zero status.
Recommended Production Usage
Prefer this pattern:
- choose a dedicated test course
- ensure the course has at least one professor and one active participant
- run the command with
--create-session - review:
- command output
- Django logs
- Nginx logs
This avoids mutating a real student-facing live class.