Issue #1197 - adding testcase for Authorization use in WSClient

This commit is contained in:
Joakim Erdfelt 2016-12-27 13:32:21 -07:00
parent 68f041cf03
commit 03a283235c
1 changed files with 28 additions and 0 deletions

View File

@ -48,6 +48,7 @@ import org.junit.Test;
/**
* Various connect condition testing
*/
@SuppressWarnings("Duplicates")
public class ClientConnectTest
{
@Rule
@ -129,7 +130,34 @@ public class ClientConnectTest
assertThat("Connect.UpgradeRequest", wsocket.connectUpgradeRequest, notNullValue());
assertThat("Connect.UpgradeResponse", wsocket.connectUpgradeResponse, notNullValue());
}
@Test
public void testUpgradeWithAuthorizationHeader() throws Exception
{
JettyTrackingSocket wsocket = new JettyTrackingSocket();
URI wsUri = server.getWsUri();
ClientUpgradeRequest upgradeRequest = new ClientUpgradeRequest();
// actual value for this test is irrelevant, its important that this
// header actually be sent with a value (the value specified)
upgradeRequest.setHeader("Authorization", "Bogus SHA1");
Future<Session> future = client.connect(wsocket,wsUri,upgradeRequest);
IBlockheadServerConnection connection = server.accept();
List<String> requestLines = connection.upgrade();
Session sess = future.get(30,TimeUnit.SECONDS);
sess.close();
String authLine = requestLines.stream()
.filter((line) -> line.startsWith("Authorization:"))
.findFirst().get();
assertThat("Request Container Authorization", authLine, is("Authorization: Bogus SHA1"));
assertThat("Connect.UpgradeRequest", wsocket.connectUpgradeRequest, notNullValue());
assertThat("Connect.UpgradeResponse", wsocket.connectUpgradeResponse, notNullValue());
}
@Test
public void testBadHandshake() throws Exception
{