From: jerome Date: Tue, 28 Apr 2009 07:04:50 +0000 (+0000) Subject: web services MDL-12886 fix REST/SOAP/XMLRPC test clients (function names are not... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=f83dfcf6864a094c0169ff49fd5f064d6f58c606;p=moodle.git web services MDL-12886 fix REST/SOAP/XMLRPC test clients (function names are not called tmp_ anymore) --- diff --git a/lang/en_utf8/webservice.php b/lang/en_utf8/webservice.php index 8f05c55ae1..c717b13dfd 100644 --- a/lang/en_utf8/webservice.php +++ b/lang/en_utf8/webservice.php @@ -1,6 +1,6 @@ SOAP Manual - 1. Call the method tmp_get_token on \"http://remotemoodle/webservice/soap/server.php?wsdl\"
+ 1. Call the method get_token on \"http://remotemoodle/webservice/soap/server.php?wsdl\"
The function parameter is an array: in PHP it would be array(\"username\" => \"wsuser\", \"password\" => \"wspassword\")
Return value is a token (integer)

@@ -14,7 +14,7 @@ $string['soapdocumentation'] = '

SOAP Manual

your_client->tmp_delete_user(array(\"username\" => \"username_to_delete\",\"mnethostid\" => 1))

'; $string['xmlrpcdocumentation'] = '

XMLRPC Manual

- 1. Call the method authentication.tmp_get_token on \"http://remotemoodle/webservice/xmlrpc/server.php\"
+ 1. Call the method authentication.get_token on \"http://remotemoodle/webservice/xmlrpc/server.php\"
The function parameter is an array: in PHP it would be array(\"username\" => \"wsuser\", \"password\" => \"wspassword\")
Return value is a token (integer)

diff --git a/webservice/lib.php b/webservice/lib.php index f1ef37139f..891ff6f97c 100644 --- a/webservice/lib.php +++ b/webservice/lib.php @@ -593,7 +593,7 @@ class ws_authentication { * @param array|struct $params * @return integer */ - function tmp_get_token($params) { + function get_token($params) { if ($params['username'] == 'wsuser' && $params['password'] == 'wspassword') { return '456'; } else { diff --git a/webservice/rest/locallib.php b/webservice/rest/locallib.php index 39b1f1d0ec..1ed14f7b0b 100644 --- a/webservice/rest/locallib.php +++ b/webservice/rest/locallib.php @@ -52,7 +52,7 @@ function call_moodle_function ($rest_arguments) { /// TODO: this use a fake token => need to implement token generation $token = optional_param('token',null,PARAM_ALPHANUM); if (empty($token)) { - if ($functionname != 'tmp_get_token') { + if ($functionname != 'get_token') { throw new moodle_exception('identifyfirst'); } else { /// TODO: authentication + token generation need to be implemented diff --git a/webservice/rest/testclient/addgroupmember.php b/webservice/rest/testclient/addgroupmember.php index e769545cd0..61a7b9e8e6 100644 --- a/webservice/rest/testclient/addgroupmember.php +++ b/webservice/rest/testclient/addgroupmember.php @@ -31,14 +31,14 @@ start_interface("Add group member to group"); if ($groupid && $userid) { - var_dump($CFG->serverurl.'/group/tmp_add_groupmember'); + var_dump($CFG->serverurl.'/group/add_groupmember'); //we are asking for a token $connectiondata['username'] = 'wsuser'; $connectiondata['password'] = 'wspassword'; $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $CFG->serverurl.'/user/tmp_get_token'); + curl_setopt($ch, CURLOPT_URL, $CFG->serverurl.'/user/get_token'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, format_postdata($connectiondata)); @@ -49,7 +49,7 @@ if ($groupid && $userid) { $data['userid'] = $userid; $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $CFG->serverurl.'/group/tmp_add_groupmember'); + curl_setopt($ch, CURLOPT_URL, $CFG->serverurl.'/group/add_groupmember'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, format_postdata($data)); diff --git a/webservice/rest/testclient/creategroup.php b/webservice/rest/testclient/creategroup.php index c02ef42598..c7b78fa958 100644 --- a/webservice/rest/testclient/creategroup.php +++ b/webservice/rest/testclient/creategroup.php @@ -32,14 +32,14 @@ start_interface("Create Group"); if ($groupname && $courseid) { - var_dump($CFG->serverurl.'/group/tmp_create_group'); + var_dump($CFG->serverurl.'/group/create_group'); //we are asking for a token $connectiondata['username'] = 'wsuser'; $connectiondata['password'] = 'wspassword'; $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $CFG->serverurl.'/user/tmp_get_token'); + curl_setopt($ch, CURLOPT_URL, $CFG->serverurl.'/user/get_token'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, format_postdata($connectiondata)); @@ -50,7 +50,7 @@ if ($groupname && $courseid) { $data['courseid'] = $courseid; $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $CFG->serverurl.'/group/tmp_create_group'); + curl_setopt($ch, CURLOPT_URL, $CFG->serverurl.'/group/create_group'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, format_postdata($data)); diff --git a/webservice/rest/testclient/createuser.php b/webservice/rest/testclient/createuser.php index 3b2f8e0c65..6a8b983a39 100644 --- a/webservice/rest/testclient/createuser.php +++ b/webservice/rest/testclient/createuser.php @@ -25,14 +25,14 @@ var_dump($data); $connectiondata['username'] = 'wsuser'; $connectiondata['password'] = 'wspassword'; $ch = curl_init(); -curl_setopt($ch, CURLOPT_URL, $CFG->serverurl.'/user/tmp_get_token'); +curl_setopt($ch, CURLOPT_URL, $CFG->serverurl.'/user/get_token'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, format_postdata($connectiondata)); $token = curl_exec($ch); $data['token'] = $token; -curl_setopt($ch, CURLOPT_URL, $CFG->serverurl.'/user/tmp_create_user'); +curl_setopt($ch, CURLOPT_URL, $CFG->serverurl.'/user/create_user'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, format_postdata($data)); diff --git a/webservice/rest/testclient/deletegroup.php b/webservice/rest/testclient/deletegroup.php index 546b9658c9..889aee63db 100644 --- a/webservice/rest/testclient/deletegroup.php +++ b/webservice/rest/testclient/deletegroup.php @@ -35,7 +35,7 @@ if ($groupid) { $connectiondata['username'] = 'wsuser'; $connectiondata['password'] = 'wspassword'; $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $CFG->serverurl.'/user/tmp_get_token'); + curl_setopt($ch, CURLOPT_URL, $CFG->serverurl.'/user/get_token'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, format_postdata($connectiondata)); @@ -46,7 +46,7 @@ if ($groupid) { $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $CFG->serverurl.'/group/tmp_delete_group'); + curl_setopt($ch, CURLOPT_URL, $CFG->serverurl.'/group/delete_group'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, format_postdata($data)); diff --git a/webservice/rest/testclient/deletegroupmember.php b/webservice/rest/testclient/deletegroupmember.php index c1093da84c..5d493aac1e 100644 --- a/webservice/rest/testclient/deletegroupmember.php +++ b/webservice/rest/testclient/deletegroupmember.php @@ -31,14 +31,14 @@ start_interface("Delete group member from a group"); if ($groupid && $userid) { - var_dump($CFG->serverurl.'/group/tmp_delete_groupmember'); + var_dump($CFG->serverurl.'/group/delete_groupmember'); //we are asking for a token $connectiondata['username'] = 'wsuser'; $connectiondata['password'] = 'wspassword'; $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $CFG->serverurl.'/user/tmp_get_token'); + curl_setopt($ch, CURLOPT_URL, $CFG->serverurl.'/user/get_token'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, format_postdata($connectiondata)); @@ -49,7 +49,7 @@ if ($groupid && $userid) { $data['userid'] = $userid; $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $CFG->serverurl.'/group/tmp_delete_groupmember'); + curl_setopt($ch, CURLOPT_URL, $CFG->serverurl.'/group/delete_groupmember'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, format_postdata($data)); diff --git a/webservice/rest/testclient/deleteuser.php b/webservice/rest/testclient/deleteuser.php index e65f4ec7ed..5aa15ab465 100644 --- a/webservice/rest/testclient/deleteuser.php +++ b/webservice/rest/testclient/deleteuser.php @@ -35,7 +35,7 @@ if ($username) { $connectiondata['username'] = 'wsuser'; $connectiondata['password'] = 'wspassword'; $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $CFG->serverurl.'/user/tmp_get_token'); + curl_setopt($ch, CURLOPT_URL, $CFG->serverurl.'/user/get_token'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, format_postdata($connectiondata)); @@ -46,7 +46,7 @@ if ($username) { $data['mnethostid'] = $mnethostid; $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $CFG->serverurl.'/user/tmp_delete_user'); + curl_setopt($ch, CURLOPT_URL, $CFG->serverurl.'/user/delete_user'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, format_postdata($data)); diff --git a/webservice/rest/testclient/getgroup.php b/webservice/rest/testclient/getgroup.php index 3a3a9003ad..cdc8d90702 100644 --- a/webservice/rest/testclient/getgroup.php +++ b/webservice/rest/testclient/getgroup.php @@ -35,7 +35,7 @@ if ($groupid) { $connectiondata['username'] = 'wsuser'; $connectiondata['password'] = 'wspassword'; $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $CFG->serverurl.'/user/tmp_get_token'); + curl_setopt($ch, CURLOPT_URL, $CFG->serverurl.'/user/get_token'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, format_postdata($connectiondata)); @@ -45,7 +45,7 @@ if ($groupid) { $data['groupid'] = $groupid; $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $CFG->serverurl.'/group/tmp_get_group'); + curl_setopt($ch, CURLOPT_URL, $CFG->serverurl.'/group/get_group'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, format_postdata($data)); diff --git a/webservice/rest/testclient/getusers.php b/webservice/rest/testclient/getusers.php index 4e62b9a6dc..f8117f6e3d 100644 --- a/webservice/rest/testclient/getusers.php +++ b/webservice/rest/testclient/getusers.php @@ -36,7 +36,7 @@ if ($search) { $connectiondata['username'] = 'wsuser'; $connectiondata['password'] = 'wspassword'; $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $CFG->serverurl.'/user/tmp_get_token'); + curl_setopt($ch, CURLOPT_URL, $CFG->serverurl.'/user/get_token'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, format_postdata($connectiondata)); @@ -44,7 +44,7 @@ if ($search) { $data['token'] = $token; $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $CFG->serverurl.'/user/tmp_get_users'); + curl_setopt($ch, CURLOPT_URL, $CFG->serverurl.'/user/get_users'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, format_postdata($data)); diff --git a/webservice/rest/testclient/updateuser.php b/webservice/rest/testclient/updateuser.php index 978ca0b687..8ecbfcd534 100644 --- a/webservice/rest/testclient/updateuser.php +++ b/webservice/rest/testclient/updateuser.php @@ -37,7 +37,7 @@ if ($username) { $connectiondata['username'] = 'wsuser'; $connectiondata['password'] = 'wspassword'; $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $CFG->serverurl.'/user/tmp_get_token'); + curl_setopt($ch, CURLOPT_URL, $CFG->serverurl.'/user/get_token'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, format_postdata($connectiondata)); @@ -50,7 +50,7 @@ if ($username) { $data['firstname'] = $firstname; $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $CFG->serverurl.'/user/tmp_update_user'); + curl_setopt($ch, CURLOPT_URL, $CFG->serverurl.'/user/update_user'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, format_postdata($data)); diff --git a/webservice/soap/testclient/zend_soap_client.php b/webservice/soap/testclient/zend_soap_client.php index 484f8364b8..7efe5832dd 100644 --- a/webservice/soap/testclient/zend_soap_client.php +++ b/webservice/soap/testclient/zend_soap_client.php @@ -44,7 +44,7 @@ if (!webservice_lib::display_webservices_availability("soap")) { //1. authentication $client = new Zend_Soap_Client($CFG->wwwroot."/webservice/soap/server.php?wsdl"); try { - $token = $client->tmp_get_token(array('username' => "wsuser", 'password' => "wspassword")); + $token = $client->get_token(array('username' => "wsuser", 'password' => "wspassword")); print "
\n";
     var_dump($token);
     print "
"; @@ -64,7 +64,7 @@ try { $client = new Zend_Soap_Client($CFG->wwwroot."/webservice/soap/server.php?token=".$token."&classpath=user&wsdl"); var_dump($CFG->wwwroot."/webservice/soap/server.php?token=".$token."&classpath=user&wsdl"); print "
\n";
-var_dump($client->tmp_get_users(array('search' => "admin")));
+var_dump($client->get_users(array('search' => "admin")));
 print "
"; //$param = array('search' => "admin"); @@ -85,15 +85,15 @@ print ""; //call_soap_function($client,$functionname,$param,$expectedresult); print "
\n";
-var_dump($client->tmp_create_users(array(array('username' => "mockuser66",'firstname' => "firstname6",'lastname' => "lastname6",'email' => "mockuser6@mockuser6.com",'password' => "password6"))));
+var_dump($client->create_users(array(array('username' => "mockuser66",'firstname' => "firstname6",'lastname' => "lastname6",'email' => "mockuser6@mockuser6.com",'password' => "password6"))));
 print "
"; print "
\n";
-var_dump($client->tmp_update_users(array(array('username' => "mockuser66",'newusername' => "mockuser6b",'firstname' => "firstname6b"))));
+var_dump($client->update_users(array(array('username' => "mockuser66",'newusername' => "mockuser6b",'firstname' => "firstname6b"))));
 print "
"; print "
\n";
-var_dump($client->tmp_delete_users(array(array('username' => "mockuser6b"))));
+var_dump($client->delete_users(array(array('username' => "mockuser6b"))));
 print "
"; //print "
\n";
diff --git a/webservice/xmlrpc/testclient/zend_xmlrpc_client.php b/webservice/xmlrpc/testclient/zend_xmlrpc_client.php
index 8acd88f084..f70ca558ee 100644
--- a/webservice/xmlrpc/testclient/zend_xmlrpc_client.php
+++ b/webservice/xmlrpc/testclient/zend_xmlrpc_client.php
@@ -34,18 +34,18 @@ Zend_Loader::registerAutoload();
 
 //1. authentication
 $client = new Zend_XmlRpc_Client($CFG->wwwroot."/webservice/xmlrpc/server.php");
-$token = $client->call('authentication.tmp_get_token', array(array('username' => "wsuser", 'password' => "wspassword")));
+$token = $client->call('authentication.get_token', array(array('username' => "wsuser", 'password' => "wspassword")));
 var_dump($token);
 
 //2. test functions
 $client = new Zend_XmlRpc_Client($CFG->wwwroot."/webservice/xmlrpc/server.php?classpath=user&token=".$token);
-var_dump($users = $client->call('user.tmp_get_users', array(array('search' => "admin"))));
+var_dump($users = $client->call('user.get_users', array(array('search' => "admin"))));
 print "

\n"; -var_dump($users = $client->call('user.tmp_create_users', array(array(array('firstname' => "firstname6",'username' => "mockuser66",'lastname' => "lastname6",'email' => "mockuser6@mockuser6.com",'password' => "password6"))))); +var_dump($users = $client->call('user.create_users', array(array(array('firstname' => "firstname6",'username' => "mockuser66",'lastname' => "lastname6",'email' => "mockuser6@mockuser6.com",'password' => "password6"))))); print "

\n"; -var_dump($users = $client->call('user.tmp_update_users', array(array(array('username' => "mockuser66",'newusername' => "mockuser6b",'firstname' => "firstname6b"))))); +var_dump($users = $client->call('user.update_users', array(array(array('username' => "mockuser66",'newusername' => "mockuser6b",'firstname' => "firstname6b"))))); print "

\n"; -var_dump($users = $client->call('user.tmp_delete_users', array(array(array('username' => "mockuser6b"))))); +var_dump($users = $client->call('user.delete_users', array(array(array('username' => "mockuser6b"))))); //print "

\n"; //var_dump($users = $client->call('user.tmp_do_multiple_user_searches', array(array(array('search' => "jerome"),array('search' => "admin"))))); //print "

\n";