Skip to content

Commit 7a53237

Browse files
committed
🐛(backend) there are no more cookie on BBB recording url
Due to change config on BBB of ESR Add test to try if cookie set or not. Add changelog
1 parent cdbc379 commit 7a53237

File tree

3 files changed

+70
-2
lines changed

3 files changed

+70
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ Versioning](https://semver.org/spec/v2.0.0.html).
88

99
## [Unreleased]
1010

11+
### Fixed
12+
13+
- Get recording from BBB even if no cookie
14+
1115
## [5.12.1] - 2025-12-12
1216

1317
### Fixed

src/backend/marsha/core/tasks/recording.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def copy_video_recording(record_url: str, video_pk: str, stamp: str):
4242
if not response.history:
4343
raise RecordingSourceError("No redirection have been followed.")
4444

45-
raw_cookie = response.history[0].headers.get("set-cookie")
45+
raw_cookie = response.history[0].headers.get("set-cookie", "")
4646
cookie = raw_cookie.split(";")[0]
4747

4848
base_url = response.url.rstrip("/")
@@ -56,7 +56,7 @@ def copy_video_recording(record_url: str, video_pk: str, stamp: str):
5656

5757
with requests.get(
5858
video_url,
59-
headers={"Cookie": cookie},
59+
headers={"Cookie": cookie} if cookie else {},
6060
stream=True,
6161
timeout=10,
6262
) as video_response:

src/backend/marsha/core/tests/tasks/test_recording.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,70 @@ def setUpTestData(cls):
3131
cls.html_content = TEST_HTML_PATH.read_text()
3232
cls.video_content = TEST_VIDEO_PATH.read_bytes()
3333

34+
@responses.activate(assert_all_requests_are_fired=True)
35+
def test_copy_video_recording_no_cookie(self):
36+
"""
37+
Test the copy_video_recording task without cookie.
38+
"""
39+
# Prepare URLs
40+
record_url = "https://example.com/recording/1234/video"
41+
playback_url = "https://example.com/playback/video/1234"
42+
html_video_url = "https://example.com/video/1234"
43+
video_file_url = f"{html_video_url}/video-0.m4v"
44+
45+
# First redirect from record URL
46+
responses.add(
47+
responses.GET,
48+
record_url,
49+
status=302,
50+
headers={
51+
"Location": playback_url,
52+
"Content-Type": "text/html",
53+
},
54+
)
55+
56+
# Second redirect to HTML video page
57+
responses.add(
58+
responses.GET,
59+
playback_url,
60+
status=302,
61+
headers={"Location": html_video_url, "Content-Type": "text/html"},
62+
)
63+
64+
# HTML video page response
65+
responses.add(
66+
responses.GET,
67+
html_video_url,
68+
status=200,
69+
body=self.html_content,
70+
headers={"Content-Type": "text/html"},
71+
)
72+
73+
# Video file response
74+
responses.add(
75+
responses.GET,
76+
video_file_url,
77+
status=200,
78+
body=self.video_content,
79+
headers={"Content-Type": "video/mp4"},
80+
)
81+
82+
video = VideoFactory()
83+
stamp = "1640995200"
84+
85+
copy_video_recording(record_url, video.pk, stamp)
86+
87+
video.refresh_from_db()
88+
self.assertEqual(video.upload_state, defaults.PROCESSING)
89+
90+
expected_key = f"tmp/{str(video.pk)}/video/{stamp}"
91+
self.assertTrue(file_storage.exists(expected_key))
92+
with file_storage.open(expected_key, "rb") as video_file:
93+
self.assertEqual(
94+
video_file.read(),
95+
self.video_content,
96+
)
97+
3498
@responses.activate(assert_all_requests_are_fired=True)
3599
def test_copy_video_recording(self):
36100
"""

0 commit comments

Comments
 (0)