diff --git a/test/unittest/transport/TCPv6Tests.cpp b/test/unittest/transport/TCPv6Tests.cpp index 55e3479de12..7abc6fabc08 100644 --- a/test/unittest/transport/TCPv6Tests.cpp +++ b/test/unittest/transport/TCPv6Tests.cpp @@ -668,6 +668,88 @@ TEST_F(TCPv6Tests, add_logical_port_on_send_resource_creation) } } +/* + TEST_F(TCPv6Tests, send_and_receive_between_both_secure_ports) + { + eprosima::fastdds::dds::Log::SetVerbosity(eprosima::fastdds::dds::Log::Kind::Info); + + using TLSOptions = TCPTransportDescriptor::TLSConfig::TLSOptions; + using TLSVerifyMode = TCPTransportDescriptor::TLSConfig::TLSVerifyMode; + + TCPv6TransportDescriptor recvDescriptor; + recvDescriptor.add_listener_port(g_default_port); + recvDescriptor.apply_security = true; + recvDescriptor.tls_config.password = "testkey"; + recvDescriptor.tls_config.cert_chain_file = "mainpubcert.pem"; + recvDescriptor.tls_config.private_key_file = "mainpubkey.pem"; + recvDescriptor.tls_config.verify_file = "maincacert.pem"; + // Server doesn't accept clients without certs + recvDescriptor.tls_config.verify_mode = TLSVerifyMode::VERIFY_PEER | TLSVerifyMode::VERIFY_FAIL_IF_NO_PEER_CERT; + recvDescriptor.tls_config.add_option(TLSOptions::DEFAULT_WORKAROUNDS); + recvDescriptor.tls_config.add_option(TLSOptions::SINGLE_DH_USE); + recvDescriptor.tls_config.add_option(TLSOptions::NO_COMPRESSION); + recvDescriptor.tls_config.add_option(TLSOptions::NO_SSLV2); + recvDescriptor.tls_config.add_option(TLSOptions::NO_SSLV3); + TCPv6Transport receiveTransportUnderTest(recvDescriptor); + receiveTransportUnderTest.init(); + + TCPv6TransportDescriptor sendDescriptor; + sendDescriptor.apply_security = true; + sendDescriptor.tls_config.password = "testkey"; + sendDescriptor.tls_config.cert_chain_file = "mainsubcert.pem"; + sendDescriptor.tls_config.private_key_file = "mainsubkey.pem"; + sendDescriptor.tls_config.verify_file = "maincacert.pem"; + sendDescriptor.tls_config.verify_mode = TLSVerifyMode::VERIFY_PEER; + sendDescriptor.tls_config.add_option(TLSOptions::DEFAULT_WORKAROUNDS); + sendDescriptor.tls_config.add_option(TLSOptions::SINGLE_DH_USE); + sendDescriptor.tls_config.add_option(TLSOptions::NO_COMPRESSION); + sendDescriptor.tls_config.add_option(TLSOptions::NO_SSLV2); + sendDescriptor.tls_config.add_option(TLSOptions::NO_SSLV3); + TCPv6Transport sendTransportUnderTest(sendDescriptor); + sendTransportUnderTest.init(); + + Locator_t inputLocator; + inputLocator.kind = LOCATOR_KIND_TCPv6; + inputLocator.port = g_default_port; + IPLocator::setIPv4(inputLocator, "::1"); + IPLocator::setLogicalPort(inputLocator, 7410); + + Locator_t outputLocator; + outputLocator.kind = LOCATOR_KIND_TCPv6; + IPLocator::setIPv4(outputLocator, "::1"); + outputLocator.port = g_default_port; + IPLocator::setLogicalPort(outputLocator, 7410); + + { + MockReceiverResource receiver(receiveTransportUnderTest, inputLocator); + MockMessageReceiver *msg_recv = dynamic_cast(receiver.CreateMessageReceiver()); + ASSERT_TRUE(receiveTransportUnderTest.IsInputChannelOpen(inputLocator)); + + ASSERT_TRUE(sendTransportUnderTest.OpenOutputChannel(outputLocator)); + octet message[5] = { 'H','e','l','l','o' }; + + Semaphore sem; + std::function recCallback = [&]() + { + EXPECT_EQ(memcmp(message, msg_recv->data, 5), 0); + sem.post(); + }; + }; + + msg_recv->setCallback(recCallback); + + auto sendThreadFunction = [&]() + { + EXPECT_TRUE(transportUnderTest.send(message, 5, outputChannelLocator, multicastLocator)); + }; + + senderThread.reset(new std::thread(sendThreadFunction)); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); + senderThread->join(); + sem.wait(); + ASSERT_TRUE(transportUnderTest.CloseOutputChannel(outputChannelLocator)); + } + */ #endif // ifndef __APPLE__ void TCPv6Tests::HELPER_SetDescriptorDefaults()