use of org.webpieces.ssl.api.dto.SslAction in project webpieces by deanhiller.
the class TestSslCloseClient method testBasicCloseFromServer.
// @Test
public void testBasicCloseFromServer() throws GeneralSecurityException, IOException, InterruptedException, ExecutionException, TimeoutException {
SslAction action = svrSslParser.close();
Assert.assertEquals(SslActionEnum.SEND_TO_SOCKET, action.getSslAction());
mockChannel.forceDataRead(mockJdk, action.getEncryptedData());
Assert.assertTrue(mockClientDataListener.isClosed());
SslAction action2 = parseIncoming();
Assert.assertEquals(SslActionEnum.LINK_SUCCESSFULLY_CLOSED, action2.getSslAction());
}
use of org.webpieces.ssl.api.dto.SslAction in project webpieces by deanhiller.
the class TestSslCloseClient method parseIncoming.
private SslAction parseIncoming() throws InterruptedException, ExecutionException, TimeoutException {
DataWrapper payload = mockChannel.nextPayload();
XFuture<List<SslAction>> resultFuture2 = svrSslParser.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 TestSslCloseClient method setup.
@Before
public void setup() throws GeneralSecurityException, IOException, InterruptedException, ExecutionException, TimeoutException {
svrSslParser = createSslSvrParser();
channel = createClientChannel("server", mockJdk);
int port = 8443;
mockChannel.setNumBytesToConsume(100000);
mockChannel.addConnectReturnValue(true);
// trick the selector into thinking we are on the selector thread
mockJdk.setThread(Thread.currentThread());
connectFuture = channel.connect(new InetSocketAddress("localhost", port), mockClientDataListener);
// not connected until ssl handshake is complete
Assert.assertFalse(connectFuture.isDone());
SslAction result = parseIncoming();
Assert.assertEquals(SslActionEnum.SEND_TO_SOCKET, result.getSslAction());
mockChannel.forceDataRead(mockJdk, result.getEncryptedData());
Assert.assertEquals(SslActionEnum.WAIT_FOR_MORE_DATA_FROM_REMOTE_END, parseIncoming().getSslAction());
Assert.assertEquals(SslActionEnum.WAIT_FOR_MORE_DATA_FROM_REMOTE_END, parseIncoming().getSslAction());
DataWrapper payload = mockChannel.nextPayload();
XFuture<List<SslAction>> resultFuture2 = svrSslParser.parseIncoming(payload);
List<SslAction> result2 = resultFuture2.get(2, TimeUnit.SECONDS);
Assert.assertEquals(SslActionEnum.SEND_TO_SOCKET, result2.get(0).getSslAction());
Assert.assertEquals(SslActionEnum.SEND_LINK_ESTABLISHED_TO_APP, result2.get(1).getSslAction());
// client is still NOT connected yet until the SSL handshake final messages are received
Assert.assertFalse(connectFuture.isDone());
mockChannel.forceDataRead(mockJdk, result2.get(0).getEncryptedData());
connectFuture.get(2, TimeUnit.SECONDS);
transferBigData();
}
use of org.webpieces.ssl.api.dto.SslAction in project webpieces by deanhiller.
the class TestSslBasicClient method testCombineBuffers.
// @Test
public void testCombineBuffers() throws InterruptedException, ExecutionException, TimeoutException {
// in this case, combine the output of all 3 of the client engine...
DataWrapper fullData = dataGen.chainDataWrappers(mockChannel.nextPayload(), mockChannel.nextPayload(), mockChannel.nextPayload());
XFuture<List<SslAction>> resultFuture2 = svrSslParser.parseIncoming(fullData);
List<SslAction> result2 = resultFuture2.get(2, TimeUnit.SECONDS);
Assert.assertEquals(SslActionEnum.SEND_TO_SOCKET, result2.get(0).getSslAction());
Assert.assertEquals(SslActionEnum.SEND_LINK_ESTABLISHED_TO_APP, result2.get(1).getSslAction());
// client is still NOT connected yet until the SSL handshake final messages are received
Assert.assertFalse(connectFuture.isDone());
mockChannel.forceDataRead(mockJdk, result2.get(0).getEncryptedData());
connectFuture.get(2, TimeUnit.SECONDS);
}
use of org.webpieces.ssl.api.dto.SslAction in project webpieces by deanhiller.
the class TestSslBasicClient method parseIncoming.
private SslAction parseIncoming() throws InterruptedException, ExecutionException, TimeoutException {
DataWrapper payload = mockChannel.nextPayload();
XFuture<List<SslAction>> resultFuture2 = svrSslParser.parseIncoming(payload);
List<SslAction> result2 = resultFuture2.get(2, TimeUnit.SECONDS);
Assert.assertEquals(1, result2.size());
return result2.get(0);
}
Aggregations