2013-06-03 15:34:57 +02:00
|
|
|
<?php
|
2016-02-08 15:41:00 +01:00
|
|
|
/* Icinga Web 2 | (c) 2013 Icinga Development Team | GPLv2+ */
|
2014-04-09 14:18:14 +02:00
|
|
|
|
2013-06-03 15:34:57 +02:00
|
|
|
namespace Tests\Icinga\Protocol\Ldap;
|
2014-04-09 14:18:14 +02:00
|
|
|
|
2014-11-18 13:11:52 +01:00
|
|
|
use Icinga\Data\ConfigObject;
|
2014-04-10 10:32:50 +02:00
|
|
|
use Icinga\Test\BaseTestCase;
|
2015-06-24 09:05:29 +02:00
|
|
|
use Icinga\Protocol\Ldap\LdapConnection;
|
2014-04-09 14:18:14 +02:00
|
|
|
|
2014-04-10 10:32:50 +02:00
|
|
|
class QueryTest extends BaseTestCase
|
2013-06-03 15:34:57 +02:00
|
|
|
{
|
|
|
|
private function emptySelect()
|
|
|
|
{
|
2014-11-18 13:11:52 +01:00
|
|
|
$config = new ConfigObject(
|
2013-10-22 16:24:49 +02:00
|
|
|
array(
|
|
|
|
'hostname' => 'localhost',
|
|
|
|
'root_dn' => 'dc=example,dc=com',
|
|
|
|
'bind_dn' => 'cn=user,ou=users,dc=example,dc=com',
|
|
|
|
'bind_pw' => '***'
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2015-06-24 09:05:29 +02:00
|
|
|
$connection = new LdapConnection($config);
|
2013-06-03 15:34:57 +02:00
|
|
|
return $connection->select();
|
|
|
|
}
|
|
|
|
|
|
|
|
private function prepareSelect()
|
|
|
|
{
|
|
|
|
$select = $this->emptySelect();
|
|
|
|
$select->from('dummyClass', array('testIntColumn', 'testStringColumn'))
|
|
|
|
->where('testIntColumn', 1)
|
|
|
|
->where('testStringColumn', 'test')
|
|
|
|
->where('testWildcard', 'abc*')
|
|
|
|
->order('testIntColumn')
|
|
|
|
->limit(10, 4);
|
|
|
|
return $select;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testFetchTree()
|
|
|
|
{
|
|
|
|
$this->markTestIncomplete('testFetchTree is not implemented yet - requires real LDAP');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testWhere()
|
|
|
|
{
|
|
|
|
$this->markTestIncomplete('testWhere is not implemented yet');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testOrder()
|
|
|
|
{
|
2015-05-04 11:26:27 +02:00
|
|
|
$this->markTestIncomplete('testOrder is not implemented yet, order support for ldap queries is incomplete');
|
2013-06-03 15:34:57 +02:00
|
|
|
}
|
|
|
|
|
2015-05-04 11:26:27 +02:00
|
|
|
public function testRenderFilter()
|
2013-06-03 15:34:57 +02:00
|
|
|
{
|
|
|
|
$select = $this->prepareSelect();
|
|
|
|
$res = '(&(objectClass=dummyClass)(testIntColumn=1)(testStringColumn=test)(testWildcard=abc*))';
|
2015-05-04 11:26:27 +02:00
|
|
|
$this->assertEquals($res, (string) $select);
|
2013-06-03 15:34:57 +02:00
|
|
|
}
|
|
|
|
}
|