Use Config helper (#10339)

remove usage of global variable
This commit is contained in:
Tony Murray
2019-06-23 00:29:12 -05:00
committed by GitHub
parent 342acf50f1
commit f3ba8947f7
367 changed files with 1589 additions and 1857 deletions
+5 -7
View File
@@ -26,6 +26,7 @@
namespace LibreNMS\Tests;
use LibreNMS\Authentication\LegacyAuth;
use LibreNMS\Config;
use LibreNMS\Exceptions\AuthenticationException;
// Note that as this test set depends on mres(), it is a DBTestCase even though the database is unused
@@ -34,8 +35,7 @@ class AuthHTTPTest extends DBTestCase
// Document the modules current behaviour, so that changes trigger test failures
public function testCapabilityFunctions()
{
global $config;
$config['auth_mechanism'] = 'http-auth';
Config::set('auth_mechanism', 'http-auth');
$a = LegacyAuth::reset();
@@ -48,12 +48,10 @@ class AuthHTTPTest extends DBTestCase
public function testOldBehaviourAgainstCurrent()
{
global $config;
$old_username = null;
$new_username = null;
$config['auth_mechanism'] = 'http-auth';
Config::set('auth_mechanism', 'http-auth');
$users = array('steve', ' steve', 'steve ', ' steve ', ' steve ', '', 'CAT');
$vars = array('REMOTE_USER', 'PHP_AUTH_USER');
@@ -66,7 +64,7 @@ class AuthHTTPTest extends DBTestCase
// Old Behaviour
if (isset($_SERVER['REMOTE_USER'])) {
$old_username = clean($_SERVER['REMOTE_USER']);
} elseif (isset($_SERVER['PHP_AUTH_USER']) && $config['auth_mechanism'] === 'http-auth') {
} elseif (isset($_SERVER['PHP_AUTH_USER']) && Config::get('auth_mechanism') === 'http-auth') {
$old_username = clean($_SERVER['PHP_AUTH_USER']);
}
@@ -84,6 +82,6 @@ class AuthHTTPTest extends DBTestCase
unset($_SERVER[$v]);
}
unset($config['auth_mechanism']);
Config::forget('auth_mechanism');
}
}