From 68ec3575595f25873fb5b80e7bec59de04b8b4c2 Mon Sep 17 00:00:00 2001 From: rurban Date: Fri, 10 Dec 2004 02:42:11 +0000 Subject: [PATCH] add the xmlrpc testsuite (wiki and interop) from xmlrpc-epi git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/trunk@4258 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- tests/unit/runme_mem | 3 - tests/unit/test.php | 2 +- tests/xmlrpc/interop-client.php | 309 ++++++++ tests/xmlrpc/interop-server.php | 269 +++++++ tests/xmlrpc/validate-form.php | 1163 ++++++++++++++++++++++++++++ tests/xmlrpc/validate.php | 257 ++++++ tests/xmlrpc/xmlrpc-client.php | 218 ++++++ tests/xmlrpc/xmlrpc-introspect.php | 316 ++++++++ tests/xmlrpc/xmlrpc-servers.php | 256 ++++++ tests/xmlrpc/xmlrpc_utils.php | 12 + 10 files changed, 2801 insertions(+), 4 deletions(-) create mode 100644 tests/xmlrpc/interop-client.php create mode 100644 tests/xmlrpc/interop-server.php create mode 100644 tests/xmlrpc/validate-form.php create mode 100644 tests/xmlrpc/validate.php create mode 100644 tests/xmlrpc/xmlrpc-client.php create mode 100644 tests/xmlrpc/xmlrpc-introspect.php create mode 100644 tests/xmlrpc/xmlrpc-servers.php create mode 100644 tests/xmlrpc/xmlrpc_utils.php diff --git a/tests/unit/runme_mem b/tests/unit/runme_mem index 5127592a9..327d366f8 100755 --- a/tests/unit/runme_mem +++ b/tests/unit/runme_mem @@ -39,6 +39,3 @@ done #pl -png -o compare.png -prefab compare data=$prefix_combined.data catfields=1 y=3 y2=4 y3=5 y4=6 ylbl="memory (kb)" title="$title" ygrid=yes ylbldet="adjust=-0.1,0" barwidth=0.01 stubvert=yes header=yes name=file name2=dba name3=SQL name4=ADODB #pl -png -o lines.png -prefab lines data=$prefix_combined.data x=2 y=3 y2=4 y3=5 y4=6 ylbl="memory (kb)" title="$title" ygrid=yes ylbldet="adjust=-0.1,0" stubvert=yes header=yes name=file name2=dba name3=SQL name4=ADODB - - - diff --git a/tests/unit/test.php b/tests/unit/test.php index 15e965c4d..9ad9e5e78 100644 --- a/tests/unit/test.php +++ b/tests/unit/test.php @@ -471,7 +471,7 @@ ob_end_flush(); if ($debug_level & 1) { //echo "\n"; - echo "PHPWIKI_VERSION=",PHPWIKI_VERSION, strstr(PHPWIKI_VERSION,"pre") ? strftime("-%Y%m%d") : "","\n"; + echo "PHPWIKI_VERSION=",PHPWIKI_VERSION, strstr(PHPWIKI_VERSION,"pre") ? strftime(" / %Y%m%d") : "","\n"; if ($debug_level & 9) { // which constants affect memory? foreach (explode(",","USECACHE,WIKIDB_NOCACHE_MARKUP,ENABLE_USER_NEW,ENABLE_PAGEPERM") as $v) { diff --git a/tests/xmlrpc/interop-client.php b/tests/xmlrpc/interop-client.php new file mode 100644 index 000000000..0606eec92 --- /dev/null +++ b/tests/xmlrpc/interop-client.php @@ -0,0 +1,309 @@ + $c) { + $d = $b[$key]; + if (!match($c, $d)) { + $matches = false; + break; + } + } + } else { + if ($a !== $b || xmlrpc_get_type($a) !== xmlrpc_get_type($b)) { + $matches = false; + } + } + return $matches; +} + +function pass($method) { + echo "pass $method()
"; +} + +function fail($method, $sent, $received) { + echo "fail $method()
"; + if ($sent) { + echo "

sent

"; + var_dump($sent); + echo ""; + } + + if ($received) { + echo "

received

