diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2015-05-05 15:52:01 -0230 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2015-05-05 15:52:01 -0230 |
commit | b61582b1c6b16be4339aa0bded3ad8f542a01df9 (patch) | |
tree | 2040386a942217e2412e48c1e56465817ecac3d5 | |
parent | Missing export declarations (diff) | |
download | ice-b61582b1c6b16be4339aa0bded3ad8f542a01df9.tar.bz2 ice-b61582b1c6b16be4339aa0bded3ad8f542a01df9.tar.xz ice-b61582b1c6b16be4339aa0bded3ad8f542a01df9.zip |
ICE-6471 Add support for IceSSL endpoint/connection info to Python/Ruby/PHP
-rw-r--r-- | objective-c/test/Ice/info/AllTests.m | 24 | ||||
-rw-r--r-- | objective-c/test/Ice/info/TestI.m | 12 | ||||
-rw-r--r-- | php/src/IcePHP/Connection.cpp | 75 | ||||
-rw-r--r-- | php/src/IcePHP/Endpoint.cpp | 41 | ||||
-rw-r--r-- | php/test/Ice/info/Client.php | 14 | ||||
-rw-r--r-- | python/config/Make.rules | 2 | ||||
-rw-r--r-- | python/modules/IcePy/ConnectionInfo.cpp | 207 | ||||
-rw-r--r-- | python/modules/IcePy/EndpointInfo.cpp | 144 | ||||
-rw-r--r-- | python/python/Ice.py | 6 | ||||
-rw-r--r-- | python/test/Ice/info/AllTests.py | 9 | ||||
-rw-r--r-- | python/test/Ice/info/TestI.py | 2 | ||||
-rw-r--r-- | ruby/src/IceRuby/Connection.cpp | 62 | ||||
-rw-r--r-- | ruby/src/IceRuby/Endpoint.cpp | 40 | ||||
-rw-r--r-- | ruby/test/Ice/info/AllTests.rb | 9 |
14 files changed, 623 insertions, 24 deletions
diff --git a/objective-c/test/Ice/info/AllTests.m b/objective-c/test/Ice/info/AllTests.m index c4f290e5693..b2eb99227f7 100644 --- a/objective-c/test/Ice/info/AllTests.m +++ b/objective-c/test/Ice/info/AllTests.m @@ -171,13 +171,25 @@ infoAllTests(id<ICECommunicator> communicator) test([[ctx objectForKey:@"remotePort"] intValue] == info.localPort); test([[ctx objectForKey:@"localPort"] intValue] == info.remotePort); - if([info isKindOfClass:[ICEWSConnectionInfo class]]) + if([info isKindOfClass:[ICEWSConnectionInfo class]] || [info isKindOfClass:[ICESSLWSSConnectionInfo class]]) { - ICEWSConnectionInfo* wsinfo = (ICEWSConnectionInfo*)info; - test([[wsinfo.headers objectForKey:@"Upgrade"] isEqualToString:@"websocket"]); - test([[wsinfo.headers objectForKey:@"Connection"] isEqualToString:@"Upgrade"]); - test([[wsinfo.headers objectForKey:@"Sec-WebSocket-Protocol"] isEqualToString:@"ice.zeroc.com"]); - test([wsinfo.headers objectForKey:@"Sec-WebSocket-Accept"] != nil); + ICEHeaderDict* headers; + if([info isKindOfClass:[ICEWSConnectionInfo class]]) + { + ICEWSConnectionInfo* wsinfo = (ICEWSConnectionInfo*)info; + headers = wsinfo.headers; + } + + if([info isKindOfClass:[ICESSLWSSConnectionInfo class]]) + { + ICESSLWSSConnectionInfo* wssinfo = (ICESSLWSSConnectionInfo*)info; + headers = wssinfo.headers; + } + + test([[headers objectForKey:@"Upgrade"] isEqualToString:@"websocket"]); + test([[headers objectForKey:@"Connection"] isEqualToString:@"Upgrade"]); + test([[headers objectForKey:@"Sec-WebSocket-Protocol"] isEqualToString:@"ice.zeroc.com"]); + test([headers objectForKey:@"Sec-WebSocket-Accept"] != nil); test([[ctx objectForKey:@"ws.Upgrade"] isEqualToString:@"websocket"]); test([[ctx objectForKey:@"ws.Connection"] isEqualToString:@"Upgrade"]); diff --git a/objective-c/test/Ice/info/TestI.m b/objective-c/test/Ice/info/TestI.m index cbc6a257664..9c4fb5895a5 100644 --- a/objective-c/test/Ice/info/TestI.m +++ b/objective-c/test/Ice/info/TestI.m @@ -8,6 +8,7 @@ // ********************************************************************** #import <objc/Ice.h> +#import <objc/IceSSL.h> #import <info/TestI.h> #import <TestCommon.h> @@ -50,11 +51,13 @@ ICEConnectionInfo* info = [[current con] getInfo]; ICEMutableContext* ctx = [ICEMutableContext dictionaryWithObject:[info adapterName] forKey:@"adapterName"]; [ctx setObject:info.incoming ? @"true" : @"false" forKey:@"incoming"]; + ICEIPConnectionInfo* ipinfo = (ICEIPConnectionInfo*)info; [ctx setObject:ipinfo.localAddress forKey:@"localAddress"]; [ctx setObject:[NSString stringWithFormat:@"%d", ipinfo.localPort] forKey:@"localPort"]; [ctx setObject:ipinfo.remoteAddress forKey:@"remoteAddress"]; [ctx setObject:[NSString stringWithFormat:@"%d", ipinfo.remotePort] forKey:@"remotePort"]; + if([info isKindOfClass:[ICEWSConnectionInfo class]]) { ICEWSConnectionInfo* wsinfo = (ICEWSConnectionInfo*)info; @@ -63,6 +66,15 @@ [ctx setObject:[wsinfo.headers objectForKey:key] forKey:[NSString stringWithFormat:@"ws.%@", key]]; } } + + if([info isKindOfClass:[ICESSLWSSConnectionInfo class]]) + { + ICESSLWSSConnectionInfo* wssinfo = (ICESSLWSSConnectionInfo*)info; + for(NSString* key in wssinfo.headers) + { + [ctx setObject:[wssinfo.headers objectForKey:key] forKey:[NSString stringWithFormat:@"ws.%@", key]]; + } + } return ctx; } @end diff --git a/php/src/IcePHP/Connection.cpp b/php/src/IcePHP/Connection.cpp index b664cd9fac5..cdb739c8693 100644 --- a/php/src/IcePHP/Connection.cpp +++ b/php/src/IcePHP/Connection.cpp @@ -11,6 +11,7 @@ #include <Endpoint.h> #include <Types.h> #include <Util.h> +#include <IceSSL/ConnectionInfo.h> using namespace std; using namespace IcePHP; @@ -27,6 +28,8 @@ static zend_class_entry* ipConnectionInfoClassEntry = 0; static zend_class_entry* tcpConnectionInfoClassEntry = 0; static zend_class_entry* udpConnectionInfoClassEntry = 0; static zend_class_entry* wsConnectionInfoClassEntry = 0; +static zend_class_entry* sslConnectionInfoClassEntry = 0; +static zend_class_entry* wssConnectionInfoClassEntry = 0; // // Ice::Connection support. @@ -572,6 +575,37 @@ IcePHP::connectionInit(TSRMLS_D) zend_declare_property_string(wsConnectionInfoClassEntry, STRCAST("headers"), sizeof("headers") - 1, STRCAST(""), ZEND_ACC_PUBLIC TSRMLS_CC); + // + // Register the SSLConnectionInfo class. + // +#ifdef ICEPHP_USE_NAMESPACES + INIT_NS_CLASS_ENTRY(ce, "Ice", "SSLConnectionInfo", NULL); +#else + INIT_CLASS_ENTRY(ce, "Ice_SSLConnectionInfo", NULL); +#endif + ce.create_object = handleConnectionInfoAlloc; + sslConnectionInfoClassEntry = zend_register_internal_class_ex(&ce, ipConnectionInfoClassEntry, NULL TSRMLS_CC); + zend_declare_property_string(sslConnectionInfoClassEntry, STRCAST("cipher"), sizeof("cipher") - 1, + STRCAST(""), ZEND_ACC_PUBLIC TSRMLS_CC); + zend_declare_property_string(sslConnectionInfoClassEntry, STRCAST("certs"), sizeof("certs") - 1, + STRCAST(""), ZEND_ACC_PUBLIC TSRMLS_CC); + zend_declare_property_bool(sslConnectionInfoClassEntry, STRCAST("verified"), sizeof("verified") - 1, 0, + ZEND_ACC_PUBLIC TSRMLS_CC); + + // + // Register the WSConnectionInfo class. + // +#ifdef ICEPHP_USE_NAMESPACES + INIT_NS_CLASS_ENTRY(ce, "Ice", "WSSConnectionInfo", NULL); +#else + INIT_CLASS_ENTRY(ce, "Ice_WSSConnectionInfo", NULL); +#endif + ce.create_object = handleConnectionInfoAlloc; + wssConnectionInfoClassEntry = zend_register_internal_class_ex(&ce, sslConnectionInfoClassEntry, NULL TSRMLS_CC); + zend_declare_property_string(wssConnectionInfoClassEntry, STRCAST("headers"), sizeof("headers") - 1, + STRCAST(""), ZEND_ACC_PUBLIC TSRMLS_CC); + + return true; } @@ -651,6 +685,28 @@ IcePHP::createConnectionInfo(zval* zv, const Ice::ConnectionInfoPtr& p TSRMLS_DC add_property_long(zv, STRCAST("mcastPort"), static_cast<long>(info->mcastPort)); } } + else if(IceSSL::WSSConnectionInfoPtr::dynamicCast(p)) + { + IceSSL::WSSConnectionInfoPtr info = IceSSL::WSSConnectionInfoPtr::dynamicCast(p); + if((status = object_init_ex(zv, wssConnectionInfoClassEntry)) == SUCCESS) + { + zval* zmap; + MAKE_STD_ZVAL(zmap); + AutoDestroy mapDestroyer(zmap); + if(createStringMap(zmap, info->headers TSRMLS_CC)) + { + add_property_zval(zv, STRCAST("headers"), zmap); + } + else + { + return false; + } + } + } + else if(IceSSL::ConnectionInfoPtr::dynamicCast(p)) + { + status = object_init_ex(zv, sslConnectionInfoClassEntry); + } else if(Ice::IPConnectionInfoPtr::dynamicCast(p)) { status = object_init_ex(zv, ipConnectionInfoClassEntry); @@ -666,6 +722,25 @@ IcePHP::createConnectionInfo(zval* zv, const Ice::ConnectionInfoPtr& p TSRMLS_DC return false; } + if(IceSSL::ConnectionInfoPtr::dynamicCast(p)) + { + IceSSL::ConnectionInfoPtr info = IceSSL::ConnectionInfoPtr::dynamicCast(p); + add_property_string(zv, STRCAST("cipher"), const_cast<char*>(info->cipher.c_str()), 1); + add_property_bool(zv, STRCAST("verified"), info->verified ? 1 : 0); + + zval* zarr; + MAKE_STD_ZVAL(zarr); + AutoDestroy listDestroyer(zarr); + if(createStringArray(zarr, info->certs TSRMLS_CC)) + { + add_property_zval(zv, STRCAST("certs"), zarr); + } + else + { + return false; + } + } + if(Ice::IPConnectionInfoPtr::dynamicCast(p)) { Ice::IPConnectionInfoPtr info = Ice::IPConnectionInfoPtr::dynamicCast(p); diff --git a/php/src/IcePHP/Endpoint.cpp b/php/src/IcePHP/Endpoint.cpp index 317dcb6c3d8..4ca32bbf600 100644 --- a/php/src/IcePHP/Endpoint.cpp +++ b/php/src/IcePHP/Endpoint.cpp @@ -9,6 +9,7 @@ #include <Endpoint.h> #include <Util.h> +#include <IceSSL/EndpointInfo.h> using namespace std; using namespace IcePHP; @@ -26,6 +27,8 @@ static zend_class_entry* tcpEndpointInfoClassEntry = 0; static zend_class_entry* udpEndpointInfoClassEntry = 0; static zend_class_entry* wsEndpointInfoClassEntry = 0; static zend_class_entry* opaqueEndpointInfoClassEntry = 0; +static zend_class_entry* sslEndpointInfoClassEntry = 0; +static zend_class_entry* wssEndpointInfoClassEntry = 0; // // Ice::Endpoint support. @@ -362,7 +365,7 @@ IcePHP::endpointInit(TSRMLS_D) #endif ce.create_object = handleEndpointInfoAlloc; wsEndpointInfoClassEntry = zend_register_internal_class_ex(&ce, ipEndpointInfoClassEntry, NULL TSRMLS_CC); - zend_declare_property_string(udpEndpointInfoClassEntry, STRCAST("resource"), sizeof("resource") - 1, + zend_declare_property_string(wsEndpointInfoClassEntry, STRCAST("resource"), sizeof("resource") - 1, STRCAST(""), ZEND_ACC_PUBLIC TSRMLS_CC); // @@ -380,6 +383,30 @@ IcePHP::endpointInit(TSRMLS_D) zend_declare_property_null(opaqueEndpointInfoClassEntry, STRCAST("rawBytes"), sizeof("rawBytes") - 1, ZEND_ACC_PUBLIC TSRMLS_CC); + // + // Define the SSLEndpointInfo class. + // +#ifdef ICEPHP_USE_NAMESPACES + INIT_NS_CLASS_ENTRY(ce, "Ice", "SSLEndpointInfo", NULL); +#else + INIT_CLASS_ENTRY(ce, "Ice_SSLEndpointInfo", NULL); +#endif + ce.create_object = handleEndpointInfoAlloc; + sslEndpointInfoClassEntry = zend_register_internal_class_ex(&ce, ipEndpointInfoClassEntry, NULL TSRMLS_CC); + + // + // Define the WSSEndpointInfo class. + // +#ifdef ICEPHP_USE_NAMESPACES + INIT_NS_CLASS_ENTRY(ce, "Ice", "WSSEndpointInfo", NULL); +#else + INIT_CLASS_ENTRY(ce, "Ice_WSSEndpointInfo", NULL); +#endif + ce.create_object = handleEndpointInfoAlloc; + wssEndpointInfoClassEntry = zend_register_internal_class_ex(&ce, sslEndpointInfoClassEntry, NULL TSRMLS_CC); + zend_declare_property_string(wssEndpointInfoClassEntry, STRCAST("resource"), sizeof("resource") - 1, + STRCAST(""), ZEND_ACC_PUBLIC TSRMLS_CC); + return true; } @@ -471,6 +498,18 @@ IcePHP::createEndpointInfo(zval* zv, const Ice::EndpointInfoPtr& p TSRMLS_DC) zval_ptr_dtor(&rawBytes); // add_property_zval increased the refcount of rawBytes } } + else if(IceSSL::WSSEndpointInfoPtr::dynamicCast(p)) + { + IceSSL::WSSEndpointInfoPtr info = IceSSL::WSSEndpointInfoPtr::dynamicCast(p); + if((status = object_init_ex(zv, wssEndpointInfoClassEntry)) == SUCCESS) + { + add_property_string(zv, STRCAST("resource"), const_cast<char*>(info->resource.c_str()), 1); + } + } + else if(IceSSL::EndpointInfoPtr::dynamicCast(p)) + { + status = object_init_ex(zv, sslEndpointInfoClassEntry); + } else if(Ice::IPEndpointInfoPtr::dynamicCast(p)) { status = object_init_ex(zv, ipEndpointInfoClassEntry); diff --git a/php/test/Ice/info/Client.php b/php/test/Ice/info/Client.php index 05053c00a20..e5f3fc1d032 100644 --- a/php/test/Ice/info/Client.php +++ b/php/test/Ice/info/Client.php @@ -38,10 +38,12 @@ function allTests($communicator) $tcpEndpointInfoClass = $NS ? "Ice\\TCPEndpointInfo" : "Ice_TCPEndpointInfo"; $udpEndpointType = $NS ? constant("Ice\\UDPEndpointType") : constant("Ice_UDPEndpointType"); $udpEndpointInfoClass = $NS ? "Ice\\UDPEndpointInfo" : "Ice_UDPEndpointInfo"; - $sslEndpointType = 2; + $sslEndpointType = $NS ? constant("Ice\\SSLEndpointType") : constant("Ice_SSLEndpointType"); + $sslEndpointInfoClass = $NS ? "Ice\\SSLEndpointInfo" : "Ice_SSLEndpointInfo"; $wsEndpointType = $NS ? constant("Ice\\WSEndpointType") : constant("Ice_WSEndpointType"); $wsEndpointInfoClass = $NS ? "Ice\\WSEndpointInfo" : "Ice_WSEndpointInfo"; $wssEndpointType = $NS ? constant("Ice\\WSSEndpointType") : constant("Ice_WSSEndpointType"); + $wssEndpointInfoClass = $NS ? "Ice\\WSSEndpointInfo" : "Ice_WSSEndpointInfo"; $protocolVersionClass = $NS ? "Ice\\ProtocolVersion" : "Ice_ProtocolVersion"; $encodingVersionClass = $NS ? "Ice\\EncodingVersion" : "Ice_EncodingVersion"; @@ -68,9 +70,9 @@ function allTests($communicator) ($ipEndpoint->type() == $wsEndpointType && !$ipEndpoint->secure()) || ($ipEndpoint->type() == $wssEndpointType && $ipEndpoint->secure())); test(($ipEndpoint->type() == $tcpEndpointType && ($ipEndpoint instanceof $tcpEndpointInfoClass)) || - ($ipEndpoint->type() == $sslEndpointType && ($ipEndpoint instanceof $ipEndpointInfoClass)) || + ($ipEndpoint->type() == $sslEndpointType && ($ipEndpoint instanceof $sslEndpointInfoClass)) || ($ipEndpoint->type() == $wsEndpointType && ($ipEndpoint instanceof $wsEndpointInfoClass)) || - ($ipEndpoint->type() == $wssEndpointType && ($ipEndpoint instanceof $ipEndpointInfoClass))); + ($ipEndpoint->type() == $wssEndpointType && ($ipEndpoint instanceof $wssEndpointInfoClass))); $udpEndpoint = $endps[1]->getInfo(); test($udpEndpoint instanceof $udpEndpointInfoClass); @@ -120,6 +122,7 @@ function allTests($communicator) { $ipConnectionInfoClass = $NS ? "Ice\\IPConnectionInfo" : "Ice_IPConnectionInfo"; $wsConnectionInfoClass = $NS ? "Ice\\WSConnectionInfo" : "Ice_WSConnectionInfo"; + $wssConnectionInfoClass = $NS ? "Ice\\WSSConnectionInfo" : "Ice_WSSConnectionInfo"; $connection = $base->ice_getConnection(); $connection->setBufferSize(1024, 2048); @@ -145,9 +148,10 @@ function allTests($communicator) test($ctx["remotePort"] == $info->localPort); test($ctx["localPort"] == $info->remotePort); - if($base->ice_getConnection()->type() == "ws") + if($base->ice_getConnection()->type() == "ws" || $base->ice_getConnection()->type() == "wss") { - test($info instanceof $wsConnectionInfoClass); + test(($base->ice_getConnection()->type() == "ws" && $info instanceof $wsConnectionInfoClass) || + ($base->ice_getConnection()->type() == "wss" && $info instanceof $wssConnectionInfoClass)); test($info->headers["Upgrade"] == "websocket"); test($info->headers["Connection"] == "Upgrade"); diff --git a/python/config/Make.rules b/python/config/Make.rules index 7bafb323543..718e634b5d8 100644 --- a/python/config/Make.rules +++ b/python/config/Make.rules @@ -135,7 +135,7 @@ else ICE_LIB_DIR = -L$(ice_dir)/$(libsubdir) ICE_FLAGS = -I$(ice_dir)/include endif -ICE_LIBS = $(ICE_LIB_DIR) -lIce -lSlice -lIceUtil +ICE_LIBS = $(ICE_LIB_DIR) -lIceSSL -lIce -lSlice -lIceUtil CPPFLAGS = ICECPPFLAGS = -I$(slicedir) diff --git a/python/modules/IcePy/ConnectionInfo.cpp b/python/modules/IcePy/ConnectionInfo.cpp index bac83235083..2b7750c1cf8 100644 --- a/python/modules/IcePy/ConnectionInfo.cpp +++ b/python/modules/IcePy/ConnectionInfo.cpp @@ -14,6 +14,8 @@ #include <EndpointInfo.h> #include <Util.h> #include <Ice/Object.h> +#include <IceSSL/ConnectionInfo.h> + using namespace std; using namespace IcePy; @@ -178,6 +180,69 @@ wsConnectionInfoGetHeaders(ConnectionInfoObject* self) return result.release(); } +#ifdef WIN32 +extern "C" +#endif +static PyObject* +sslConnectionInfoGetCipher(ConnectionInfoObject* self) +{ + IceSSL::ConnectionInfoPtr info = IceSSL::ConnectionInfoPtr::dynamicCast(*self->connectionInfo); + assert(info); + return createString(info->cipher); +} + +#ifdef WIN32 +extern "C" +#endif +static PyObject* +sslConnectionInfoGetCerts(ConnectionInfoObject* self) +{ + IceSSL::ConnectionInfoPtr info = IceSSL::ConnectionInfoPtr::dynamicCast(*self->connectionInfo); + assert(info); + PyObject* certs = PyList_New(0); + stringSeqToList(info->certs, certs); + return certs; +} + +#ifdef WIN32 +extern "C" +#endif +static PyObject* +sslConnectionInfoGetVerified(ConnectionInfoObject* self) +{ + IceSSL::ConnectionInfoPtr info = IceSSL::ConnectionInfoPtr::dynamicCast(*self->connectionInfo); + assert(info); + PyObject* result = info->incoming ? getTrue() : getFalse(); + Py_INCREF(result); + return result; +} + +#ifdef WIN32 +extern "C" +#endif +static PyObject* +wssConnectionInfoGetHeaders(ConnectionInfoObject* self) +{ + IceSSL::WSSConnectionInfoPtr info = IceSSL::WSSConnectionInfoPtr::dynamicCast(*self->connectionInfo); + assert(info); + + PyObjectHandle result = PyDict_New(); + if(result.get()) + { + for(Ice::HeaderDict::iterator p = info->headers.begin(); p != info->headers.end(); ++p) + { + PyObjectHandle key = createString(p->first); + PyObjectHandle val = createString(p->second); + if(!val.get() || PyDict_SetItem(result.get(), key.get(), val.get()) < 0) + { + return 0; + } + } + } + + return result.release(); +} + static PyGetSetDef ConnectionInfoGetters[] = { { STRCAST("incoming"), reinterpret_cast<getter>(connectionInfoGetIncoming), 0, @@ -220,6 +285,24 @@ static PyGetSetDef WSConnectionInfoGetters[] = { 0, 0 } /* sentinel */ }; +static PyGetSetDef SSLConnectionInfoGetters[] = +{ + { STRCAST("cipher"), reinterpret_cast<getter>(sslConnectionInfoGetCipher), 0, + PyDoc_STR(STRCAST("negotiated cipher suite")), 0 }, + { STRCAST("certs"), reinterpret_cast<getter>(sslConnectionInfoGetCerts), 0, + PyDoc_STR(STRCAST("certificate chain")), 0 }, + { STRCAST("verified"), reinterpret_cast<getter>(sslConnectionInfoGetVerified), 0, + PyDoc_STR(STRCAST("certificate chain verification status")), 0 }, + { 0, 0 } /* sentinel */ +}; + +static PyGetSetDef WSSConnectionInfoGetters[] = +{ + { STRCAST("headers"), reinterpret_cast<getter>(wssConnectionInfoGetHeaders), 0, + PyDoc_STR(STRCAST("request headers")), 0 }, + { 0, 0 } /* sentinel */ +}; + namespace IcePy { @@ -458,6 +541,100 @@ PyTypeObject WSConnectionInfoType = 0, /* tp_is_gc */ }; +PyTypeObject SSLConnectionInfoType = +{ + /* The ob_type field must be initialized in the module init function + * to be portable to Windows without using C++. */ + PyVarObject_HEAD_INIT(0, 0) + STRCAST("IcePy.SSLConnectionInfo"),/* tp_name */ + sizeof(ConnectionInfoObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + /* methods */ + (destructor)connectionInfoDealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + 0, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + SSLConnectionInfoGetters, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + (newfunc)connectionInfoNew, /* tp_new */ + 0, /* tp_free */ + 0, /* tp_is_gc */ +}; + +PyTypeObject WSSConnectionInfoType = +{ + /* The ob_type field must be initialized in the module init function + * to be portable to Windows without using C++. */ + PyVarObject_HEAD_INIT(0, 0) + STRCAST("IcePy.WSSConnectionInfo"),/* tp_name */ + sizeof(ConnectionInfoObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + /* methods */ + (destructor)connectionInfoDealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + 0, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + WSSConnectionInfoGetters, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + (newfunc)connectionInfoNew, /* tp_new */ + 0, /* tp_free */ + 0, /* tp_is_gc */ +}; + } bool @@ -517,6 +694,28 @@ IcePy::initConnectionInfo(PyObject* module) return false; } + SSLConnectionInfoType.tp_base = &IPConnectionInfoType; // Force inheritance from IPConnectionInfoType. + if(PyType_Ready(&SSLConnectionInfoType) < 0) + { + return false; + } + type = &SSLConnectionInfoType; // Necessary to prevent GCC's strict-alias warnings. + if(PyModule_AddObject(module, STRCAST("SSLConnectionInfo"), reinterpret_cast<PyObject*>(type)) < 0) + { + return false; + } + + WSSConnectionInfoType.tp_base = &SSLConnectionInfoType; // Force inheritance from IPConnectionType. + if(PyType_Ready(&WSSConnectionInfoType) < 0) + { + return false; + } + type = &WSSConnectionInfoType; // Necessary to prevent GCC's strict-alias warnings. + if(PyModule_AddObject(module, STRCAST("WSSConnectionInfo"), reinterpret_cast<PyObject*>(type)) < 0) + { + return false; + } + return true; } @@ -544,6 +743,14 @@ IcePy::createConnectionInfo(const Ice::ConnectionInfoPtr& connectionInfo) { type = &UDPConnectionInfoType; } + else if(IceSSL::WSSConnectionInfoPtr::dynamicCast(connectionInfo)) + { + type = &WSSConnectionInfoType; + } + else if(IceSSL::ConnectionInfoPtr::dynamicCast(connectionInfo)) + { + type = &SSLConnectionInfoType; + } else if(Ice::IPConnectionInfoPtr::dynamicCast(connectionInfo)) { type = &IPConnectionInfoType; diff --git a/python/modules/IcePy/EndpointInfo.cpp b/python/modules/IcePy/EndpointInfo.cpp index 1106390b20a..9df2eaae114 100644 --- a/python/modules/IcePy/EndpointInfo.cpp +++ b/python/modules/IcePy/EndpointInfo.cpp @@ -12,6 +12,7 @@ #endif #include <EndpointInfo.h> #include <Util.h> +#include <IceSSL/EndpointInfo.h> using namespace std; using namespace IcePy; @@ -209,6 +210,17 @@ wsEndpointInfoGetResource(EndpointInfoObject* self) extern "C" #endif static PyObject* +wssEndpointInfoGetResource(EndpointInfoObject* self) +{ + IceSSL::WSSEndpointInfoPtr info = IceSSL::WSSEndpointInfoPtr::dynamicCast(*self->endpointInfo); + assert(info); + return createString(info->resource); +} + +#ifdef WIN32 +extern "C" +#endif +static PyObject* opaqueEndpointInfoGetRawBytes(EndpointInfoObject* self) { Ice::OpaqueEndpointInfoPtr info = Ice::OpaqueEndpointInfoPtr::dynamicCast(*self->endpointInfo); @@ -280,6 +292,13 @@ static PyGetSetDef WSEndpointInfoGetters[] = { 0, 0 } /* sentinel */ }; +static PyGetSetDef WSSEndpointInfoGetters[] = +{ + { STRCAST("resource"), reinterpret_cast<getter>(wssEndpointInfoGetResource), 0, + PyDoc_STR(STRCAST("resource")), 0 }, + { 0, 0 } /* sentinel */ +}; + static PyGetSetDef OpaqueEndpointInfoGetters[] = { { STRCAST("rawBytes"), reinterpret_cast<getter>(opaqueEndpointInfoGetRawBytes), 0, @@ -527,6 +546,100 @@ PyTypeObject WSEndpointInfoType = 0, /* tp_is_gc */ }; +PyTypeObject SSLEndpointInfoType = +{ + /* The ob_type field must be initialized in the module init function + * to be portable to Windows without using C++. */ + PyVarObject_HEAD_INIT(0, 0) + STRCAST("IcePy.SSLEndpointInfo"),/* tp_name */ + sizeof(EndpointInfoObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + /* methods */ + reinterpret_cast<destructor>(endpointInfoDealloc), /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + 0, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + reinterpret_cast<newfunc>(endpointInfoNew), /* tp_new */ + 0, /* tp_free */ + 0, /* tp_is_gc */ +}; + +PyTypeObject WSSEndpointInfoType = +{ + /* The ob_type field must be initialized in the module init function + * to be portable to Windows without using C++. */ + PyVarObject_HEAD_INIT(0, 0) + STRCAST("IcePy.WSSEndpointInfo"), /* tp_name */ + sizeof(EndpointInfoObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + /* methods */ + reinterpret_cast<destructor>(endpointInfoDealloc), /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + 0, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + WSSEndpointInfoGetters, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + reinterpret_cast<newfunc>(endpointInfoNew), /* tp_new */ + 0, /* tp_free */ + 0, /* tp_is_gc */ +}; + PyTypeObject OpaqueEndpointInfoType = { /* The ob_type field must be initialized in the module init function @@ -633,6 +746,28 @@ IcePy::initEndpointInfo(PyObject* module) return false; } + SSLEndpointInfoType.tp_base = &IPEndpointInfoType; // Force inheritance from IPEndpointInfoType. + if(PyType_Ready(&SSLEndpointInfoType) < 0) + { + return false; + } + type = &SSLEndpointInfoType; // Necessary to prevent GCC's strict-alias warnings. + if(PyModule_AddObject(module, STRCAST("SSLEndpointInfo"), reinterpret_cast<PyObject*>(type)) < 0) + { + return false; + } + + WSSEndpointInfoType.tp_base = &SSLEndpointInfoType; // Force inheritance from SSLEndpointInfoType. + if(PyType_Ready(&WSSEndpointInfoType) < 0) + { + return false; + } + type = &WSSEndpointInfoType; // Necessary to prevent GCC's strict-alias warnings. + if(PyModule_AddObject(module, STRCAST("WSSEndpointInfo"), reinterpret_cast<PyObject*>(type)) < 0) + { + return false; + } + OpaqueEndpointInfoType.tp_base = &EndpointInfoType; // Force inheritance from EndpointType. if(PyType_Ready(&OpaqueEndpointInfoType) < 0) { @@ -671,6 +806,14 @@ IcePy::createEndpointInfo(const Ice::EndpointInfoPtr& endpointInfo) { type = &UDPEndpointInfoType; } + else if(IceSSL::WSSEndpointInfoPtr::dynamicCast(endpointInfo)) + { + type = &WSSEndpointInfoType; + } + else if(IceSSL::EndpointInfoPtr::dynamicCast(endpointInfo)) + { + type = &SSLEndpointInfoType; + } else if(Ice::OpaqueEndpointInfoPtr::dynamicCast(endpointInfo)) { type = &OpaqueEndpointInfoType; @@ -681,6 +824,7 @@ IcePy::createEndpointInfo(const Ice::EndpointInfoPtr& endpointInfo) } else { + std::cout << "CREATE" << std::endl; type = &EndpointInfoType; } diff --git a/python/python/Ice.py b/python/python/Ice.py index b8c9f0a8721..2ef4dbfcd47 100644 --- a/python/python/Ice.py +++ b/python/python/Ice.py @@ -471,6 +471,9 @@ WSEndpointInfo = IcePy.WSEndpointInfo del OpaqueEndpointInfo OpaqueEndpointInfo = IcePy.OpaqueEndpointInfo +SSLEndpointInfo = IcePy.SSLEndpointInfo +WSSEndpointInfo = IcePy.WSSEndpointInfo + # # Replace ConnectionInfo with our implementation. # @@ -485,6 +488,9 @@ UDPConnectionInfo = IcePy.UDPConnectionInfo del WSConnectionInfo WSConnectionInfo = IcePy.WSConnectionInfo +SSLConnectionInfo = IcePy.SSLConnectionInfo +WSSConnectionInfo = IcePy.WSSConnectionInfo + class ThreadNotification(object): '''Base class for thread notification callbacks. A subclass must define the start and stop methods.''' diff --git a/python/test/Ice/info/AllTests.py b/python/test/Ice/info/AllTests.py index 5dd6dbb5c69..35b21233b34 100644 --- a/python/test/Ice/info/AllTests.py +++ b/python/test/Ice/info/AllTests.py @@ -36,9 +36,9 @@ def allTests(communicator): (ipEndpoint.type() == Ice.WSEndpointType and not ipEndpoint.secure()) or # WS (ipEndpoint.type() == Ice.WSSEndpointType and ipEndpoint.secure())) # WS test((ipEndpoint.type() == Ice.TCPEndpointType and isinstance(ipEndpoint, Ice.TCPEndpointInfo)) or - (ipEndpoint.type() == Ice.SSLEndpointType) or + (ipEndpoint.type() == Ice.SSLEndpointType and isinstance(ipEndpoint, Ice.SSLEndpointInfo)) or (ipEndpoint.type() == Ice.WSEndpointType and isinstance(ipEndpoint, Ice.WSEndpointInfo)) or - (ipEndpoint.type() == Ice.WSSEndpointType)) + (ipEndpoint.type() == Ice.WSSEndpointType and isinstance(ipEndpoint, Ice.WSSEndpointInfo))) udpEndpoint = endps[1].getInfo() test(isinstance(udpEndpoint, Ice.UDPEndpointInfo)) @@ -153,8 +153,9 @@ def allTests(communicator): test(ctx["remotePort"] == str(info.localPort)) test(ctx["localPort"] == str(info.remotePort)) - if(base.ice_getConnection().type() == "ws"): - test(isinstance(info, Ice.WSConnectionInfo)) + if(base.ice_getConnection().type() == "ws" or base.ice_getConnection().type() == "wss"): + test((base.ice_getConnection().type() == "ws" and isinstance(info, Ice.WSConnectionInfo)) or + (base.ice_getConnection().type() == "wss" and isinstance(info, Ice.WSSConnectionInfo))) test(info.headers["Upgrade"] == "websocket") test(info.headers["Connection"] == "Upgrade") diff --git a/python/test/Ice/info/TestI.py b/python/test/Ice/info/TestI.py index c0b266a7ba4..863ac7ffdc9 100644 --- a/python/test/Ice/info/TestI.py +++ b/python/test/Ice/info/TestI.py @@ -62,7 +62,7 @@ class MyDerivedClassI(Test.TestIntf): ctx["remoteAddress"] = info.remoteAddress ctx["remotePort"] = str(info.remotePort) - if isinstance(info, Ice.WSConnectionInfo): + if isinstance(info, Ice.WSConnectionInfo) or isinstance(info, Ice.WSSConnectionInfo): for key, value in info.headers.items(): ctx["ws." + key] = value diff --git a/ruby/src/IceRuby/Connection.cpp b/ruby/src/IceRuby/Connection.cpp index df2caa1000b..2bad860a09a 100644 --- a/ruby/src/IceRuby/Connection.cpp +++ b/ruby/src/IceRuby/Connection.cpp @@ -12,6 +12,7 @@ #include <Types.h> #include <Util.h> #include <Ice/Object.h> +#include <IceSSL/ConnectionInfo.h> using namespace std; using namespace IceRuby; @@ -23,6 +24,8 @@ static VALUE _ipConnectionInfoClass; static VALUE _tcpConnectionInfoClass; static VALUE _udpConnectionInfoClass; static VALUE _wsConnectionInfoClass; +static VALUE _sslConnectionInfoClass; +static VALUE _wssConnectionInfoClass; // ********************************************************************** // Connection @@ -332,6 +335,41 @@ IceRuby::createConnectionInfo(const Ice::ConnectionInfoPtr& p) rb_ivar_set(info, rb_intern("@mcastAddress"), createString(udp->mcastAddress)); rb_ivar_set(info, rb_intern("@mcastPort"), INT2FIX(udp->mcastPort)); } + else if(IceSSL::WSSConnectionInfoPtr::dynamicCast(p)) + { + info = Data_Wrap_Struct(_wssConnectionInfoClass, 0, IceRuby_ConnectionInfo_free, new Ice::ConnectionInfoPtr(p)); + + IceSSL::WSSConnectionInfoPtr wss = IceSSL::WSSConnectionInfoPtr::dynamicCast(p); + rb_ivar_set(info, rb_intern("@localAddress"), createString(wss->localAddress)); + rb_ivar_set(info, rb_intern("@localPort"), INT2FIX(wss->localPort)); + rb_ivar_set(info, rb_intern("@remoteAddress"), createString(wss->remoteAddress)); + rb_ivar_set(info, rb_intern("@remotePort"), INT2FIX(wss->remotePort)); + rb_ivar_set(info, rb_intern("@cipher"), createString(wss->cipher)); + rb_ivar_set(info, rb_intern("@certs"), stringSeqToArray(wss->certs)); + rb_ivar_set(info, rb_intern("@verified"), wss->verified ? Qtrue : Qfalse); + + volatile VALUE result = callRuby(rb_hash_new); + for(Ice::HeaderDict::const_iterator q = wss->headers.begin(); q != wss->headers.end(); ++q) + { + volatile VALUE key = createString(q->first); + volatile VALUE value = createString(q->second); + callRuby(rb_hash_aset, result, key, value); + } + rb_ivar_set(info, rb_intern("@headers"), result); + } + else if(IceSSL::ConnectionInfoPtr::dynamicCast(p)) + { + info = Data_Wrap_Struct(_sslConnectionInfoClass, 0, IceRuby_ConnectionInfo_free, new Ice::ConnectionInfoPtr(p)); + + IceSSL::ConnectionInfoPtr ssl = IceSSL::ConnectionInfoPtr::dynamicCast(p); + rb_ivar_set(info, rb_intern("@localAddress"), createString(ssl->localAddress)); + rb_ivar_set(info, rb_intern("@localPort"), INT2FIX(ssl->localPort)); + rb_ivar_set(info, rb_intern("@remoteAddress"), createString(ssl->remoteAddress)); + rb_ivar_set(info, rb_intern("@remotePort"), INT2FIX(ssl->remotePort)); + rb_ivar_set(info, rb_intern("@cipher"), createString(ssl->cipher)); + rb_ivar_set(info, rb_intern("@certs"), stringSeqToArray(ssl->certs)); + rb_ivar_set(info, rb_intern("@verified"), ssl->verified ? Qtrue : Qfalse); + } else if(Ice::IPConnectionInfoPtr::dynamicCast(p)) { info = Data_Wrap_Struct(_ipConnectionInfoClass, 0, IceRuby_ConnectionInfo_free, new Ice::ConnectionInfoPtr(p)); @@ -429,5 +467,27 @@ IceRuby::initConnection(VALUE iceModule) // // Instance members. // - //rb_define_attr(_wsConnectionInfoClass, "headers", 1, 0); + rb_define_attr(_wsConnectionInfoClass, "headers", 1, 0); + + // + // SSLConnectionInfo + // + _sslConnectionInfoClass = rb_define_class_under(iceModule, "SSLConnectionInfo", _ipConnectionInfoClass); + + // + // Instance members. + // + rb_define_attr(_wsConnectionInfoClass, "cipher", 1, 0); + rb_define_attr(_wsConnectionInfoClass, "certs", 1, 0); + rb_define_attr(_wsConnectionInfoClass, "verified", 1, 0); + + // + // WSSConnectionInfo + // + _wssConnectionInfoClass = rb_define_class_under(iceModule, "WSSConnectionInfo", _sslConnectionInfoClass); + + // + // Instance members. + // + rb_define_attr(_wssConnectionInfoClass, "headers", 1, 0); } diff --git a/ruby/src/IceRuby/Endpoint.cpp b/ruby/src/IceRuby/Endpoint.cpp index c6f8d8565e3..cad2ba3ba44 100644 --- a/ruby/src/IceRuby/Endpoint.cpp +++ b/ruby/src/IceRuby/Endpoint.cpp @@ -10,6 +10,7 @@ #include <Endpoint.h> #include <Util.h> #include <Ice/Object.h> +#include <IceSSL/EndpointInfo.h> using namespace std; using namespace IceRuby; @@ -22,6 +23,8 @@ static VALUE _tcpEndpointInfoClass; static VALUE _udpEndpointInfoClass; static VALUE _wsEndpointInfoClass; static VALUE _opaqueEndpointInfoClass; +static VALUE _sslEndpointInfoClass; +static VALUE _wssEndpointInfoClass; // ********************************************************************** // Endpoint @@ -170,6 +173,25 @@ IceRuby::createEndpointInfo(const Ice::EndpointInfoPtr& p) rb_ivar_set(info, rb_intern("@rawBytes"), v); rb_ivar_set(info, rb_intern("@rawEncoding"), createEncodingVersion(opaque->rawEncoding)); } + else if(IceSSL::WSSEndpointInfoPtr::dynamicCast(p)) + { + info = Data_Wrap_Struct(_wssEndpointInfoClass, 0, IceRuby_EndpointInfo_free, new Ice::EndpointInfoPtr(p)); + + IceSSL::WSSEndpointInfoPtr wss = IceSSL::WSSEndpointInfoPtr::dynamicCast(p); + rb_ivar_set(info, rb_intern("@host"), createString(wss->host)); + rb_ivar_set(info, rb_intern("@port"), INT2FIX(wss->port)); + rb_ivar_set(info, rb_intern("@sourceAddress"), createString(wss->sourceAddress)); + rb_ivar_set(info, rb_intern("@resource"), createString(wss->resource)); + } + else if(IceSSL::EndpointInfoPtr::dynamicCast(p)) + { + info = Data_Wrap_Struct(_sslEndpointInfoClass, 0, IceRuby_EndpointInfo_free, new Ice::EndpointInfoPtr(p)); + + IceSSL::EndpointInfoPtr ssl = IceSSL::EndpointInfoPtr::dynamicCast(p); + rb_ivar_set(info, rb_intern("@host"), createString(ssl->host)); + rb_ivar_set(info, rb_intern("@port"), INT2FIX(ssl->port)); + rb_ivar_set(info, rb_intern("@sourceAddress"), createString(ssl->sourceAddress)); + } else if(Ice::IPEndpointInfoPtr::dynamicCast(p)) { info = Data_Wrap_Struct(_ipEndpointInfoClass, 0, IceRuby_EndpointInfo_free, new Ice::EndpointInfoPtr(p)); @@ -183,6 +205,7 @@ IceRuby::createEndpointInfo(const Ice::EndpointInfoPtr& p) { info = Data_Wrap_Struct(_endpointInfoClass, 0, IceRuby_EndpointInfo_free, new Ice::EndpointInfoPtr(p)); } + rb_ivar_set(info, rb_intern("@timeout"), INT2FIX(p->timeout)); rb_ivar_set(info, rb_intern("@compress"), p->compress ? Qtrue : Qfalse); return info; @@ -306,7 +329,7 @@ IceRuby::initEndpoint(VALUE iceModule) // // WSEndpointInfo // - _wsEndpointInfoClass = rb_define_class_under(iceModule, "WSEndpointInfo", _ipEndpointInfoClass); + _wsEndpointInfoClass = rb_define_class_under(iceModule, "WSEndpointInfo", _tcpEndpointInfoClass); // // Instance members. @@ -323,6 +346,21 @@ IceRuby::initEndpoint(VALUE iceModule) // rb_define_attr(_opaqueEndpointInfoClass, "rawBytes", 1, 0); rb_define_attr(_opaqueEndpointInfoClass, "rawEncoding", 1, 0); + + // + // SSLEndpointInfo + // + _sslEndpointInfoClass = rb_define_class_under(iceModule, "SSLEndpointInfo", _ipEndpointInfoClass); + + // + // WSSEndpointInfo + // + _wssEndpointInfoClass = rb_define_class_under(iceModule, "WSSEndpointInfo", _sslEndpointInfoClass); + + // + // Instance members. + // + rb_define_attr(_wssEndpointInfoClass, "resource", 1, 0); } bool diff --git a/ruby/test/Ice/info/AllTests.rb b/ruby/test/Ice/info/AllTests.rb index a2ca97ba20f..8f66870a57d 100644 --- a/ruby/test/Ice/info/AllTests.rb +++ b/ruby/test/Ice/info/AllTests.rb @@ -30,9 +30,9 @@ def allTests(communicator) (ipEndpoint.type() == Ice::WSEndpointType && !ipEndpoint.secure()) || (ipEndpoint.type() == Ice::WSSEndpointType && ipEndpoint.secure())) test((ipEndpoint.type() == Ice::TCPEndpointType && ipEndpoint.is_a?(Ice::TCPEndpointInfo)) || - (ipEndpoint.type() == Ice::SSLEndpointType) || + (ipEndpoint.type() == Ice::SSLEndpointType && ipEndpoint.is_a?(Ice::SSLEndpointInfo)) || (ipEndpoint.type() == Ice::WSEndpointType && ipEndpoint.is_a?(Ice::WSEndpointInfo)) || - (ipEndpoint.type() == Ice::WSSEndpointType)) + (ipEndpoint.type() == Ice::WSSEndpointType && ipEndpoint.is_a?(Ice::WSSEndpointInfo))) udpEndpoint = endps[1].getInfo() test(udpEndpoint.is_a?(Ice::UDPEndpointInfo)); @@ -102,8 +102,9 @@ def allTests(communicator) test(ctx["remotePort"] == info.localPort.to_s()) test(ctx["localPort"] == info.remotePort.to_s()) - if base.ice_getConnection().type() == "ws" - test(info.is_a?(Ice::WSConnectionInfo)) + if base.ice_getConnection().type() == "ws" || base.ice_getConnection().type() == "wss" + test((base.ice_getConnection().type() == "ws" && info.is_a?(Ice::WSConnectionInfo)) || + (base.ice_getConnection().type() == "wss" && info.is_a?(Ice::WSSConnectionInfo))) test(info.headers["Upgrade"] == "websocket") test(info.headers["Connection"] == "Upgrade") |