Fix user destination parsing in simp messaging
This commit fixes the parsing of message destinations such as "/user/anna/queue/foo", reverting a regression introduced by SPR-11506, which worked well with @SendToUser use cases but caused issues for messages sent to other users. Issue: SPR-12444
This commit is contained in:
@@ -117,6 +117,25 @@ public class DefaultUserDestinationResolverTests {
|
||||
assertEquals(this.user.getName(), actual.getUser());
|
||||
}
|
||||
|
||||
// SPR-12444
|
||||
@Test
|
||||
public void handleMessageToOtherUser() {
|
||||
final String OTHER_SESSION_ID = "456";
|
||||
final String OTHER_USER_NAME = "anna";
|
||||
|
||||
String sourceDestination = "/user/"+OTHER_USER_NAME+"/queue/foo";
|
||||
TestPrincipal otherUser = new TestPrincipal(OTHER_USER_NAME);
|
||||
this.registry.registerSessionId(otherUser.getName(), OTHER_SESSION_ID);
|
||||
Message<?> message = createMessage(SimpMessageType.MESSAGE, this.user, SESSION_ID, sourceDestination);
|
||||
UserDestinationResult actual = this.resolver.resolveDestination(message);
|
||||
|
||||
assertEquals(sourceDestination, actual.getSourceDestination());
|
||||
assertEquals(1, actual.getTargetDestinations().size());
|
||||
assertEquals("/queue/foo-user" + OTHER_SESSION_ID, actual.getTargetDestinations().iterator().next());
|
||||
assertEquals("/user/queue/foo", actual.getSubscribeDestination());
|
||||
assertEquals(otherUser.getName(), actual.getUser());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void handleMessageEncodedUserName() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user