"; + var_dump($received); + echo ""; + } +} + +function check_if_matches($method, $sent, $received) { + if (match($sent, $received)) { + pass($method); + } + else { + fail($method, $sent, $received); + } +} + +function foo($method_name, $args) { + xmlrpc_encode_request($method_name, $args); +} + +function run_test($server, $debug, $output, $method, $args) { + echo "
"; + $params = array($args); + $result = xu_rpc_http_concise(array(method => $method, + args => $params, + host => $server[host], + uri => $server[uri], + port => $server[port], + debug => $debug, + output => $output)); + check_if_matches($method, $args, $result); + echo ""; + flush(); +} + +function run_no_param_test($server, $debug, $output, $method) { + echo "
"; + $result = xu_rpc_http_concise(array(method => $method, + host => $server[host], + uri => $server[uri], + port => $server[port], + debug => $debug, + output => $output)); + + if($result && gettype($result) === "integer") { + pass($method); + } + else { + fail($method, false, $result); + } + + flush(); +} + + +$decl_1 = "IN CONGRESS, July 4, 1776."; +$decl_2 = "The unanimous Declaration of the thirteen united States of America,"; +$decl_3 = "When in the Course of human events, it becomes necessary for one people to dissolve the political bands which have connected them with another, and to assume among the powers of the earth, the separate and equal station to which the Laws of Nature and of Nature's God entitle them, a decent respect to the opinions of mankind requires that they should declare the causes which impel them to the separation."; +$decl_4 = "We hold these truths to be self-evident, that all men are created equal, that they are endowed by their Creator with certain unalienable Rights,that among these are Life, Liberty and the pursuit of Happiness.--That to secure these rights, Governments are instituted among Men, deriving their just powers from the consent of the governed, --That whenever any Form of Government becomes destructive of these ends, it is the Right of the People to alter or to abolish it, and to institute new Government, laying its foundation on such principles and organizing its powers in such form, as to them shall seem most likely to effect their Safety and Happiness. Prudence, indeed, will dictate that Governments long established should not be changed for light and transient causes; and accordingly all experience hath shewn, that mankind are more disposed to suffer, while evils are sufferable, than to right themselves by abolishing the forms to which they are accustomed. But when a long train of abuses and usurpations, pursuing invariably the same Object evinces a design to reduce them under absolute Despotism, it is their right, it is their duty, to throw off such Government, and to provide new Guards for their future security.--Such has been the patient sufferance of these Colonies; and such is now the necessity which constrains them to alter their former Systems of Government. The history of the present King of Great Britain is a history of repeated injuries and usurpations, all having in direct object the establishment of an absolute Tyranny over these States. To prove this, let Facts be submitted to a candid world."; + +// a method to run interop tests against remote server. tests described at bottom. +function run_easy_tests($server, $debug=0, $output = null) { + global $decl_1, $decl_2, $decl_3, $decl_4; + run_test($server, $debug, $output, "interopEchoTests.echoString", "That government is best, which governs least"); + run_test($server, $debug, $output, "interopEchoTests.echoBoolean", true); + run_test($server, $debug, $output, "interopEchoTests.echoInteger", 42); + run_test($server, $debug, $output, "interopEchoTests.echoFloat", 3.1416); + run_test($server, $debug, $output, "interopEchoTests.echoStruct", array("varFloat" => 1.2345, + "varInt" => 186000, + "varString" => "a string" )); + run_test($server, $debug, $output, "interopEchoTests.echoStringArray", array($decl_1, $decl_2, $decl_3, $decl_4)); + run_test($server, $debug, $output, "interopEchoTests.echoIntegerArray", array(23, 234, 1, 0, -10, 999)); + run_test($server, $debug, $output, "interopEchoTests.echoFloatArray", array(2.45, 9.9999)); + run_test($server, $debug, $output, "interopEchoTests.echoStructArray", array(array("varFloat" => 1.2345, + "varInt" => 186000, + "varString" => "a string"), + array("varFloat" => 10.98765, + "varInt" => 3200, + "varString" => "happy little string" ) + )); + + $foo = "some base64 string"; + xmlrpc_set_type(&$foo, "base64"); + run_test($server, $debug, $output, "interopEchoTests.echoBase64", $foo); + + $foo="19980717T14:08:55"; + xmlrpc_set_type(&$foo, "datetime"); + run_test($server, $debug, $output, "interopEchoTests.echoDate", $foo); + + run_no_param_test($server, $debug, $output, "interopEchoTests.noInParams"); +} + +function ident($server, $debug=0, $output=null) { + $method = "interopEchoTests.whichToolkit"; + $result = xu_rpc_http_concise(array('method' => $method, + 'host' => $server['host'], + 'uri' => $server['uri'], + 'port' => $server['port'], + 'debug' => $debug, + 'output' => $output)); + if ($result && $result['toolkitDocsUrl'] && !$result['faultCode']) { + pass($method); + echo "
"; + foreach($result as $key => $value) { + if(substr($value, 0, 7) === "http://") { + $value = "$value"; + } + echo "$key: $value
"; + } + } + else { + fail($method, false, $result); + } +} + +function run_stress_tests($server, $debug=0, $output=null) { + global $decl_1, $decl_2, $decl_3, $decl_4; + run_test($server, $debug, $output, "interopEchoTests.echoString", "XML Comment in a string: "); + run_test($server, $debug, $output, "interopEchoTests.echoInteger", 4200000000); + run_test($server, $debug, $output, "interopEchoTests.echoFloat", 1.2); + run_test($server, $debug, $output, "interopEchoTests.echoStruct", + array("varFloat" => 1.2345, + "varInt" => 186000, + "varString" => "18 > 2 && 2 < 18 && 42 == the answer to life, the universe, and everything" )); + run_test($server, $debug, $output, "interopEchoTests.echoStringArray", + array($decl_1, $decl_2, $decl_3, $decl_4, "non-ascii chars above 127 (165-170): ¥, ¦, §, ¨, ©, ª")); + run_test($server, $debug, $output, "interopEchoTests.echoIntegerArray", + array(23, 234, 1, 0, -10, 999)); + run_test($server, $debug, $output, "interopEchoTests.echoFloatArray", + array(2.45, 9.9999)); + run_test($server, $debug, $output, "interopEchoTests.echoStructArray", + array(array("varFloat" => 1.2345, + "varInt" => 186000, + "varString" => "non-print char (8): "), + array("varFloat" => 10.98765, + "varInt" => 3200, + "varString" => "happy little string" ) + )); +} + +// a method to display an html form for invoking the script +function print_html_form($servers_list) { + + echo <<< END +

Choose an xmlrpc server to run interop tests against live!

+END; + + print_servers_form($servers_list); + +echo <<< END +

+if you know of any other servers that support interop tests, please send a note to + xmlrpc-epi-devel@lists.sourceforge.net + and we will add it to the list. +END; + +} + +// some code which determines if we are in form display or response mode. +$server_list = get_interop_servers(); +$server = get_server_from_user($server_list); +if ($server) { + $debug = $GLOBALS['HTTP_GET_VARS']['debug'] || $GLOBALS['HTTP_GET_VARS']['start_debug']; + $output['version'] = $GLOBALS['HTTP_GET_VARS']['version']; + if ($server) { + $title = $server['title']; + echo "

Results for $title

"; + + ident($server, $debug, $output); + + if($GLOBALS['HTTP_GET_VARS']['stress'] == 1) { + run_stress_tests($server, $debug, $output); + } + else { + run_easy_tests($server, $debug, $output); + } + } + else { + echo "

invalid option

"; + } +} +else { + print_html_form($server_list); +} + +/* Interop tests description: + +interopEchoTests.echoString (inputString) -- Sends a random string to the server, and checks that the +response is a string whose value is the same as the string that was sent. + +interopEchoTests.echoInteger (inputInteger) -- Sends a random integer to the server, and checks that +the response is an integer whose value is the same as the integer that was sent. + +interopEchoTests.echoFloat (inputFloat) -- Sends a random floating point number to the server, and +checks that the response is a float whose value is the same as the number that was sent. + +interopEchoTests.echoStruct (inputStruct) -- Sends a struct to the server, which contains three +elements: varString, varInt, and varFloat, a random string, a random integer, and a random float, +respectively, and checks that the response is a struct containing the same values that were sent. + +interopEchoTests.echoStringArray (inputStringArray) -- Sends an array of random strings to the server, +and checks that the response is an array of strings, whose values are the same as the values that were +sent. + +interopEchoTests.echoIntegerArray (inputIntegerArray) -- Sends an array of random integers to the +server, and checks that the response is an array of integers, whose values are the same as the values that +were sent. + +interopEchoTests.echoFloatArray (inputFloatArray) -- Sends an array of random floating point numbers +to the server, and checks that the response is an array of floats, whose values are the same as the values +that were sent. + +interopEchoTests.echoStructArray (inputStructArray) -- Sends an array of structs to the server, and +checks that the response is an array of structs, which contain the same values that were sent. Each struct +contains three elements: varString, varInt, and varFloat, a string, an integer, and a floating point number, +respectively. + + */ \ No newline at end of file diff --git a/tests/xmlrpc/interop-server.php b/tests/xmlrpc/interop-server.php new file mode 100644 index 000000000..a7789037c --- /dev/null +++ b/tests/xmlrpc/interop-server.php @@ -0,0 +1,269 @@ + "http://xmlrpc-epi.sourceforge.net/", + toolkitName => "xmlrpc-epi-php", + toolkitVersion => "0.26", // (need to implement xmlrpc_get_version() + toolkitOperatingSystem => $GLOBALS[MACHTYPE] + ); +} + +/* +interopEchoTests.echoString (inputString) -- Sends a random string to the server, and checks that the +response is a string whose value is the same as the string that was sent. + +interopEchoTests.echoInteger (inputInteger) -- Sends a random integer to the server, and checks that +the response is an integer whose value is the same as the integer that was sent. + +interopEchoTests.echoFloat (inputFloat) -- Sends a random floating point number to the server, and +checks that the response is a float whose value is the same as the number that was sent. + +interopEchoTests.echoStruct (inputStruct) -- Sends a struct to the server, which contains three +elements: varString, varInt, and varFloat, a random string, a random integer, and a random float, +respectively, and checks that the response is a struct containing the same values that were sent. + +interopEchoTests.echoStringArray (inputStringArray) -- Sends an array of random strings to the server, +and checks that the response is an array of strings, whose values are the same as the values that were +sent. + +interopEchoTests.echoIntegerArray (inputIntegerArray) -- Sends an array of random integers to the +server, and checks that the response is an array of integers, whose values are the same as the values that +were sent. + +interopEchoTests.echoFloatArray (inputFloatArray) -- Sends an array of random floating point numbers +to the server, and checks that the response is an array of floats, whose values are the same as the values +that were sent. + +interopEchoTests.echoStructArray (inputStructArray) -- Sends an array of structs to the server, and +checks that the response is an array of structs, which contain the same values that were sent. Each struct +contains three elements: varString, varInt, and varFloat, a string, an integer, and a floating point number, +respectively. +*/ + +$request_xml = $HTTP_RAW_POST_DATA; +if(!$request_xml) { + $request_xml = $HTTP_POST_VARS[xml]; +} + +if(!$request_xml) { + echo "

