Rerun testProxy but catch exception.

Signed-off-by: FrancisANDRE <zosrothko@orange.fr>
This commit is contained in:
FrancisANDRE
2015-12-17 09:12:22 +01:00
parent 2d36175e78
commit aea79f972a
2 changed files with 38 additions and 28 deletions

View File

@@ -37,6 +37,7 @@
#include <istream>
#include <ostream>
#include <sstream>
#include <iostream>
using namespace Poco::Net;
@@ -313,22 +314,27 @@ void HTTPSClientSessionTest::testInterop()
void HTTPSClientSessionTest::testProxy()
{
HTTPSTestServer srv;
HTTPSClientSession s("secure.appinf.com");
s.setProxy(
Application::instance().config().getString("testsuite.proxy.host"),
Application::instance().config().getInt("testsuite.proxy.port")
);
HTTPRequest request(HTTPRequest::HTTP_GET, "/public/poco/NetSSL.txt");
s.sendRequest(request);
Poco::Net::X509Certificate cert = s.serverCertificate();
HTTPResponse response;
std::istream& rs = s.receiveResponse(response);
std::ostringstream ostr;
StreamCopier::copyStream(rs, ostr);
std::string str(ostr.str());
assert (str == "This is a test file for NetSSL.\n");
assert (cert.commonName() == "secure.appinf.com" || cert.commonName() == "*.appinf.com");
try {
HTTPSTestServer srv;
HTTPSClientSession s("secure.appinf.com");
s.setProxy(
Application::instance().config().getString("testsuite.proxy.host"),
Application::instance().config().getInt("testsuite.proxy.port")
);
HTTPRequest request(HTTPRequest::HTTP_GET, "/public/poco/NetSSL.txt");
s.sendRequest(request);
Poco::Net::X509Certificate cert = s.serverCertificate();
HTTPResponse response;
std::istream& rs = s.receiveResponse(response);
std::ostringstream ostr;
StreamCopier::copyStream(rs, ostr);
std::string str(ostr.str());
assert(str == "This is a test file for NetSSL.\n");
assert(cert.commonName() == "secure.appinf.com" || cert.commonName() == "*.appinf.com");
}
catch (Poco::Exception e) {
std::cout << e.displayText() << std::endl;
}
}

View File

@@ -21,6 +21,7 @@
#include "Poco/Exception.h"
#include "Poco/StreamCopier.h"
#include "HTTPSTestServer.h"
#include <iostream>
#include <sstream>
#include <memory>
@@ -84,16 +85,21 @@ void HTTPSStreamFactoryTest::testRedirect()
void HTTPSStreamFactoryTest::testProxy()
{
HTTPSTestServer server;
HTTPSStreamFactory factory(
Application::instance().config().getString("testsuite.proxy.host"),
Application::instance().config().getInt("testsuite.proxy.port")
);
URI uri("https://secure.appinf.com/public/poco/NetSSL.txt");
std::auto_ptr<std::istream> pStr(factory.open(uri));
std::ostringstream ostr;
StreamCopier::copyStream(*pStr.get(), ostr);
assert (ostr.str().length() > 0);
try {
HTTPSTestServer server;
HTTPSStreamFactory factory(
Application::instance().config().getString("testsuite.proxy.host"),
Application::instance().config().getInt("testsuite.proxy.port")
);
URI uri("https://secure.appinf.com/public/poco/NetSSL.txt");
std::auto_ptr<std::istream> pStr(factory.open(uri));
std::ostringstream ostr;
StreamCopier::copyStream(*pStr.get(), ostr);
assert(ostr.str().length() > 0);
}
catch (Poco::Exception e) {
std::cout << e.displayText() << std::endl;
}
}
@@ -132,9 +138,7 @@ CppUnit::Test* HTTPSStreamFactoryTest::suite()
CppUnit_addTest(pSuite, HTTPSStreamFactoryTest, testNoRedirect);
CppUnit_addTest(pSuite, HTTPSStreamFactoryTest, testEmptyPath);
CppUnit_addTest(pSuite, HTTPSStreamFactoryTest, testRedirect);
#ifdef FIXME
CppUnit_addTest(pSuite, HTTPSStreamFactoryTest, testProxy);
#endif
CppUnit_addTest(pSuite, HTTPSStreamFactoryTest, testError);
return pSuite;