testUnwrapBehavior() — netty Function Reference
Architecture documentation for the testUnwrapBehavior() function in SSLEngineTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD e2e50c11_3d50_49ea_6ae2_fe300aceb7e7["testUnwrapBehavior()"] 9150c92a_2afc_b83a_c3bf_86dfac6e9d9b["SSLEngineTest"] e2e50c11_3d50_49ea_6ae2_fe300aceb7e7 -->|defined in| 9150c92a_2afc_b83a_c3bf_86dfac6e9d9b bf19737b_7dc7_9dfd_0a67_ae31448ebbe8["protocols()"] e2e50c11_3d50_49ea_6ae2_fe300aceb7e7 -->|calls| bf19737b_7dc7_9dfd_0a67_ae31448ebbe8 e3b541e6_b593_4b1f_a637_da19020e73df["ciphers()"] e2e50c11_3d50_49ea_6ae2_fe300aceb7e7 -->|calls| e3b541e6_b593_4b1f_a637_da19020e73df 7380f50e_d3f0_3078_ee65_de1cb780c79d["handshake()"] e2e50c11_3d50_49ea_6ae2_fe300aceb7e7 -->|calls| 7380f50e_d3f0_3078_ee65_de1cb780c79d 13aca077_a788_4333_9f8b_2b1437653846["delegate()"] e2e50c11_3d50_49ea_6ae2_fe300aceb7e7 -->|calls| 13aca077_a788_4333_9f8b_2b1437653846 87e8e20d_ffbe_f5c3_4fd0_7d8ac419206d["cleanupClientSslEngine()"] e2e50c11_3d50_49ea_6ae2_fe300aceb7e7 -->|calls| 87e8e20d_ffbe_f5c3_4fd0_7d8ac419206d 78ad5fe5_58d2_9877_f633_22a7048c0e5e["cleanupServerSslEngine()"] e2e50c11_3d50_49ea_6ae2_fe300aceb7e7 -->|calls| 78ad5fe5_58d2_9877_f633_22a7048c0e5e style e2e50c11_3d50_49ea_6ae2_fe300aceb7e7 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
handler/src/test/java/io/netty/handler/ssl/SSLEngineTest.java lines 2115–2200
@MethodSource("newTestParams")
@ParameterizedTest
public void testUnwrapBehavior(SSLEngineTestParam param) throws Exception {
SelfSignedCertificate cert = CachedSelfSignedCertificate.getCachedCertificate();
clientSslCtx = wrapContext(param, SslContextBuilder
.forClient()
.trustManager(cert.cert())
.sslProvider(sslClientProvider())
.protocols(param.protocols())
.ciphers(param.ciphers())
.endpointIdentificationAlgorithm(null)
.build());
SSLEngine client = wrapEngine(clientSslCtx.newEngine(UnpooledByteBufAllocator.DEFAULT));
serverSslCtx = wrapContext(param, SslContextBuilder
.forServer(cert.certificate(), cert.privateKey())
.sslProvider(sslServerProvider())
.protocols(param.protocols())
.ciphers(param.ciphers())
.build());
SSLEngine server = wrapEngine(serverSslCtx.newEngine(UnpooledByteBufAllocator.DEFAULT));
byte[] bytes = "Hello World".getBytes(CharsetUtil.US_ASCII);
try {
ByteBuffer plainClientOut = allocateBuffer(param.type, client.getSession().getApplicationBufferSize());
ByteBuffer encryptedClientToServer = allocateBuffer(
param.type, server.getSession().getPacketBufferSize() * 2);
ByteBuffer plainServerIn = allocateBuffer(param.type, server.getSession().getApplicationBufferSize());
handshake(param.type(), param.delegate(), client, server);
// create two TLS frames
// first frame
plainClientOut.put(bytes, 0, 5);
plainClientOut.flip();
SSLEngineResult result = client.wrap(plainClientOut, encryptedClientToServer);
assertEquals(SSLEngineResult.Status.OK, result.getStatus());
assertEquals(5, result.bytesConsumed());
assertTrue(result.bytesProduced() > 0);
assertFalse(plainClientOut.hasRemaining());
// second frame
plainClientOut.clear();
plainClientOut.put(bytes, 5, 6);
plainClientOut.flip();
result = client.wrap(plainClientOut, encryptedClientToServer);
assertEquals(SSLEngineResult.Status.OK, result.getStatus());
assertEquals(6, result.bytesConsumed());
assertTrue(result.bytesProduced() > 0);
// send over to server
encryptedClientToServer.flip();
// try with too small output buffer first (to check BUFFER_OVERFLOW case)
int remaining = encryptedClientToServer.remaining();
ByteBuffer small = allocateBuffer(param.type, 3);
result = server.unwrap(encryptedClientToServer, small);
assertEquals(SSLEngineResult.Status.BUFFER_OVERFLOW, result.getStatus());
assertEquals(remaining, encryptedClientToServer.remaining());
// now with big enough buffer
result = server.unwrap(encryptedClientToServer, plainServerIn);
assertEquals(SSLEngineResult.Status.OK, result.getStatus());
assertEquals(5, result.bytesProduced());
assertTrue(encryptedClientToServer.hasRemaining());
result = server.unwrap(encryptedClientToServer, plainServerIn);
assertEquals(SSLEngineResult.Status.OK, result.getStatus());
assertEquals(6, result.bytesProduced());
assertFalse(encryptedClientToServer.hasRemaining());
plainServerIn.flip();
assertEquals(ByteBuffer.wrap(bytes), plainServerIn);
Domain
Subdomains
Source
Frequently Asked Questions
What does testUnwrapBehavior() do?
testUnwrapBehavior() is a function in the netty codebase, defined in handler/src/test/java/io/netty/handler/ssl/SSLEngineTest.java.
Where is testUnwrapBehavior() defined?
testUnwrapBehavior() is defined in handler/src/test/java/io/netty/handler/ssl/SSLEngineTest.java at line 2115.
What does testUnwrapBehavior() call?
testUnwrapBehavior() calls 6 function(s): ciphers, cleanupClientSslEngine, cleanupServerSslEngine, delegate, handshake, protocols.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free