Kaynağa Gözat

ZF-8478: getMethodSignature() returns string when system.* methods are registered

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@19733 44c647ce-9c0f-0410-b52a-842ac1e357ba
jan 16 yıl önce
ebeveyn
işleme
94f62729f2

+ 5 - 0
library/Zend/XmlRpc/Client/ServerIntrospection.php

@@ -144,6 +144,11 @@ class Zend_XmlRpc_Client_ServerIntrospection
     public function getMethodSignature($method)
     {
         $signature = $this->_system->methodSignature($method);
+        if (!is_array($signature)) {
+            $error = 'Invalid signature for method "' . $method . '"';
+            require_once 'Zend/XmlRpc/Client/IntrospectException.php';
+            throw new Zend_XmlRpc_Client_IntrospectException($error);
+        }
         return $signature;
     }
 

+ 45 - 0
tests/Zend/XmlRpc/ClientTest.php

@@ -27,6 +27,8 @@ require_once 'Zend/XmlRpc/Response.php';
 
 require_once 'Zend/Http/Client/Adapter/Test.php';
 
+require_once 'Zend/XmlRpc/Value/DateTime.php';
+
 /**
  * Test case for Zend_XmlRpc_Value
  *
@@ -662,6 +664,27 @@ class Zend_XmlRpc_ClientTest extends PHPUnit_Framework_TestCase
         $this->assertTrue($this->xmlrpcClient->call('method'));
         $this->assertSame($expectedUserAgent, $this->httpClient->getHeader('user-agent'));
     }
+    
+    /**
+     * @group ZF-8478
+     */
+    public function testPythonSimpleXMLRPCServerWithUnsupportedMethodSignatures()
+    {
+        try
+        {
+        	$introspector = new Zend_XmlRpc_Client_ServerIntrospection(
+                new Test_XmlRpc_Client('http://localhost/')
+            );
+            
+            $signature = $introspector->getMethodSignature('add');
+            if (!is_array($signature)) {
+                $this->fail('Expected exception has not been thrown');
+            }
+        }
+        catch (Zend_XmlRpc_Client_IntrospectException $e) {
+            $this->assertEquals('Invalid signature for method "add"', $e->getMessage());
+        }
+    }
 
     // Helpers
     public function setServerResponseTo($nativeVars)
@@ -716,6 +739,28 @@ class Zend_XmlRpc_ClientTest extends PHPUnit_Framework_TestCase
     }
 }
 
+/** related to ZF-8478 */
+require_once 'Zend/XmlRpc/Client/ServerProxy.php';
+class Python_SimpleXMLRPCServerWithUnsupportedIntrospection extends Zend_XmlRpc_Client_ServerProxy {
+    public function __call($method, $args) {
+        if ($method == 'methodSignature') {
+            return 'signatures not supported';
+        }
+        return parent::__call($method, $args);
+    }
+}
+
+/** related to ZF-8478 */
+require_once 'Zend/XmlRpc/Client.php';
+class Test_XmlRpc_Client extends Zend_XmlRpc_Client {
+    public function getProxy($namespace = '') {
+    	if (empty($this->_proxyCache[$namespace])) {
+    	    $this->_proxyCache[$namespace] = new Python_SimpleXMLRPCServerWithUnsupportedIntrospection($this, $namespace);
+    	}
+        return parent::getProxy($namespace);
+    }
+}
+
 // Call Zend_XmlRpc_ClientTest::main() if this source file is executed directly.
 if (PHPUnit_MAIN_METHOD == "Zend_XmlRpc_ClientTest::main") {
     Zend_XmlRpc_ClientTest::main();