-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #2215 Fix invalid Origin header sent by client for non-SSL WebS…
…ocket connections
- Loading branch information
Showing
2 changed files
with
40 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
modules/websockets/src/test/java/org/glassfish/grizzly/websockets/HandShakeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package org.glassfish.grizzly.websockets; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import java.net.URI; | ||
import java.net.URISyntaxException; | ||
import java.util.logging.Logger; | ||
|
||
import org.glassfish.grizzly.websockets.rfc6455.RFC6455HandShake; | ||
import org.junit.Test; | ||
|
||
public class HandShakeTest { | ||
private static final Logger LOGGER = Logger.getLogger("HandShakeTest"); | ||
private static String SSL = "wss://localhost:8443"; | ||
private static String NON_SSL = "ws://localhost:8080"; | ||
private static String RESOURCE_PATH = "/websocket"; | ||
|
||
@Test | ||
public void testOrigin() throws URISyntaxException { | ||
// non-ssl | ||
HandShake handshake = new RFC6455HandShake(new URI(NON_SSL + RESOURCE_PATH)); | ||
LOGGER.info("Handshake: isSecure=" + handshake.isSecure() + ", headers: " + handshake.composeHeaders().getHttpHeader()); | ||
assertEquals(NON_SSL, handshake.getOrigin()); | ||
assertFalse(handshake.isSecure()); | ||
assertEquals(NON_SSL + RESOURCE_PATH, handshake.getLocation()); | ||
|
||
// ssl | ||
handshake = new RFC6455HandShake(new URI(SSL + RESOURCE_PATH)); | ||
LOGGER.info("Handshake: isSecure=" + handshake.isSecure() + ", headers: " + handshake.composeHeaders().getHttpHeader()); | ||
assertEquals(SSL, handshake.getOrigin()); | ||
assertTrue(handshake.isSecure()); | ||
assertEquals(SSL + RESOURCE_PATH, handshake.getLocation()); | ||
|
||
|
||
} | ||
} |