From 19d30558d849b30b9461dd934078c997c96689e6 Mon Sep 17 00:00:00 2001 From: pabloFuente Date: Mon, 16 Sep 2019 14:42:54 +0200 Subject: [PATCH] openvidu-server: POST /api/signal return 406 if any connectionId wrong --- .../io/openvidu/server/core/SessionEventsHandler.java | 10 +++++----- .../io/openvidu/test/e2e/OpenViduTestAppE2eTest.java | 2 ++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/openvidu-server/src/main/java/io/openvidu/server/core/SessionEventsHandler.java b/openvidu-server/src/main/java/io/openvidu/server/core/SessionEventsHandler.java index 61b19430..59163f06 100644 --- a/openvidu-server/src/main/java/io/openvidu/server/core/SessionEventsHandler.java +++ b/openvidu-server/src/main/java/io/openvidu/server/core/SessionEventsHandler.java @@ -356,16 +356,16 @@ public class SessionEventsHandler { } else { Set participantPublicIds = participants.stream().map(Participant::getParticipantPublicId) .collect(Collectors.toSet()); - for (String to : toSet) { - if (participantPublicIds.contains(to)) { + if (participantPublicIds.containsAll(toSet)) { + for (String to : toSet) { Optional p = participants.stream().filter(x -> to.equals(x.getParticipantPublicId())) .findFirst(); rpcNotificationService.sendNotification(p.get().getParticipantPrivateId(), ProtocolElements.PARTICIPANTSENDMESSAGE_METHOD, params); - } else { - throw new OpenViduException(Code.SIGNAL_TO_INVALID_ERROR_CODE, - "Signal \"to\" field invalid format: Connection [" + to + "] does not exist"); } + } else { + throw new OpenViduException(Code.SIGNAL_TO_INVALID_ERROR_CODE, + "Signal \"to\" field invalid format: some connectionId does not exist in this session"); } } diff --git a/openvidu-test-e2e/src/test/java/io/openvidu/test/e2e/OpenViduTestAppE2eTest.java b/openvidu-test-e2e/src/test/java/io/openvidu/test/e2e/OpenViduTestAppE2eTest.java index 8713068e..dd65590e 100644 --- a/openvidu-test-e2e/src/test/java/io/openvidu/test/e2e/OpenViduTestAppE2eTest.java +++ b/openvidu-test-e2e/src/test/java/io/openvidu/test/e2e/OpenViduTestAppE2eTest.java @@ -2579,6 +2579,8 @@ public class OpenViduTestAppE2eTest { /** POST /api/signal (ACTIVE SESSION) **/ body = "{'session':'CUSTOM_SESSION_ID','to':['wrongConnectionId']}"; restClient.rest(HttpMethod.POST, "/api/signal", body, HttpStatus.SC_NOT_ACCEPTABLE); // No valid connectionId + body = "{'session':'CUSTOM_SESSION_ID','to':['" + connectionId + "','wrongConnectionId']}"; + restClient.rest(HttpMethod.POST, "/api/signal", body, HttpStatus.SC_NOT_ACCEPTABLE); // No valid connectionId body = "{'session':'CUSTOM_SESSION_ID'}"; restClient.rest(HttpMethod.POST, "/api/signal", body, HttpStatus.SC_OK); user.getEventManager().waitUntilEventReaches("signal", 2);