Skip to content

Commit

Permalink
Refs #20141: Solve conflicts
Browse files Browse the repository at this point in the history
Signed-off-by: Jesus Perez <jesusperez@eprosima.com>
  • Loading branch information
jepemi committed Apr 10, 2024
1 parent 2226ed4 commit c077af7
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 75 deletions.
64 changes: 0 additions & 64 deletions test/unittest/transport/TCPv6Tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,70 +205,6 @@ TEST_F(TCPv6Tests, autofill_port)
EXPECT_TRUE(transportUnderTest_multiple_autofill.configuration()->listening_ports.size() == 3);
}

static void GetIP6s(
std::vector<IPFinder::info_IP>& interfaces)
{
IPFinder::getIPs(&interfaces, false);
auto new_end = remove_if(interfaces.begin(),
interfaces.end(),
[](IPFinder::info_IP ip)
{
return ip.type != IPFinder::IP6 && ip.type != IPFinder::IP6_LOCAL;
});
interfaces.erase(new_end, interfaces.end());
std::for_each(interfaces.begin(), interfaces.end(), [](IPFinder::info_IP& loc)
{
loc.locator.kind = LOCATOR_KIND_TCPv6;
});
}

TEST_F(TCPv6Tests, check_TCPv6_interface_whitelist_initialization)
{
std::vector<IPFinder::info_IP> interfaces;

GetIP6s(interfaces);

// asio::ip::addres_v6 appends the interface name to the IP address, but the locator does not
// Create two different vectors to compare them
std::vector<std::string> asio_interfaces;
std::vector<std::string> locator_interfaces;
for (auto& ip : interfaces)
{
asio_interfaces.push_back(ip.name);
locator_interfaces.push_back(IPLocator::toIPv6string(ip.locator));
}
// Add manually localhost to test adding multiple interfaces
asio_interfaces.push_back("::1");
locator_interfaces.push_back("::1");

for (auto& ip : locator_interfaces)
{
descriptor.interfaceWhiteList.emplace_back(ip);
}
descriptor.add_listener_port(g_default_port);
MockTCPv6Transport transportUnderTest(descriptor);
transportUnderTest.init();

// Check that the transport whitelist and the acceptors map is the same size as the locator_interfaces
ASSERT_EQ(transportUnderTest.get_interface_whitelist().size(), descriptor.interfaceWhiteList.size());
ASSERT_EQ(transportUnderTest.get_acceptors_map().size(), descriptor.interfaceWhiteList.size());

// Check that every interface is in the whitelist
auto check_whitelist = transportUnderTest.get_interface_whitelist();
for (auto& ip : asio_interfaces)
{
ASSERT_NE(std::find(check_whitelist.begin(), check_whitelist.end(), asio::ip::address_v6::from_string(
ip)), check_whitelist.end());
}

// Check that every interface is in the acceptors map
for (const auto& test : transportUnderTest.get_acceptors_map())
{
ASSERT_NE(std::find(locator_interfaces.begin(), locator_interfaces.end(), IPLocator::toIPv6string(
test.first)), locator_interfaces.end());
}
}

// This test verifies server's channel resources mapping keys uniqueness, where keys are clients locators.
// Clients typically communicated its PID as its locator port. When having several clients in the same
// process this lead to overwriting server's channel resources map elements.
Expand Down
2 changes: 1 addition & 1 deletion test/unittest/transport/mock/MockTCPv4Transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class MockTCPv4Transport : public TCPv4Transport
{
return TCPv4Transport::send(send_buffer, send_buffer_size, send_resource_locator, remote_locator);
}

};

} // namespace rtps
Expand Down
10 changes: 0 additions & 10 deletions test/unittest/transport/mock/MockTCPv6Transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,6 @@ class MockTCPv6Transport : public TCPv6Transport
return unbound_channel_resources_;
}

const std::vector<asio::ip::address_v6>& get_interface_whitelist() const
{
return interface_whitelist_;
}

const std::map<Locator_t, std::shared_ptr<fastdds::rtps::TCPAcceptor>>& get_acceptors_map() const
{
return acceptors_;
}

bool send(
const fastrtps::rtps::octet* send_buffer,
uint32_t send_buffer_size,
Expand Down

0 comments on commit c077af7

Please sign in to comment.