Earlier detection of token authentication
Use a callback to detect token authentication (via inteceptor) thus avoiding a potential race between that detection after the message is sent on the inbound channel (via Executor) and the processing of the CONNECTED frame returned from the broker on the outbound channel. Closes gh-23160
This commit is contained in:
@@ -378,6 +378,15 @@ public class StompSubProtocolHandlerTests {
|
||||
Principal user = SimpMessageHeaderAccessor.getUser(message.getHeaders());
|
||||
assertNotNull(user);
|
||||
assertEquals("__pete__@gmail.com", user.getName());
|
||||
|
||||
StompHeaderAccessor accessor = StompHeaderAccessor.create(StompCommand.CONNECTED);
|
||||
message = MessageBuilder.createMessage(EMPTY_PAYLOAD, accessor.getMessageHeaders());
|
||||
handler.handleMessageToClient(this.session, message);
|
||||
|
||||
assertEquals(1, this.session.getSentMessages().size());
|
||||
WebSocketMessage<?> textMessage = this.session.getSentMessages().get(0);
|
||||
assertEquals("CONNECTED\n" + "user-name:__pete__@gmail.com\n" + "\n" + "\u0000",
|
||||
textMessage.getPayload());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user