Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/Backends/LDAPTest.php
Show First 20 Lines • Show All 168 Lines • ▼ Show 20 Lines | public function testGroup(): void | ||||
foreach ($expected as $attr => $value) { | foreach ($expected as $attr => $value) { | ||||
$this->assertEquals($value, isset($ldap_group[$attr]) ? $ldap_group[$attr] : null, "Group $attr attribute"); | $this->assertEquals($value, isset($ldap_group[$attr]) ? $ldap_group[$attr] : null, "Group $attr attribute"); | ||||
} | } | ||||
$this->assertSame(['member3@testldap.com'], $group->fresh()->members); | $this->assertSame(['member3@testldap.com'], $group->fresh()->members); | ||||
// Update members (add non-existing local member, expect it to be aot-removed from the group) | // Update members (add non-existing local member, expect it to be aot-removed from the group) | ||||
// Update group name and sender_policy | |||||
$group->members = ['member3@testldap.com', 'member-local@kolab.org']; | $group->members = ['member3@testldap.com', 'member-local@kolab.org']; | ||||
$group->name = 'Te(=ść)1'; | |||||
$group->save(); | $group->save(); | ||||
$group->setSetting('sender_policy', null); | $group->setSetting('sender_policy', null); | ||||
LDAP::updateGroup($group); | LDAP::updateGroup($group); | ||||
// TODO: Should we force this to be always an array? | // TODO: Should we force this to be always an array? | ||||
$expected['uniquemember'] = 'uid=member3@testldap.com,ou=People,ou=kolab.org,' . $root_dn; | $expected['uniquemember'] = 'uid=member3@testldap.com,ou=People,ou=kolab.org,' . $root_dn; | ||||
$expected['kolaballowsmtpsender'] = null; | $expected['kolaballowsmtpsender'] = null; | ||||
$expected['dn'] = 'cn=Te(\\3dść)1,ou=Groups,ou=kolab.org,' . $root_dn; | |||||
$expected['cn'] = 'Te(=ść)1'; | |||||
$ldap_group = LDAP::getGroup($group->email); | $ldap_group = LDAP::getGroup($group->email); | ||||
foreach ($expected as $attr => $value) { | foreach ($expected as $attr => $value) { | ||||
$this->assertEquals($value, isset($ldap_group[$attr]) ? $ldap_group[$attr] : null, "Group $attr attribute"); | $this->assertEquals($value, isset($ldap_group[$attr]) ? $ldap_group[$attr] : null, "Group $attr attribute"); | ||||
} | } | ||||
$this->assertSame(['member3@testldap.com'], $group->fresh()->members); | $this->assertSame(['member3@testldap.com'], $group->fresh()->members); | ||||
▲ Show 20 Lines • Show All 116 Lines • ▼ Show 20 Lines | public function testUser(): void | ||||
// Delete the user | // Delete the user | ||||
LDAP::deleteUser($user); | LDAP::deleteUser($user); | ||||
$this->assertSame(null, LDAP::getUser($user->email)); | $this->assertSame(null, LDAP::getUser($user->email)); | ||||
} | } | ||||
/** | /** | ||||
* Test handling errors on a group creation | |||||
* | |||||
* @group ldap | |||||
*/ | |||||
public function testCreateGroupException(): void | |||||
{ | |||||
$this->expectException(\Exception::class); | |||||
$this->expectExceptionMessageMatches('/Failed to create group/'); | |||||
$group = new Group([ | |||||
'name' => 'test', | |||||
'email' => 'test@testldap.com', | |||||
'status' => Group::STATUS_NEW | Group::STATUS_ACTIVE, | |||||
]); | |||||
LDAP::createGroup($group); | |||||
} | |||||
/** | |||||
* Test handling errors on user creation | * Test handling errors on user creation | ||||
* | * | ||||
* @group ldap | * @group ldap | ||||
*/ | */ | ||||
public function testCreateUserException(): void | public function testCreateUserException(): void | ||||
{ | { | ||||
$this->expectException(\Exception::class); | $this->expectException(\Exception::class); | ||||
$this->expectExceptionMessageMatches('/Failed to create user/'); | $this->expectExceptionMessageMatches('/Failed to create user/'); | ||||
Show All 31 Lines | class LDAPTest extends TestCase | ||||
* @group ldap | * @group ldap | ||||
*/ | */ | ||||
public function testUpdateGroupException(): void | public function testUpdateGroupException(): void | ||||
{ | { | ||||
$this->expectException(\Exception::class); | $this->expectException(\Exception::class); | ||||
$this->expectExceptionMessageMatches('/group not found/'); | $this->expectExceptionMessageMatches('/group not found/'); | ||||
$group = new Group([ | $group = new Group([ | ||||
'name' => 'test', | |||||
'email' => 'test@testldap.com', | 'email' => 'test@testldap.com', | ||||
'status' => Group::STATUS_NEW | Group::STATUS_ACTIVE, | 'status' => Group::STATUS_NEW | Group::STATUS_ACTIVE, | ||||
]); | ]); | ||||
LDAP::updateGroup($group); | LDAP::updateGroup($group); | ||||
} | } | ||||
/** | /** | ||||
Show All 17 Lines |