No XML input found!

"; +} +else { + // create server + $xmlrpc_server = xmlrpc_server_create(); + + if($xmlrpc_server) { + // register xmlrpc methods + xmlrpc_server_register_method($xmlrpc_server, "interopEchoTests.echoBoolean", "method_echo"); + xmlrpc_server_register_method($xmlrpc_server, "interopEchoTests.echoString", "method_echo"); + xmlrpc_server_register_method($xmlrpc_server, "interopEchoTests.echoInteger", "method_echo"); + xmlrpc_server_register_method($xmlrpc_server, "interopEchoTests.echoFloat", "method_echo"); + xmlrpc_server_register_method($xmlrpc_server, "interopEchoTests.echoBase64", "method_echo"); + xmlrpc_server_register_method($xmlrpc_server, "interopEchoTests.echoDate", "method_echo"); + xmlrpc_server_register_method($xmlrpc_server, "interopEchoTests.echoValue", "method_echo"); + xmlrpc_server_register_method($xmlrpc_server, "interopEchoTests.echoStruct", "method_echo"); + xmlrpc_server_register_method($xmlrpc_server, "interopEchoTests.echoStringArray", "method_echo"); + xmlrpc_server_register_method($xmlrpc_server, "interopEchoTests.echoIntegerArray", "method_echo"); + xmlrpc_server_register_method($xmlrpc_server, "interopEchoTests.echoFloatArray", "method_echo"); + xmlrpc_server_register_method($xmlrpc_server, "interopEchoTests.echoStructArray", "method_echo"); + xmlrpc_server_register_method($xmlrpc_server, "interopEchoTests.echoVoid", "method_echo_void"); + xmlrpc_server_register_method($xmlrpc_server, "interopEchoTests.whichToolkit", "method_toolkit"); + xmlrpc_server_register_method($xmlrpc_server, "interopEchoTests.noInParams", "method_no_in_params"); + + // soap methods (interop test naming conventions are slightly different for soap) + xmlrpc_server_register_method($xmlrpc_server, "echoBoolean", "method_echo"); + xmlrpc_server_register_method($xmlrpc_server, "echoString", "method_echo"); + xmlrpc_server_register_method($xmlrpc_server, "echoInteger", "method_echo"); + xmlrpc_server_register_method($xmlrpc_server, "echoFloat", "method_echo"); + xmlrpc_server_register_method($xmlrpc_server, "echoBase64", "method_echo"); + xmlrpc_server_register_method($xmlrpc_server, "echoDate", "method_echo"); + xmlrpc_server_register_method($xmlrpc_server, "echoValue", "method_echo"); + xmlrpc_server_register_method($xmlrpc_server, "echoStruct", "method_echo"); + xmlrpc_server_register_method($xmlrpc_server, "echoStringArray", "method_echo"); + xmlrpc_server_register_method($xmlrpc_server, "echoIntegerArray", "method_echo"); + xmlrpc_server_register_method($xmlrpc_server, "echoFloatArray", "method_echo"); + xmlrpc_server_register_method($xmlrpc_server, "echoStructArray", "method_echo"); + xmlrpc_server_register_method($xmlrpc_server, "echoVoid", "method_echo_void"); + xmlrpc_server_register_method($xmlrpc_server, "whichToolkit", "method_toolkit"); + xmlrpc_server_register_method($xmlrpc_server, "noInParams", "method_no_in_params"); + + + xmlrpc_server_register_introspection_callback($xmlrpc_server, "introspection_cb"); + + //$val = xmlrpc_decode($request_xml, &$method); + //echo "xml: $request_xml\n"; + //echo "method: $method\nvar: "; + //print_r($val); + // parse xml and call method + echo xmlrpc_server_call_method($xmlrpc_server, $request_xml, $response, array(output_type => "xml", version => "auto")); + + // free server resources + $success = xmlrpc_server_destroy($xmlrpc_server); + } +} + + + +/******************** +* API Documentation * +********************/ + +function introspection_cb($method) { + /* if our xml is not parsed correctly, a php warning will be displayed. + * however, very little structural validation is done, so we must be careful. + * make sure to test this xml for syntax errors by calling system.describeMethods() + * after making any changes. + */ + + $methods = array("boolean", "string", "integer", "float", "base64", "date", "value", "struct"); + $type_map = array(integer => "int", float => "double", date => "datetime", value => "any"); + + foreach($methods as $method) { + $title = ucfirst($method); + $type = $type_map[$method] ? $type_map[$method] : $method; + + $xml_methods .= <<< END + + + Dan Libby <dan@libby.com> + echos $type parameter back to caller + 1.0 + + + + + + + + + + + + + + + +END; + + + } + + $methods = array("string", "integer", "float", "struct"); + foreach($methods as $method) { + $title = ucfirst($method) . "Array"; + $type = $type_map[$method] ? $type_map[$method] : $method; + + $xml_methods .= <<< END + + + Dan Libby <dan@libby.com> + echos array of $type parameter back to caller + 1.0 + + + + + + + + + + + + + + + + + + + +END; + + + } + + return <<< END + + + + + + + $xml_methods + + + + Dan Libby <dan@libby.com> + returns information about the xml-rpc library in use + 1.0 + + + + + + + + + + + + + + + + + + + + + Dan Libby <dan@libby.com> + tests calling methods with no parameters + 1.0 + + + + + + + + + + + + + + + + +END; + +} + + + +?> diff --git a/tests/xmlrpc/validate-form.php b/tests/xmlrpc/validate-form.php new file mode 100644 index 000000000..5a33824d1 --- /dev/null +++ b/tests/xmlrpc/validate-form.php @@ -0,0 +1,1163 @@ + + +$desc

"; + } +echo <<< END +

TEST: $title

+$desc +

Enter your xmlrpc query

