User roles are now synced with LDAP at each login

This commit is contained in:
Frederic Guillot
2016-05-07 10:36:46 -04:00
parent 400e230881
commit 94989663ec
4 changed files with 62 additions and 3 deletions

View File

@@ -31,7 +31,7 @@ class UserPropertyTest extends Base
$this->assertEquals($expected, UserProperty::getProperties($user));
}
public function testFilterProperties()
public function testFilterPropertiesDoNotOverrideExistingValue()
{
$profile = array(
'id' => 123,
@@ -57,4 +57,58 @@ class UserPropertyTest extends Base
$this->assertEquals($expected, UserProperty::filterProperties($profile, $properties));
}
public function testFilterPropertiesOverrideExistingValueWhenNecessary()
{
$profile = array(
'id' => 123,
'username' => 'bob',
'name' => null,
'email' => '',
'other_column' => 'myvalue',
'role' => Role::APP_USER,
);
$properties = array(
'external_id' => '456',
'username' => 'bobby',
'name' => 'Bobby',
'email' => 'admin@localhost',
'role' => Role::APP_MANAGER,
);
$expected = array(
'name' => 'Bobby',
'email' => 'admin@localhost',
'role' => Role::APP_MANAGER,
);
$this->assertEquals($expected, UserProperty::filterProperties($profile, $properties));
}
public function testFilterPropertiesDoNotOverrideSameValue()
{
$profile = array(
'id' => 123,
'username' => 'bob',
'name' => 'Bobby',
'email' => 'admin@example.org',
'other_column' => 'myvalue',
'role' => Role::APP_MANAGER,
);
$properties = array(
'external_id' => '456',
'username' => 'bobby',
'name' => 'Bobby',
'email' => 'admin@localhost',
'role' => Role::APP_MANAGER,
);
$expected = array(
'email' => 'admin@localhost',
);
$this->assertEquals($expected, UserProperty::filterProperties($profile, $properties));
}
}