From e9fedf3e5cd63aea4da7a71f6647ee427c62fa49 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sat, 5 Dec 2015 20:31:27 -0500 Subject: Rewrite of the authentication and authorization system --- app/Group/DatabaseBackendGroupProvider.php | 34 +++++++++++++ app/Group/DatabaseGroupProvider.php | 66 ++++++++++++++++++++++++++ app/Group/LdapBackendGroupProvider.php | 54 +++++++++++++++++++++ app/Group/LdapGroupProvider.php | 76 ++++++++++++++++++++++++++++++ 4 files changed, 230 insertions(+) create mode 100644 app/Group/DatabaseBackendGroupProvider.php create mode 100644 app/Group/DatabaseGroupProvider.php create mode 100644 app/Group/LdapBackendGroupProvider.php create mode 100644 app/Group/LdapGroupProvider.php (limited to 'app/Group') diff --git a/app/Group/DatabaseBackendGroupProvider.php b/app/Group/DatabaseBackendGroupProvider.php new file mode 100644 index 00000000..a53516a0 --- /dev/null +++ b/app/Group/DatabaseBackendGroupProvider.php @@ -0,0 +1,34 @@ +group->search($input); + + foreach ($groups as $group) { + $result[] = new DatabaseGroupProvider($group); + } + + return $result; + } +} diff --git a/app/Group/DatabaseGroupProvider.php b/app/Group/DatabaseGroupProvider.php new file mode 100644 index 00000000..e00f36ba --- /dev/null +++ b/app/Group/DatabaseGroupProvider.php @@ -0,0 +1,66 @@ +group = $group; + } + + /** + * Get internal id + * + * @access public + * @return integer + */ + public function getInternalId() + { + return $this->group['id']; + } + + /** + * Get external id + * + * @access public + * @return string + */ + public function getExternalId() + { + return ''; + } + + /** + * Get group name + * + * @access public + * @return string + */ + public function getName() + { + return $this->group['name']; + } +} diff --git a/app/Group/LdapBackendGroupProvider.php b/app/Group/LdapBackendGroupProvider.php new file mode 100644 index 00000000..40273466 --- /dev/null +++ b/app/Group/LdapBackendGroupProvider.php @@ -0,0 +1,54 @@ +getLdapGroupPattern($input)); + + } catch (LdapException $e) { + $this->logger->error($e->getMessage()); + return array(); + } + } + + /** + * Get LDAP group pattern + * + * @access public + * @param string $input + * @return string + */ + public function getLdapGroupPattern($input) + { + if (empty(LDAP_GROUP_FILTER)) { + throw new LogicException('LDAP group filter empty, check the parameter LDAP_GROUP_FILTER'); + } + + return sprintf(LDAP_GROUP_FILTER, $input); + } +} diff --git a/app/Group/LdapGroupProvider.php b/app/Group/LdapGroupProvider.php new file mode 100644 index 00000000..b497d485 --- /dev/null +++ b/app/Group/LdapGroupProvider.php @@ -0,0 +1,76 @@ +dn = $dn; + $this->name = $name; + } + + /** + * Get internal id + * + * @access public + * @return integer + */ + public function getInternalId() + { + return ''; + } + + /** + * Get external id + * + * @access public + * @return string + */ + public function getExternalId() + { + return $this->dn; + } + + /** + * Get group name + * + * @access public + * @return string + */ + public function getName() + { + return $this->name; + } +} -- cgit v1.2.3 From 18c56a50e77b5e151b10f1df727fa2279e9d89a4 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sat, 5 Dec 2015 21:22:37 -0500 Subject: Fix phpdoc --- app/Auth/DatabaseAuth.php | 2 +- app/Auth/GithubAuth.php | 2 +- app/Auth/GitlabAuth.php | 2 +- app/Auth/GoogleAuth.php | 2 +- app/Auth/RememberMeAuth.php | 2 +- app/Auth/ReverseProxyAuth.php | 2 +- app/Core/Ldap/Entries.php | 2 +- app/Core/Mail/Transport/Mail.php | 2 +- app/Core/Mail/Transport/Sendmail.php | 2 +- app/Core/Mail/Transport/Smtp.php | 2 +- app/Core/User/UserSession.php | 2 +- app/Group/DatabaseBackendGroupProvider.php | 2 +- app/Group/LdapBackendGroupProvider.php | 2 +- app/Model/ProjectGroupRole.php | 6 +++--- 14 files changed, 16 insertions(+), 16 deletions(-) (limited to 'app/Group') diff --git a/app/Auth/DatabaseAuth.php b/app/Auth/DatabaseAuth.php index 727afaf3..69260fe7 100644 --- a/app/Auth/DatabaseAuth.php +++ b/app/Auth/DatabaseAuth.php @@ -90,7 +90,7 @@ class DatabaseAuth extends Base implements PasswordAuthenticationProviderInterfa * Get user object * * @access public - * @return null|\Kanboard\User\DatabaseUserProvider + * @return \Kanboard\User\DatabaseUserProvider */ public function getUser() { diff --git a/app/Auth/GithubAuth.php b/app/Auth/GithubAuth.php index 47da0413..a03c7158 100644 --- a/app/Auth/GithubAuth.php +++ b/app/Auth/GithubAuth.php @@ -84,7 +84,7 @@ class GithubAuth extends Base implements OAuthAuthenticationProviderInterface * Get user object * * @access public - * @return null|GithubUserProvider + * @return GithubUserProvider */ public function getUser() { diff --git a/app/Auth/GitlabAuth.php b/app/Auth/GitlabAuth.php index df6e0176..9e1ac4ef 100644 --- a/app/Auth/GitlabAuth.php +++ b/app/Auth/GitlabAuth.php @@ -84,7 +84,7 @@ class GitlabAuth extends Base implements OAuthAuthenticationProviderInterface * Get user object * * @access public - * @return null|GitlabUserProvider + * @return GitlabUserProvider */ public function getUser() { diff --git a/app/Auth/GoogleAuth.php b/app/Auth/GoogleAuth.php index 0dc1c62f..c4acfa0f 100644 --- a/app/Auth/GoogleAuth.php +++ b/app/Auth/GoogleAuth.php @@ -84,7 +84,7 @@ class GoogleAuth extends Base implements OAuthAuthenticationProviderInterface * Get user object * * @access public - * @return null|GoogleUserProvider + * @return GoogleUserProvider */ public function getUser() { diff --git a/app/Auth/RememberMeAuth.php b/app/Auth/RememberMeAuth.php index 02b7b9f6..5a0e48ec 100644 --- a/app/Auth/RememberMeAuth.php +++ b/app/Auth/RememberMeAuth.php @@ -66,7 +66,7 @@ class RememberMeAuth extends Base implements PreAuthenticationProviderInterface * Get user object * * @access public - * @return null|DatabaseUserProvider + * @return DatabaseUserProvider */ public function getUser() { diff --git a/app/Auth/ReverseProxyAuth.php b/app/Auth/ReverseProxyAuth.php index 8af7f0a2..06573edb 100644 --- a/app/Auth/ReverseProxyAuth.php +++ b/app/Auth/ReverseProxyAuth.php @@ -67,7 +67,7 @@ class ReverseProxyAuth extends Base implements PreAuthenticationProviderInterfac * Get user object * * @access public - * @return null|ReverseProxyUserProvider + * @return ReverseProxyUserProvider */ public function getUser() { diff --git a/app/Core/Ldap/Entries.php b/app/Core/Ldap/Entries.php index b0f78fa4..3487541f 100644 --- a/app/Core/Ldap/Entries.php +++ b/app/Core/Ldap/Entries.php @@ -33,7 +33,7 @@ class Entries * Get all entries * * @access public - * @return []Entry + * @return Entry[] */ public function getAll() { diff --git a/app/Core/Mail/Transport/Mail.php b/app/Core/Mail/Transport/Mail.php index 4d833f8f..aff3ee20 100644 --- a/app/Core/Mail/Transport/Mail.php +++ b/app/Core/Mail/Transport/Mail.php @@ -46,7 +46,7 @@ class Mail extends Base implements ClientInterface * Get SwiftMailer transport * * @access protected - * @return \Swift_Transport + * @return \Swift_Transport|\Swift_MailTransport|\Swift_SmtpTransport|\Swift_SendmailTransport */ protected function getTransport() { diff --git a/app/Core/Mail/Transport/Sendmail.php b/app/Core/Mail/Transport/Sendmail.php index 849e3385..039be705 100644 --- a/app/Core/Mail/Transport/Sendmail.php +++ b/app/Core/Mail/Transport/Sendmail.php @@ -16,7 +16,7 @@ class Sendmail extends Mail * Get SwiftMailer transport * * @access protected - * @return \Swift_Transport + * @return \Swift_Transport|\Swift_MailTransport|\Swift_SmtpTransport|\Swift_SendmailTransport */ protected function getTransport() { diff --git a/app/Core/Mail/Transport/Smtp.php b/app/Core/Mail/Transport/Smtp.php index 757408ea..66f0a3aa 100644 --- a/app/Core/Mail/Transport/Smtp.php +++ b/app/Core/Mail/Transport/Smtp.php @@ -16,7 +16,7 @@ class Smtp extends Mail * Get SwiftMailer transport * * @access protected - * @return \Swift_Transport + * @return \Swift_Transport|\Swift_MailTransport|\Swift_SmtpTransport|\Swift_SendmailTransport */ protected function getTransport() { diff --git a/app/Core/User/UserSession.php b/app/Core/User/UserSession.php index d1e0bb93..534e5192 100644 --- a/app/Core/User/UserSession.php +++ b/app/Core/User/UserSession.php @@ -114,7 +114,7 @@ class UserSession extends Base * Get username * * @access public - * @return integer + * @return string */ public function getUsername() { diff --git a/app/Group/DatabaseBackendGroupProvider.php b/app/Group/DatabaseBackendGroupProvider.php index a53516a0..6dbaa43c 100644 --- a/app/Group/DatabaseBackendGroupProvider.php +++ b/app/Group/DatabaseBackendGroupProvider.php @@ -18,7 +18,7 @@ class DatabaseBackendGroupProvider extends Base implements GroupBackendProviderI * * @access public * @param string $input - * @return []DatabaseGroupProvider + * @return DatabaseGroupProvider[] */ public function find($input) { diff --git a/app/Group/LdapBackendGroupProvider.php b/app/Group/LdapBackendGroupProvider.php index 40273466..d65a9865 100644 --- a/app/Group/LdapBackendGroupProvider.php +++ b/app/Group/LdapBackendGroupProvider.php @@ -22,7 +22,7 @@ class LdapBackendGroupProvider extends Base implements GroupBackendProviderInter * * @access public * @param string $input - * @return []LdapGroupProvider + * @return LdapGroupProvider[] */ public function find($input) { diff --git a/app/Model/ProjectGroupRole.php b/app/Model/ProjectGroupRole.php index 87fdec10..2fe22ca6 100644 --- a/app/Model/ProjectGroupRole.php +++ b/app/Model/ProjectGroupRole.php @@ -172,9 +172,9 @@ class ProjectGroupRole extends Base foreach ($rows as $row) { $result = $this->db->table(self::TABLE)->save(array( - 'project_id' => $project_dst_id, - 'group_id' => $row['group_id'], - 'role' => $row['role'], + 'project_id' => $project_dst_id, + 'group_id' => $row['group_id'], + 'role' => $row['role'], )); if (! $result) { -- cgit v1.2.3 From 9bd7985ba41b385c63213970b862ffc06f1096b0 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sun, 6 Dec 2015 00:00:09 -0500 Subject: Add more unit tests --- app/Auth/GithubAuth.php | 4 +- app/Auth/GitlabAuth.php | 4 +- app/Auth/GoogleAuth.php | 4 +- app/Core/Group/GroupManager.php | 2 +- app/Group/DatabaseGroupProvider.php | 2 +- app/Model/Group.php | 2 +- tests/units/Auth/GithubAuthTest.php | 89 +++++++++++++++++++++++++++++ tests/units/Auth/GitlabAuthTest.php | 89 +++++++++++++++++++++++++++++ tests/units/Auth/GoogleAuthTest.php | 89 +++++++++++++++++++++++++++++ tests/units/Core/Group/GroupManagerTest.php | 42 ++++++++++++++ 10 files changed, 318 insertions(+), 9 deletions(-) create mode 100644 tests/units/Auth/GithubAuthTest.php create mode 100644 tests/units/Auth/GitlabAuthTest.php create mode 100644 tests/units/Auth/GoogleAuthTest.php create mode 100644 tests/units/Core/Group/GroupManagerTest.php (limited to 'app/Group') diff --git a/app/Auth/GithubAuth.php b/app/Auth/GithubAuth.php index a03c7158..606ab301 100644 --- a/app/Auth/GithubAuth.php +++ b/app/Auth/GithubAuth.php @@ -116,10 +116,10 @@ class GithubAuth extends Base implements OAuthAuthenticationProviderInterface /** * Get Github profile * - * @access private + * @access public * @return array */ - private function getProfile() + public function getProfile() { $this->getService()->getAccessToken($this->code); diff --git a/app/Auth/GitlabAuth.php b/app/Auth/GitlabAuth.php index 9e1ac4ef..084e8ab9 100644 --- a/app/Auth/GitlabAuth.php +++ b/app/Auth/GitlabAuth.php @@ -116,10 +116,10 @@ class GitlabAuth extends Base implements OAuthAuthenticationProviderInterface /** * Get Gitlab profile * - * @access private + * @access public * @return array */ - private function getProfile() + public function getProfile() { $this->getService()->getAccessToken($this->code); diff --git a/app/Auth/GoogleAuth.php b/app/Auth/GoogleAuth.php index c4acfa0f..2a1f1b46 100644 --- a/app/Auth/GoogleAuth.php +++ b/app/Auth/GoogleAuth.php @@ -116,10 +116,10 @@ class GoogleAuth extends Base implements OAuthAuthenticationProviderInterface /** * Get Google profile * - * @access private + * @access public * @return array */ - private function getProfile() + public function getProfile() { $this->getService()->getAccessToken($this->code); diff --git a/app/Core/Group/GroupManager.php b/app/Core/Group/GroupManager.php index e49ffa0f..48b6c4f8 100644 --- a/app/Core/Group/GroupManager.php +++ b/app/Core/Group/GroupManager.php @@ -66,6 +66,6 @@ class GroupManager } } - return $result; + return array_values($result); } } diff --git a/app/Group/DatabaseGroupProvider.php b/app/Group/DatabaseGroupProvider.php index e00f36ba..430121a3 100644 --- a/app/Group/DatabaseGroupProvider.php +++ b/app/Group/DatabaseGroupProvider.php @@ -39,7 +39,7 @@ class DatabaseGroupProvider implements GroupProviderInterface */ public function getInternalId() { - return $this->group['id']; + return (int) $this->group['id']; } /** diff --git a/app/Model/Group.php b/app/Model/Group.php index 36171ca4..a086fe9d 100644 --- a/app/Model/Group.php +++ b/app/Model/Group.php @@ -75,7 +75,7 @@ class Group extends Base */ public function search($input) { - return $this->db->table(self::TABLE)->ilike('name', '%'.$input.'%')->findAll(); + return $this->db->table(self::TABLE)->ilike('name', '%'.$input.'%')->asc('name')->findAll(); } /** diff --git a/tests/units/Auth/GithubAuthTest.php b/tests/units/Auth/GithubAuthTest.php new file mode 100644 index 00000000..e9ab066f --- /dev/null +++ b/tests/units/Auth/GithubAuthTest.php @@ -0,0 +1,89 @@ +container); + $this->assertEquals('Github', $provider->getName()); + } + + public function testAuthenticationSuccessful() + { + $profile = array( + 'id' => 1234, + 'email' => 'test@localhost', + 'name' => 'Test', + ); + + $provider = $this + ->getMockBuilder('\Kanboard\Auth\GithubAuth') + ->setConstructorArgs(array($this->container)) + ->setMethods(array( + 'getProfile', + )) + ->getMock(); + + $provider->expects($this->once()) + ->method('getProfile') + ->will($this->returnValue($profile)); + + $this->assertInstanceOf('Kanboard\Auth\GithubAuth', $provider->setCode('1234')); + + $this->assertTrue($provider->authenticate()); + + $user = $provider->getUser(); + $this->assertInstanceOf('Kanboard\User\GithubUserProvider', $user); + $this->assertEquals('Test', $user->getName()); + $this->assertEquals('', $user->getInternalId()); + $this->assertEquals(1234, $user->getExternalId()); + $this->assertEquals('', $user->getRole()); + $this->assertEquals('', $user->getUsername()); + $this->assertEquals('test@localhost', $user->getEmail()); + $this->assertEquals('github_id', $user->getExternalIdColumn()); + $this->assertEquals(array(), $user->getExternalGroupIds()); + $this->assertEquals(array(), $user->getExtraAttributes()); + $this->assertFalse($user->isUserCreationAllowed()); + } + + public function testAuthenticationFailed() + { + $provider = $this + ->getMockBuilder('\Kanboard\Auth\GithubAuth') + ->setConstructorArgs(array($this->container)) + ->setMethods(array( + 'getProfile', + )) + ->getMock(); + + $provider->expects($this->once()) + ->method('getProfile') + ->will($this->returnValue(array())); + + $this->assertFalse($provider->authenticate()); + $this->assertEquals(null, $provider->getUser()); + } + + public function testGetService() + { + $provider = new GithubAuth($this->container); + $this->assertInstanceOf('Kanboard\Core\Http\OAuth2', $provider->getService()); + } + + public function testUnlink() + { + $userModel = new User($this->container); + $provider = new GithubAuth($this->container); + + $this->assertEquals(2, $userModel->create(array('username' => 'test', 'github_id' => '1234'))); + $this->assertNotEmpty($userModel->getByExternalId('github_id', 1234)); + + $this->assertTrue($provider->unlink(2)); + $this->assertEmpty($userModel->getByExternalId('github_id', 1234)); + } +} diff --git a/tests/units/Auth/GitlabAuthTest.php b/tests/units/Auth/GitlabAuthTest.php new file mode 100644 index 00000000..e3ae0bdd --- /dev/null +++ b/tests/units/Auth/GitlabAuthTest.php @@ -0,0 +1,89 @@ +container); + $this->assertEquals('Gitlab', $provider->getName()); + } + + public function testAuthenticationSuccessful() + { + $profile = array( + 'id' => 1234, + 'email' => 'test@localhost', + 'name' => 'Test', + ); + + $provider = $this + ->getMockBuilder('\Kanboard\Auth\GitlabAuth') + ->setConstructorArgs(array($this->container)) + ->setMethods(array( + 'getProfile', + )) + ->getMock(); + + $provider->expects($this->once()) + ->method('getProfile') + ->will($this->returnValue($profile)); + + $this->assertInstanceOf('Kanboard\Auth\GitlabAuth', $provider->setCode('1234')); + + $this->assertTrue($provider->authenticate()); + + $user = $provider->getUser(); + $this->assertInstanceOf('Kanboard\User\GitlabUserProvider', $user); + $this->assertEquals('Test', $user->getName()); + $this->assertEquals('', $user->getInternalId()); + $this->assertEquals(1234, $user->getExternalId()); + $this->assertEquals('', $user->getRole()); + $this->assertEquals('', $user->getUsername()); + $this->assertEquals('test@localhost', $user->getEmail()); + $this->assertEquals('gitlab_id', $user->getExternalIdColumn()); + $this->assertEquals(array(), $user->getExternalGroupIds()); + $this->assertEquals(array(), $user->getExtraAttributes()); + $this->assertFalse($user->isUserCreationAllowed()); + } + + public function testAuthenticationFailed() + { + $provider = $this + ->getMockBuilder('\Kanboard\Auth\GitlabAuth') + ->setConstructorArgs(array($this->container)) + ->setMethods(array( + 'getProfile', + )) + ->getMock(); + + $provider->expects($this->once()) + ->method('getProfile') + ->will($this->returnValue(array())); + + $this->assertFalse($provider->authenticate()); + $this->assertEquals(null, $provider->getUser()); + } + + public function testGetService() + { + $provider = new GitlabAuth($this->container); + $this->assertInstanceOf('Kanboard\Core\Http\OAuth2', $provider->getService()); + } + + public function testUnlink() + { + $userModel = new User($this->container); + $provider = new GitlabAuth($this->container); + + $this->assertEquals(2, $userModel->create(array('username' => 'test', 'gitlab_id' => '1234'))); + $this->assertNotEmpty($userModel->getByExternalId('gitlab_id', 1234)); + + $this->assertTrue($provider->unlink(2)); + $this->assertEmpty($userModel->getByExternalId('gitlab_id', 1234)); + } +} diff --git a/tests/units/Auth/GoogleAuthTest.php b/tests/units/Auth/GoogleAuthTest.php new file mode 100644 index 00000000..b9a7d811 --- /dev/null +++ b/tests/units/Auth/GoogleAuthTest.php @@ -0,0 +1,89 @@ +container); + $this->assertEquals('Google', $provider->getName()); + } + + public function testAuthenticationSuccessful() + { + $profile = array( + 'id' => 1234, + 'email' => 'test@localhost', + 'name' => 'Test', + ); + + $provider = $this + ->getMockBuilder('\Kanboard\Auth\GoogleAuth') + ->setConstructorArgs(array($this->container)) + ->setMethods(array( + 'getProfile', + )) + ->getMock(); + + $provider->expects($this->once()) + ->method('getProfile') + ->will($this->returnValue($profile)); + + $this->assertInstanceOf('Kanboard\Auth\GoogleAuth', $provider->setCode('1234')); + + $this->assertTrue($provider->authenticate()); + + $user = $provider->getUser(); + $this->assertInstanceOf('Kanboard\User\GoogleUserProvider', $user); + $this->assertEquals('Test', $user->getName()); + $this->assertEquals('', $user->getInternalId()); + $this->assertEquals(1234, $user->getExternalId()); + $this->assertEquals('', $user->getRole()); + $this->assertEquals('', $user->getUsername()); + $this->assertEquals('test@localhost', $user->getEmail()); + $this->assertEquals('google_id', $user->getExternalIdColumn()); + $this->assertEquals(array(), $user->getExternalGroupIds()); + $this->assertEquals(array(), $user->getExtraAttributes()); + $this->assertFalse($user->isUserCreationAllowed()); + } + + public function testAuthenticationFailed() + { + $provider = $this + ->getMockBuilder('\Kanboard\Auth\GoogleAuth') + ->setConstructorArgs(array($this->container)) + ->setMethods(array( + 'getProfile', + )) + ->getMock(); + + $provider->expects($this->once()) + ->method('getProfile') + ->will($this->returnValue(array())); + + $this->assertFalse($provider->authenticate()); + $this->assertEquals(null, $provider->getUser()); + } + + public function testGetService() + { + $provider = new GoogleAuth($this->container); + $this->assertInstanceOf('Kanboard\Core\Http\OAuth2', $provider->getService()); + } + + public function testUnlink() + { + $userModel = new User($this->container); + $provider = new GoogleAuth($this->container); + + $this->assertEquals(2, $userModel->create(array('username' => 'test', 'google_id' => '1234'))); + $this->assertNotEmpty($userModel->getByExternalId('google_id', 1234)); + + $this->assertTrue($provider->unlink(2)); + $this->assertEmpty($userModel->getByExternalId('google_id', 1234)); + } +} diff --git a/tests/units/Core/Group/GroupManagerTest.php b/tests/units/Core/Group/GroupManagerTest.php new file mode 100644 index 00000000..faf5501f --- /dev/null +++ b/tests/units/Core/Group/GroupManagerTest.php @@ -0,0 +1,42 @@ +container); + $groupManager = new GroupManager; + + $this->assertEquals(1, $groupModel->create('Group 1')); + $this->assertEquals(2, $groupModel->create('Group 2')); + + $this->assertEmpty($groupManager->find('group 1')); + + $groupManager->register(new DatabaseBackendGroupProvider($this->container)); + $groupManager->register(new DatabaseBackendGroupProvider($this->container)); + + $groups = $groupManager->find('group 1'); + $this->assertCount(1, $groups); + $this->assertInstanceOf('Kanboard\Group\DatabaseGroupProvider', $groups[0]); + $this->assertEquals('Group 1', $groups[0]->getName()); + $this->assertEquals('', $groups[0]->getExternalId()); + $this->assertEquals(1, $groups[0]->getInternalId()); + + $groups = $groupManager->find('grou'); + $this->assertCount(2, $groups); + $this->assertInstanceOf('Kanboard\Group\DatabaseGroupProvider', $groups[0]); + $this->assertInstanceOf('Kanboard\Group\DatabaseGroupProvider', $groups[1]); + $this->assertEquals('Group 1', $groups[0]->getName()); + $this->assertEquals('Group 2', $groups[1]->getName()); + $this->assertEquals('', $groups[0]->getExternalId()); + $this->assertEquals('', $groups[1]->getExternalId()); + $this->assertEquals(1, $groups[0]->getInternalId()); + $this->assertEquals(2, $groups[1]->getInternalId()); + } +} -- cgit v1.2.3 From 8ff2032ea3fa49972fe076166c831719131e829d Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Tue, 22 Dec 2015 19:35:41 +0100 Subject: Avoid PHP error when enabling LDAP group provider with PHP < 5.5 --- ChangeLog | 1 + app/Group/LdapBackendGroupProvider.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'app/Group') diff --git a/ChangeLog b/ChangeLog index e49fdb19..a062848e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,7 @@ Bug fixes: - Fix wrong constant name that cause a PHP error in project management section - Fix pagination in group members listing +- Avoid PHP error when enabling LDAP group provider with PHP < 5.5 Version 1.0.22 -------------- diff --git a/app/Group/LdapBackendGroupProvider.php b/app/Group/LdapBackendGroupProvider.php index d65a9865..cad732c4 100644 --- a/app/Group/LdapBackendGroupProvider.php +++ b/app/Group/LdapBackendGroupProvider.php @@ -45,7 +45,7 @@ class LdapBackendGroupProvider extends Base implements GroupBackendProviderInter */ public function getLdapGroupPattern($input) { - if (empty(LDAP_GROUP_FILTER)) { + if (LDAP_GROUP_FILTER === '') { throw new LogicException('LDAP group filter empty, check the parameter LDAP_GROUP_FILTER'); } -- cgit v1.2.3