+
+
+ +encoding
+ +
+ +output type
+xml +php +
+
+These options apply to xml output type only.
+ +output version
+xmlrpc +simple +
+ +output verbosity
+pretty +newlines only +no white space +
+ +output escaping
+markup +cdata +non-ascii +non-print +
+ + + +
+
+END; + +} + + +$test_cases = array( + array( + title => "custom user input", + desc => "Enter your own xml here if you have a specific xmlrpc query you would like to perform.", + xml => ""), +array( + title => "arrayOfStructsTest", + desc => + "This handler takes a single parameter, an array of structs, each of which contains at least three elements + named moe, larry and curly, all s. Your handler must add all the struct elements named curly and + return the result.", + xml => +" + + +validator1.arrayOfStructsTest + + + + + + + +curly + +-79 + + + +larry + +34 + + + +moe + +19 + + + + + + + +curly + +-33 + + + +larry + +36 + + + +moe + +40 + + + + + + + +curly + +-30 + + + +larry + +52 + + + +moe + +1 + + + + + + + +curly + +-7 + + + +larry + +82 + + + +moe + +35 + + + + + + + +curly + +0 + + + +larry + +54 + + + +moe + +82 + + + + + + + +curly + +-5 + + + +larry + +5 + + + +moe + +66 + + + + + + + +curly + +-10 + + + +larry + +65 + + + +moe + +53 + + + + + + + +curly + +-2 + + + +larry + +66 + + + +moe + +43 + + + + + + + + +" ), + + array( + title => "countTheEntities", + desc => "This handler takes a single parameter, a string, that contains any number of predefined entities, namely <, + >, &, ' and \". + + Your handler must return a struct that contains five fields, all numbers: ctLeftAngleBrackets, + ctRightAngleBrackets, ctAmpersands, ctApostrophes, ctQuotes. + + To validate, the numbers must be correct", + xml => +" + +validator1.countTheEntities + + +b&amp;htj&gt;q&lt;e&gt;ow&lt;&gt;&lt;a&quot;&gt;&quot;&gt;m&amp;&lt;y&gt;&gt;g&lt;&quot;kf&amp;nup&gt;&amp;lsz&amp;lt;xi&amp;d&quot;&lt;&apos;crv&lt; + + +"), + array( + title => "easyStructTest", + desc => "This handler takes a single parameter, a struct, containing at least three elements named moe, larry and curly, all s. Your handler must add the three numbers and return the result.", + xml => +" + + validator1.easyStructTest + + + + + curly + + -60 + + + + larry + + 22 + + + + moe + + 37 + + + + + + "), + array( + title => "echoStructTest", + desc => "This handler takes a single parameter, a struct. Your handler must return the struct.", + xml => +" + + validator1.echoStructTest + + + + + substruct0 + + + + curly + + -52 + + + + larry + + 55 + + + + moe + + 82 + + + + + + + substruct1 + + + + curly + + -59 + + + + larry + + 70 + + + + moe + + 20 + + + + + + + substruct2 + + + + curly + + -26 + + + + larry + + 1 + + + + moe + + 4 + + + + + + + substruct3 + + + + curly + + -42 + + + + larry + + 73 + + + + moe + + 45 + + + + + + + substruct4 + + + + curly + + -48 + + + + larry + + 16 + + + + moe + + 57 + + + + + + + substruct5 + + + + curly + + -1 + + + + larry + + 77 + + + + moe + + 100 + + + + + + + substruct6 + + + + curly + + -44 + + + + larry + + 2 + + + + moe + + 42 + + + + + + + substruct7 + + + + curly + + -84 + + + + larry + + 18 + + + + moe + + 95 + + + + + + + substruct8 + + + + curly + + -48 + + + + larry + + 93 + + + + moe + + 80 + + + + + + + substruct9 + + + + curly + + -82 + + + + larry + + 58 + + + + moe + + 21 + + + + + + + + + "), + array( + title => "manyTypesTest", + desc => "This handler takes six parameters, and returns an array containing all the parameters.", + xml => +" + + validator1.manyTypesTest + + + 24288 + + + 0 + + + Texas + + + 1762.0 + + + 19040101T05:24:54 + + + R0lGODlhFgASAJEAAP/////OnM7O/wAAACH5BAEAAAAALAAAAAAWABIAAAJAhI+py40zDIzujEDBzW0n74AaFGChqZUYylyYq7ILXJJ1BU95l6r23RrRYhyL5jiJAT/Ink8WTPoqHx31im0UAAA7 + + + "), + array( + title => "moderateSizeArrayCheck", + desc => "This handler takes a single parameter, which is an array containing between 100 and 200 elements. Each of the items is a string, your handler must return a string containing the concatenated text of the first and last elements.", + xml => +" + + validator1.moderateSizeArrayCheck + + + + + Maine + Nebraska + Nebraska + Kansas + Tennessee + Ohio + Oregon + Missouri + Mississippi + Michigan + Pennsylvania + Rhode Island + Iowa + Iowa + Nebraska + Washington + Oregon + Virginia + Arizona + Utah + South Carolina + Montana + Tennessee + Iowa + Maryland + Michigan + Iowa + Wisconsin + Delaware + Kansas + North Dakota + Massachusetts + New Mexico + Alaska + Michigan + Colorado + Wisconsin + South Dakota + Vermont + Virginia + Arkansas + Wisconsin + Colorado + Iowa + Oregon + Arizona + Michigan + Illinois + Virginia + Florida + South Carolina + Florida + Arkansas + Maryland + Rhode Island + Washington + Georgia + Arizona + Iowa + Louisiana + Washington + Nevada + Alaska + Hawaii + New Hampshire + West Virginia + South Carolina + Vermont + Tennessee + Connecticut + Maine + Louisiana + Alaska + Maine + California + Vermont + Rhode Island + West Virginia + Colorado + Delaware + Massachusetts + Rhode Island + Nevada + Oklahoma + Nebraska + Ohio + Indiana + Mississippi + Mississippi + Washington + Tennessee + Arkansas + Alaska + Rhode Island + Oklahoma + Massachusetts + Connecticut + Connecticut + Virginia + Nebraska + Alabama + Louisiana + Colorado + Vermont + New Hampshire + Ohio + Nebraska + Wisconsin + Kansas + + + + + "), + array( + title => "nestedStructTest", + desc => "This handler takes a single parameter, a struct, that models a daily calendar. At the top level, there is one + struct for each year. Each year is broken down into months, and months into days. Most of the days are + empty in the struct you receive, but the entry for April 1, 2000 contains a least three elements named moe, + larry and curly, all s. Your handler must add the three numbers and return the result. +

+ Ken MacLeod: \"This description isn't clear, I expected '2000.April.1' when in fact it's '2000.04.01'. Adding + a note saying that month and day are two-digits with leading 0s, and January is 01 would help.\" Done.", + xml => +" + +validator1.nestedStructTest + + + + +2000 + + + +03 + + + +10 + + + + + + +11 + + + + + + +12 + + + + + + +13 + + + + + + +14 + + + + + + +15 + + + + + + +16 + + + + + + +17 + + + + + + +18 + + + + + + +19 + + + + + + +20 + + + + + + +21 + + + + + + +22 + + + + + + +23 + + + + + + +24 + + + + + + +25 + + + + + + +26 + + + + + + +27 + + + + + + +28 + + + + + + +29 + + + + + + +30 + + + + + + +31 + + + + + + + + + +04 + + + +01 + + + +curly + + -23 + + + +larry + + 96 + + + +moe + + 17 + + + + + + +02 + + + + + + +03 + + + + + + +04 + + + + + + +05 + + + + + + +06 + + + + + + +07 + + + + + + +08 + + + + + + +09 + + + + + + +10 + + + + + + +11 + + + + + + +12 + + + + + + +13 + + + + + + +14 + + + + + + +15 + + + + + + +16 + + + + + + +17 + + + + + + +18 + + + + + + +19 + + + + + + +20 + + + + + + +21 + + + + + + +22 + + + + + + +23 + + + + + + + + + + + + + + +"), + array( + title => "simpleStructReturnTest", + desc => "This handler takes one parameter, and returns a struct containing three elements, times10, times100 and times1000, the result of multiplying the number by 10, 100 and 1000.", + xml => +" + +validator1.simpleStructReturnTest + + + 55 + + +") + +); + +foreach($test_cases as $test_case) { + do_test_case($test_case[title], $test_case[desc], $test_case[xml]); +} + +?> + + diff --git a/tests/xmlrpc/validate.php b/tests/xmlrpc/validate.php new file mode 100644 index 000000000..1e4455886 --- /dev/null +++ b/tests/xmlrpc/validate.php @@ -0,0 +1,257 @@ +s. + * Your handler must add all the struct elements named curly and return the + * result. + */ +function validator1_arrayOfStructsTest($method_name, $params, $app_data) { + $iCurly = 0; + + foreach(array_pop($params) as $iter) { + $iCurly += $iter["curly"]; + } + + return $iCurly; +} + +/* + * This handler takes a single parameter, a string, that contains any number + * of predefined entities, namely <, >, &, ' and ". + * + * Your handler must return a struct that contains five fields, all numbers: + * ctLeftAngleBrackets, ctRightAngleBrackets, ctAmpersands, ctApostrophes, + * ctQuotes. + * + * To validate, the numbers must be correct. + */ +function validator1_countTheEntities ($method_name, $params, $app_data) { + $xStruct = array(); + + //returns struct + $counts = count_chars(array_pop($params), 0); + + $xStruct["ctLeftAngleBrackets"] = $counts[ord('<')]; + $xStruct["ctRightAngleBrackets"] = $counts[ord('>')]; + $xStruct["ctAmpersands"] = $counts[ord('&')]; + $xStruct["ctApostrophes"] = $counts[ord("'")]; + $xStruct["ctQuotes"] = $counts[ord('"')]; + + return $xStruct; +} + +/* + * This handler takes a single parameter, a struct, containing at least three + * elements named moe, larry and curly, all s. Your handler must add the + * three numbers and return the result. + */ +function validator1_easyStructTest ($method_name, $params, $app_data) { + $iSum = 0; + + $xStruct = array_pop($params); + if($xStruct) { + $iSum += $xStruct[curly]; + $iSum += $xStruct[moe]; + $iSum += $xStruct[larry]; + } + + return $iSum; +} + +/* + * This handler takes a single parameter, a struct. Your handler must return + * the struct. + */ +function validator1_echoStructTest($method_name, $params, $app_data) { + return $params[0]; +} + + +/* + * This handler takes six parameters, and returns an array containing all the + * parameters. + */ +function validator1_manyTypesTest ($method_name, $params, $app_data) { + $xArray = array(); + + foreach($params as $iter) { + array_push($xArray, $iter); + } + + + return $xArray; +} + +/* + * This handler takes a single parameter, which is an array containing + * between 100 and 200 elements. Each of the items is a string, your handler + * must return a string containing the concatenated text of the first and + * last elements. + */ +function validator1_moderateSizeArrayCheck ($method_name, $params, $app_data) { + $xArray = array_pop($params); + if($xArray) { + $buf = $xArray[0] . $xArray[count($xArray) - 1]; + } + + return $buf; +} + +/* + * This handler takes a single parameter, a struct, that models a daily + * calendar. At the top level, there is one struct for each year. Each year + * is broken down into months, and months into days. Most of the days are + * empty in the struct you receive, but the entry for April 1, 2000 contains + * a least three elements named moe, larry and curly, all s. Your + * handler must add the three numbers and return the result. + * + * Ken MacLeod: "This description isn't clear, I expected '2000.April.1' when + * in fact it's '2000.04.01'. Adding a note saying that month and day are + * two-digits with leading 0s, and January is 01 would help." Done. + */ +function validator1_nestedStructTest ($method_name, $params, $app_data) { + + $iSum = 0; + + $xStruct = array_pop($params); + $xYear = $xStruct['2000']; + $xMonth = $xYear['04']; + $xDay = $xMonth['01']; + + $iSum += $xDay["larry"]; + $iSum += $xDay["curly"]; + $iSum += $xDay["moe"]; + + return $iSum; +} + +/* + * This handler takes one parameter, and returns a struct containing three + * elements, times10, times100 and times1000, the result of multiplying the + * number by 10, 100 and 1000. + */ +function validator1_simpleStructReturnTest ($method_name, $params, $app_data) { + $xStruct = array(); + + $iIncoming = array_pop($params); + + $xStruct["times10"] = $iIncoming * 10; + $xStruct["times100"] = $iIncoming * 100; + $xStruct["times1000"] = $iIncoming * 1000; + + return $xStruct; +} + + + /* create a new server object */ + $server = xmlrpc_server_create(); + + xmlrpc_server_register_method($server, "validator1.arrayOfStructsTest", "validator1_arrayOfStructsTest"); + xmlrpc_server_register_method($server, "validator1.countTheEntities", "validator1_countTheEntities"); + xmlrpc_server_register_method($server, "validator1.easyStructTest", "validator1_easyStructTest"); + xmlrpc_server_register_method($server, "validator1.echoStructTest", "validator1_echoStructTest"); + xmlrpc_server_register_method($server, "validator1.manyTypesTest", "validator1_manyTypesTest"); + xmlrpc_server_register_method($server, "validator1.moderateSizeArrayCheck", "validator1_moderateSizeArrayCheck"); + xmlrpc_server_register_method($server, "validator1.nestedStructTest", "validator1_nestedStructTest"); + xmlrpc_server_register_method($server, "validator1.simpleStructReturnTest", "validator1_simpleStructReturnTest"); + + // name differently for soap. + xmlrpc_server_register_method($server, "arrayOfStructsTest", "validator1_arrayOfStructsTest"); + xmlrpc_server_register_method($server, "countTheEntities", "validator1_countTheEntities"); + xmlrpc_server_register_method($server, "easyStructTest", "validator1_easyStructTest"); + xmlrpc_server_register_method($server, "echoStructTest", "validator1_echoStructTest"); + xmlrpc_server_register_method($server, "manyTypesTest", "validator1_manyTypesTest"); + xmlrpc_server_register_method($server, "moderateSizeArrayCheck", "validator1_moderateSizeArrayCheck"); + xmlrpc_server_register_method($server, "nestedStructTest", "validator1_nestedStructTest"); + xmlrpc_server_register_method($server, "simpleStructReturnTest", "validator1_simpleStructReturnTest"); + + + /* Now, let's get the client's request from the post data.... */ + $request_xml = $HTTP_RAW_POST_DATA; + if(!$request_xml) { + $request_xml = $HTTP_GET_VARS[xml]; + } + if(!$request_xml) { + echo "

No XML input found!

"; + } + else { + /* setup some (optional) output options */ + $display = array(); + if($HTTP_POST_VARS[verbosity]) { + $display[verbosity] = $HTTP_POST_VARS[verbosity]; + } + if($HTTP_POST_VARS[escaping]) { + $display[escaping] = $HTTP_POST_VARS[escaping]; + } + else { + $display[escaping] = array("non-ascii", "markup"); + } + if($HTTP_POST_VARS[version]) { + $display[version] = $HTTP_POST_VARS[version]; + } + if($HTTP_POST_VARS[encoding]) { + $display[encoding] = $HTTP_POST_VARS[encoding]; + } + if($HTTP_POST_VARS[output_type]) { + $display[output_type] = $HTTP_POST_VARS[output_type]; + } + + /* handle the request */ + $response = xmlrpc_server_call_method($server, $request_xml, $response, $display); + + if($HTTP_POST_VARS[disp] === "html") { + if($HTTP_POST_VARS[output_type] === "php") { + echo "\n"; + var_dump($response); + echo "\n\n"; + } + else { + echo "\n$response\n\n"; + } + } + else { + echo "$response"; + } + } + +?> diff --git a/tests/xmlrpc/xmlrpc-client.php b/tests/xmlrpc/xmlrpc-client.php new file mode 100644 index 000000000..c821020d4 --- /dev/null +++ b/tests/xmlrpc/xmlrpc-client.php @@ -0,0 +1,218 @@ + $c) { + $d = $b[$key]; + if (!match($c, $d)) { + $matches = false; + break; + } + } + } else { + if ($a !== $b || xmlrpc_get_type($a) !== xmlrpc_get_type($b)) { + $matches = false; + } + } + return $matches; +} + +function pass($method) { + echo "pass $method()
"; +} + +function fail($method, $sent, $received) { + echo "fail $method()
"; + if ($sent) { + echo "

sent

"; + var_dump($sent); + echo ""; + } + + if ($received) { + echo "

received

"; + var_dump($received); + echo ""; + } +} + +function check_if_matches($method, $sent, $received) { + if (match($sent, $received)) { + pass($method); + } + else { + fail($method, $sent, $received); + } +} + +function foo($method_name, $args) { + xmlrpc_encode_request($method_name, $args); +} + +function run_test($server, $debug, $output, $method, $args) { + global $HTTP_GET_VARS; + echo "
"; + $params = array($args); + if (!empty($HTTP_GET_VARS['start_debug'])) // zend ide support + $server['uri'] .= "?start_debug=1"; + $result = xu_rpc_http_concise(array('method' => $method, + 'args' => $params, + 'host' => $server['host'], + 'uri' => $server['uri'], + 'port' => $server['port'], + 'debug' => $debug, + 'output' => $output)); + check_if_matches($method, $args, $result); + echo ""; + flush(); +} + +function run_no_param_test($server, $debug, $output, $method) { + global $HTTP_GET_VARS; + echo "
"; + if (!empty($HTTP_GET_VARS['start_debug'])) // zend ide support + $server['uri'] .= "?start_debug=1"; + $result = xu_rpc_http_concise(array('method' => $method, + 'host' => $server['host'], + 'uri' => $server['uri'], + 'port' => $server['port'], + 'debug' => $debug, + 'output' => $output)); + + if ($result && gettype($result) === "integer") { + pass($method); + } + else { + fail($method, false, $result); + } + + flush(); +} + + +// a method to run wiki tests against remote server. tests described at bottom. +function run_easy_tests($server, $debug=0, $output = null) { + + global $wiki_dmap; + + run_no_param_test($server, $debug, $output, "wiki.getRPCVersionSupported"); + // of the last day: + run_test($server, $debug, $output, "wiki.getRecentChanges", iso8601_encode(time()-86400, 1)); + /* ... */ +} + +function run_stress_tests($server, $debug=0, $output=null) { + + global $wiki_dmap; + + run_no_param_test($server, $debug, $output, "wiki.getRPCVersionSupported"); + // of the last day: + run_test($server, $debug, $output, "wiki.getRecentChanges", iso8601_encode(time()-86400, 1)); + /* ... */ +} + +// a method to display an html form for invoking the script +function print_html_form($servers_list) { + + echo <<< END +

Choose an xmlrpc wiki server to run tests against

+END; + + print_servers_form($servers_list); +} + +// some code which determines if we are in form display or response mode. +$server_list = get_wiki_servers(); +$server = get_server_from_user($server_list); +if ($server) { + $debug = $GLOBALS['HTTP_GET_VARS']['debug'] || $GLOBALS['HTTP_GET_VARS']['start_debug']; + $output['version'] = $GLOBALS['HTTP_GET_VARS']['version']; + if ($server) { + $title = $server['title']; + echo "

