Merge branch 'MDL-40050-master' of git://github.com/FMCorz/moodle
This commit is contained in:
@@ -83,7 +83,7 @@ if ($mform->is_cancelled()) {
|
||||
$params = array(
|
||||
'objectid' => $servicedata->id
|
||||
);
|
||||
$event = \core\event\webservice_service_updated::create($params);
|
||||
$event = \core\event\webservice_service_created::create($params);
|
||||
$event->add_record_snapshot('external_services', $servicedata);
|
||||
$event->trigger();
|
||||
|
||||
@@ -98,7 +98,7 @@ if ($mform->is_cancelled()) {
|
||||
$params = array(
|
||||
'objectid' => $servicedata->id
|
||||
);
|
||||
$event = \core\event\webservice_service_created::create($params);
|
||||
$event = \core\event\webservice_service_updated::create($params);
|
||||
$event->add_record_snapshot('external_services', $servicedata);
|
||||
$event->trigger();
|
||||
}
|
||||
|
||||
@@ -92,6 +92,15 @@ class webservice_login_failed extends \core\event\base {
|
||||
/**
|
||||
* Custom validation.
|
||||
*
|
||||
* It is recommended to set the properties:
|
||||
* - $other['tokenid']
|
||||
* - $other['username']
|
||||
*
|
||||
* However they are not mandatory as they are not always known.
|
||||
*
|
||||
* Please note that the token CANNOT be specified, it is considered
|
||||
* as a password and should never be displayed.
|
||||
*
|
||||
* @throws \coding_exception
|
||||
* @return void
|
||||
*/
|
||||
@@ -100,8 +109,8 @@ class webservice_login_failed extends \core\event\base {
|
||||
throw new \coding_exception('The key \'reason\' needs to be set in $other.');
|
||||
} else if (!isset($this->other['method'])) {
|
||||
throw new \coding_exception('The key \'method\' needs to be set in $other.');
|
||||
} else if (!isset($this->other['token']) && !isset($this->other['tokenid']) && !isset($this->other['username'])) {
|
||||
throw new \coding_exception('The keys \'username\', \'token\' or \'tokenid\' need to be set in $other.');
|
||||
} else if (isset($this->other['token'])) {
|
||||
throw new \coding_exception('The token cannot be set in $other.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-4
@@ -866,8 +866,7 @@ abstract class webservice_server implements webservice_server_interface {
|
||||
'context' => context_system::instance(),
|
||||
'other' => array(
|
||||
'method' => $this->authmethod,
|
||||
'reason' => null,
|
||||
'token' => $this->token
|
||||
'reason' => null
|
||||
)
|
||||
);
|
||||
|
||||
@@ -1015,8 +1014,7 @@ abstract class webservice_server implements webservice_server_interface {
|
||||
'context' => context_system::instance(),
|
||||
'other' => array(
|
||||
'method' => $this->authmethod,
|
||||
'reason' => null,
|
||||
'token' => $this->token
|
||||
'reason' => null
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* @copyright 2013 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class webservice_events_testcase extends advanced_testcase {
|
||||
class core_webservice_events_testcase extends advanced_testcase {
|
||||
|
||||
public function setUp() {
|
||||
$this->resetAfterTest();
|
||||
@@ -77,7 +77,7 @@ class webservice_events_testcase extends advanced_testcase {
|
||||
'other' => array(
|
||||
'reason' => 'Unit Test',
|
||||
'method' => 'Some method',
|
||||
'token' => 'A fake token'
|
||||
'tokenid' => '123'
|
||||
)
|
||||
);
|
||||
$event = \core\event\webservice_login_failed::create($params);
|
||||
@@ -91,8 +91,16 @@ class webservice_events_testcase extends advanced_testcase {
|
||||
$this->assertEquals(context_system::instance(), $event->get_context());
|
||||
$this->assertEquals($params['other']['reason'], $event->other['reason']);
|
||||
$this->assertEquals($params['other']['method'], $event->other['method']);
|
||||
$this->assertEquals($params['other']['token'], $event->other['token']);
|
||||
$this->assertEquals($params['other']['tokenid'], $event->other['tokenid']);
|
||||
$this->assertEventLegacyLogData($fakelogdata, $event);
|
||||
|
||||
// We cannot set the token in the other properties.
|
||||
$params['other']['token'] = 'I should not be set';
|
||||
try {
|
||||
$event = \core\event\webservice_login_failed::create($params);
|
||||
$this->fail('The token cannot be allowed in \core\event\webservice_login_failed');
|
||||
} catch (coding_exception $e) {
|
||||
}
|
||||
}
|
||||
|
||||
public function test_service_created() {
|
||||
Reference in New Issue
Block a user