Skip to content

Commit

Permalink
[Bug kbss-cvut#303] Update websocket security tests to reflect new ex…
Browse files Browse the repository at this point in the history
…ception handling
  • Loading branch information
lukaskabc committed Nov 30, 2024
1 parent 7921462 commit 7b7a2c2
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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());
}

/**
Expand Down Expand Up @@ -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());
}

/**
Expand All @@ -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());
}
}

0 comments on commit 7b7a2c2

Please sign in to comment.