Commit ce1a97ac authored by Aaron Wells's avatar Aaron Wells

Bug 1600099: Cleanup of the webservice admin page

This patch does a few things:

1. Renames "webservice_enabled" config to "webservice_provider_enabled",
to indicate that this config only controls Mahara's actions as
a webservice provider, *not* a webservice client.

2. Renames all the "webservice_<protocol>_enabled" configs to
"webservice_provider_<protocol>_enabled" to indicate that they only
control whether Mahara will provide webservices via that protocol,
and not whether Mahara will use that protocol as a client.

3. Renames "webservice_connections_enabled" config to
"webservice_requester_enabled", to clarify that this config
controls whether Mahara is allowed to request webservices
from external sources.

4. Updates language strings to make these changes clearer.

5. Rearranges and renames the form methods in
webservice/admin/index.php to make the flow of control more
obvious. Now the main form method is first, followed in order
by the methods that generate its subforms and each of their
submit handlers.

behatnotneeded: Covered by existing tests

Change-Id: I58dadb352d1f1542ca67a104ebfd702b4ca90fc9
parent 8e4a1f64
......@@ -462,6 +462,27 @@ function xmldb_auth_webservice_upgrade($oldversion=0) {
}
}
if ($oldversion < 2016071400) {
log_debug('Updating DB names of webservice config fields');
$configstochange = array(
'webservice_enabled' => 'webservice_provider_enabled',
'webservice_soap_enabled' => 'webservice_provider_soap_enabled',
'webservice_xmlrpc_enabled' => 'webservice_provider_xmlrpc_enabled',
'webservice_rest_enabled' => 'webservice_provider_rest_enabled',
'webservice_oauth_enabled' => 'webservice_provider_oauth_enabled',
'webservice_connections_enabled' => 'webservice_requester_enabled'
);
foreach ($configstochange as $old => $new) {
set_config(
$new,
get_config($old)
);
delete_records('config', 'field', $old);
}
}
// sweep for webservice updates everytime
$status = external_reload_webservices();
......
......@@ -84,15 +84,15 @@ $string['consumer'] = 'Consumer key';
$string['secret'] = 'Secret';
// core webservices strings start here
$string['control_webservices1'] = 'Use web services: ';
$string['control_webservices'] = 'Switch web services on or off: ';
$string['control_webservices_connections'] = 'Switch web service connections on or off: ';
$string['masterswitch'] = 'Web services master switch';
$string['connectionsmasterswitch'] = 'Web service client connections master switch';
$string['webservice_requester_enabled_label'] = 'Web service requester master switch';
$string['webservice_requester_enabled_label2'] = 'Allow outgoing web service requests:';
$string['webservice_provider_enabled_label'] = 'Web service provider master switch';
$string['webservice_provider_enabled_label2'] = 'Accept incoming web service requests:';
$string['formatdate'] = '';
$string['protocolswitches'] = 'Switch protocols on or off';
$string['webservice_master_switches'] = 'Enable web service functionality';
$string['connectionsswitch'] = 'Switch managed client connections on or off';
$string['manage_protocols'] = 'Enable or disable protocols that are to be supported:';
$string['manage_protocols1'] = 'Enable or disable protocols supported as a web services provider:';
$string['protocol'] = 'Protocol';
$string['rest'] = 'REST';
$string['soap'] = 'SOAP';
......
......@@ -188,7 +188,7 @@ class PluginAuthWebservice extends PluginAuth {
// activate webservices
foreach (array('soap', 'xmlrpc', 'rest', 'oauth') as $proto) {
set_config('webservice_' . $proto.'_enabled', 1);
set_config('webservice_provider_' . $proto.'_enabled', 1);
}
}
}
......
......@@ -12,7 +12,7 @@
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2014112800;
$config->release = '1.0.1';
$config->version = 2016071400;
$config->release = '1.1.0';
$config->requires_config = 0;
$config->requires_parent = 0;
......@@ -2058,7 +2058,7 @@ abstract class Plugin implements IPlugin {
global $USER;
// is the web service connection switch enabled?
if (!get_config('webservice_connections_enabled')) {
if (!get_config('webservice_requester_enabled')) {
log_debug('get_webservice_connections: disabled');
return array();
}
......
......@@ -16,7 +16,7 @@ $config = new stdClass();
// See https://wiki.mahara.org/wiki/Developer_Area/Version_Numbering_Policy
// For upgrades on stable branches, increment the version by one. On master, use the date.
$config->version = 2016082400;
$config->version = 2016082900;
$config->series = '16.10';
$config->release = '16.10dev';
$config->minupgradefrom = 2012080604;
......
This diff is collapsed.
......@@ -706,16 +706,17 @@ class external_multiple_structure extends external_description {
*/
class external_function_parameters extends external_single_structure {
}
/**
* Is protocol enabled?
* @param string $protocol name of WS protocol
* @return bool
*/
function webservice_protocol_is_enabled($protocol) {
if (!get_config('webservice_enabled')) {
if (!get_config('webservice_provider_enabled')) {
return false;
}
return get_config('webservice_'.$protocol.'_enabled');
return get_config('webservice_provider_'.$protocol.'_enabled');
}
//=== WS classes ===
......
......@@ -48,7 +48,7 @@ if ($result = $SESSION->get('ws_call_results')) {
// add protocol choice
$popts = array();
foreach (array('soap', 'xmlrpc', 'rest') as $proto) {
$enabled = (get_config('webservice_'.$proto.'_enabled') || 0);
$enabled = (get_config('webservice_provider_'.$proto.'_enabled') || 0);
if ($enabled) {
$popts[$proto] = get_string($proto, 'auth.webservice');
}
......@@ -239,7 +239,7 @@ safe_require('auth', 'webservice');
$smarty->assign('form', $form);
// Check that webservices is enabled
$smarty->assign('disabled', (get_config('webservice_enabled') ? false : true));
$smarty->assign('disabled', (get_config('webservice_provider_enabled') ? false : true));
$smarty->assign('disabledhttps', ((!is_https() && get_config('productionmode')) ? true : false));
$smarty->assign('disabledprotocols', (empty($elements['protocol']['options']) ? get_config('wwwroot') . 'webservice/admin/index.php' : false));
$smarty->display('auth:webservice:testclient.tpl');
......
......@@ -86,11 +86,11 @@ class WebServiceTestBase extends MaharaUnitTest {
$USER->id = 1;
$USER->admin = 1;
set_config('webservice_enabled', true);
set_config('webservice_rest_enabled', true);
set_config('webservice_xmlrpc_enabled', true);
set_config('webservice_soap_enabled', true);
set_config('webservice_oauth_enabled', true);
set_config('webservice_provider_enabled', true);
set_config('webservice_provider_rest_enabled', true);
set_config('webservice_provider_xmlrpc_enabled', true);
set_config('webservice_provider_soap_enabled', true);
set_config('webservice_provider_oauth_enabled', true);
//token to test
$this->servicename = 'test webservices';
......
......@@ -15,7 +15,7 @@ Scenario: Turning master switch on
And I follow "Administration"
And I choose "Configuration" in "Web services"
# Turning the master switch on
And I enable the switch "Use web services:"
And I enable the switch "Accept incoming web service requests:"
When I go to "/webservice/testclient.php"
And I should not see "The web service authentication plugin is disabled"
And I log out
......
......@@ -4,17 +4,20 @@ In order to be able to access the webservies menus successfully
As an admin
So I can benefit from the mahara/moodle cross over.
Scenario: Turning Master swtiches and protocol switches on checking test client page is accessible (Bug 1431540)
Scenario: Testing web service admin page on/off switches, and checking test client page is accessible (Bug 1431540)
Given I log in as "admin" with password "Kupuhipa1"
And I follow "Administration"
And I choose "Configuration" in "Web services"
# Turning the master switch on
And I enable the switch "Use web services:"
# Turning the master switch off so the protocols are disabled
And I disable the switch "Use web services:"
# Turning the master switch back on
And I enable the switch "Use web services:"
And I should see "You need to enable at least one Protocol"
# Toggle Web service requester master switch
And I disable the switch "Allow outgoing web service requests:"
And I enable the switch "Allow outgoing web service requests:"
# Turning the Web service provider master switch on
And I enable the switch "Accept incoming web service requests:"
# Turning the Web service provider master switch off so the protocols are disabled
And I disable the switch "Accept incoming web service requests:"
# Turning the Web service provider master switch back on
And I enable the switch "Accept incoming web service requests:"
And I should see "You need to enable at least one protocol"
# Turning a protocol on
And I enable the switch "SOAP:"
# Navigating to the test client page to see it's accessible
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment