Skip to content

Commit 662b7b2

Browse files
pablocarlePablo Carle
andauthored
fix: improve websocket message (#4019)
Signed-off-by: Pablo Carle <pablo.carle@broadcom.com> Co-authored-by: Pablo Carle <pablo.carle@broadcom.com>
1 parent d176bfd commit 662b7b2

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

gateway-service/src/main/java/org/zowe/apiml/gateway/websocket/ApimlWebSocketSession.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,6 @@ public void onError(Throwable ex) {
4545
if (ex.getCause() instanceof AuthenticationException) {
4646
close(new CloseStatus(1003, "Invalid login credentials"));
4747
}
48-
close(CloseStatus.SERVER_ERROR);
48+
close(CloseStatus.create(CloseStatus.SERVER_ERROR.getCode(), ex.getMessage()));
4949
}
5050
}

gateway-service/src/test/java/org/zowe/apiml/gateway/websocket/ApimlWebSocketSessionTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import reactor.core.publisher.Sinks;
2323

2424
import static org.mockito.ArgumentMatchers.any;
25+
import static org.mockito.ArgumentMatchers.argThat;
2526
import static org.mockito.Mockito.doCallRealMethod;
2627
import static org.mockito.Mockito.mock;
2728
import static org.mockito.Mockito.times;
@@ -52,7 +53,7 @@ void givenAuthenticationException_WhenError_then1003() {
5253
@Test
5354
void givenGenericException_WhenError_thenServerError() {
5455
webSocketSession.onError(new RuntimeException("message"));
55-
verify(webSocketSession, times(1)).close(CloseStatus.SERVER_ERROR);
56+
verify(webSocketSession, times(1)).close(argThat(status -> status.getCode() == CloseStatus.SERVER_ERROR.getCode() && status.getReason().equals("message")));
5657
}
5758

5859
@Test

0 commit comments

Comments
 (0)