summaryrefslogtreecommitdiff
path: root/cpp/test
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2016-06-27 17:54:30 +0200
committerBenoit Foucher <benoit@zeroc.com>2016-06-27 17:54:30 +0200
commitc56f8ab6ca6ca0bdb9536fcce1ef24f1ef40ddc7 (patch)
tree5cb64dfe155e5d2349efb6c7dc4b0f5b5284d44a /cpp/test
parentFix Windows php build to restore nuget packages (diff)
downloadice-c56f8ab6ca6ca0bdb9536fcce1ef24f1ef40ddc7.tar.bz2
ice-c56f8ab6ca6ca0bdb9536fcce1ef24f1ef40ddc7.tar.xz
ice-c56f8ab6ca6ca0bdb9536fcce1ef24f1ef40ddc7.zip
Refactored SSL and iAP transports, support for running SSL on top
of TCP/iAP/Bluetooth.
Diffstat (limited to 'cpp/test')
-rw-r--r--cpp/test/Ice/background/EndpointFactory.cpp2
-rw-r--r--cpp/test/Ice/background/EndpointFactory.h3
-rw-r--r--cpp/test/Ice/background/EndpointI.cpp4
-rw-r--r--cpp/test/Ice/background/EndpointI.h4
-rw-r--r--cpp/test/Ice/info/AllTests.cpp98
-rw-r--r--cpp/test/Ice/info/TestI.cpp48
-rw-r--r--cpp/test/Ice/metrics/AllTests.cpp54
-rw-r--r--cpp/test/Ice/metrics/Client.cpp2
-rw-r--r--cpp/test/Ice/networkProxy/AllTests.cpp21
-rw-r--r--cpp/test/Ice/operations/Client.cpp5
-rw-r--r--cpp/test/Ice/slicing/exceptions/AllTests.cpp27
-rw-r--r--cpp/test/IceSSL/configuration/AllTests.cpp154
-rw-r--r--cpp/test/IceSSL/configuration/Client.cpp37
-rw-r--r--cpp/test/IceSSL/configuration/Makefile.mk4
-rw-r--r--cpp/test/IceSSL/configuration/Server.cpp7
-rw-r--r--cpp/test/IceSSL/configuration/TestI.cpp3
-rwxr-xr-xcpp/test/ios/C++ Test Suite.xcodeproj/project.pbxproj10
-rw-r--r--cpp/test/ios/Classes/AppDelegate.mm1
-rw-r--r--cpp/test/uwp/MainPage.xaml.cpp1
19 files changed, 363 insertions, 122 deletions
diff --git a/cpp/test/Ice/background/EndpointFactory.cpp b/cpp/test/Ice/background/EndpointFactory.cpp
index 9cf7d4a16eb..bf1cb1422b0 100644
--- a/cpp/test/Ice/background/EndpointFactory.cpp
+++ b/cpp/test/Ice/background/EndpointFactory.cpp
@@ -56,7 +56,7 @@ EndpointFactory::destroy()
}
IceInternal::EndpointFactoryPtr
-EndpointFactory::clone(const IceInternal::ProtocolInstancePtr&) const
+EndpointFactory::clone(const IceInternal::ProtocolInstancePtr&, const IceInternal::EndpointFactoryPtr&) const
{
return const_cast<EndpointFactory*>(this);
}
diff --git a/cpp/test/Ice/background/EndpointFactory.h b/cpp/test/Ice/background/EndpointFactory.h
index 5f265996bd8..9dab2bac2ef 100644
--- a/cpp/test/Ice/background/EndpointFactory.h
+++ b/cpp/test/Ice/background/EndpointFactory.h
@@ -24,7 +24,8 @@ public:
virtual IceInternal::EndpointIPtr read(Ice::InputStream*) const;
virtual void destroy();
- virtual IceInternal::EndpointFactoryPtr clone(const IceInternal::ProtocolInstancePtr&) const;
+ virtual IceInternal::EndpointFactoryPtr clone(const IceInternal::ProtocolInstancePtr&,
+ const IceInternal::EndpointFactoryPtr&) const;
protected:
diff --git a/cpp/test/Ice/background/EndpointI.cpp b/cpp/test/Ice/background/EndpointI.cpp
index 6cd3550e563..76748bea94a 100644
--- a/cpp/test/Ice/background/EndpointI.cpp
+++ b/cpp/test/Ice/background/EndpointI.cpp
@@ -32,12 +32,10 @@ EndpointI::EndpointI(const IceInternal::EndpointIPtr& endpoint) :
}
void
-EndpointI::streamWrite(Ice::OutputStream* s) const
+EndpointI::streamWriteImpl(Ice::OutputStream* s) const
{
- s->startEncapsulation();
s->write(_endpoint->type());
_endpoint->streamWrite(s);
- s->endEncapsulation();
}
Ice::Short
diff --git a/cpp/test/Ice/background/EndpointI.h b/cpp/test/Ice/background/EndpointI.h
index ea9423331b6..2e8b823b7a4 100644
--- a/cpp/test/Ice/background/EndpointI.h
+++ b/cpp/test/Ice/background/EndpointI.h
@@ -23,11 +23,11 @@ class EndpointI : public IceInternal::EndpointI, public Ice::EnableSharedFromThi
public:
static Ice::Short TYPE_BASE;
-
+
EndpointI(const IceInternal::EndpointIPtr&);
// From EndpointI
- virtual void streamWrite(Ice::OutputStream*) const;
+ virtual void streamWriteImpl(Ice::OutputStream*) const;
virtual Ice::Short type() const;
virtual const std::string& protocol() const;
virtual IceInternal::EndpointIPtr timeout(Ice::Int) const;
diff --git a/cpp/test/Ice/info/AllTests.cpp b/cpp/test/Ice/info/AllTests.cpp
index 81da1e2aafa..e9edf0327ee 100644
--- a/cpp/test/Ice/info/AllTests.cpp
+++ b/cpp/test/Ice/info/AllTests.cpp
@@ -15,6 +15,39 @@
using namespace std;
using namespace Test;
+namespace
+{
+
+Ice::TCPEndpointInfoPtr
+getTCPEndpointInfo(const Ice::EndpointInfoPtr& info)
+{
+ for(Ice::EndpointInfoPtr p = info; p; p = p->underlying)
+ {
+ Ice::TCPEndpointInfoPtr tcpInfo = ICE_DYNAMIC_CAST(Ice::TCPEndpointInfo, p);
+ if(tcpInfo)
+ {
+ return tcpInfo;
+ }
+ }
+ return ICE_NULLPTR;
+}
+
+Ice::TCPConnectionInfoPtr
+getTCPConnectionInfo(const Ice::ConnectionInfoPtr& info)
+{
+ for(Ice::ConnectionInfoPtr p = info; p; p = p->underlying)
+ {
+ Ice::TCPConnectionInfoPtr tcpInfo = ICE_DYNAMIC_CAST(Ice::TCPConnectionInfo, p);
+ if(tcpInfo)
+ {
+ return tcpInfo;
+ }
+ }
+ return ICE_NULLPTR;
+}
+
+}
+
void
allTests(const Ice::CommunicatorPtr& communicator)
{
@@ -27,7 +60,8 @@ allTests(const Ice::CommunicatorPtr& communicator)
Ice::EndpointSeq endps = p1->ice_getEndpoints();
- Ice::IPEndpointInfoPtr ipEndpoint = ICE_DYNAMIC_CAST(Ice::IPEndpointInfo, endps[0]->getInfo());
+ Ice::EndpointInfoPtr info = endps[0]->getInfo();
+ Ice::TCPEndpointInfoPtr ipEndpoint = getTCPEndpointInfo(info);
test(ipEndpoint);
test(ipEndpoint->host == "tcphost");
test(ipEndpoint->port == 10000);
@@ -38,13 +72,14 @@ allTests(const Ice::CommunicatorPtr& communicator)
test(ipEndpoint->compress);
test(!ipEndpoint->datagram());
test((ipEndpoint->type() == Ice::TCPEndpointType && !ipEndpoint->secure()) ||
- (ipEndpoint->type() == IceSSL::EndpointType && ipEndpoint->secure()) ||
+ (ipEndpoint->type() == Ice::SSLEndpointType && ipEndpoint->secure()) ||
(ipEndpoint->type() == Ice::WSEndpointType && !ipEndpoint->secure()) ||
(ipEndpoint->type() == Ice::WSSEndpointType && ipEndpoint->secure()));
- test((ipEndpoint->type() == Ice::TCPEndpointType && ICE_DYNAMIC_CAST(Ice::TCPEndpointInfo, ipEndpoint)) ||
- (ipEndpoint->type() == IceSSL::EndpointType && ICE_DYNAMIC_CAST(IceSSL::EndpointInfo, ipEndpoint)) ||
- (ipEndpoint->type() == Ice::WSEndpointType && ICE_DYNAMIC_CAST(Ice::WSEndpointInfo, ipEndpoint)) ||
- (ipEndpoint->type() == Ice::WSSEndpointType && ICE_DYNAMIC_CAST(IceSSL::WSSEndpointInfo, ipEndpoint)));
+
+ test((ipEndpoint->type() == Ice::TCPEndpointType && ICE_DYNAMIC_CAST(Ice::TCPEndpointInfo, info)) ||
+ (ipEndpoint->type() == Ice::SSLEndpointType && ICE_DYNAMIC_CAST(IceSSL::EndpointInfo, info)) ||
+ (ipEndpoint->type() == Ice::WSEndpointType && ICE_DYNAMIC_CAST(Ice::WSEndpointInfo, info)) ||
+ (ipEndpoint->type() == Ice::WSSEndpointType && ICE_DYNAMIC_CAST(Ice::WSEndpointInfo, info)));
Ice::UDPEndpointInfoPtr udpEndpoint = ICE_DYNAMIC_CAST(Ice::UDPEndpointInfo, endps[1]->getInfo());
test(udpEndpoint);
@@ -81,9 +116,9 @@ allTests(const Ice::CommunicatorPtr& communicator)
Ice::EndpointSeq publishedEndpoints = adapter->getPublishedEndpoints();
test(endpoints == publishedEndpoints);
- Ice::IPEndpointInfoPtr ipEndpoint = ICE_DYNAMIC_CAST(Ice::IPEndpointInfo, endpoints[0]->getInfo());
+ Ice::TCPEndpointInfoPtr ipEndpoint = getTCPEndpointInfo(endpoints[0]->getInfo());
test(ipEndpoint);
- test(ipEndpoint->type() == Ice::TCPEndpointType || ipEndpoint->type() == IceSSL::EndpointType ||
+ test(ipEndpoint->type() == Ice::TCPEndpointType || ipEndpoint->type() == Ice::SSLEndpointType ||
ipEndpoint->type() == Ice::WSEndpointType || ipEndpoint->type() == Ice::WSSEndpointType);
test(ipEndpoint->host == "127.0.0.1");
test(ipEndpoint->port > 0);
@@ -108,11 +143,11 @@ allTests(const Ice::CommunicatorPtr& communicator)
for(Ice::EndpointSeq::const_iterator p = endpoints.begin(); p != endpoints.end(); ++p)
{
- ipEndpoint = ICE_DYNAMIC_CAST(Ice::IPEndpointInfo, (*p)->getInfo());
+ ipEndpoint = getTCPEndpointInfo((*p)->getInfo());
test(ipEndpoint->port == 12020);
}
- ipEndpoint = ICE_DYNAMIC_CAST(Ice::IPEndpointInfo, publishedEndpoints[0]->getInfo());
+ ipEndpoint = getTCPEndpointInfo(publishedEndpoints[0]->getInfo());
test(ipEndpoint->host == "127.0.0.1");
test(ipEndpoint->port == 12020);
@@ -126,15 +161,15 @@ allTests(const Ice::CommunicatorPtr& communicator)
cout << "test connection endpoint information... " << flush;
{
Ice::EndpointInfoPtr info = base->ice_getConnection()->getEndpoint()->getInfo();
- Ice::IPEndpointInfoPtr ipinfo = ICE_DYNAMIC_CAST(Ice::IPEndpointInfo, info);
- test(ipinfo->port == 12010);
- test(!ipinfo->compress);
- test(ipinfo->host == defaultHost);
+ Ice::TCPEndpointInfoPtr tcpinfo = getTCPEndpointInfo(info);
+ test(tcpinfo->port == 12010);
+ test(!tcpinfo->compress);
+ test(tcpinfo->host == defaultHost);
ostringstream os;
Ice::Context ctx = testIntf->getEndpointInfoAsContext();
- test(ctx["host"] == ipinfo->host);
+ test(ctx["host"] == tcpinfo->host);
test(ctx["compress"] == "false");
istringstream is(ctx["port"]);
int port;
@@ -154,7 +189,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
Ice::ConnectionPtr connection = base->ice_getConnection();
connection->setBufferSize(1024, 2048);
- Ice::IPConnectionInfoPtr info = ICE_DYNAMIC_CAST(Ice::IPConnectionInfo, connection->getInfo());
+ Ice::TCPConnectionInfoPtr info = getTCPConnectionInfo(connection->getInfo());
test(info);
test(!info->incoming);
test(info->adapterName.empty());
@@ -188,16 +223,13 @@ allTests(const Ice::CommunicatorPtr& communicator)
{
Ice::HeaderDict headers;
- Ice::WSConnectionInfoPtr wsinfo = ICE_DYNAMIC_CAST(Ice::WSConnectionInfo, info);
- if(wsinfo)
- {
- headers = wsinfo->headers;
- }
+ Ice::WSConnectionInfoPtr wsinfo = ICE_DYNAMIC_CAST(Ice::WSConnectionInfo, connection->getInfo());
+ test(wsinfo);
+ headers = wsinfo->headers;
- IceSSL::WSSConnectionInfoPtr wssinfo = ICE_DYNAMIC_CAST(IceSSL::WSSConnectionInfo, info);
- if(wssinfo)
+ if(base->ice_getConnection()->type() == "wss")
{
- headers = wssinfo->headers;
+ IceSSL::ConnectionInfoPtr wssinfo = ICE_DYNAMIC_CAST(IceSSL::ConnectionInfo, wsinfo->underlying);
test(wssinfo->verified);
#if !defined(ICE_OS_WINRT) && TARGET_OS_IPHONE==0
test(!wssinfo->certs.empty());
@@ -219,20 +251,20 @@ allTests(const Ice::CommunicatorPtr& communicator)
connection = base->ice_datagram()->ice_getConnection();
connection->setBufferSize(2048, 1024);
- info = ICE_DYNAMIC_CAST(Ice::IPConnectionInfo, connection->getInfo());
- test(!info->incoming);
- test(info->adapterName.empty());
- test(info->localPort > 0);
- test(info->remotePort == 12010);
+ Ice::UDPConnectionInfoPtr udpinfo = ICE_DYNAMIC_CAST(Ice::UDPConnectionInfo, connection->getInfo());
+ test(!udpinfo->incoming);
+ test(udpinfo->adapterName.empty());
+ test(udpinfo->localPort > 0);
+ test(udpinfo->remotePort == 12010);
if(defaultHost == "127.0.0.1")
{
- test(info->remoteAddress == defaultHost);
- test(info->localAddress == defaultHost);
+ test(udpinfo->remoteAddress == defaultHost);
+ test(udpinfo->localAddress == defaultHost);
}
#if !defined(ICE_OS_WINRT)
- test(info->rcvSize >= 2048);
- test(info->sndSize >= 1024);
+ test(udpinfo->rcvSize >= 2048);
+ test(udpinfo->sndSize >= 1024);
#endif
}
cout << "ok" << endl;
diff --git a/cpp/test/Ice/info/TestI.cpp b/cpp/test/Ice/info/TestI.cpp
index ddacb9874dc..06e17ab89a1 100644
--- a/cpp/test/Ice/info/TestI.cpp
+++ b/cpp/test/Ice/info/TestI.cpp
@@ -16,6 +16,39 @@ using namespace std;
using namespace Ice;
using namespace Test;
+namespace
+{
+
+Ice::IPEndpointInfoPtr
+getIPEndpointInfo(const Ice::EndpointInfoPtr& info)
+{
+ for(Ice::EndpointInfoPtr p = info; p; p = p->underlying)
+ {
+ Ice::IPEndpointInfoPtr ipInfo = ICE_DYNAMIC_CAST(Ice::IPEndpointInfo, p);
+ if(ipInfo)
+ {
+ return ipInfo;
+ }
+ }
+ return ICE_NULLPTR;
+}
+
+Ice::IPConnectionInfoPtr
+getIPConnectionInfo(const Ice::ConnectionInfoPtr& info)
+{
+ for(Ice::ConnectionInfoPtr p = info; p; p = p->underlying)
+ {
+ Ice::IPConnectionInfoPtr ipInfo = ICE_DYNAMIC_CAST(Ice::IPConnectionInfo, p);
+ if(ipInfo)
+ {
+ return ipInfo;
+ }
+ }
+ return ICE_NULLPTR;
+}
+
+}
+
void
TestI::shutdown(const Ice::Current& current)
{
@@ -38,8 +71,8 @@ TestI::getEndpointInfoAsContext(const Ice::Current& c)
os << info->type();
ctx["type"] = os.str();
- Ice::IPEndpointInfoPtr ipinfo = ICE_DYNAMIC_CAST(Ice::IPEndpointInfo, info);
- test(info);
+ Ice::IPEndpointInfoPtr ipinfo = getIPEndpointInfo(info);
+ test(ipinfo);
ctx["host"] = ipinfo->host;
os.str("");
os << ipinfo->port;
@@ -64,7 +97,7 @@ TestI::getConnectionInfoAsContext(const Ice::Current& c)
ctx["incoming"] = info->incoming ? "true" : "false";
ostringstream os;
- Ice::IPConnectionInfoPtr ipinfo = ICE_DYNAMIC_CAST(Ice::IPConnectionInfo, info);
+ Ice::IPConnectionInfoPtr ipinfo = getIPConnectionInfo(info);
test(ipinfo);
ctx["localAddress"] = ipinfo->localAddress;
os.str("");
@@ -84,14 +117,5 @@ TestI::getConnectionInfoAsContext(const Ice::Current& c)
}
}
- IceSSL::WSSConnectionInfoPtr wssinfo = ICE_DYNAMIC_CAST(IceSSL::WSSConnectionInfo, info);
- if(wssinfo)
- {
- for(Ice::HeaderDict::const_iterator p = wssinfo->headers.begin(); p != wssinfo->headers.end(); ++p)
- {
- ctx["ws." + p->first] = p->second;
- }
- }
-
return ctx;
}
diff --git a/cpp/test/Ice/metrics/AllTests.cpp b/cpp/test/Ice/metrics/AllTests.cpp
index 08e6ba8e8af..86fba324ef5 100644
--- a/cpp/test/Ice/metrics/AllTests.cpp
+++ b/cpp/test/Ice/metrics/AllTests.cpp
@@ -494,6 +494,24 @@ allTests(const Ice::CommunicatorPtr& communicator, const CommunicatorObserverIPt
map<string, IceMX::MetricsPtr> map;
+ string endpoint;
+ {
+ ostringstream os;
+ os << communicator->getProperties()->getPropertyWithDefault("Ice.Default.Protocol", "tcp") << " -h 127.0.0.1 -p 12010";
+ endpoint = os.str();
+ }
+ string type;
+ string isSecure;
+ if(!collocated)
+ {
+ Ice::EndpointInfoPtr endpointInfo = metrics->ice_getConnection()->getEndpoint()->getInfo();
+ {
+ ostringstream os;
+ os << endpointInfo->type();
+ type = os.str();
+ }
+ isSecure = endpointInfo->secure() ? "true": "false";
+ }
if(!collocated)
{
cout << "testing connection metrics... " << flush;
@@ -567,7 +585,8 @@ allTests(const Ice::CommunicatorPtr& communicator, const CommunicatorObserverIPt
updateProps(clientProps, serverProps, update.get(), props, "Connection");
map = toMap(serverMetrics->getMetricsView("View", timestamp)["Connection"]);
-
+ test(map["active"]->current == 1);
+ map = toMap(clientMetrics->getMetricsView("View", timestamp)["Connection"]);
test(map["active"]->current == 1);
ControllerPrxPtr controller = ICE_CHECKED_CAST(ControllerPrx, communicator->stringToProxy("controller:default -p 12011"));
@@ -631,11 +650,10 @@ allTests(const Ice::CommunicatorPtr& communicator, const CommunicatorObserverIPt
testAttribute(clientMetrics, clientProps, update.get(), "Connection", "parent", "Communicator");
//testAttribute(clientMetrics, clientProps, update.get(), "Connection", "id", "");
- testAttribute(clientMetrics, clientProps, update.get(), "Connection", "endpoint", "tcp -h 127.0.0.1 -p 12010 -t 500");
-
- testAttribute(clientMetrics, clientProps, update.get(), "Connection", "endpointType", "1");
+ testAttribute(clientMetrics, clientProps, update.get(), "Connection", "endpoint", endpoint + " -t 500");
+ testAttribute(clientMetrics, clientProps, update.get(), "Connection", "endpointType", type);
testAttribute(clientMetrics, clientProps, update.get(), "Connection", "endpointIsDatagram", "false");
- testAttribute(clientMetrics, clientProps, update.get(), "Connection", "endpointIsSecure", "false");
+ testAttribute(clientMetrics, clientProps, update.get(), "Connection", "endpointIsSecure", isSecure);
testAttribute(clientMetrics, clientProps, update.get(), "Connection", "endpointTimeout", "500");
testAttribute(clientMetrics, clientProps, update.get(), "Connection", "endpointCompress", "false");
testAttribute(clientMetrics, clientProps, update.get(), "Connection", "endpointHost", "127.0.0.1");
@@ -695,11 +713,11 @@ allTests(const Ice::CommunicatorPtr& communicator, const CommunicatorObserverIPt
testAttribute(clientMetrics, clientProps, update.get(), "ConnectionEstablishment", "parent", "Communicator", c);
testAttribute(clientMetrics, clientProps, update.get(), "ConnectionEstablishment", "id", "127.0.0.1:12010", c);
testAttribute(clientMetrics, clientProps, update.get(), "ConnectionEstablishment", "endpoint",
- "tcp -h 127.0.0.1 -p 12010 -t 60000", c);
+ endpoint + " -t 60000", c);
- testAttribute(clientMetrics, clientProps, update.get(), "ConnectionEstablishment", "endpointType", "1", c);
+ testAttribute(clientMetrics, clientProps, update.get(), "ConnectionEstablishment", "endpointType", type, c);
testAttribute(clientMetrics, clientProps, update.get(), "ConnectionEstablishment", "endpointIsDatagram", "false", c);
- testAttribute(clientMetrics, clientProps, update.get(), "ConnectionEstablishment", "endpointIsSecure", "false", c);
+ testAttribute(clientMetrics, clientProps, update.get(), "ConnectionEstablishment", "endpointIsSecure", isSecure, c);
testAttribute(clientMetrics, clientProps, update.get(), "ConnectionEstablishment", "endpointTimeout", "60000", c);
testAttribute(clientMetrics, clientProps, update.get(), "ConnectionEstablishment", "endpointCompress", "false", c);
testAttribute(clientMetrics, clientProps, update.get(), "ConnectionEstablishment", "endpointHost", "127.0.0.1", c);
@@ -724,7 +742,7 @@ allTests(const Ice::CommunicatorPtr& communicator, const CommunicatorObserverIPt
test(clientMetrics->getMetricsView("View", timestamp)["EndpointLookup"].size() == 1);
m1 = clientMetrics->getMetricsView("View", timestamp)["EndpointLookup"][0];
- test(m1->current <= 1 && m1->total == 1 && m1->id == "tcp -h localhost -p 12010 -t infinite");
+ test(m1->current <= 1 && m1->total == 1 && m1->id == prx->ice_getConnection()->getEndpoint()->toString());
prx->ice_getConnection()->close(false);
@@ -755,13 +773,13 @@ allTests(const Ice::CommunicatorPtr& communicator, const CommunicatorObserverIPt
testAttribute(clientMetrics, clientProps, update.get(), "EndpointLookup", "parent", "Communicator", c);
testAttribute(clientMetrics, clientProps, update.get(), "EndpointLookup", "id",
- "tcp -h localhost -p 12010 -t infinite", c);
+ prx->ice_getConnection()->getEndpoint()->toString(), c);
testAttribute(clientMetrics, clientProps, update.get(), "EndpointLookup", "endpoint",
- "tcp -h localhost -p 12010 -t infinite", c);
+ prx->ice_getConnection()->getEndpoint()->toString(), c);
- testAttribute(clientMetrics, clientProps, update.get(), "EndpointLookup", "endpointType", "1", c);
+ testAttribute(clientMetrics, clientProps, update.get(), "EndpointLookup", "endpointType", type, c);
testAttribute(clientMetrics, clientProps, update.get(), "EndpointLookup", "endpointIsDatagram", "false", c);
- testAttribute(clientMetrics, clientProps, update.get(), "EndpointLookup", "endpointIsSecure", "false", c);
+ testAttribute(clientMetrics, clientProps, update.get(), "EndpointLookup", "endpointIsSecure", isSecure, c);
testAttribute(clientMetrics, clientProps, update.get(), "EndpointLookup", "endpointTimeout", "-1", c);
testAttribute(clientMetrics, clientProps, update.get(), "EndpointLookup", "endpointCompress", "false", c);
testAttribute(clientMetrics, clientProps, update.get(), "EndpointLookup", "endpointHost", "localhost", c);
@@ -861,13 +879,12 @@ allTests(const Ice::CommunicatorPtr& communicator, const CommunicatorObserverIPt
testAttribute(serverMetrics, serverProps, update.get(), "Dispatch", "id", "metrics [op]", op);
if(!collocated)
{
- testAttribute(serverMetrics, serverProps, update.get(), "Dispatch", "endpoint", "tcp -h 127.0.0.1 -p 12010 -t 60000",
- op);
+ testAttribute(serverMetrics, serverProps, update.get(), "Dispatch", "endpoint", endpoint + " -t 60000", op);
//testAttribute(serverMetrics, serverProps, update.get(), "Dispatch", "connection", "", op);
- testAttribute(serverMetrics, serverProps, update.get(), "Dispatch", "endpointType", "1", op);
+ testAttribute(serverMetrics, serverProps, update.get(), "Dispatch", "endpointType", type, op);
testAttribute(serverMetrics, serverProps, update.get(), "Dispatch", "endpointIsDatagram", "false", op);
- testAttribute(serverMetrics, serverProps, update.get(), "Dispatch", "endpointIsSecure", "false", op);
+ testAttribute(serverMetrics, serverProps, update.get(), "Dispatch", "endpointIsSecure", isSecure, op);
testAttribute(serverMetrics, serverProps, update.get(), "Dispatch", "endpointTimeout", "60000", op);
testAttribute(serverMetrics, serverProps, update.get(), "Dispatch", "endpointCompress", "false", op);
testAttribute(serverMetrics, serverProps, update.get(), "Dispatch", "endpointHost", "127.0.0.1", op);
@@ -1275,8 +1292,7 @@ allTests(const Ice::CommunicatorPtr& communicator, const CommunicatorObserverIPt
testAttribute(clientMetrics, clientProps, update.get(), "Invocation", "encoding", "1.1", op);
testAttribute(clientMetrics, clientProps, update.get(), "Invocation", "mode", "twoway", op);
testAttribute(clientMetrics, clientProps, update.get(), "Invocation", "proxy",
- "metrics -t -e 1.1:tcp -h 127.0.0.1 -p 12010 -t 60000", op);
-
+ "metrics -t -e 1.1:" + endpoint + " -t 60000", op);
testAttribute(clientMetrics, clientProps, update.get(), "Invocation", "context.entry1", "test", op);
testAttribute(clientMetrics, clientProps, update.get(), "Invocation", "context.entry2", "", op);
testAttribute(clientMetrics, clientProps, update.get(), "Invocation", "context.entry3", "", op);
diff --git a/cpp/test/Ice/metrics/Client.cpp b/cpp/test/Ice/metrics/Client.cpp
index 88c19ae6f18..65611a7de95 100644
--- a/cpp/test/Ice/metrics/Client.cpp
+++ b/cpp/test/Ice/metrics/Client.cpp
@@ -36,7 +36,7 @@ main(int argc, char* argv[])
{
Ice::InitializationData initData;
initData.properties = Ice::createProperties(argc, argv);
- initData.properties->setProperty("Ice.Admin.Endpoints", "tcp");
+ initData.properties->setProperty("Ice.Admin.Endpoints", "default");
initData.properties->setProperty("Ice.Admin.InstanceName", "client");
initData.properties->setProperty("Ice.Admin.DelayCreation", "1");
initData.properties->setProperty("Ice.Warn.Connections", "0");
diff --git a/cpp/test/Ice/networkProxy/AllTests.cpp b/cpp/test/Ice/networkProxy/AllTests.cpp
index 3ab6aedcffd..f1d2fa1fe71 100644
--- a/cpp/test/Ice/networkProxy/AllTests.cpp
+++ b/cpp/test/Ice/networkProxy/AllTests.cpp
@@ -14,6 +14,25 @@
using namespace std;
using namespace Test;
+namespace
+{
+
+Ice::IPConnectionInfoPtr
+getIPConnectionInfo(const Ice::ConnectionInfoPtr& info)
+{
+ for(Ice::ConnectionInfoPtr p = info; p; p = p->underlying)
+ {
+ Ice::IPConnectionInfoPtr ipInfo = ICE_DYNAMIC_CAST(Ice::IPConnectionInfo, p);
+ if(ipInfo)
+ {
+ return ipInfo;
+ }
+ }
+ return ICE_NULLPTR;
+}
+
+}
+
void
allTests(const Ice::CommunicatorPtr& communicator)
{
@@ -32,7 +51,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
cout << "testing connection information... " << flush;
{
- Ice::IPConnectionInfoPtr info = ICE_DYNAMIC_CAST(Ice::IPConnectionInfo, test->ice_getConnection()->getInfo());
+ Ice::IPConnectionInfoPtr info = getIPConnectionInfo(test->ice_getConnection()->getInfo());
test(info->remotePort == 12030 || info->remotePort == 12031); // make sure we are connected to the proxy port.
}
cout << "ok" << endl;
diff --git a/cpp/test/Ice/operations/Client.cpp b/cpp/test/Ice/operations/Client.cpp
index 73b19851fb0..a000b049a77 100644
--- a/cpp/test/Ice/operations/Client.cpp
+++ b/cpp/test/Ice/operations/Client.cpp
@@ -17,7 +17,7 @@ using namespace std;
int
run(int, char**, const Ice::CommunicatorPtr& communicator, bool remote)
-{
+{
Test::MyClassPrxPtr allTests(const Ice::CommunicatorPtr&);
Test::MyClassPrxPtr myClass = allTests(communicator);
@@ -67,8 +67,7 @@ main(int argc, char* argv[])
initData.properties = Ice::createProperties(argc, argv);
initData.properties->setProperty("Ice.ThreadPool.Client.Size", "2");
initData.properties->setProperty("Ice.ThreadPool.Client.SizeWarn", "0");
-
- initData.properties->setProperty("Ice.BatchAutoFlushSize", "100");
+ initData.properties->setProperty("Ice.BatchAutoFlushSize", "100");
Ice::CommunicatorHolder ich = Ice::initialize(argc, argv, initData);
RemoteConfig rc("Ice/operations", argc, argv, ich.communicator());
diff --git a/cpp/test/Ice/slicing/exceptions/AllTests.cpp b/cpp/test/Ice/slicing/exceptions/AllTests.cpp
index 28e11dae7b4..b510a7f0c76 100644
--- a/cpp/test/Ice/slicing/exceptions/AllTests.cpp
+++ b/cpp/test/Ice/slicing/exceptions/AllTests.cpp
@@ -411,7 +411,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
{
test(false);
}
-
+
#else
CallbackPtr cb = new Callback;
test->begin_baseAsBase(
@@ -557,7 +557,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
#else
CallbackPtr cb = new Callback;
test->begin_knownDerivedAsKnownDerived(
- newCallback_TestIntf_knownDerivedAsKnownDerived(cb, &Callback::response,
+ newCallback_TestIntf_knownDerivedAsKnownDerived(cb, &Callback::response,
&Callback::exception_knownDerivedAsKnownDerived));
cb->check();
#endif
@@ -604,7 +604,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
#else
CallbackPtr cb = new Callback;
test->begin_unknownIntermediateAsBase(
- newCallback_TestIntf_unknownIntermediateAsBase(cb, &Callback::response,
+ newCallback_TestIntf_unknownIntermediateAsBase(cb, &Callback::response,
&Callback::exception_unknownIntermediateAsBase));
cb->check();
#endif
@@ -653,7 +653,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
#else
CallbackPtr cb = new Callback;
test->begin_knownIntermediateAsBase(
- newCallback_TestIntf_knownIntermediateAsBase(cb, &Callback::response,
+ newCallback_TestIntf_knownIntermediateAsBase(cb, &Callback::response,
&Callback::exception_knownIntermediateAsBase));
cb->check();
#endif
@@ -704,7 +704,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
#else
CallbackPtr cb = new Callback;
test->begin_knownMostDerivedAsBase(
- newCallback_TestIntf_knownMostDerivedAsBase(cb, &Callback::response,
+ newCallback_TestIntf_knownMostDerivedAsBase(cb, &Callback::response,
&Callback::exception_knownMostDerivedAsBase));
cb->check();
#endif
@@ -753,7 +753,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
#else
CallbackPtr cb = new Callback;
test->begin_knownIntermediateAsKnownIntermediate(
- newCallback_TestIntf_knownIntermediateAsKnownIntermediate(cb, &Callback::response,
+ newCallback_TestIntf_knownIntermediateAsKnownIntermediate(cb, &Callback::response,
&Callback::exception_knownIntermediateAsKnownIntermediate));
cb->check();
#endif
@@ -804,7 +804,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
#else
CallbackPtr cb = new Callback;
test->begin_knownMostDerivedAsKnownIntermediate(
- newCallback_TestIntf_knownMostDerivedAsKnownIntermediate(cb, &Callback::response,
+ newCallback_TestIntf_knownMostDerivedAsKnownIntermediate(cb, &Callback::response,
&Callback::exception_knownMostDerivedAsKnownIntermediate));
cb->check();
#endif
@@ -855,7 +855,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
#else
CallbackPtr cb = new Callback;
test->begin_knownMostDerivedAsKnownMostDerived(
- newCallback_TestIntf_knownMostDerivedAsKnownMostDerived(cb, &Callback::response,
+ newCallback_TestIntf_knownMostDerivedAsKnownMostDerived(cb, &Callback::response,
&Callback::exception_knownMostDerivedAsKnownMostDerived));
cb->check();
#endif
@@ -904,7 +904,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
#else
CallbackPtr cb = new Callback;
test->begin_unknownMostDerived1AsBase(
- newCallback_TestIntf_unknownMostDerived1AsBase(cb, &Callback::response,
+ newCallback_TestIntf_unknownMostDerived1AsBase(cb, &Callback::response,
&Callback::exception_unknownMostDerived1AsBase));
cb->check();
#endif
@@ -953,7 +953,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
#else
CallbackPtr cb = new Callback;
test->begin_unknownMostDerived1AsKnownIntermediate(
- newCallback_TestIntf_unknownMostDerived1AsKnownIntermediate(cb, &Callback::response,
+ newCallback_TestIntf_unknownMostDerived1AsKnownIntermediate(cb, &Callback::response,
&Callback::exception_unknownMostDerived1AsKnownIntermediate));
cb->check();
#endif
@@ -1000,7 +1000,7 @@ allTests(const Ice::CommunicatorPtr& communicator)
#else
CallbackPtr cb = new Callback;
test->begin_unknownMostDerived2AsBase(
- newCallback_TestIntf_unknownMostDerived2AsBase(cb, &Callback::response,
+ newCallback_TestIntf_unknownMostDerived2AsBase(cb, &Callback::response,
&Callback::exception_unknownMostDerived2AsBase));
cb->check();
#endif
@@ -1072,11 +1072,6 @@ allTests(const Ice::CommunicatorPtr& communicator)
catch(const Ice::OperationNotExistException&)
{
}
- catch(const Ice::LocalException& ex)
- {
- cout << endl << "** OOPS" << endl << ex << endl;
- test(false);
- }
catch(...)
{
test(false);
diff --git a/cpp/test/IceSSL/configuration/AllTests.cpp b/cpp/test/IceSSL/configuration/AllTests.cpp
index 3313424859a..65d4d031640 100644
--- a/cpp/test/IceSSL/configuration/AllTests.cpp
+++ b/cpp/test/IceSSL/configuration/AllTests.cpp
@@ -2,7 +2,7 @@
//
// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved.
//
-// This copy of Ice is licensed to you under the terms described in the
+// This copy of Ice is licensed to you under the terms dribed in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
@@ -15,6 +15,9 @@
#ifdef __APPLE__
# include <sys/sysctl.h>
+#if TARGET_OS_IPHONE != 0
+#include <IceSSL/Util.h> // For loadCertificateChain
+#endif
#endif
#ifdef ICE_CPP11_MAPPING
@@ -141,6 +144,83 @@ private:
vector<PCCERT_CONTEXT> _certs;
};
+#elif defined(__APPLE__) && TARGET_OS_IPHONE != 0
+class ImportCerts
+{
+public:
+
+ ImportCerts(const string& defaultDir, const char* certificates[])
+ {
+ for(int i = 0; certificates[i] != 0; ++i)
+ {
+ string resolved;
+ if(IceSSL::checkPath(certificates[i], defaultDir, false, resolved))
+ {
+ CFArrayRef certs = IceSSL::loadCertificateChain(resolved, "", "", "", "password", 0, 0);
+ SecIdentityRef identity = (SecIdentityRef)CFArrayGetValueAtIndex(certs, 0);
+ CFRetain(identity);
+ _identities.push_back(identity);
+ OSStatus err;
+ CFMutableDictionaryRef query;
+
+ query = CFDictionaryCreateMutable(0, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+ CFDictionarySetValue(query, kSecValueRef, identity);
+ if((err = SecItemAdd(query, 0)))
+ {
+ cerr << "failed to add identity " << certificates[i] << ": " << err << endl;
+ }
+ CFRelease(query);
+
+ // query = CFDictionaryCreateMutable(0, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+ // CFDictionarySetValue(query, kSecClass, kSecClassCertificate);
+ // CFDictionarySetValue(query, kSecReturnRef, kCFBooleanTrue);
+ // CFDictionarySetValue(query, kSecMatchLimit, kSecMatchLimitAll);
+ // CFArrayRef array = 0;
+ // err = SecItemCopyMatching(query, (CFTypeRef*)&array);
+ // printf("Certificates\n");
+ // for(int i = 0; i < CFArrayGetCount(array); ++i)
+ // {
+ // printf("Cert %d: %s\n", i, (new IceSSL::Certificate((SecCertificateRef)CFArrayGetValueAtIndex(array, i)))->toString().c_str());
+ // }
+ // CFRelease(certs);
+ }
+ }
+ // Nothing to do.
+ }
+
+ ~ImportCerts()
+ {
+ cleanup();
+ }
+
+ void cleanup()
+ {
+ CFMutableDictionaryRef query;
+ for(vector<SecIdentityRef>::const_iterator p = _identities.begin(); p != _identities.end(); ++p)
+ {
+ query = CFDictionaryCreateMutable(0, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+ CFDictionarySetValue(query, kSecClass, kSecClassIdentity);
+ CFDictionarySetValue(query, kSecValueRef, *p);
+ SecItemDelete(query);
+ CFRelease(query);
+
+ SecCertificateRef cert;
+ SecIdentityCopyCertificate(*p, &cert);
+ query = CFDictionaryCreateMutable(0, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+ CFDictionarySetValue(query, kSecClass, kSecClassCertificate);
+ CFDictionarySetValue(query, kSecValueRef, cert);
+ SecItemDelete(query);
+ CFRelease(query);
+
+ CFRelease(*p);
+ }
+ _identities.clear();
+ }
+
+private:
+
+ vector<SecIdentityRef> _identities;
+};
#else
class ImportCerts
{
@@ -197,6 +277,7 @@ public:
{
if(info->nativeCerts.size() > 0)
{
+#if !defined(__APPLE__) || TARGET_OS_IPHONE == 0
//
// Subject alternative name
//
@@ -243,6 +324,7 @@ public:
test(find(ipAddresses.begin(), ipAddresses.end(), "127.0.0.1") != ipAddresses.end());
test(find(emailAddresses.begin(), emailAddresses.end(), "issuer@zeroc.com") != emailAddresses.end());
}
+#endif
}
_hadCert = info->nativeCerts.size() != 0;
@@ -306,7 +388,8 @@ createClientProps(const Ice::PropertiesPtr& defaultProps, const string& defaultD
{
result->setProperty("IceSSL.Password", "password");
}
- //result->setProperty("IceSSL.Trace.Security", "1");
+// result->setProperty("IceSSL.Trace.Security", "1");
+// result->setProperty("Ice.Trace.Network", "1");
#ifdef ICE_USE_SECURE_TRANSPORT
ostringstream keychainName;
keychainName << "../certs/keychain/client" << keychainN++ << ".keychain";
@@ -338,7 +421,8 @@ createServerProps(const Ice::PropertiesPtr& defaultProps, const string& defaultD
{
result["IceSSL.Password"] = "password";
}
- //result["IceSSL.Trace.Security"] = "1";
+// result["Ice.Trace.Network"] = "1";
+// result["IceSSL.Trace.Security"] = "1";
#ifdef ICE_USE_SECURE_TRANSPORT
ostringstream keychainName;
keychainName << "../certs/keychain/server" << keychainN << ".keychain";
@@ -420,8 +504,8 @@ void verify(const IceSSL::CertificatePtr& cert, const IceSSL::CertificatePtr& ca
cerr << endl;
}
-void
-allTests(const CommunicatorPtr& communicator, const string& testDir, bool p12, bool shutdown)
+Test::ServerFactoryPrxPtr
+allTests(const CommunicatorPtr& communicator, const string& testDir, bool p12)
{
bool elCapitanUpdate2OrLower = false;
#ifdef __APPLE__
@@ -441,14 +525,19 @@ allTests(const CommunicatorPtr& communicator, const string& testDir, bool p12, b
}
}
#endif
-
- string factoryRef = "factory:tcp -p 12010";
+ string endpt = getTestEndpoint(communicator, 0);
+ string factoryRef = "factory:" + endpt;
ObjectPrxPtr base = communicator->stringToProxy(factoryRef);
test(base);
Test::ServerFactoryPrxPtr factory = ICE_CHECKED_CAST(Test::ServerFactoryPrx, base);
string defaultHost = communicator->getProperties()->getProperty("Ice.Default.Host");
+#if !defined(__APPLE__) || TARGET_OS_IPHONE == 0
string defaultDir = testDir + "/../certs";
+#else
+ string defaultDir = "certs";
+#endif
+
Ice::PropertiesPtr defaultProps = communicator->getProperties();
#ifdef _WIN32
string sep = ";";
@@ -484,7 +573,7 @@ allTests(const CommunicatorPtr& communicator, const string& testDir, bool p12, b
//
// Anonymous cipher are not supported with SChannel
//
-#ifndef ICE_USE_SCHANNEL
+#if !defined(ICE_USE_SCHANNEL)
{
InitializationData initData;
initData.properties = createClientProps(defaultProps, defaultDir, defaultHost, p12);
@@ -647,16 +736,22 @@ allTests(const CommunicatorPtr& communicator, const string& testDir, bool p12, b
IceSSL::CertificatePtr serverCert = IceSSL::Certificate::load(defaultDir + "/s_rsa_ca1_pub.pem");
test(ICE_TARGET_EQUALS(IceSSL::Certificate::decode(serverCert->encode()), serverCert));
test(ICE_TARGET_EQUALS(serverCert, serverCert));
+#if !defined(__APPLE__) || TARGET_OS_IPHONE == 0
test(serverCert->checkValidity());
test(!serverCert->checkValidity(IceUtil::Time::seconds(0)));
+#endif
IceSSL::CertificatePtr caCert = IceSSL::Certificate::load(defaultDir + "/cacert1.pem");
+ IceSSL::CertificatePtr caCert2 = IceSSL::Certificate::load(defaultDir + "/cacert2.pem");
test(ICE_TARGET_EQUALS(caCert, caCert));
+#if !defined(__APPLE__) || TARGET_OS_IPHONE == 0
test(caCert->checkValidity());
test(!caCert->checkValidity(IceUtil::Time::seconds(0)));
+#endif
test(!serverCert->verify(serverCert));
test(serverCert->verify(caCert));
+ test(!serverCert->verify(caCert2));
test(caCert->verify(caCert));
info = ICE_DYNAMIC_CAST(IceSSL::NativeConnectionInfo, server->ice_getConnection()->getInfo());
@@ -669,9 +764,11 @@ allTests(const CommunicatorPtr& communicator, const string& testDir, bool p12, b
test(!(ICE_TARGET_EQUALS(serverCert, info->nativeCerts[1])));
test(!(ICE_TARGET_EQUALS(caCert, info->nativeCerts[0])));
+#if !defined(__APPLE__) || TARGET_OS_IPHONE == 0
test(info->nativeCerts[0]->checkValidity() && info->nativeCerts[1]->checkValidity());
test(!info->nativeCerts[0]->checkValidity(IceUtil::Time::seconds(0)) &&
!info->nativeCerts[1]->checkValidity(IceUtil::Time::seconds(0)));
+#endif
test(info->nativeCerts[0]->verify(info->nativeCerts[1]));
test(info->nativeCerts.size() == 2 &&
info->nativeCerts[0]->getSubjectDN() == serverCert->getSubjectDN() &&
@@ -874,8 +971,9 @@ allTests(const CommunicatorPtr& communicator, const string& testDir, bool p12, b
{
server->ice_ping();
}
- catch(const LocalException&)
+ catch(const LocalException& ex)
{
+ cerr << ex << endl;
test(false);
}
fact->destroyServer(server);
@@ -1589,10 +1687,12 @@ allTests(const CommunicatorPtr& communicator, const string& testDir, bool p12, b
//
// This should fail because the server's certificate is expired.
//
+#if !defined(__APPLE__) || TARGET_OS_IPHONE == 0
{
IceSSL::CertificatePtr cert = IceSSL::Certificate::load(defaultDir + "/s_rsa_ca1_exp_pub.pem");
test(!cert->checkValidity());
}
+#endif
InitializationData initData;
initData.properties = createClientProps(defaultProps, defaultDir, defaultHost, p12, "c_rsa_ca1", "cacert1");
@@ -1621,10 +1721,12 @@ allTests(const CommunicatorPtr& communicator, const string& testDir, bool p12, b
//
// This should fail because the client's certificate is expired.
//
+#if !defined(__APPLE__) || TARGET_OS_IPHONE == 0
{
IceSSL::CertificatePtr cert = IceSSL::Certificate::load(defaultDir + "/c_rsa_ca1_exp_pub.pem");
test(!cert->checkValidity());
}
+#endif
initData.properties = createClientProps(defaultProps, defaultDir, defaultHost, p12, "c_rsa_ca1_exp", "cacert1");
comm = initialize(initData);
@@ -2193,9 +2295,14 @@ allTests(const CommunicatorPtr& communicator, const string& testDir, bool p12, b
cout << "ok" << endl;
cout << "testing IceSSL.TrustOnly... " << flush;
+ //
+ // iOS support only provides access to the CN of the certificate so we
+ // can't check for other attributes
+ //
{
InitializationData initData;
initData.properties = createClientProps(defaultProps, defaultDir, defaultHost, p12, "c_rsa_ca1", "cacert1");
+ initData.properties->setProperty("IceSSL.TrustOnly", "CN=Server");
initData.properties->setProperty("IceSSL.TrustOnly", "C=US, ST=Florida, O=ZeroC\\, Inc.,"
"OU=Ice, emailAddress=info@zeroc.com, CN=Server");
CommunicatorPtr comm = initialize(initData);
@@ -2568,7 +2675,7 @@ allTests(const CommunicatorPtr& communicator, const string& testDir, bool p12, b
test(fact);
Test::Properties d = createServerProps(defaultProps, defaultDir, defaultHost, p12, "s_rsa_ca1", "cacert1");
d["IceSSL.VerifyPeer"] = "0";
- d["IceSSL.TrustOnly"] = "C=US, ST=Florida, O=ZeroC\\, Inc.,OU=Ice, emailAddress=info@zeroc.com, CN=Client";
+ d["IceSSL.TrustOnly"] = "CN=Client";
Test::ServerPrxPtr server = fact->createServer(d);
try
{
@@ -2593,7 +2700,7 @@ allTests(const CommunicatorPtr& communicator, const string& testDir, bool p12, b
Test::ServerFactoryPrxPtr fact = ICE_CHECKED_CAST(Test::ServerFactoryPrx, comm->stringToProxy(factoryRef));
test(fact);
Test::Properties d = createServerProps(defaultProps, defaultDir, defaultHost, p12, "s_rsa_ca1", "cacert1");
- d["IceSSL.TrustOnly"] = "!C=US, ST=Florida, O=ZeroC\\, Inc.,OU=Ice, emailAddress=info@zeroc.com, CN=Client";
+ d["IceSSL.TrustOnly"] = "!CN=Client";
d["IceSSL.VerifyPeer"] = "0";
Test::ServerPrxPtr server = fact->createServer(d);
try
@@ -3116,7 +3223,7 @@ allTests(const CommunicatorPtr& communicator, const string& testDir, bool p12, b
cout << "testing IceSSL.FindCert... " << flush;
const char* clientFindCertProperties[] =
{
- "SUBJECT:Client",
+// "SUBJECT:Client",
"LABEL:'Client'",
"SUBJECTKEYID:'FC 5D 4F AB F0 6C 03 11 B8 F3 68 CF 89 54 92 3F F9 79 2A 06'",
"SERIAL:02",
@@ -3126,7 +3233,10 @@ allTests(const CommunicatorPtr& communicator, const string& testDir, bool p12, b
const char* serverFindCertProperties[] =
{
+#if !defined(__APPLE__) || TARGET_OS_IPHONE == 0
+ // iOS match on Subject DN isn't supported by SecItemCopyMatch
"SUBJECT:Server",
+#endif
"LABEL:'Server'",
"SUBJECTKEYID:'47 84 AE F9 F2 85 3D 99 30 6A 03 38 41 1A B9 EB C3 9C B5 4D'",
"SERIAL:01",
@@ -3139,7 +3249,10 @@ allTests(const CommunicatorPtr& communicator, const string& testDir, bool p12, b
"nolabel",
"unknownlabel:foo",
"LABEL:",
+#if !defined(__APPLE__) || TARGET_OS_IPHONE == 0
+ // iOS match on Subject DN isn't supported by SecItemCopyMatch
"SUBJECT:ServerX",
+#endif
"LABEL:'ServerX'",
"SUBJECTKEYID:'a6 42 aa 17 04 41 86 56 67 e4 04 64 59 34 30 c7 4c 6b ef ff'",
"SERIAL:04",
@@ -3147,6 +3260,9 @@ allTests(const CommunicatorPtr& communicator, const string& testDir, bool p12, b
0
};
+ const char* certificates[] = {"/s_rsa_ca1.p12", "/c_rsa_ca1.p12", 0};
+ ImportCerts import(defaultDir, certificates);
+
for(int i = 0; clientFindCertProperties[i] != 0; i++)
{
InitializationData initData;
@@ -3169,6 +3285,7 @@ allTests(const CommunicatorPtr& communicator, const string& testDir, bool p12, b
d["IceSSL.Keychain"] = "../certs/Find.keychain";
d["IceSSL.KeychainPassword"] = "password";
d["IceSSL.FindCert"] = serverFindCertProperties[i];
+
//
// Use TrustOnly to ensure the peer has pick the expected certificate.
//
@@ -3198,6 +3315,7 @@ allTests(const CommunicatorPtr& communicator, const string& testDir, bool p12, b
try
{
CommunicatorPtr comm = initialize(initData);
+ printf("failed %s", failFindCertProperties[i]);
test(false);
}
catch(const PluginInitializationException&)
@@ -3247,11 +3365,11 @@ allTests(const CommunicatorPtr& communicator, const string& testDir, bool p12, b
comm = initialize(initData);
p = comm->stringToProxy("dummy:wss -h demo.zeroc.com -p 5064");
- IceSSL::WSSConnectionInfoPtr info;
try
{
- info = ICE_DYNAMIC_CAST(IceSSL::WSSConnectionInfo, p->ice_getConnection()->getInfo());
- test(info->verified);
+ Ice::WSConnectionInfoPtr info = ICE_DYNAMIC_CAST(Ice::WSConnectionInfo, p->ice_getConnection()->getInfo());
+ IceSSL::ConnectionInfoPtr sslInfo = ICE_DYNAMIC_CAST(IceSSL::ConnectionInfo, info->underlying);
+ test(sslInfo->verified);
}
catch(const Ice::LocalException& ex)
{
@@ -3261,9 +3379,5 @@ allTests(const CommunicatorPtr& communicator, const string& testDir, bool p12, b
}
cout << "ok" << endl;
#endif
-
- if(shutdown)
- {
- factory->shutdown();
- }
+ return factory;
}
diff --git a/cpp/test/IceSSL/configuration/Client.cpp b/cpp/test/IceSSL/configuration/Client.cpp
index 14538e7beac..68d3ad936e1 100644
--- a/cpp/test/IceSSL/configuration/Client.cpp
+++ b/cpp/test/IceSSL/configuration/Client.cpp
@@ -9,26 +9,51 @@
#include <Ice/Ice.h>
#include <IceSSL/IceSSL.h>
+#include <TestCommon.h>
+#include <Test.h>
+
+DEFINE_TEST("client")
using namespace std;
int
run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
{
+ string testdir;
+#if TARGET_OS_IPHONE == 0
if(argc < 2)
{
cerr << "Usage: " << argv[0] << " testdir" << endl;
return 1;
}
+ testdir = argv[1];
+#endif
- void allTests(const Ice::CommunicatorPtr&, const string&, bool, bool);
-
- cerr << "testing with PKCS12 certificates..." << endl;
- allTests(communicator, argv[1], true, false);
- cerr << "testing with PEM certificates..." << endl;
- allTests(communicator, argv[1], false, true);
+ Test::ServerFactoryPrxPtr allTests(const Ice::CommunicatorPtr&, const string&, bool);
+ try
+ {
+ cerr << "testing with PKCS12 certificates..." << endl;
+ Test::ServerFactoryPrxPtr factory = allTests(communicator, testdir, true);
+#if !defined(__APPLE__) || TARGET_OS_IPHONE == 0
+ cerr << "testing with PEM certificates..." << endl;
+ factory = allTests(communicator, testdir, false);
+#endif
+ if(factory)
+ {
+ factory->shutdown();
+ }
+ }
+ catch(const IceSSL::CertificateReadException& ex)
+ {
+ cout << "couldn't read certificate: " << ex.reason << endl;
+ }
+ catch(const std::exception& ex)
+ {
+ cout << "unexpected exception: " << ex.what() << endl;
+ }
return EXIT_SUCCESS;
+
}
int
diff --git a/cpp/test/IceSSL/configuration/Makefile.mk b/cpp/test/IceSSL/configuration/Makefile.mk
index 92098e429b6..9eb4e1b4c75 100644
--- a/cpp/test/IceSSL/configuration/Makefile.mk
+++ b/cpp/test/IceSSL/configuration/Makefile.mk
@@ -9,4 +9,8 @@
$(test)_dependencies = IceSSL Ice TestCommon
+# Need to load certificates with functions from src/IceSSL/Util.h
+$(test)[iphoneos]_cppflags := -Isrc
+$(test)[iphonesimulator]_cppflags := -Isrc
+
tests += $(test)
diff --git a/cpp/test/IceSSL/configuration/Server.cpp b/cpp/test/IceSSL/configuration/Server.cpp
index 5ed1e401b15..6a1f98614dd 100644
--- a/cpp/test/IceSSL/configuration/Server.cpp
+++ b/cpp/test/IceSSL/configuration/Server.cpp
@@ -9,18 +9,21 @@
#include <Ice/Ice.h>
#include <TestI.h>
+#include <TestCommon.h>
+
+DEFINE_TEST("server")
using namespace std;
int
run(int, char**, const Ice::CommunicatorPtr& communicator)
{
- communicator->getProperties()->setProperty("TestAdapter.Endpoints", "tcp -p 12010");
+ communicator->getProperties()->setProperty("TestAdapter.Endpoints", getTestEndpoint(communicator, 0));
Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter");
Ice::Identity id = communicator->stringToIdentity("factory");
adapter->add(ICE_MAKE_SHARED(ServerFactoryI), id);
adapter->activate();
-
+ TEST_READY
communicator->waitForShutdown();
return EXIT_SUCCESS;
}
diff --git a/cpp/test/IceSSL/configuration/TestI.cpp b/cpp/test/IceSSL/configuration/TestI.cpp
index 7723da865b3..39b78d02712 100644
--- a/cpp/test/IceSSL/configuration/TestI.cpp
+++ b/cpp/test/IceSSL/configuration/TestI.cpp
@@ -45,7 +45,8 @@ ServerI::checkCert(ICE_IN(string) subjectDN, ICE_IN(string) issuerDN, const Ice:
test(info->verified);
test(info->nativeCerts.size() == 2 &&
info->nativeCerts[0]->getSubjectDN() == IceSSL::DistinguishedName(subjectDN) &&
- info->nativeCerts[0]->getIssuerDN() == IceSSL::DistinguishedName(issuerDN));
+ info->nativeCerts[0]->getIssuerDN() == IceSSL::DistinguishedName(issuerDN)
+ );
}
catch(const Ice::LocalException&)
{
diff --git a/cpp/test/ios/C++ Test Suite.xcodeproj/project.pbxproj b/cpp/test/ios/C++ Test Suite.xcodeproj/project.pbxproj
index 497f4f097c9..f254b1f0bef 100755
--- a/cpp/test/ios/C++ Test Suite.xcodeproj/project.pbxproj
+++ b/cpp/test/ios/C++ Test Suite.xcodeproj/project.pbxproj
@@ -66,6 +66,9 @@
144B483C1A78F71F00C0E06B /* CFNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 344126370FD8E8EA00C8D69C /* CFNetwork.framework */; };
144B483D1A78F71F00C0E06B /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 34E396620FF1D71400FBACD6 /* CoreGraphics.framework */; };
1450A10C1ABC5E9C00A71895 /* client.p12 in Resources */ = {isa = PBXBuildFile; fileRef = 1450A10B1ABC5E9C00A71895 /* client.p12 */; };
+ 14D7F3391D0ED442008C79C9 /* certs in Resources */ = {isa = PBXBuildFile; fileRef = 14D7F3381D0ED442008C79C9 /* certs */; };
+ 14D7F33A1D0ED442008C79C9 /* certs in Resources */ = {isa = PBXBuildFile; fileRef = 14D7F3381D0ED442008C79C9 /* certs */; };
+ 14D7F33B1D0ED442008C79C9 /* certs in Resources */ = {isa = PBXBuildFile; fileRef = 14D7F3381D0ED442008C79C9 /* certs */; };
D837179F1BFFC25C005D65BC /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D8842ED91BFF87E700A8B607 /* Images.xcassets */; };
D8842EDA1BFF87E700A8B607 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D8842ED91BFF87E700A8B607 /* Images.xcassets */; };
D8842EDC1BFF885600A8B607 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D8842EDB1BFF885600A8B607 /* Default-568h@2x.png */; };
@@ -79,6 +82,7 @@
1450A10B1ABC5E9C00A71895 /* client.p12 */ = {isa = PBXFileReference; lastKnownFileType = file; name = client.p12; path = ../../../../ice/certs/client.p12; sourceTree = "<group>"; };
1477FACD1A652B7E00BC2890 /* C++98 Test Suite-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "C++98 Test Suite-Info.plist"; sourceTree = "<group>"; };
148668D31B6BAFD300234C12 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
+ 14D7F3381D0ED442008C79C9 /* certs */ = {isa = PBXFileReference; lastKnownFileType = folder; name = certs; path = ../IceSSL/certs; sourceTree = "<group>"; };
1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
28AD733E0D9D9553002E5188 /* MainWindow.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MainWindow.xib; sourceTree = "<group>"; };
@@ -198,6 +202,7 @@
29B97317FDCFA39411CA2CEA /* Resources */ = {
isa = PBXGroup;
children = (
+ 14D7F3381D0ED442008C79C9 /* certs */,
342EBA8A0E926F90000051FA /* cacert.der */,
1450A10B1ABC5E9C00A71895 /* client.p12 */,
D8842EDB1BFF885600A8B607 /* Default-568h@2x.png */,
@@ -328,6 +333,7 @@
14103B141CFC5E0E0097DE5A /* Default-568h@2x.png in Resources */,
14103B151CFC5E0E0097DE5A /* client.p12 in Resources */,
14103B161CFC5E0E0097DE5A /* cacert.der in Resources */,
+ 14D7F33B1D0ED442008C79C9 /* certs in Resources */,
14103B171CFC5E0E0097DE5A /* TestSelect-iPad.xib in Resources */,
14103B181CFC5E0E0097DE5A /* MainWindow-iPad.xib in Resources */,
14103B191CFC5E0E0097DE5A /* TestView.xib in Resources */,
@@ -339,6 +345,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
+ 14D7F33A1D0ED442008C79C9 /* certs in Resources */,
142B83841B6BA7A600E28347 /* MainWindow.xib in Resources */,
D837179F1BFFC25C005D65BC /* Images.xcassets in Resources */,
142B83851B6BA7A600E28347 /* TestSelect.xib in Resources */,
@@ -363,6 +370,7 @@
D8842EDC1BFF885600A8B607 /* Default-568h@2x.png in Resources */,
1450A10C1ABC5E9C00A71895 /* client.p12 in Resources */,
144B482B1A78F71F00C0E06B /* cacert.der in Resources */,
+ 14D7F3391D0ED442008C79C9 /* certs in Resources */,
144B482C1A78F71F00C0E06B /* TestSelect-iPad.xib in Resources */,
144B482D1A78F71F00C0E06B /* MainWindow-iPad.xib in Resources */,
144B482E1A78F71F00C0E06B /* TestView.xib in Resources */,
@@ -399,7 +407,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
- shellScript = "#\n# We don't use a CopyFile build phase here to copy the test bundles because the test\n# bundles are located in different location depending on the platform. This script\n# copies the bundles if updated and sign them.\n#\nFRAMEWORKS_PATH=\"${TARGET_BUILD_DIR}\"/\"${FRAMEWORKS_FOLDER_PATH}\"\ncd \"Bundles-${PLATFORM_NAME}\"\nif [ ! -d \"$FRAMEWORKS_PATH\" ]; then\n mkdir -p \"$FRAMEWORKS_PATH\"\nfi;\nfor i in `ls -d *.bundle`;\ndo\n if [ ! -d \"$FRAMEWORKS_PATH/$i\" -o \"$i\" -nt \"$FRAMEWORKS_PATH/$i\" ];\n then\n echo \"Copying $i\";\n cp -rf $i \"$FRAMEWORKS_PATH\"/;\n fi;\ndone\n\n";
+ shellScript = "#\n# We don't use a CopyFile build phase here to copy the test bundles because the test\n# bundles are located in different location depending on the platform. This script\n# copies the bundles if updated and sign them.\n#\nFRAMEWORKS_PATH=\"${TARGET_BUILD_DIR}\"/\"${FRAMEWORKS_FOLDER_PATH}\"\ncd \"Bundles-${PLATFORM_NAME}\"\nif [ ! -d \"$FRAMEWORKS_PATH\" ]; then\n mkdir -p \"$FRAMEWORKS_PATH\"\nfi;\nfor i in `ls -d */*.bundle`;\ndo\n if [ ! -d \"$FRAMEWORKS_PATH/$i\" -o \"$i\" -nt \"$FRAMEWORKS_PATH/$i\" ];\n then\n echo \"Copying $i\";\n mkdir -p \"$FRAMEWORKS_PATH/$(dirname $i)\"\n cp -rf $i \"$FRAMEWORKS_PATH/$(dirname $i)\"\n fi;\ndone\n\n";
};
144B488F1A78F71F00C0E06B /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
diff --git a/cpp/test/ios/Classes/AppDelegate.mm b/cpp/test/ios/Classes/AppDelegate.mm
index 6f8f217bc4a..ac7e99dcaeb 100644
--- a/cpp/test/ios/Classes/AppDelegate.mm
+++ b/cpp/test/ios/Classes/AppDelegate.mm
@@ -65,6 +65,7 @@ static const struct TestData alltests[] =
{ @"metrics", @"Ice_metrics", @"client.bundle", @"server.bundle", 0, 0, false, false, false, false, true },
{ @"enums", @"Ice_enums", @"client.bundle", @"server.bundle", 0, 0, true, true, false, true, true },
{ @"services", @"Ice_services", @"client.bundle", 0, 0, 0, true, true, false, false, true },
+{ @"configuration", @"IceSSL_configuration", @"client.bundle", @"server.bundle", 0, 0, false, false, false, false, true },
};
@implementation AppDelegate
diff --git a/cpp/test/uwp/MainPage.xaml.cpp b/cpp/test/uwp/MainPage.xaml.cpp
index 303174816cc..5561f5b25c1 100644
--- a/cpp/test/uwp/MainPage.xaml.cpp
+++ b/cpp/test/uwp/MainPage.xaml.cpp
@@ -796,6 +796,7 @@ MainPage::MainPage() :
_messages(ref new Vector<String^>())
{
InitializeComponent();
+ Ice::registerIceSSL();
}
void