Use random id for WebSocket sessions
Issue: SPR-17228
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.web.socket.adapter.standard;
|
||||
|
||||
import java.net.URI;
|
||||
import javax.websocket.CloseReason;
|
||||
import javax.websocket.CloseReason.CloseCodes;
|
||||
import javax.websocket.MessageHandler;
|
||||
@@ -56,14 +57,15 @@ public class StandardWebSocketHandlerAdapterTests {
|
||||
|
||||
@Test
|
||||
public void onOpen() throws Throwable {
|
||||
given(this.session.getId()).willReturn("123");
|
||||
URI uri = URI.create("http://example.org");
|
||||
given(this.session.getRequestURI()).willReturn(uri);
|
||||
this.adapter.onOpen(this.session, null);
|
||||
|
||||
verify(this.webSocketHandler).afterConnectionEstablished(this.webSocketSession);
|
||||
verify(this.session, atLeast(2)).addMessageHandler(any(MessageHandler.Whole.class));
|
||||
|
||||
given(this.session.getId()).willReturn("123");
|
||||
assertEquals("123", this.webSocketSession.getId());
|
||||
given(this.session.getRequestURI()).willReturn(uri);
|
||||
assertEquals(uri, this.webSocketSession.getUri());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user