MDL-65335 auth: Make oauth2 enabled check more efficient

This commit is contained in:
Mark Johnson
2019-09-20 08:56:06 +01:00
parent 6709fdbb6d
commit c63863df2b
2 changed files with 20 additions and 2 deletions
+1 -2
View File
@@ -402,7 +402,6 @@ class api {
* @return bool
*/
public static function is_enabled() {
$plugininfo = \core_plugin_manager::instance()->get_plugin_info('auth_oauth2');
return $plugininfo->is_enabled();
return is_enabled_auth('oauth2');
}
}
+19
View File
@@ -140,4 +140,23 @@ class auth_oauth2_external_testcase extends advanced_testcase {
$this->assertEquals($newuser->id, $match->get('userid'));
}
/**
* Test that is_enabled correctly identifies when the plugin is enabled.
*/
public function test_is_enabled() {
$this->resetAfterTest();
set_config('auth', 'manual,oauth2');
$this->assertTrue(\auth_oauth2\api::is_enabled());
}
/**
* Test that is_enabled correctly identifies when the plugin is disabled.
*/
public function test_is_enabled_disabled() {
$this->resetAfterTest();
set_config('auth', 'manual');
$this->assertFalse(\auth_oauth2\api::is_enabled());
}
}