|
|
@@ -332,6 +332,41 @@ class VideoSessionCompatibilityTest {
|
|
|
@Override protected void doRollback(org.springframework.transaction.support.DefaultTransactionStatus status) { rollback.run(); }
|
|
|
}
|
|
|
|
|
|
+ @org.junit.jupiter.params.ParameterizedTest
|
|
|
+ @org.junit.jupiter.params.provider.ValueSource(strings = {"native", "emptyKey", "blankKey"})
|
|
|
+ void aProxyResponseCannotBypassCleanupIdentity(String scenario) {
|
|
|
+ VideoDeviceRecord manual = new VideoDeviceRecord();
|
|
|
+ manual.setEquipmentId(DEVICE);
|
|
|
+ manual.setSourceType("MANUAL");
|
|
|
+ manual.setVideoUrl("rtsp://camera.invalid/live");
|
|
|
+ when(bindings.find(DEVICE)).thenReturn(manual);
|
|
|
+ Map<String, Object> response = scenario.equals("native")
|
|
|
+ ? Map.of("url", "https://media.invalid/live.flv", "native", true)
|
|
|
+ : Map.of("url", "https://media.invalid/live.flv", "stream", "manual_camera-1", "proxyKey", scenario.equals("emptyKey") ? "" : " ");
|
|
|
+ when(media.post(eq("/internal/video/manual/start"), any())).thenReturn(response);
|
|
|
+ assertThrows(ServiceException.class, () -> service.startAnonymous(DEVICE, null));
|
|
|
+ verify(sessions, never()).insert(any(VideoSession.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ @org.junit.jupiter.params.ParameterizedTest
|
|
|
+ @org.junit.jupiter.params.provider.CsvSource({"true,true", "true,false", "false,true", "false,false"})
|
|
|
+ void manualNativeAndProxySourcesKeepWorkingForBothOwnerKinds(boolean nativeStream, boolean anonymous) {
|
|
|
+ VideoDeviceRecord manual = new VideoDeviceRecord();
|
|
|
+ manual.setEquipmentId(DEVICE); manual.setSourceType("MANUAL");
|
|
|
+ manual.setVideoUrl(nativeStream ? "HTTPS://camera.invalid/live.mp4" : "rtsp://camera.invalid/live");
|
|
|
+ when(bindings.find(DEVICE)).thenReturn(manual);
|
|
|
+ String key = "__defaultVhost__/city_video/manual_camera-1";
|
|
|
+ when(media.post(eq("/internal/video/manual/start"), any())).thenReturn(
|
|
|
+ Map.of("flv", "https://media.invalid/live.flv", "stream", "manual_camera-1", "proxyKey", key));
|
|
|
+ login(41);
|
|
|
+ Map<String, Object> result = anonymous ? service.startAnonymous(DEVICE, null) : service.start(DEVICE, null);
|
|
|
+ assertFalse(result.containsKey("proxyKey"));
|
|
|
+ String id = (String) result.get("sessionId");
|
|
|
+ if (anonymous) service.stop(id, (String) result.get("sessionToken")); else service.stop(id);
|
|
|
+ if (nativeStream) verifyNoInteractions(media);
|
|
|
+ else verify(media).post("/internal/video/manual/stop", Map.of("key", key));
|
|
|
+ }
|
|
|
+
|
|
|
private static VideoSession copy(VideoSession row) {
|
|
|
if (row == null) return null;
|
|
|
VideoSession copy = new VideoSession();
|