mirror of
https://github.com/Icinga/icinga2.git
synced 2026-05-28 04:12:13 -04:00
Revert "Merge pull request #10799 from Icinga/fix-pdwc-tls-host-check"
This reverts commit03d3558621, reversing changes made to81d39f1f78.
This commit is contained in:
parent
e037b74eb3
commit
12a20b18d5
5 changed files with 15 additions and 21 deletions
|
|
@ -99,7 +99,7 @@ AsioTlsOrTcpStream PerfdataWriterConnection::MakeStream() const
|
|||
{
|
||||
AsioTlsOrTcpStream ret;
|
||||
if (m_SslContext) {
|
||||
ret = Shared<AsioTlsStream>::Make(IoEngine::Get().GetIoContext(), *m_SslContext, m_Host);
|
||||
ret = Shared<AsioTlsStream>::Make(IoEngine::Get().GetIoContext(), *m_SslContext);
|
||||
} else {
|
||||
ret = Shared<AsioTcpStream>::Make(IoEngine::Get().GetIoContext());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,24 +39,16 @@ public:
|
|||
explicit PerfdataWriterTargetFixture(AsioTlsOrTcpStream stream)
|
||||
: m_Stream(std::move(stream)),
|
||||
m_Acceptor(
|
||||
IoEngine::Get().GetIoContext()
|
||||
IoEngine::Get().GetIoContext(),
|
||||
boost::asio::ip::tcp::endpoint{boost::asio::ip::address_v4::loopback(), 0}
|
||||
)
|
||||
{
|
||||
boost::asio::ip::tcp::endpoint ep{boost::asio::ip::address_v4::loopback(), 0};
|
||||
m_Acceptor.open(ep.protocol());
|
||||
m_Acceptor.bind(ep);
|
||||
}
|
||||
|
||||
unsigned short GetPort() { return m_Acceptor.local_endpoint().port(); }
|
||||
|
||||
void Listen()
|
||||
{
|
||||
m_Acceptor.listen();
|
||||
}
|
||||
|
||||
void Accept()
|
||||
{
|
||||
Listen();
|
||||
BOOST_REQUIRE_NO_THROW(
|
||||
std::visit([&](auto& stream) { return m_Acceptor.accept(stream->lowest_layer()); }, m_Stream)
|
||||
);
|
||||
|
|
@ -90,7 +82,7 @@ public:
|
|||
void ResetStream()
|
||||
{
|
||||
if (std::holds_alternative<Shared<AsioTlsStream>::Ptr>(m_Stream)) {
|
||||
m_Stream = Shared<AsioTlsStream>::Make(IoEngine::Get().GetIoContext(), *m_SslContext, "localhost");
|
||||
m_Stream = Shared<AsioTlsStream>::Make(IoEngine::Get().GetIoContext(), *m_SslContext);
|
||||
} else {
|
||||
m_Stream = Shared<AsioTcpStream>::Make(IoEngine::Get().GetIoContext());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ public:
|
|||
{
|
||||
m_PdwSslContext = MakeContext("client");
|
||||
|
||||
m_Conn = new PerfdataWriterConnection{"Test", "test", "localhost", std::to_string(GetPort()), m_PdwSslContext};
|
||||
m_Conn = new PerfdataWriterConnection{"Test", "test", "127.0.0.1", std::to_string(GetPort()), m_PdwSslContext};
|
||||
}
|
||||
|
||||
auto& GetConnection() { return *m_Conn; }
|
||||
|
|
@ -130,9 +130,10 @@ BOOST_AUTO_TEST_CASE(finish_during_timeout)
|
|||
*/
|
||||
BOOST_AUTO_TEST_CASE(stuck_in_handshake)
|
||||
{
|
||||
TestThread mockTargetThread{[&]() { Accept(); }};
|
||||
|
||||
std::promise<void> p;
|
||||
TestThread timeoutThread{[&]() {
|
||||
Accept();
|
||||
auto f = p.get_future();
|
||||
GetConnection().CancelAfterTimeout(f, 50ms);
|
||||
BOOST_REQUIRE(f.wait_for(0ms) == std::future_status::timeout);
|
||||
|
|
@ -143,6 +144,7 @@ BOOST_AUTO_TEST_CASE(stuck_in_handshake)
|
|||
);
|
||||
|
||||
REQUIRE_JOINS_WITHIN(timeoutThread, 1s);
|
||||
REQUIRE_JOINS_WITHIN(mockTargetThread, 1s);
|
||||
}
|
||||
|
||||
/* When the disconnect timeout runs out while sending something to a slow or blocking server, we
|
||||
|
|
|
|||
|
|
@ -95,19 +95,19 @@ void RequiresCertificate::AddCaFixture(const String& caFixtureName)
|
|||
m_CaFixtures.emplace_back(caFixtureName);
|
||||
}
|
||||
|
||||
void RequiresCertificate::AddCertFixture(const String& name, const String& caFixture, const String& certFixture)
|
||||
void RequiresCertificate::AddCertFixture(const String& cn, const String& caFixture, const String& certFixture)
|
||||
{
|
||||
auto& mts = boost::unit_test::framework::master_test_suite();
|
||||
boost::unit_test::decorator::base_ptr certLabel{new boost::unit_test::label{"cert"}};
|
||||
|
||||
auto* setup = boost::unit_test::make_test_case(
|
||||
[name]() {
|
||||
[cn]() {
|
||||
CertificateFixture certFixture;
|
||||
auto persistentCertsPath = CertificateFixture::m_PersistentCertsDir / "certs";
|
||||
auto keyFile = persistentCertsPath / (name.GetData() + ".key");
|
||||
auto csrFile = persistentCertsPath / (name.GetData() + ".csr");
|
||||
auto crtFile = persistentCertsPath / (name.GetData() + ".crt");
|
||||
PkiUtility::NewCert("localhost", keyFile.string(), csrFile.string(), "");
|
||||
auto keyFile = persistentCertsPath / (cn.GetData() + ".key");
|
||||
auto csrFile = persistentCertsPath / (cn.GetData() + ".csr");
|
||||
auto crtFile = persistentCertsPath / (cn.GetData() + ".crt");
|
||||
PkiUtility::NewCert(cn, keyFile.string(), csrFile.string(), "");
|
||||
PkiUtility::SignCsr(csrFile.string(), crtFile.string());
|
||||
},
|
||||
certFixture.GetData() + "_setup",
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ private:
|
|||
static inline std::vector<String> m_CaFixtures;
|
||||
|
||||
static void AddCaFixture(const String& caFixtureName);
|
||||
static void AddCertFixture(const String& name, const String& caFixture, const String& certFixture);
|
||||
static void AddCertFixture(const String& cn, const String& caFixture, const String& certFixture);
|
||||
};
|
||||
|
||||
} // namespace icinga
|
||||
|
|
|
|||
Loading…
Reference in a new issue