mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-06-21 17:47:13 +02:00
Update POCO to 1.11.0
This commit is contained in:
@ -371,7 +371,6 @@ void HTTPSClientSessionTest::testCachedSession()
|
||||
HTTPSClientSession s2("127.0.0.1", srv.port(), pClientContext, pSession1);
|
||||
HTTPRequest request2(HTTPRequest::HTTP_GET, "/small");
|
||||
s2.sendRequest(request2);
|
||||
Session::Ptr pSession2 = s2.sslSession();
|
||||
HTTPResponse response2;
|
||||
std::istream& rs2 = s2.receiveResponse(response2);
|
||||
assertTrue (response2.getContentLength() == HTTPSTestServer::SMALL_BODY.length());
|
||||
@ -380,11 +379,8 @@ void HTTPSClientSessionTest::testCachedSession()
|
||||
StreamCopier::copyStream(rs2, ostr2);
|
||||
assertTrue (ostr2.str() == HTTPSTestServer::SMALL_BODY);
|
||||
|
||||
assertTrue (pSession1 == pSession2);
|
||||
|
||||
HTTPRequest request3(HTTPRequest::HTTP_GET, "/small");
|
||||
s2.sendRequest(request3);
|
||||
Session::Ptr pSession3 = s2.sslSession();
|
||||
HTTPResponse response3;
|
||||
std::istream& rs3 = s2.receiveResponse(response3);
|
||||
assertTrue (response3.getContentLength() == HTTPSTestServer::SMALL_BODY.length());
|
||||
@ -393,14 +389,11 @@ void HTTPSClientSessionTest::testCachedSession()
|
||||
StreamCopier::copyStream(rs3, ostr3);
|
||||
assertTrue (ostr3.str() == HTTPSTestServer::SMALL_BODY);
|
||||
|
||||
assertTrue (pSession1 == pSession3);
|
||||
|
||||
Thread::sleep(15000); // wait for session to expire
|
||||
pServerContext->flushSessionCache();
|
||||
|
||||
HTTPRequest request4(HTTPRequest::HTTP_GET, "/small");
|
||||
s2.sendRequest(request4);
|
||||
Session::Ptr pSession4 = s2.sslSession();
|
||||
HTTPResponse response4;
|
||||
std::istream& rs4 = s2.receiveResponse(response4);
|
||||
assertTrue (response4.getContentLength() == HTTPSTestServer::SMALL_BODY.length());
|
||||
@ -408,8 +401,6 @@ void HTTPSClientSessionTest::testCachedSession()
|
||||
std::ostringstream ostr4;
|
||||
StreamCopier::copyStream(rs4, ostr4);
|
||||
assertTrue (ostr4.str() == HTTPSTestServer::SMALL_BODY);
|
||||
|
||||
assertTrue (pSession1 != pSession4);
|
||||
}
|
||||
|
||||
|
||||
|
@ -18,6 +18,8 @@
|
||||
#include "Poco/Net/SecureStreamSocket.h"
|
||||
#include "Poco/Net/SecureServerSocket.h"
|
||||
#include "Poco/Net/Context.h"
|
||||
#include "Poco/Net/RejectCertificateHandler.h"
|
||||
#include "Poco/Net/AcceptCertificateHandler.h"
|
||||
#include "Poco/Net/Session.h"
|
||||
#include "Poco/Net/SSLManager.h"
|
||||
#include "Poco/Util/Application.h"
|
||||
@ -70,6 +72,26 @@ namespace
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class NullConnection: public TCPServerConnection
|
||||
{
|
||||
public:
|
||||
NullConnection(const StreamSocket& s): TCPServerConnection(s)
|
||||
{
|
||||
}
|
||||
|
||||
void run()
|
||||
{
|
||||
SecureStreamSocket ss = socket();
|
||||
try
|
||||
{
|
||||
ss.completeHandshake();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -381,6 +403,50 @@ void TCPServerTest::testReuseSession()
|
||||
}
|
||||
|
||||
|
||||
void TCPServerTest::testContextInvalidCertificateHandler()
|
||||
{
|
||||
SecureServerSocket svs(0);
|
||||
TCPServer srv(new TCPServerConnectionFactoryImpl<NullConnection>(), svs);
|
||||
srv.start();
|
||||
|
||||
Context::Ptr pClientContext = new Context(
|
||||
Context::CLIENT_USE,
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
Context::VERIFY_RELAXED,
|
||||
9,
|
||||
true,
|
||||
"ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
|
||||
|
||||
pClientContext->setInvalidCertificateHandler(new Poco::Net::RejectCertificateHandler(false));
|
||||
|
||||
SocketAddress sa("127.0.0.1", svs.address().port());
|
||||
|
||||
try
|
||||
{
|
||||
SecureStreamSocket ss1(sa, pClientContext);
|
||||
fail("must throw with RejectCertificateHandler");
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
|
||||
pClientContext->setInvalidCertificateHandler(new Poco::Net::AcceptCertificateHandler(false));
|
||||
|
||||
try
|
||||
{
|
||||
SecureStreamSocket ss1(sa, pClientContext);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
fail("must not throw with AcceptCertificateHandler");
|
||||
}
|
||||
|
||||
srv.stop();
|
||||
}
|
||||
|
||||
|
||||
void TCPServerTest::setUp()
|
||||
{
|
||||
}
|
||||
@ -400,6 +466,7 @@ CppUnit::Test* TCPServerTest::suite()
|
||||
CppUnit_addTest(pSuite, TCPServerTest, testMultiConnections);
|
||||
CppUnit_addTest(pSuite, TCPServerTest, testReuseSocket);
|
||||
CppUnit_addTest(pSuite, TCPServerTest, testReuseSession);
|
||||
CppUnit_addTest(pSuite, TCPServerTest, testContextInvalidCertificateHandler);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ public:
|
||||
void testMultiConnections();
|
||||
void testReuseSocket();
|
||||
void testReuseSession();
|
||||
void testContextInvalidCertificateHandler();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
Reference in New Issue
Block a user