use of org.webpieces.ssl.api.dto.SslAction in project webpieces by deanhiller.
the class TestSslBasicSvr method testSplitData.
// @Test
public void testSplitData() throws InterruptedException, ExecutionException, TimeoutException {
// 3 encrypted packets sent here
SslAction action = parseIncoming();
Assert.assertEquals(SslActionEnum.SEND_TO_SOCKET, action.getSslAction());
List<DataWrapper> split = split(action.getEncryptedData());
DataWrapper back = dataGen.chainDataWrappers(split.get(0), split.get(1), split.get(2), split.get(3));
byte[] b1 = action.getEncryptedData().createByteArray();
byte[] b2 = back.createByteArray();
Assert.assertEquals(b1.length, b2.length);
for (int i = 0; i < b1.length; i++) {
Assert.assertEquals(b1[i], b2[i]);
}
mockChannel.forceDataRead(mockJdk, split.get(0));
Assert.assertEquals(0, mockChannel.getPayloadQueueSize());
mockChannel.forceDataRead(mockJdk, split.get(1));
Assert.assertEquals(0, mockChannel.getPayloadQueueSize());
mockChannel.forceDataRead(mockJdk, split.get(2));
Assert.assertEquals(0, mockChannel.getPayloadQueueSize());
mockChannel.forceDataRead(mockJdk, split.get(3));
Assert.assertEquals(2, mockChannel.getPayloadQueueSize());
Assert.assertEquals(SslActionEnum.WAIT_FOR_MORE_DATA_FROM_REMOTE_END, parseIncoming().getSslAction());
Assert.assertEquals(SslActionEnum.SEND_LINK_ESTABLISHED_TO_APP, parseIncoming().getSslAction());
ConnectionOpen openedInfo = listener.getConnectionOpenedInfo();
Assert.assertEquals(true, openedInfo.isReadyForWrites);
Assert.assertEquals(channel, openedInfo.channel);
transferBigData();
}
use of org.webpieces.ssl.api.dto.SslAction in project webpieces by deanhiller.
the class TestSslBasicSvr method testBasic.
// begin handshake results in ONE packet client -> server (server creates runnable, creating ONE
// server creates runnable, runs it creating ONE packet server -> client
// client creates runnable, runs it creating THREE packets client -> server
// all 3 received, server creates TWO packets client -> server (server is connected here)
// client receives two packets and is connected
// @Test
public void testBasic() throws InterruptedException, ExecutionException, TimeoutException, GeneralSecurityException, IOException {
// 3 encrypted packets sent here
SslAction action = parseIncoming();
Assert.assertEquals(SslActionEnum.SEND_TO_SOCKET, action.getSslAction());
mockChannel.forceDataRead(mockJdk, action.getEncryptedData());
Assert.assertEquals(SslActionEnum.WAIT_FOR_MORE_DATA_FROM_REMOTE_END, parseIncoming().getSslAction());
Assert.assertEquals(SslActionEnum.SEND_LINK_ESTABLISHED_TO_APP, parseIncoming().getSslAction());
ConnectionOpen openedInfo = listener.getConnectionOpenedInfo();
Assert.assertEquals(true, openedInfo.isReadyForWrites);
Assert.assertEquals(channel, openedInfo.channel);
transferBigData();
}
use of org.webpieces.ssl.api.dto.SslAction in project webpieces by deanhiller.
the class TestSslBasicSvr method parseIncoming.
private SslAction parseIncoming() throws InterruptedException, ExecutionException, TimeoutException {
DataWrapper payload = mockChannel.nextPayload();
XFuture<List<SslAction>> resultFuture2 = clientSslParser.parseIncoming(payload);
List<SslAction> result2 = resultFuture2.get(2, TimeUnit.SECONDS);
Assert.assertEquals(1, result2.size());
return result2.get(0);
}
use of org.webpieces.ssl.api.dto.SslAction in project webpieces by deanhiller.
the class TestSslCloseSvr method testBasicCloseFromServer.
// @Test
public void testBasicCloseFromServer() throws GeneralSecurityException, IOException, InterruptedException, ExecutionException, TimeoutException {
XFuture<Void> future = channel.close();
Assert.assertTrue(future.isDone());
DataWrapper payload = mockChannel.nextPayload();
XFuture<List<SslAction>> resultFuture2 = clientSslParser.parseIncoming(payload);
List<SslAction> result2 = resultFuture2.get(2, TimeUnit.SECONDS);
Assert.assertEquals(2, result2.size());
Assert.assertTrue(future.isDone());
Assert.assertEquals(SslActionEnum.SEND_TO_SOCKET, result2.get(0).getSslAction());
Assert.assertEquals(SslActionEnum.SEND_LINK_CLOSED_TO_APP, result2.get(1).getSslAction());
mockChannel.forceDataRead(mockJdk, result2.get(0).getEncryptedData());
future.get(2, TimeUnit.SECONDS);
}
use of org.webpieces.ssl.api.dto.SslAction in project webpieces by deanhiller.
the class TestSslCloseSvr method parseIncoming.
private SslAction parseIncoming() throws InterruptedException, ExecutionException, TimeoutException {
DataWrapper payload = mockChannel.nextPayload();
XFuture<List<SslAction>> resultFuture2 = clientSslParser.parseIncoming(payload);
List<SslAction> result2 = resultFuture2.get(2, TimeUnit.SECONDS);
Assert.assertEquals(1, result2.size());
return result2.get(0);
}
Aggregations