refactor: Share code between all mysql based authorizers (#8174)

* Share code between all mysql based authorizers
I plan to update the mysql password encryption and this will allow the code to be changed in a single location.
It also reduces a lot of duplication.

* Fix tests, I suspect reauthenticate will work for these...
Do not allow password updates for several authorizers
This commit is contained in:
Tony Murray
2018-02-06 15:20:34 -06:00
committed by Neil Lathwood
parent f706d0ab41
commit 5141fc4872
10 changed files with 55 additions and 279 deletions

View File

@@ -26,10 +26,17 @@
namespace LibreNMS\Tests;
use LibreNMS\Authentication\Auth;
use LibreNMS\Exceptions\AuthenticationException;
// Note that as this test set depends on mres(), it is a DBTestCase even though the database is unused
class AuthHTTPTest extends DBTestCase
{
public function testReauthenticate()
{
$this->setExpectedException(AuthenticationException::class);
Auth::reset()->reauthenticate(null, null);
}
// Document the modules current behaviour, so that changes trigger test failures
public function testCapabilityFunctions()
{
@@ -38,7 +45,6 @@ class AuthHTTPTest extends DBTestCase
$a = Auth::reset();
$this->assertFalse($a->reauthenticate(null, null));
$this->assertTrue($a->canUpdatePasswords() === 0);
$this->assertTrue($a->changePassword(null, null) === 0);
$this->assertTrue($a->canManageUsers() === 1);
@@ -49,7 +55,7 @@ class AuthHTTPTest extends DBTestCase
public function testOldBehaviourAgainstCurrent()
{
global $config;
$old_username = null;
$new_username = null;