Results for $title

"; + + if($GLOBALS['HTTP_GET_VARS']['stress'] == 1) { + run_stress_tests($server, $debug, $output); + } + else { + run_easy_tests($server, $debug, $output); + } + } + else { + echo "

invalid option

"; + } +} +else { + print_html_form($server_list); +} diff --git a/tests/xmlrpc/xmlrpc-introspect.php b/tests/xmlrpc/xmlrpc-introspect.php new file mode 100644 index 000000000..e20c48a7c --- /dev/null +++ b/tests/xmlrpc/xmlrpc-introspect.php @@ -0,0 +1,316 @@ +Methods\n
    "; + foreach($methodList as $method) { + $name = $method[name]; + $buf .= "
  • $name()\n"; + $method_hash[$name] = $method; + } + $buf .= "
"; + } + if ($typeList) { + $buf .= "Types\n
    "; + foreach($typeList as $type) { + $name = $type[name]; + $buf .= "
  • $name\n"; + $xi_type_hash[$name] = $type; + } + $buf .= "
"; + } + + + $buf .= "

Methods

"; + foreach($methodList as $method) { + $name = $method[name]; + $author = $method[author] ? $method[author] : $unknown; + $version = $method[version] ? $method[version] : $unknown; + $desc = $method[purpose] ? $method[purpose] : $unknown; + $sigs = $method[signatures]; + $buf .= ""; + $buf .= "" . field("Signature(s)", get_sigs($method), 3) . ""; + $buf .= "" . field("Author", $author, 2) . field("Version", $version) . ""; + $buf .= "" . field("Purpose", $desc, 3) . ""; + + $exclude_list = array( + "see", + "signatures", + "purpose", + "version", + "author", + "name" + ); + foreach($method as $key => $val) { + if (!in_array($key, $exclude_list)) { + if (is_array($val)) { + $buf .= ""; + + foreach($val as $key2 => $desc) { + if (gettype($desc) === "string") { + if (gettype($key2) !== "string") { + $key2 = false; + } + + $buf .= "" . field(ucfirst($key2), $desc, 3) . ""; + } + } + } + else { + $buf .= "" . field(ucfirst($key), $val, 3) . ""; + } + } + } + + + if ($sigs) { + $bmultiple = count($sigs) > 1; + foreach($sigs as $sig) { + if ($bmultiple) { + $count ++; + $buf .= ""; + } + + if ($sig[params]) { + $buf .= ""; + + $buf .= ""; + } + + if ($sig[returns]) { + $buf .= ""; + $buf .= ""; + } + } + } + + if ($method[see]) { + $buf .= ""; + + foreach($method[see] as $name => $desc) { + if ($method_hash[$name]) { + $name = "$name"; + } + + $buf .= "" . field($name, $desc, 3) . ""; + } + } + } + $buf .= "
$name
" . ucfirst($key) . "
Signature $count: " . get_sig($name, $sig) . "
Parameters
"; + $buf .= do_params($sig[params], false, false); + $buf .= "
Return Value(s)
"; + $buf .= do_params($sig[returns], false, false); + $buf .= "
See Also

