mirror of
https://github.com/pocoproject/poco.git
synced 2025-01-19 00:46:03 +01:00
fix tests on macOS
This commit is contained in:
parent
75a153dbc9
commit
b80fb988a1
@ -51,7 +51,7 @@ public:
|
||||
TestRequestHandler()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void handleRequest(HTTPServerRequest& request, HTTPServerResponse& response)
|
||||
{
|
||||
response.setChunkedTransferEncoding(true);
|
||||
@ -90,7 +90,7 @@ HTTPSClientSessionTest::~HTTPSClientSessionTest()
|
||||
void HTTPSClientSessionTest::testGetSmall()
|
||||
{
|
||||
HTTPSTestServer srv;
|
||||
HTTPSClientSession s("localhost", srv.port());
|
||||
HTTPSClientSession s("127.0.0.1", srv.port());
|
||||
HTTPRequest request(HTTPRequest::HTTP_GET, "/small");
|
||||
s.sendRequest(request);
|
||||
HTTPResponse response;
|
||||
@ -106,7 +106,7 @@ void HTTPSClientSessionTest::testGetSmall()
|
||||
void HTTPSClientSessionTest::testGetLarge()
|
||||
{
|
||||
HTTPSTestServer srv;
|
||||
HTTPSClientSession s("localhost", srv.port());
|
||||
HTTPSClientSession s("127.0.0.1", srv.port());
|
||||
HTTPRequest request(HTTPRequest::HTTP_GET, "/large");
|
||||
s.sendRequest(request);
|
||||
HTTPResponse response;
|
||||
@ -122,7 +122,7 @@ void HTTPSClientSessionTest::testGetLarge()
|
||||
void HTTPSClientSessionTest::testHead()
|
||||
{
|
||||
HTTPSTestServer srv;
|
||||
HTTPSClientSession s("localhost", srv.port());
|
||||
HTTPSClientSession s("127.0.0.1", srv.port());
|
||||
HTTPRequest request(HTTPRequest::HTTP_HEAD, "/large");
|
||||
s.sendRequest(request);
|
||||
HTTPResponse response;
|
||||
@ -137,7 +137,7 @@ void HTTPSClientSessionTest::testHead()
|
||||
void HTTPSClientSessionTest::testPostSmallIdentity()
|
||||
{
|
||||
HTTPSTestServer srv;
|
||||
HTTPSClientSession s("localhost", srv.port());
|
||||
HTTPSClientSession s("127.0.0.1", srv.port());
|
||||
HTTPRequest request(HTTPRequest::HTTP_POST, "/echo");
|
||||
std::string body("this is a random request body\r\n0\r\n");
|
||||
request.setContentLength((int) body.length());
|
||||
@ -154,7 +154,7 @@ void HTTPSClientSessionTest::testPostSmallIdentity()
|
||||
void HTTPSClientSessionTest::testPostLargeIdentity()
|
||||
{
|
||||
HTTPSTestServer srv;
|
||||
HTTPSClientSession s("localhost", srv.port());
|
||||
HTTPSClientSession s("127.0.0.1", srv.port());
|
||||
HTTPRequest request(HTTPRequest::HTTP_POST, "/echo");
|
||||
std::string body(8000, 'x');
|
||||
body.append("\r\n0\r\n");
|
||||
@ -172,7 +172,7 @@ void HTTPSClientSessionTest::testPostLargeIdentity()
|
||||
void HTTPSClientSessionTest::testPostSmallChunked()
|
||||
{
|
||||
HTTPSTestServer srv;
|
||||
HTTPSClientSession s("localhost", srv.port());
|
||||
HTTPSClientSession s("127.0.0.1", srv.port());
|
||||
HTTPRequest request(HTTPRequest::HTTP_POST, "/echo");
|
||||
std::string body("this is a random request body");
|
||||
request.setChunkedTransferEncoding(true);
|
||||
@ -190,7 +190,7 @@ void HTTPSClientSessionTest::testPostSmallChunked()
|
||||
void HTTPSClientSessionTest::testPostLargeChunked()
|
||||
{
|
||||
HTTPSTestServer srv;
|
||||
HTTPSClientSession s("localhost", srv.port());
|
||||
HTTPSClientSession s("127.0.0.1", srv.port());
|
||||
HTTPRequest request(HTTPRequest::HTTP_POST, "/echo");
|
||||
std::string body(16000, 'x');
|
||||
request.setChunkedTransferEncoding(true);
|
||||
@ -212,7 +212,7 @@ void HTTPSClientSessionTest::testPostLargeChunkedKeepAlive()
|
||||
srv.start();
|
||||
try
|
||||
{
|
||||
HTTPSClientSession s("localhost", srv.port());
|
||||
HTTPSClientSession s("127.0.0.1", srv.port());
|
||||
s.setKeepAlive(true);
|
||||
for (int i = 0; i < 10; ++i)
|
||||
{
|
||||
@ -241,7 +241,7 @@ void HTTPSClientSessionTest::testPostLargeChunkedKeepAlive()
|
||||
void HTTPSClientSessionTest::testKeepAlive()
|
||||
{
|
||||
HTTPSTestServer srv;
|
||||
HTTPSClientSession s("localhost", srv.port());
|
||||
HTTPSClientSession s("127.0.0.1", srv.port());
|
||||
s.setKeepAlive(true);
|
||||
HTTPRequest request(HTTPRequest::HTTP_HEAD, "/keepAlive", HTTPMessage::HTTP_1_1);
|
||||
s.sendRequest(request);
|
||||
@ -252,7 +252,7 @@ void HTTPSClientSessionTest::testKeepAlive()
|
||||
assert (response.getKeepAlive());
|
||||
std::ostringstream ostr1;
|
||||
assert (StreamCopier::copyStream(rs1, ostr1) == 0);
|
||||
|
||||
|
||||
request.setMethod(HTTPRequest::HTTP_GET);
|
||||
request.setURI("/small");
|
||||
s.sendRequest(request);
|
||||
@ -262,7 +262,7 @@ void HTTPSClientSessionTest::testKeepAlive()
|
||||
std::ostringstream ostr2;
|
||||
StreamCopier::copyStream(rs2, ostr2);
|
||||
assert (ostr2.str() == HTTPSTestServer::SMALL_BODY);
|
||||
|
||||
|
||||
request.setMethod(HTTPRequest::HTTP_GET);
|
||||
request.setURI("/large");
|
||||
s.sendRequest(request);
|
||||
@ -307,7 +307,7 @@ void HTTPSClientSessionTest::testProxy()
|
||||
HTTPSTestServer srv;
|
||||
HTTPSClientSession s("secure.appinf.com");
|
||||
s.setProxy(
|
||||
Application::instance().config().getString("testsuite.proxy.host"),
|
||||
Application::instance().config().getString("testsuite.proxy.host"),
|
||||
Application::instance().config().getInt("testsuite.proxy.port")
|
||||
);
|
||||
HTTPRequest request(HTTPRequest::HTTP_GET, "/public/poco/NetSSL.txt");
|
||||
@ -328,16 +328,16 @@ void HTTPSClientSessionTest::testCachedSession()
|
||||
// ensure OpenSSL machinery is fully setup
|
||||
Context::Ptr pDefaultServerContext = SSLManager::instance().defaultServerContext();
|
||||
Context::Ptr pDefaultClientContext = SSLManager::instance().defaultClientContext();
|
||||
|
||||
|
||||
Context::Ptr pServerContext = new Context(
|
||||
Context::SERVER_USE,
|
||||
Context::SERVER_USE,
|
||||
Application::instance().config().getString("openSSL.server.privateKeyFile"),
|
||||
Application::instance().config().getString("openSSL.server.privateKeyFile"),
|
||||
Application::instance().config().getString("openSSL.server.caConfig"),
|
||||
Context::VERIFY_NONE,
|
||||
9,
|
||||
true,
|
||||
"ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
|
||||
"ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
|
||||
pServerContext->enableSessionCache(true, "TestSuite");
|
||||
pServerContext->setSessionTimeout(10);
|
||||
pServerContext->setSessionCacheSize(1000);
|
||||
@ -346,7 +346,7 @@ void HTTPSClientSessionTest::testCachedSession()
|
||||
HTTPSTestServer srv(pServerContext);
|
||||
|
||||
Context::Ptr pClientContext = new Context(
|
||||
Context::CLIENT_USE,
|
||||
Context::CLIENT_USE,
|
||||
Application::instance().config().getString("openSSL.client.privateKeyFile"),
|
||||
Application::instance().config().getString("openSSL.client.privateKeyFile"),
|
||||
Application::instance().config().getString("openSSL.client.caConfig"),
|
||||
@ -356,7 +356,7 @@ void HTTPSClientSessionTest::testCachedSession()
|
||||
"ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
|
||||
pClientContext->enableSessionCache(true);
|
||||
|
||||
HTTPSClientSession s1("localhost", srv.port(), pClientContext);
|
||||
HTTPSClientSession s1("127.0.0.1", srv.port(), pClientContext);
|
||||
HTTPRequest request1(HTTPRequest::HTTP_GET, "/small");
|
||||
s1.sendRequest(request1);
|
||||
Session::Ptr pSession1 = s1.sslSession();
|
||||
@ -368,7 +368,7 @@ void HTTPSClientSessionTest::testCachedSession()
|
||||
StreamCopier::copyStream(rs1, ostr1);
|
||||
assert (ostr1.str() == HTTPSTestServer::SMALL_BODY);
|
||||
|
||||
HTTPSClientSession s2("localhost", srv.port(), pClientContext, pSession1);
|
||||
HTTPSClientSession s2("127.0.0.1", srv.port(), pClientContext, pSession1);
|
||||
HTTPRequest request2(HTTPRequest::HTTP_GET, "/small");
|
||||
s2.sendRequest(request2);
|
||||
Session::Ptr pSession2 = s2.sslSession();
|
||||
@ -379,7 +379,7 @@ void HTTPSClientSessionTest::testCachedSession()
|
||||
std::ostringstream ostr2;
|
||||
StreamCopier::copyStream(rs2, ostr2);
|
||||
assert (ostr2.str() == HTTPSTestServer::SMALL_BODY);
|
||||
|
||||
|
||||
assert (pSession1 == pSession2);
|
||||
|
||||
HTTPRequest request3(HTTPRequest::HTTP_GET, "/small");
|
||||
@ -397,7 +397,7 @@ void HTTPSClientSessionTest::testCachedSession()
|
||||
|
||||
Thread::sleep(15000); // wait for session to expire
|
||||
pServerContext->flushSessionCache();
|
||||
|
||||
|
||||
HTTPRequest request4(HTTPRequest::HTTP_GET, "/small");
|
||||
s2.sendRequest(request4);
|
||||
Session::Ptr pSession4 = s2.sslSession();
|
||||
@ -416,7 +416,7 @@ void HTTPSClientSessionTest::testCachedSession()
|
||||
void HTTPSClientSessionTest::testUnknownContentLength()
|
||||
{
|
||||
HTTPSTestServer srv;
|
||||
HTTPSClientSession s("localhost", srv.port());
|
||||
HTTPSClientSession s("127.0.0.1", srv.port());
|
||||
HTTPRequest request(HTTPRequest::HTTP_GET, "/nolength");
|
||||
s.sendRequest(request);
|
||||
HTTPResponse response;
|
||||
@ -432,7 +432,7 @@ void HTTPSClientSessionTest::testUnknownContentLength()
|
||||
void HTTPSClientSessionTest::testServerAbort()
|
||||
{
|
||||
HTTPSTestServer srv;
|
||||
HTTPSClientSession s("localhost", srv.port());
|
||||
HTTPSClientSession s("127.0.0.1", srv.port());
|
||||
HTTPRequest request(HTTPRequest::HTTP_GET, "/nolength/connection/abort");
|
||||
s.sendRequest(request);
|
||||
HTTPResponse response;
|
||||
|
@ -50,15 +50,15 @@ namespace
|
||||
response.setChunkedTransferEncoding(true);
|
||||
else if (request.getContentLength() != HTTPMessage::UNKNOWN_CONTENT_LENGTH)
|
||||
response.setContentLength(request.getContentLength());
|
||||
|
||||
|
||||
response.setContentType(request.getContentType());
|
||||
|
||||
|
||||
std::istream& istr = request.stream();
|
||||
std::ostream& ostr = response.send();
|
||||
StreamCopier::copyStream(istr, ostr);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class EchoHeaderRequestHandler: public HTTPRequestHandler
|
||||
{
|
||||
public:
|
||||
@ -92,7 +92,7 @@ namespace
|
||||
response.send();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class RequestHandlerFactory: public HTTPRequestHandlerFactory
|
||||
{
|
||||
public:
|
||||
@ -130,8 +130,8 @@ void HTTPSServerTest::testIdentityRequest()
|
||||
pParams->setKeepAlive(false);
|
||||
HTTPServer srv(new RequestHandlerFactory, svs, pParams);
|
||||
srv.start();
|
||||
|
||||
HTTPSClientSession cs("localhost", svs.address().port());
|
||||
|
||||
HTTPSClientSession cs("127.0.0.1", svs.address().port());
|
||||
std::string body(5000, 'x');
|
||||
HTTPRequest request("POST", "/echoBody");
|
||||
request.setContentLength((int) body.length());
|
||||
@ -153,8 +153,8 @@ void HTTPSServerTest::testChunkedRequest()
|
||||
pParams->setKeepAlive(false);
|
||||
HTTPServer srv(new RequestHandlerFactory, svs, pParams);
|
||||
srv.start();
|
||||
|
||||
HTTPSClientSession cs("localhost", svs.address().port());
|
||||
|
||||
HTTPSClientSession cs("127.0.0.1", svs.address().port());
|
||||
std::string body(5000, 'x');
|
||||
HTTPRequest request("POST", "/echoBody");
|
||||
request.setContentType("text/plain");
|
||||
@ -177,8 +177,8 @@ void HTTPSServerTest::testIdentityRequestKeepAlive()
|
||||
pParams->setKeepAlive(true);
|
||||
HTTPServer srv(new RequestHandlerFactory, svs, pParams);
|
||||
srv.start();
|
||||
|
||||
HTTPSClientSession cs("localhost", svs.address().port());
|
||||
|
||||
HTTPSClientSession cs("127.0.0.1", svs.address().port());
|
||||
cs.setKeepAlive(true);
|
||||
std::string body(5000, 'x');
|
||||
HTTPRequest request("POST", "/echoBody", HTTPMessage::HTTP_1_1);
|
||||
@ -192,7 +192,7 @@ void HTTPSServerTest::testIdentityRequestKeepAlive()
|
||||
assert (response.getContentType() == "text/plain");
|
||||
assert (response.getKeepAlive());
|
||||
assert (rbody == body);
|
||||
|
||||
|
||||
body.assign(1000, 'y');
|
||||
request.setContentLength((int) body.length());
|
||||
request.setKeepAlive(false);
|
||||
@ -211,8 +211,8 @@ void HTTPSServerTest::testChunkedRequestKeepAlive()
|
||||
pParams->setKeepAlive(true);
|
||||
HTTPServer srv(new RequestHandlerFactory, svs, pParams);
|
||||
srv.start();
|
||||
|
||||
HTTPSClientSession cs("localhost", svs.address().port());
|
||||
|
||||
HTTPSClientSession cs("127.0.0.1", svs.address().port());
|
||||
cs.setKeepAlive(true);
|
||||
std::string body(5000, 'x');
|
||||
HTTPRequest request("POST", "/echoBody", HTTPMessage::HTTP_1_1);
|
||||
@ -246,8 +246,8 @@ void HTTPSServerTest::test100Continue()
|
||||
pParams->setKeepAlive(false);
|
||||
HTTPServer srv(new RequestHandlerFactory, svs, pParams);
|
||||
srv.start();
|
||||
|
||||
HTTPSClientSession cs("localhost", svs.address().port());
|
||||
|
||||
HTTPSClientSession cs("127.0.0.1", svs.address().port());
|
||||
std::string body(5000, 'x');
|
||||
HTTPRequest request("POST", "/echoBody");
|
||||
request.setContentLength((int) body.length());
|
||||
@ -270,8 +270,8 @@ void HTTPSServerTest::testRedirect()
|
||||
pParams->setKeepAlive(false);
|
||||
HTTPServer srv(new RequestHandlerFactory, svs, pParams);
|
||||
srv.start();
|
||||
|
||||
HTTPSClientSession cs("localhost", svs.address().port());
|
||||
|
||||
HTTPSClientSession cs("127.0.0.1", svs.address().port());
|
||||
HTTPRequest request("GET", "/redirect");
|
||||
cs.sendRequest(request);
|
||||
HTTPResponse response;
|
||||
@ -290,8 +290,8 @@ void HTTPSServerTest::testAuth()
|
||||
pParams->setKeepAlive(false);
|
||||
HTTPServer srv(new RequestHandlerFactory, svs, pParams);
|
||||
srv.start();
|
||||
|
||||
HTTPSClientSession cs("localhost", svs.address().port());
|
||||
|
||||
HTTPSClientSession cs("127.0.0.1", svs.address().port());
|
||||
HTTPRequest request("GET", "/auth");
|
||||
cs.sendRequest(request);
|
||||
HTTPResponse response;
|
||||
@ -310,8 +310,8 @@ void HTTPSServerTest::testNotImpl()
|
||||
pParams->setKeepAlive(false);
|
||||
HTTPServer srv(new RequestHandlerFactory, svs, pParams);
|
||||
srv.start();
|
||||
|
||||
HTTPSClientSession cs("localhost", svs.address().port());
|
||||
|
||||
HTTPSClientSession cs("127.0.0.1", svs.address().port());
|
||||
HTTPRequest request("GET", "/notImpl");
|
||||
cs.sendRequest(request);
|
||||
HTTPResponse response;
|
||||
|
@ -45,7 +45,7 @@ void HTTPSStreamFactoryTest::testNoRedirect()
|
||||
{
|
||||
HTTPSTestServer server;
|
||||
HTTPSStreamFactory factory;
|
||||
URI uri("https://localhost/large");
|
||||
URI uri("https://127.0.0.1/large");
|
||||
uri.setPort(server.port());
|
||||
#ifndef POCO_ENABLE_CPP11
|
||||
std::auto_ptr<std::istream> pStr(factory.open(uri));
|
||||
@ -62,7 +62,7 @@ void HTTPSStreamFactoryTest::testEmptyPath()
|
||||
{
|
||||
HTTPSTestServer server;
|
||||
HTTPSStreamFactory factory;
|
||||
URI uri("https://localhost");
|
||||
URI uri("https://127.0.0.1");
|
||||
uri.setPort(server.port());
|
||||
#ifndef POCO_ENABLE_CPP11
|
||||
std::auto_ptr<std::istream> pStr(factory.open(uri));
|
||||
@ -79,7 +79,7 @@ void HTTPSStreamFactoryTest::testRedirect()
|
||||
{
|
||||
HTTPSTestServer server;
|
||||
HTTPSStreamFactory factory;
|
||||
URI uri("https://localhost/redirect");
|
||||
URI uri("https://127.0.0.1/redirect");
|
||||
uri.setPort(server.port());
|
||||
#ifndef POCO_ENABLE_CPP11
|
||||
std::auto_ptr<std::istream> pStr(factory.open(uri));
|
||||
@ -96,7 +96,7 @@ void HTTPSStreamFactoryTest::testProxy()
|
||||
{
|
||||
HTTPSTestServer server;
|
||||
HTTPSStreamFactory factory(
|
||||
Application::instance().config().getString("testsuite.proxy.host"),
|
||||
Application::instance().config().getString("testsuite.proxy.host"),
|
||||
Application::instance().config().getInt("testsuite.proxy.port")
|
||||
);
|
||||
URI uri("https://secure.appinf.com/public/poco/NetSSL.txt");
|
||||
@ -115,7 +115,7 @@ void HTTPSStreamFactoryTest::testError()
|
||||
{
|
||||
HTTPSTestServer server;
|
||||
HTTPSStreamFactory factory;
|
||||
URI uri("https://localhost/notfound");
|
||||
URI uri("https://127.0.0.1/notfound");
|
||||
uri.setPort(server.port());
|
||||
try
|
||||
{
|
||||
|
@ -50,7 +50,7 @@ namespace
|
||||
EchoConnection(const StreamSocket& s): TCPServerConnection(s)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void run()
|
||||
{
|
||||
StreamSocket& ss = socket();
|
||||
@ -92,8 +92,8 @@ void TCPServerTest::testOneConnection()
|
||||
assert (srv.currentThreads() == 0);
|
||||
assert (srv.queuedConnections() == 0);
|
||||
assert (srv.totalConnections() == 0);
|
||||
|
||||
SocketAddress sa("localhost", svs.address().port());
|
||||
|
||||
SocketAddress sa("127.0.0.1", svs.address().port());
|
||||
SecureStreamSocket ss1(sa);
|
||||
std::string data("hello, world");
|
||||
ss1.sendBytes(data.data(), (int) data.size());
|
||||
@ -120,8 +120,8 @@ void TCPServerTest::testTwoConnections()
|
||||
assert (srv.currentThreads() == 0);
|
||||
assert (srv.queuedConnections() == 0);
|
||||
assert (srv.totalConnections() == 0);
|
||||
|
||||
SocketAddress sa("localhost", svs.address().port());
|
||||
|
||||
SocketAddress sa("127.0.0.1", svs.address().port());
|
||||
SecureStreamSocket ss1(sa);
|
||||
SecureStreamSocket ss2(sa);
|
||||
std::string data("hello, world");
|
||||
@ -136,7 +136,7 @@ void TCPServerTest::testTwoConnections()
|
||||
n = ss2.receiveBytes(buffer, sizeof(buffer));
|
||||
assert (n > 0);
|
||||
assert (std::string(buffer, n) == data);
|
||||
|
||||
|
||||
assert (srv.currentConnections() == 2);
|
||||
assert (srv.currentThreads() == 2);
|
||||
assert (srv.queuedConnections() == 0);
|
||||
@ -167,8 +167,8 @@ void TCPServerTest::testMultiConnections()
|
||||
assert (srv.currentThreads() == 0);
|
||||
assert (srv.queuedConnections() == 0);
|
||||
assert (srv.totalConnections() == 0);
|
||||
|
||||
SocketAddress sa("localhost", svs.address().port());
|
||||
|
||||
SocketAddress sa("127.0.0.1", svs.address().port());
|
||||
SecureStreamSocket ss1(sa);
|
||||
SecureStreamSocket ss2(sa);
|
||||
SecureStreamSocket ss3(sa);
|
||||
@ -195,12 +195,12 @@ void TCPServerTest::testMultiConnections()
|
||||
n = ss4.receiveBytes(buffer, sizeof(buffer));
|
||||
assert (n > 0);
|
||||
assert (std::string(buffer, n) == data);
|
||||
|
||||
|
||||
assert (srv.currentConnections() == 4);
|
||||
assert (srv.currentThreads() == 4);
|
||||
assert (srv.queuedConnections() == 0);
|
||||
assert (srv.totalConnections() == 4);
|
||||
|
||||
|
||||
SecureStreamSocket ss5;
|
||||
ss5.setLazyHandshake();
|
||||
ss5.connect(sa);
|
||||
@ -211,7 +211,7 @@ void TCPServerTest::testMultiConnections()
|
||||
ss6.connect(sa);
|
||||
Thread::sleep(200);
|
||||
assert (srv.queuedConnections() == 2);
|
||||
|
||||
|
||||
ss1.close();
|
||||
Thread::sleep(300);
|
||||
assert (srv.currentConnections() == 4);
|
||||
@ -225,7 +225,7 @@ void TCPServerTest::testMultiConnections()
|
||||
assert (srv.currentThreads() == 4);
|
||||
assert (srv.queuedConnections() == 0);
|
||||
assert (srv.totalConnections() == 6);
|
||||
|
||||
|
||||
ss3.close();
|
||||
Thread::sleep(300);
|
||||
assert (srv.currentConnections() == 3);
|
||||
@ -256,8 +256,8 @@ void TCPServerTest::testReuseSocket()
|
||||
assert (srv.currentThreads() == 0);
|
||||
assert (srv.queuedConnections() == 0);
|
||||
assert (srv.totalConnections() == 0);
|
||||
|
||||
SocketAddress sa("localhost", svs.address().port());
|
||||
|
||||
SocketAddress sa("127.0.0.1", svs.address().port());
|
||||
SecureStreamSocket ss1(sa);
|
||||
std::string data("hello, world");
|
||||
ss1.sendBytes(data.data(), (int) data.size());
|
||||
@ -292,21 +292,21 @@ void TCPServerTest::testReuseSession()
|
||||
// ensure OpenSSL machinery is fully setup
|
||||
Context::Ptr pDefaultServerContext = SSLManager::instance().defaultServerContext();
|
||||
Context::Ptr pDefaultClientContext = SSLManager::instance().defaultClientContext();
|
||||
|
||||
|
||||
Context::Ptr pServerContext = new Context(
|
||||
Context::SERVER_USE,
|
||||
Context::SERVER_USE,
|
||||
Application::instance().config().getString("openSSL.server.privateKeyFile"),
|
||||
Application::instance().config().getString("openSSL.server.privateKeyFile"),
|
||||
Application::instance().config().getString("openSSL.server.caConfig"),
|
||||
Context::VERIFY_NONE,
|
||||
9,
|
||||
true,
|
||||
"ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
|
||||
"ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
|
||||
pServerContext->enableSessionCache(true, "TestSuite");
|
||||
pServerContext->setSessionTimeout(10);
|
||||
pServerContext->setSessionCacheSize(1000);
|
||||
pServerContext->disableStatelessSessionResumption();
|
||||
|
||||
|
||||
SecureServerSocket svs(0, 64, pServerContext);
|
||||
TCPServer srv(new TCPServerConnectionFactoryImpl<EchoConnection>(), svs);
|
||||
srv.start();
|
||||
@ -314,9 +314,9 @@ void TCPServerTest::testReuseSession()
|
||||
assert (srv.currentThreads() == 0);
|
||||
assert (srv.queuedConnections() == 0);
|
||||
assert (srv.totalConnections() == 0);
|
||||
|
||||
|
||||
Context::Ptr pClientContext = new Context(
|
||||
Context::CLIENT_USE,
|
||||
Context::CLIENT_USE,
|
||||
Application::instance().config().getString("openSSL.client.privateKeyFile"),
|
||||
Application::instance().config().getString("openSSL.client.privateKeyFile"),
|
||||
Application::instance().config().getString("openSSL.client.caConfig"),
|
||||
@ -325,8 +325,8 @@ void TCPServerTest::testReuseSession()
|
||||
true,
|
||||
"ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
|
||||
pClientContext->enableSessionCache(true);
|
||||
|
||||
SocketAddress sa("localhost", svs.address().port());
|
||||
|
||||
SocketAddress sa("127.0.0.1", svs.address().port());
|
||||
SecureStreamSocket ss1(sa, pClientContext);
|
||||
assert (!ss1.sessionWasReused());
|
||||
std::string data("hello, world");
|
||||
@ -339,9 +339,9 @@ void TCPServerTest::testReuseSession()
|
||||
assert (srv.currentThreads() == 1);
|
||||
assert (srv.queuedConnections() == 0);
|
||||
assert (srv.totalConnections() == 1);
|
||||
|
||||
|
||||
Session::Ptr pSession = ss1.currentSession();
|
||||
|
||||
|
||||
ss1.close();
|
||||
Thread::sleep(300);
|
||||
assert (srv.currentConnections() == 0);
|
||||
@ -363,7 +363,7 @@ void TCPServerTest::testReuseSession()
|
||||
|
||||
Thread::sleep(15000); // wait for session to expire
|
||||
pServerContext->flushSessionCache();
|
||||
|
||||
|
||||
ss1.useSession(pSession);
|
||||
ss1.connect(sa);
|
||||
assert (!ss1.sessionWasReused());
|
||||
|
Loading…
x
Reference in New Issue
Block a user