Search in sources :

Example 26 with SslAction

use of org.webpieces.ssl.api.dto.SslAction in project webpieces by deanhiller.

the class TestSslCloseClient method testBasicCloseFromClient.

// @Test
public void testBasicCloseFromClient() throws GeneralSecurityException, IOException, InterruptedException, ExecutionException, TimeoutException {
    XFuture<Void> future = channel.close();
    Assert.assertTrue(future.isDone());
    DataWrapper payload = mockChannel.nextPayload();
    XFuture<List<SslAction>> resultFuture2 = svrSslParser.parseIncoming(payload);
    List<SslAction> result2 = resultFuture2.get(2, TimeUnit.SECONDS);
    Assert.assertEquals(2, result2.size());
    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);
}
Also used : DataWrapper(org.webpieces.data.api.DataWrapper) List(java.util.List) SslAction(org.webpieces.ssl.api.dto.SslAction)

Example 27 with SslAction

use of org.webpieces.ssl.api.dto.SslAction in project webpieces by deanhiller.

the class TestSslCloseClient method testBothEndsAtSameTime.

// @Test
public void testBothEndsAtSameTime() throws InterruptedException, ExecutionException, TimeoutException {
    XFuture<Void> future = channel.close();
    SslAction action = svrSslParser.close();
    Assert.assertEquals(SslActionEnum.SEND_TO_SOCKET, action.getSslAction());
    Assert.assertTrue(future.isDone());
    mockChannel.forceDataRead(mockJdk, action.getEncryptedData());
    future.get(2, TimeUnit.SECONDS);
    SslAction action2 = parseIncoming();
    Assert.assertEquals(SslActionEnum.LINK_SUCCESSFULLY_CLOSED, action2.getSslAction());
    // far end closed should NOT be called...
    Assert.assertFalse(mockClientDataListener.isClosed());
}
Also used : SslAction(org.webpieces.ssl.api.dto.SslAction)

Aggregations

SslAction (org.webpieces.ssl.api.dto.SslAction)27 DataWrapper (org.webpieces.data.api.DataWrapper)11 List (java.util.List)10 ArrayList (java.util.ArrayList)6 InetSocketAddress (java.net.InetSocketAddress)4 ByteBuffer (java.nio.ByteBuffer)4 ConnectionOpen (org.webpieces.nio.api.mocks.MockAsyncListener.ConnectionOpen)4 Before (org.junit.Before)2 MeterRegistry (io.micrometer.core.instrument.MeterRegistry)1 SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)1 SSLEngine (javax.net.ssl.SSLEngine)1 AsyncConfig (org.webpieces.asyncserver.api.AsyncConfig)1 AsyncServerManager (org.webpieces.asyncserver.api.AsyncServerManager)1 BufferPool (org.webpieces.data.api.BufferPool)1 TwoPools (org.webpieces.data.api.TwoPools)1 Channel (org.webpieces.nio.api.channels.Channel)1 TCPChannel (org.webpieces.nio.api.channels.TCPChannel)1 MockSvrChannel (org.webpieces.nio.api.mocks.MockSvrChannel)1 MockSvrSideJdkChannel (org.webpieces.nio.api.mocks.MockSvrSideJdkChannel)1 SSLMetrics (org.webpieces.ssl.api.SSLMetrics)1