Types

"; + $buf .= ""; + $buf .= "
"; + + $buf .= do_params($typeList, true); + + $buf .= "
"; + + return $buf; +} + +/********************************************************************* +* The following functions are non-public and may change at any time. * +*********************************************************************/ + +/* non public - format key/val pair in a */ +function field($title, $text, $columns=false, $width=false) { + if ($columns) { + $colspan = " colspan='$columns'"; + } + if ($width) { + $width = " width='$width' "; + } + $colon = $title && $text ? ":" : ""; + return "$title$colon $text"; +} + +function is_xmlrpc_type($type) { + static $types = array("array", "struct", "mixed", "string", "int", "i4", "datetime", "base64", "boolean"); + return in_array($type, $types); +} + +function user_type($type) { + global $xi_type_hash; + return $xi_type_hash[$type] ? true : false; +} + + +function do_param($param, $bNewType=false, $bLinkUserTypes=true, $depth=0) { + /* guard against serious craziness */ + if (++ $depth >= 24) { + return "
max depth reached. bailing out...
"; + } + $name = $param[name]; + $type = $param[type]; + $desc = $param[description]; + $member = $param[member]; + $opt = $param[optional]; + $def = $param['default']; + $type_def = $param[type_def]; + + if ($type_def) { + $type_def = "$type_def "; + } + else { + $type_def = ""; + } + + $buf = "
"; + + if ($bNewType) { + $anchor = ""; + } + + if (user_type($type)) { + if ($bLinkUserTypes) { + $type = "$type"; + } + else { + /* hack to display user values inline. max depth check above. */ + global $xi_type_hash; + $newtype = $xi_type_hash[$type]; + + $newtype[name] = $param[name]; + $newtype[optional] = $param[optional]; + if ($param[description]) { + $newtype[description] = $param[description]; + } + $newtype[type_def] = $type; + $buf .= do_param($newtype, $bNewType, $bLinkUserTypes, $depth); + return $buf; + } + } + + $buf .= "$type_def$type $anchor$name"; + if ($opt || $def) { + $buf .= " ("; + if ($opt) { + $buf .= "optional" . ($def ? ", " : ""); + } + if ($def) { + $buf .= "default=$def"; + } + $buf .= ")"; + } + + if ($desc) { + $buf .= " -- $desc"; + } + if ($member) { + $buf .= do_params($member, $bNewType, $bLinkUserTypes, $depth); + } + $buf .= "
\n"; + + return $buf; +} + +/* non public - format params list recursively */ +function do_params($params, $bNewType=false, $bLinkUserTypes=true, $depth=0) { + if ($params) { + $br = $bNewType ? "
" : ""; + $buf = "\n
\n"; + foreach($params as $param) { + $buf .= do_param($param, $bNewType, $bLinkUserTypes, $depth); + } + $buf .= "
$br\n"; + } + return $buf; +} + + +function get_sig($method_name, $sig) { + $buf = ""; + if ($method_name && $sig) { + $return = $sig[returns][0][type]; + if (!$return) { + $return = "void"; + } + $buf .= "$return "; + + $buf .= "$method_name( "; + $first = true; + + if ($sig[params]) { + foreach($sig[params] as $param) { + $type = $param[type]; + $opt = $param[optional]; + $def = $param["default"]; + $name = $param["name"]; + if (user_type($type)) { + $type = "$type"; + } + + if ($opt) { + $buf .= $first ? '[' : ' ['; + } + if (!$first) { + $buf .= ', '; + } + $buf .= "$type"; + if (name) { + $buf .= " $name"; + } + if ($def) { + $buf .= " = $def"; + } + if ($opt) { + $buf .= ']'; + } + $first = false; + } + } + + $buf .= " )"; + } + + return $buf; +} + +/* non public. generate method signature from method description */ +function get_sigs($method) { + $method_name = $method[name]; + + $buf = ""; + + if ($method[signatures]) { + foreach($method[signatures] as $sig) { + $buf .= "
  • " . get_sig($method_name, $sig); + } + } + + return $buf; +} + +function name_cmp($a, $b) { + return strcmp($a[name], $b[name]); +} + + +/************************************* +* END system.describeMethods Support * +*************************************/ + + +?> diff --git a/tests/xmlrpc/xmlrpc-servers.php b/tests/xmlrpc/xmlrpc-servers.php new file mode 100644 index 000000000..c6b1463cf --- /dev/null +++ b/tests/xmlrpc/xmlrpc-servers.php @@ -0,0 +1,256 @@ + "user defined", + 'desc' => "Enter your own server to test against", + 'args' => null, + 'host' => $GLOBALS['HTTP_GET_VARS']['user_host'], + 'uri' => $GLOBALS['HTTP_GET_VARS']['user_uri'], + 'port' => ($GLOBALS['HTTP_GET_VARS']['user_port'] ? $GLOBALS['HTTP_GET_VARS']['user_port'] : 80), + 'type' => "user" + ); +} + +function get_wiki_servers($include_user=true) { + $list = + array ( + array('title' => " local ", + 'info_link' => "http://".$GLOBALS['SERVER_NAME'].dirname($GLOBALS['PHP_SELF'])."/../../RPC2.php", + 'args' => null, + 'host' => $GLOBALS['SERVER_NAME'], + 'uri' => dirname($GLOBALS['PHP_SELF'])."/../../RPC2.php", + 'port' => $GLOBALS['SERVER_PORT'], + "default" => true + ), + array('title' => "PhpWiki", + 'info_link' => "http://phpwiki.sourceforge.net/phpwiki/RPC2.php", + 'args' => null, + 'host' => "phpwiki.sourceforge.net", + 'uri' => "/phpwiki/RPC2.PHP", + 'port' => 80 + ), + array('title' => "PhpWikiDemo", + 'info_link' => "http://phpwiki.sourceforge.net/demo/RPC2.php", + 'args' => null, + 'host' => "phpwiki.sourceforge.net", + 'uri' => "/demo/RPC2.php", + 'port' => 80 + ), + ); + + if($include_user) { + $list[] = get_user_server(); + } + + return $list; +} + +function get_intro_useful_servers($include_user=true) { + $list = + array ( + array('title' => "xmlrpc-epi ( local! )", + 'info_link' => "http://".$GLOBALS['SERVER_NAME'].dirname($GLOBALS['PHP_SELF'])."/interop-server.php", + 'args' => null, + 'host' => $GLOBALS['SERVER_NAME'], + 'uri' => substr($GLOBALS['PHP_SELF'], 0, strrpos($GLOBALS['PHP_SELF'], "/") + 1) . "interop-server.php", + 'port' => $GLOBALS['SERVER_PORT'], + "default" => true + ), + array('title' => "Meerkat", + 'info_link' => "http://www.oreillynet.com/meerkat/xml-rpc/", + 'args' => null, + 'host' => "www.oreillynet.com", + 'uri' => "/meerkat/xml-rpc/server.php", + 'port' => 80 + ), + array('title' => "Usefulinc", + 'info_link' => "http://xmlrpc.usefulinc.com/php.html", + 'args' => null, + 'host' => "xmlrpc.usefulinc.com", + 'uri' => "/demo/server.php", + 'port' => 80 + ), + ); + + if($include_user) { + $list[] = get_user_server(); + } + + return $list; +} + +function get_introspection_servers($include_user=true) { + $list = + array ( + array('title' => "xmlrpc-epi interop server", + 'info_link' => "http://".$GLOBALS['SERVER_NAME'].dirname($GLOBALS['PHP_SELF'])."/interop-server.php", + 'args' => null, + 'host' => $GLOBALS['SERVER_NAME'], + 'uri' => substr($GLOBALS['PHP_SELF'], 0, strrpos($GLOBALS['PHP_SELF'], "/") + 1) . "interop-server.php", + 'port' => $GLOBALS['SERVER_PORT'], + "default" => true + ), + array('title' => "xmlrpc-epi validation server", + 'info_link' => "http://".$GLOBALS['SERVER_NAME'].dirname($GLOBALS['PHP_SELF'])."/validate.php", + 'args' => null, + 'host' => $GLOBALS['SERVER_NAME'], + 'uri' => substr($GLOBALS['PHP_SELF'], 0, strrpos($GLOBALS['PHP_SELF'], "/") + 1) . "validate.php", + 'port' => $GLOBALS['SERVER_PORT'], + ), + ); + + if($include_user) { + $list[] = get_user_server(); + } + + return $list; +} + + +function get_interop_servers($include_user=true) { + global $HTTP_SERVER_VARS; + $list = + array ( + array('title' => "local xmlrpc interop-server", + 'info_link' => "http://".$GLOBALS['SERVER_NAME'].dirname($GLOBALS['PHP_SELF'])."/interop-server.php", + 'desc' => "a php C extension utilizing the xmlrpc-epi library. running locally. by Dan Libby", + 'args' => "", + 'host' => $HTTP_SERVER_VARS['SERVER_NAME'], + 'uri' => dirname($HTTP_SERVER_VARS['SCRIPT_NAME']) . "/interop-server.php", + 'port' => $HTTP_SERVER_VARS['SERVER_PORT'], + "default" => true + ), + array('title' => "Frontier 7.0b43", + 'info_link' => "http://groups.yahoo.com/group/xml-rpc/message/2585", + 'desc' => "Jake Savin's Server. First Interop Node", + 'args' => "", + 'host' => "www.soapware.org", + 'uri' => "/RPC2", + 'port' => 80 + ), + array('title' => "XMLRPC.Net", + 'info_link' => "http://aspx.securedomains.com/cookcomputing/interopechotests.aspx", + 'desc' => "client/server by Charles Cook", + 'args' => "", + 'host' => "aspx.securedomains.com", + 'uri' => "/cookcomputing/interopechotests.aspx", + 'port' => 80 + ), + array('title' => "xmlrpc-c", + 'info_link' => "http://xmlrpc-c.sourceforge.net", + 'desc' => "a C library by Eric Kidd", + 'args' => "", + 'host' => "xmlrpc-c.sourceforge.net", + 'uri' => "/cgi-bin/interop.cgi", + 'port' => 80 + ), + array('title' => "Usefulinc", + 'info_link' => "http://xmlrpc.usefulinc.com/", + 'desc' => "a PHP script library by Edd Dumbill", + 'args' => "", + 'host' => "xmlrpc.usefulinc.com", + 'uri' => "/demo/server.php", + 'port' => 80 + ), + array('title' => "XML-RPC for ASP", + 'info_link' => "http://aspxmlrpc.sourceforge.net", + 'args' => "", + 'host' => "www.wc.cc.va.us", + 'uri' => "/dtod/xmlrpc/testing/interop.asp", + 'port' => 80 + ), + array('title' => "Frontier-RPC 0.07b3 (Perl)", + 'args' => "", + 'host' => "bitsko.slc.ut.us", + 'uri' => "/cgi-bin/interop.pl", + 'port' => 80 + ), + array('title' => "XMLRPC::Lite, v0.50", + 'args' => "", + 'host' => "xmlrpc.soaplite.com", + 'uri' => "/interop.cgi", + 'port' => 80 + ) + ); + + if($include_user) { + $list[] = get_user_server(); + } + + return $list; +} + +function print_servers_form($server_list, $action_url=false, $print_user=true) { + $action = $action_url ? "action='$action_url'" : ""; + + echo "
    "; + + foreach ($server_list as $key => $server) { + $title = $server['title']; + $link = $server['info_link']; + $type = $server['type']; + $port = $server['port']; + $default = $server["default"] ? "checked" : ""; + if($link) { + $title = "$title"; + } + echo " $title
    "; + + if($type === "user") { + echo "
    host:
    " . + "
    uri: " . + "
    port:
    "; + + } + } + if ($GLOBALS['HTTP_GET_VARS']['start_debug']) + echo ""; + echo <<< END +

    Verbosity level

    + none    + some    + much    + +

    XML Serialization

    + XML-RPC    + SOAP    + simpleRPC    +

    + +

    + +END; +} + +function get_server_from_user($server_list) { + return $server_list[$GLOBALS['HTTP_GET_VARS']['server']]; +} + +function server_uri_vars() { + extract($GLOBALS['HTTP_GET_VARS']); + return "server=$server&user_host=$user_host&user_port=$user_port&user_uri=$user_uri"; +} + +function server_vars() { + extract($GLOBALS['HTTP_GET_VARS']); + return array( + 'server' => $server, + 'user_host' => $user_host, + 'user_port' => $user_port, + 'user_uri' => $user_uri + ); +} + +?> \ No newline at end of file diff --git a/tests/xmlrpc/xmlrpc_utils.php b/tests/xmlrpc/xmlrpc_utils.php new file mode 100644 index 000000000..c85ca32d9 --- /dev/null +++ b/tests/xmlrpc/xmlrpc_utils.php @@ -0,0 +1,12 @@ + -- 2.45.0