diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-05-30 21:47:31 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-05-30 21:47:31 -0400 |
commit | 4987e245bb629e3171425bf16db341c5c3a7c3c7 (patch) | |
tree | 36a94eedcc7e50d71b9363cb410f8b7738f5dab8 /tests/units/Core | |
parent | 679a22c718e8cb2d3ae6d981e1745bad948e1b92 (diff) |
Do not sync user role if LDAP groups are not configured
Diffstat (limited to 'tests/units/Core')
-rw-r--r-- | tests/units/Core/Ldap/LdapUserTest.php | 9 | ||||
-rw-r--r-- | tests/units/Core/User/UserPropertyTest.php | 24 |
2 files changed, 31 insertions, 2 deletions
diff --git a/tests/units/Core/Ldap/LdapUserTest.php b/tests/units/Core/Ldap/LdapUserTest.php index 02b9331e..505b8a03 100644 --- a/tests/units/Core/Ldap/LdapUserTest.php +++ b/tests/units/Core/Ldap/LdapUserTest.php @@ -61,7 +61,7 @@ class LdapUserTest extends Base ->getMock(); } - public function testGetUser() + public function testGetUserWithNoGroupConfigured() { $entries = new Entries(array( 'count' => 1, @@ -136,7 +136,7 @@ class LdapUserTest extends Base $this->assertEquals('my_ldap_user', $user->getUsername()); $this->assertEquals('My LDAP user', $user->getName()); $this->assertEquals('user1@localhost', $user->getEmail()); - $this->assertEquals(Role::APP_USER, $user->getRole()); + $this->assertEquals(null, $user->getRole()); $this->assertSame('', $user->getPhoto()); $this->assertEquals(array(), $user->getExternalGroupIds()); $this->assertEquals(array('is_ldap_user' => 1), $user->getExtraAttributes()); @@ -746,6 +746,11 @@ class LdapUserTest extends Base $this->user ->expects($this->any()) + ->method('getGroupManagerDn') + ->will($this->returnValue('cn=Kanboard Managers,ou=Groups,dc=kanboard,dc=local')); + + $this->user + ->expects($this->any()) ->method('getBasDn') ->will($this->returnValue('OU=Users,DC=kanboard,DC=local')); diff --git a/tests/units/Core/User/UserPropertyTest.php b/tests/units/Core/User/UserPropertyTest.php index a2f052f4..30e651cb 100644 --- a/tests/units/Core/User/UserPropertyTest.php +++ b/tests/units/Core/User/UserPropertyTest.php @@ -56,6 +56,30 @@ class UserPropertyTest extends Base ); $this->assertEquals($expected, UserProperty::filterProperties($profile, $properties)); + + $profile = array( + 'id' => 123, + 'username' => 'bob', + 'name' => null, + 'email' => '', + 'other_column' => 'myvalue', + 'role' => Role::APP_ADMIN, + ); + + $properties = array( + 'external_id' => '456', + 'username' => 'bobby', + 'name' => 'Bobby', + 'email' => 'admin@localhost', + 'role' => null, + ); + + $expected = array( + 'name' => 'Bobby', + 'email' => 'admin@localhost', + ); + + $this->assertEquals($expected, UserProperty::filterProperties($profile, $properties)); } public function testFilterPropertiesOverrideExistingValueWhenNecessary() |