From 7b7a2c266e53d8f600d1de906d3045257664404b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Ka=C5=88ka?= Date: Sat, 30 Nov 2024 13:22:44 +0100 Subject: [PATCH] [Bug #303] Update websocket security tests to reflect new exception handling --- .../websocket/IntegrationWebSocketSecurityTest.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/test/java/cz/cvut/kbss/termit/websocket/IntegrationWebSocketSecurityTest.java b/src/test/java/cz/cvut/kbss/termit/websocket/IntegrationWebSocketSecurityTest.java index c1d2d81b0..0d47b608d 100644 --- a/src/test/java/cz/cvut/kbss/termit/websocket/IntegrationWebSocketSecurityTest.java +++ b/src/test/java/cz/cvut/kbss/termit/websocket/IntegrationWebSocketSecurityTest.java @@ -37,6 +37,7 @@ import static org.awaitility.Awaitility.await; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.ArgumentMatchers.isNull; import static org.mockito.ArgumentMatchers.notNull; import static org.mockito.Mockito.verify; @@ -86,7 +87,8 @@ void connectionIsClosedOnAnyMessageBeforeConnect(String stompCommand, Boolean wi assertTrue(receivedError.get()); assertFalse(session.isOpen()); assertFalse(receivedReply.get()); - verify(webSocketExceptionHandler).messageDeliveryException(notNull(), notNull()); + verify(webSocketExceptionHandler).delegate(notNull(), notNull()); + verify(webSocketExceptionHandler).accessDeniedException(notNull(), notNull()); } WebSocketHandler makeWebSocketHandler(AtomicBoolean receivedReply, AtomicBoolean receivedError) { @@ -131,7 +133,8 @@ void connectWithInvalidAuthorizationIsRejected() throws Throwable { assertTrue(receivedError.get()); assertFalse(session.isOpen()); assertFalse(receivedReply.get()); - verify(webSocketExceptionHandler).messageDeliveryException(notNull(), notNull()); + verify(webSocketExceptionHandler).delegate(notNull(), notNull()); + verify(webSocketExceptionHandler).authenticationException(notNull(), notNull()); } /** @@ -167,7 +170,8 @@ void connectWithInvalidJwtAuthorizationIsRejected() throws Throwable { assertFalse(session.isOpen()); assertFalse(receivedReply.get()); - verify(webSocketExceptionHandler).messageDeliveryException(notNull(), notNull()); + verify(webSocketExceptionHandler).delegate(notNull(), notNull()); + verify(webSocketExceptionHandler).authenticationException(notNull(), notNull()); } /** @@ -186,5 +190,6 @@ void connectionIsNotClosedWhenConnectMessageIsSent() throws Throwable { assertTrue(session.isConnected()); session.disconnect(); await().atMost(OPERATION_TIMEOUT, TimeUnit.SECONDS).until(() -> !session.isConnected()); + verify(webSocketExceptionHandler).delegate(notNull(), isNull()); } }