2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-22 01:49:48 +00:00

[#3696] Updated UT files

This commit is contained in:
Francis Dupont 2024-12-20 12:30:17 +01:00
parent db0891fb20
commit 120fd3d7c4
17 changed files with 48 additions and 64 deletions

View File

@ -144,16 +144,7 @@ size_t
D2Process::runIO() {
// Handle events registered by hooks using external IOService objects.
IOServiceMgr::instance().pollIOServices();
// We want to block until at least one handler is called. We'll use
// boost::asio::io_service directly for two reasons. First off
// asiolink::IOService::runOne is a void and boost::asio::io_service::stopped
// is not present in older versions of boost. We need to know if any
// handlers ran or if the io_service was stopped. That latter represents
// some form of error and the application cannot proceed with a stopped
// service. Secondly, asiolink::IOService does not provide the poll
// method. This is a handy method which runs all ready handlers without
// blocking.
// We want to block until at least one handler is called.
// Poll runs all that are ready. If none are ready it returns immediately
// with a count of zero.
size_t cnt = getIOService()->poll();

View File

@ -44,7 +44,7 @@ namespace ph = std::placeholders;
namespace isc {
namespace asiodns {
const boost::asio::ip::address TEST_HOST(boost::asio::ip::address::from_string("127.0.0.1"));
const boost::asio::ip::address TEST_HOST(boost::asio::ip::make_address("127.0.0.1"));
const uint16_t TEST_PORT(5301);
const int SEND_INTERVAL = 250; // Interval in ms between TCP sends
const size_t MAX_SIZE = 64 * 1024; // Should be able to take 64kB

View File

@ -82,7 +82,7 @@ public:
/// connectHandler as a callback function.
void connect() {
boost::asio::ip::tcp::endpoint
endpoint(boost::asio::ip::address::from_string(SERVER_ADDRESS),
endpoint(boost::asio::ip::make_address(SERVER_ADDRESS),
SERVER_PORT);
socket_.async_connect(endpoint,
std::bind(&TCPClient::connectHandler, this,
@ -208,7 +208,7 @@ public:
/// unsuccessful.
TCPAcceptorTest()
: io_service_(new IOService()), acceptor_(io_service_),
asio_endpoint_(boost::asio::ip::address::from_string(SERVER_ADDRESS),
asio_endpoint_(boost::asio::ip::make_address(SERVER_ADDRESS),
SERVER_PORT),
endpoint_(asio_endpoint_), test_timer_(io_service_), connections_(),
clients_(), connections_num_(0), aborted_connections_num_(0),

View File

@ -83,8 +83,7 @@ public:
/// connectHandler as a callback function.
void connect() {
ip::tcp::endpoint
endpoint(ip::address::from_string(SERVER_ADDRESS),
SERVER_PORT);
endpoint(ip::make_address(SERVER_ADDRESS), SERVER_PORT);
socket_.async_connect(endpoint,
std::bind(&TLSClient::connectHandler, this,
ph::_1));
@ -215,8 +214,7 @@ public:
/// unsuccessful.
TLSAcceptorTest()
: io_service_(new IOService()), acceptor_(io_service_),
asio_endpoint_(ip::address::from_string(SERVER_ADDRESS),
SERVER_PORT),
asio_endpoint_(ip::make_address(SERVER_ADDRESS), SERVER_PORT),
endpoint_(asio_endpoint_), test_timer_(io_service_), connections_(),
clients_(), connections_num_(0), aborted_connections_num_(0),
max_connections_(1), running_(true) {

View File

@ -772,7 +772,7 @@ TEST_F(TLSTest, noHandshake) {
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
tcp::endpoint server_ep(tcp::endpoint(make_address(SERVER_ADDRESS),
SERVER_PORT));
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
@ -877,7 +877,7 @@ TEST_F(TLSTest, serverNotConfigured) {
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
tcp::endpoint server_ep(tcp::endpoint(make_address(SERVER_ADDRESS),
SERVER_PORT));
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
@ -975,7 +975,7 @@ TEST_F(TLSTest, clientNotConfigured) {
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
tcp::endpoint server_ep(tcp::endpoint(make_address(SERVER_ADDRESS),
SERVER_PORT));
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
@ -1072,7 +1072,7 @@ TEST_F(TLSTest, clientHTTPnoS) {
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
tcp::endpoint server_ep(tcp::endpoint(make_address(SERVER_ADDRESS),
SERVER_PORT));
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
@ -1165,7 +1165,7 @@ TEST_F(TLSTest, unknownClient) {
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
tcp::endpoint server_ep(tcp::endpoint(make_address(SERVER_ADDRESS),
SERVER_PORT));
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
@ -1254,7 +1254,7 @@ TEST_F(TLSTest, anotherClient) {
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
tcp::endpoint server_ep(tcp::endpoint(make_address(SERVER_ADDRESS),
SERVER_PORT));
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
@ -1353,7 +1353,7 @@ TEST_F(TLSTest, selfSigned) {
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
tcp::endpoint server_ep(tcp::endpoint(make_address(SERVER_ADDRESS),
SERVER_PORT));
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
@ -1460,7 +1460,7 @@ TEST_F(TLSTest, noHandshakeCloseonError) {
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
tcp::endpoint server_ep(tcp::endpoint(make_address(SERVER_ADDRESS),
SERVER_PORT));
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
@ -1561,7 +1561,7 @@ TEST_F(TLSTest, serverNotConfiguredCloseonError) {
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
tcp::endpoint server_ep(tcp::endpoint(make_address(SERVER_ADDRESS),
SERVER_PORT));
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
@ -1658,7 +1658,7 @@ TEST_F(TLSTest, clientNotConfiguredCloseonError) {
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
tcp::endpoint server_ep(tcp::endpoint(make_address(SERVER_ADDRESS),
SERVER_PORT));
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
@ -1754,7 +1754,7 @@ TEST_F(TLSTest, clientHTTPnoSCloseonError) {
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
tcp::endpoint server_ep(tcp::endpoint(make_address(SERVER_ADDRESS),
SERVER_PORT));
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
@ -1847,7 +1847,7 @@ TEST_F(TLSTest, anotherClientCloseonError) {
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
tcp::endpoint server_ep(tcp::endpoint(make_address(SERVER_ADDRESS),
SERVER_PORT));
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
@ -1944,7 +1944,7 @@ TEST_F(TLSTest, selfSignedCloseonError) {
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
tcp::endpoint server_ep(tcp::endpoint(make_address(SERVER_ADDRESS),
SERVER_PORT));
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
@ -2048,7 +2048,7 @@ TEST_F(TLSTest, anotherClientNoReq) {
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
tcp::endpoint server_ep(tcp::endpoint(make_address(SERVER_ADDRESS),
SERVER_PORT));
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
@ -2118,7 +2118,7 @@ TEST_F(TLSTest, serverRaw) {
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
tcp::endpoint server_ep(tcp::endpoint(make_address(SERVER_ADDRESS),
SERVER_PORT));
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
@ -2189,7 +2189,7 @@ TEST_F(TLSTest, trustedSelfSigned) {
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
tcp::endpoint server_ep(tcp::endpoint(make_address(SERVER_ADDRESS),
SERVER_PORT));
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
@ -2265,7 +2265,7 @@ TEST_F(TLSTest, shutdownInactive) {
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
tcp::endpoint server_ep(tcp::endpoint(make_address(SERVER_ADDRESS),
SERVER_PORT));
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
@ -2360,7 +2360,7 @@ TEST_F(TLSTest, shutdownActive) {
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
tcp::endpoint server_ep(tcp::endpoint(make_address(SERVER_ADDRESS),
SERVER_PORT));
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
@ -2469,7 +2469,7 @@ TEST_F(TLSTest, shutdownCloseInactive) {
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
tcp::endpoint server_ep(tcp::endpoint(make_address(SERVER_ADDRESS),
SERVER_PORT));
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
@ -2570,7 +2570,7 @@ TEST_F(TLSTest, shutdownCloseActive) {
server_.reset(new TlsStream<TestCallback>(io_service_, server_ctx));
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
tcp::endpoint server_ep(tcp::endpoint(make_address(SERVER_ADDRESS),
SERVER_PORT));
tcp::acceptor acceptor(io_service_->getInternalIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));

View File

@ -101,7 +101,7 @@ public:
class client
{
public:
client(boost::asio::io_service& io_context,
client(boost::asio::io_context& io_context,
Botan::TLS::Context& context,
const tcp::endpoint& endpoint)
: socket_(io_context, context)
@ -205,11 +205,11 @@ int main(int argc, char* argv[])
return 1;
}
boost::asio::io_service io_context;
boost::asio::io_context io_context;
using namespace std; // For atoi.
tcp::endpoint endpoint(
boost::asio::ip::address::from_string(argv[1]), atoi(argv[2]));
boost::asio::ip::make_address(argv[1]), atoi(argv[2]));
Botan::AutoSeeded_RNG rng;
Client_Credentials_Manager creds_mgr(rng);
Client_Session_Manager sess_mgr;

View File

@ -160,7 +160,7 @@ private:
class server
{
public:
server(boost::asio::io_service& io_context,
server(boost::asio::io_contex& io_context,
unsigned short port,
Botan::Credentials_Manager& creds_mgr,
Botan::RandomNumberGenerator& rng,
@ -201,7 +201,7 @@ int main(int argc, char* argv[])
return 1;
}
boost::asio::io_service io_context;
boost::asio::io_context io_context;
Botan::AutoSeeded_RNG rng;
Server_Credentials_Manager creds_mgr(rng);

View File

@ -34,7 +34,7 @@ enum { max_length = 1024 };
class client
{
public:
client(boost::asio::io_service& io_context,
client(boost::asio::io_context& io_context,
boost::asio::ssl::context& context,
const tcp::endpoint& endpoint)
: socket_(io_context, context)
@ -154,11 +154,11 @@ int main(int argc, char* argv[])
return 1;
}
boost::asio::io_service io_context;
boost::asio::io_context io_context;
using namespace std; // For atoi.
tcp::endpoint endpoint(
boost::asio::ip::address::from_string(argv[1]), atoi(argv[2]));
boost::asio::ip::make_address(argv[1]), atoi(argv[2]));
boost::asio::ssl::context ctx(boost::asio::ssl::context::method::tls);
ctx.load_verify_file(CA_("kea-ca.crt"));

View File

@ -32,7 +32,7 @@ typedef boost::asio::ssl::stream<boost::asio::ip::tcp::socket> ssl_socket;
class session
{
public:
session(boost::asio::io_service& io_context,
session(boost::asio::io_context& io_context,
boost::asio::ssl::context& context)
: socket_(io_context, context)
{
@ -106,7 +106,7 @@ private:
class server
{
public:
server(boost::asio::io_service& io_context, unsigned short port)
server(boost::asio::io_context& io_context, unsigned short port)
: io_context_(io_context),
acceptor_(io_context,
boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), port)),
@ -152,7 +152,7 @@ public:
}
private:
boost::asio::io_service& io_context_;
boost::asio::io_context& io_context_;
boost::asio::ip::tcp::acceptor acceptor_;
boost::asio::ssl::context context_;
};
@ -167,7 +167,7 @@ int main(int argc, char* argv[])
return 1;
}
boost::asio::io_service io_context;
boost::asio::io_context io_context;
using namespace std; // For atoi.
server s(io_context, atoi(argv[1]));

View File

@ -179,7 +179,7 @@ public:
/// @brief Runs IO service with optional timeout.
///
/// We iterate over calls to asio::io_service.run(), until
/// We iterate over calls to asio::io_context.run(), until
/// all the clients have completed their requests. We do it this way
/// because the test clients stop the io_service when they're
/// through with a request.

View File

@ -397,8 +397,7 @@ public:
socket_.reset(new udp::socket(service_->getInternalIOService(),
boost::asio::ip::udp::v4()));
socket_->set_option(socket_base::reuse_address(true));
socket_->bind(udp::endpoint(address::from_string(TEST_ADDRESS),
TEST_PORT));
socket_->bind(udp::endpoint(make_address(TEST_ADDRESS), TEST_PORT));
// Once socket is created, we can post an IO request to receive some
// packet from this socket. This is asynchronous operation and
// nothing is received until another IO request to send a query is
@ -469,8 +468,7 @@ public:
// Setup our "loopback" server.
udp::socket udp_socket(service_->getInternalIOService(), boost::asio::ip::udp::v4());
udp_socket.set_option(socket_base::reuse_address(true));
udp_socket.bind(udp::endpoint(address::from_string(TEST_ADDRESS),
TEST_PORT));
udp_socket.bind(udp::endpoint(make_address(TEST_ADDRESS), TEST_PORT));
udp::endpoint remote;
udp_socket.async_receive_from(boost::asio::buffer(receive_buffer_,
sizeof(receive_buffer_)),

View File

@ -222,7 +222,7 @@ public:
// Create an endpoint pointed at the listener.
boost::asio::ip::udp::endpoint
listener_endpoint(boost::asio::ip::address::from_string(TEST_ADDRESS),
listener_endpoint(boost::asio::ip::make_address(TEST_ADDRESS),
LISTENER_PORT);
// A response message is now ready to send. Send it!

View File

@ -147,8 +147,7 @@ TEST_F(HttpListenerTest, addressInUse) {
tcp::acceptor acceptor(io_service_->getInternalIOService());
// Use other port than SERVER_PORT to make sure that this TCP connection
// doesn't affect subsequent tests.
tcp::endpoint endpoint(address::from_string(SERVER_ADDRESS),
SERVER_PORT + 1);
tcp::endpoint endpoint(make_address(SERVER_ADDRESS), SERVER_PORT + 1);
acceptor.open(endpoint.protocol());
acceptor.bind(endpoint);

View File

@ -161,8 +161,7 @@ TEST_F(HttpsListenerTest, addressInUse) {
tcp::acceptor acceptor(io_service_->getInternalIOService());
// Use other port than SERVER_PORT to make sure that this TCP connection
// doesn't affect subsequent tests.
tcp::endpoint endpoint(address::from_string(SERVER_ADDRESS),
SERVER_PORT + 1);
tcp::endpoint endpoint(make_address(SERVER_ADDRESS), SERVER_PORT + 1);
acceptor.open(endpoint.protocol());
acceptor.bind(endpoint);

View File

@ -117,7 +117,7 @@ public:
///
/// @param request HTTP request in the textual format.
virtual void startRequest(const std::string& request) {
tcp::endpoint endpoint(address::from_string(server_address_), server_port_);
tcp::endpoint endpoint(make_address(server_address_), server_port_);
auto ref = shared_from_this();
socket_.async_connect(endpoint,
[this, ref, request](const boost::system::error_code& ec) {
@ -392,8 +392,7 @@ public:
///
/// @param request HTTP request in the textual format.
virtual void startRequest(const std::string& request) {
tcp::endpoint endpoint(address::from_string(server_address_),
server_port_);
tcp::endpoint endpoint(make_address(server_address_), server_port_);
auto ref = shared_from_this();
stream_.lowest_layer().async_connect(endpoint,
[this, ref, request](const boost::system::error_code& ec) {

View File

@ -214,7 +214,7 @@ public:
/// @brief Runs IO service with optional timeout.
///
/// We iterate over calls to asio::io_service.run(), until
/// We iterate over calls to asio::io_context.run(), until
/// all the clients have completed their requests. We do it this way
/// because the test clients stop the io_service when they're
/// through with a request.

View File

@ -114,7 +114,7 @@ public:
/// Upon successful connection, carry out the TLS handshake. If the handshake
/// completes successful start sending requests.
void start() {
isc::asiolink::TCPEndpoint endpoint(boost::asio::ip::address::from_string(server_address_), server_port_);
isc::asiolink::TCPEndpoint endpoint(boost::asio::ip::make_address(server_address_), server_port_);
SocketCallback socket_cb(
[this](boost::system::error_code ec, size_t /*length */) {
receive_done_ = false;