|
|
@@ -171,6 +171,31 @@ class CockpitVideoControllerTest {
|
|
|
.andExpect(jsonPath("$.data.records").isEmpty());
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
+ void playbackControlReachesTheOwnedSessionAndRejectsInvalidRates() throws Exception {
|
|
|
+ when(collector.post(eq("/api/playback/start"), any())).thenReturn(Map.of());
|
|
|
+ when(collector.get(eq("/api/playback/start"), any())).thenReturn(Map.of("stream", "stream_pb", "native", true,
|
|
|
+ "flv", "https://media.invalid/pb.flv"));
|
|
|
+ JSONObject owned = JSON.parseObject(mvc.perform(post(ROOT + "/playback").contentType(MediaType.APPLICATION_JSON)
|
|
|
+ .content(JSON.toJSONString(Map.of("deviceCode", CODE,
|
|
|
+ "startTime", "2026-11-10 01:00:00", "endTime", "2026-11-10 02:00:00"))))
|
|
|
+ .andExpect(status().isOk()).andReturn().getResponse().getContentAsString()).getJSONObject("data");
|
|
|
+ String token = owned.getString("sessionToken");
|
|
|
+ String id = owned.getString("sessionId");
|
|
|
+ // A confirmed capability is forwarded to the reused media seam.
|
|
|
+ mvc.perform(post(ROOT + "/sessions/" + id + "/control").contentType(MediaType.APPLICATION_JSON)
|
|
|
+ .content(JSON.toJSONString(Map.of("sessionToken", token, "action", "pause"))))
|
|
|
+ .andExpect(status().isOk());
|
|
|
+ // An unsupported rate is refused before any media call.
|
|
|
+ mvc.perform(post(ROOT + "/sessions/" + id + "/control").contentType(MediaType.APPLICATION_JSON)
|
|
|
+ .content(JSON.toJSONString(Map.of("sessionToken", token, "action", "speed", "value", 3))))
|
|
|
+ .andExpect(status().isServiceUnavailable());
|
|
|
+ // Another viewer's token cannot control this session.
|
|
|
+ mvc.perform(post(ROOT + "/sessions/" + id + "/control").contentType(MediaType.APPLICATION_JSON)
|
|
|
+ .content(JSON.toJSONString(Map.of("sessionToken", "A".repeat(43), "action", "pause"))))
|
|
|
+ .andExpect(status().isForbidden());
|
|
|
+ }
|
|
|
+
|
|
|
@Test
|
|
|
void aFailedRecordingQueryIsItsOwnCategoryNotAGenericVideoRead() throws Exception {
|
|
|
when(collector.get(RECORD_QUERY, Map.of("deviceId", GB, "channelId", CHANNEL,
|
|
|
@@ -280,7 +305,7 @@ class CockpitVideoControllerTest {
|
|
|
@ParameterizedTest
|
|
|
@CsvSource({"GET,/live", "GET,/sessions/example/stop", "GET,/sessions/example/heartbeat",
|
|
|
"GET,/devices/remove", "GET,/record", "POST,/device", "PUT,/live", "DELETE,/live",
|
|
|
- "POST,/sessions/example/control", "POST,/ptz", "POST,/playback/control", "POST,/devices",
|
|
|
+ "POST,/sessions/example/playback", "POST,/ptz", "POST,/playback/control", "POST,/devices",
|
|
|
"POST,/sessions/example/nested/stop", "POST,/live/nested"})
|
|
|
void unpublishedVideoMethodAndPathPairsRequireAuthentication(String method, String path) throws Exception {
|
|
|
mvc.perform(request(org.springframework.http.HttpMethod.valueOf(method), ROOT + path))
|