*
* @param array $config Configuration parameters for the session.
*/
- public function __construct(
- Horde_Kolab_Session_Factory $factory,
- array $config
- ) {
+ public function __construct(array $config)
+ {
$this->_configuration = $config;
+ if (isset($config['server'])) {
+ $server_configuration = $config['server'];
+ } elseif (isset($config['ldap'])) {
+ $server_configuration = $config['ldap'];
+ } else {
+ throw new Horde_Kolab_Session_Exception(
+ 'The server configuration is missing!'
+ );
+ }
+
+ $server_factory = new Horde_Kolab_Server_Factory_Configuration(
+ $server_configuration
+ );
+
+ $factory = new Horde_Kolab_Session_Factory_Default(
+ $config, $server_factory
+ );
+
if (isset($config['logger'])) {
$factory = new Horde_Kolab_Session_Factory_Logged(
$factory, $config['logger']
*/
public function getServer()
{
- return $this->_server_factory->getServer();
+ return $this->_server_factory->getComposite();
}
/**
*/
private function _setupStorage()
{
- $this->_injector->bindImplementation(
+ $this->_injector->bindFactory(
'Horde_Kolab_Session_Storage',
- 'Horde_Kolab_Session_Storage_Sessionobjects'
+ 'Horde_Kolab_Session_Factory_Injector',
+ 'getStorage'
);
}
}
/**
+ * A helper method to seed the injector with a Horde_Kolab_Server factory
+ * definition. This should usually be done by an external setup method
+ * before constructing the session injcetion factory.
+ *
+ * @parm Horde_Injector
+ *
+ * @return NULL
+ */
+ static public function setupMockServerFactory(
+ Horde_Injector $injector
+ ) {
+ Horde_Kolab_Server_Factory_Injector::setup(
+ 'Horde_Kolab_Server_Factory_Conn_Mock',
+ array('basedn' => ''),
+ $injector
+ );
+ /** Setup the injector by constructing the server factory */
+ $injector->getInstance('Horde_Kolab_Server_Factory_Injector');
+ }
+
+ /**
* Return the kolab user db connection.
*
* @return Horde_Kolab_Server The server connection.
*/
public function getServer()
{
- return $this->_injector->getInstance('Horde_Kolab_Server');
+ return $this->_injector->getInstance('Horde_Kolab_Server_Composite');
}
/**
*/
public function getSessionStorage()
{
- return $this->_injector->getInstance('Horde_Kolab_Session_Storage');
+ $storage = new Horde_Kolab_Session_Storage_Sessionobjects(
+ Horde_SessionObjects::singleton()
+ );
+ return $storage;
}
}
global $conf;
if (!isset(self::$_instance)) {
+ $config = $conf['kolab'];
$config['logger'] = Horde::getLogger();
- $config['server'] = $conf['kolab']['server'];
- $server_factory = new Horde_Kolab_Server_Factory_Default($config);
- $server_factory = new Horde_Kolab_Server_Factory_Configuration($server_factory, $config);
- $factory = new Horde_Kolab_Session_Factory_Default($config, $server_factory);
- $factory = new Horde_Kolab_Session_Factory_Configuration($factory, $config);
+ $factory = new Horde_Kolab_Session_Factory_Configuration($config);
self::$_instance = $factory->getSession($user);
- self::$_instance->connect($credentials);
}
return self::$_instance;
}
$this->setupLogger();
}
+ public function testMethodConstructThrowsExceptionIfTheServerConfigurationIsMissing()
+ {
+ try {
+ $factory = new Horde_Kolab_Session_Factory_Configuration(array());
+ $this->fail('No exception!');
+ } catch (Horde_Kolab_Session_Exception $e) {
+ $this->assertEquals(
+ 'The server configuration is missing!',
+ $e->getMessage()
+ );
+ }
+ }
+
public function testMethodCreatesessionHasResultHordekolabsessionanonymousIfConfiguredThatWay()
{
- $session = $this->getMock('Horde_Kolab_Session');
- $factory = $this->getMock('Horde_Kolab_Session_Factory');
- $factory->expects($this->once())
- ->method('createSession')
- ->will($this->returnValue($session));
$factory = new Horde_Kolab_Session_Factory_Configuration(
- $factory,
array(
'session' => array(
'anonymous' => array(
'user' => 'anonymous',
'pass' => ''
)
+ ),
+ 'server' => array(
+ 'basedn' => ''
)
)
);
public function testMethodCreatesessionHasResultHordekolabsessionloggedIfConfiguredThatWay()
{
- $session = $this->getMock('Horde_Kolab_Session');
- $factory = $this->getMock('Horde_Kolab_Session_Factory');
- $factory->expects($this->once())
- ->method('createSession')
- ->will($this->returnValue($session));
$factory = new Horde_Kolab_Session_Factory_Configuration(
- $factory, array('logger' => $this->logger)
+ array(
+ 'logger' => $this->logger,
+ 'server' => array(
+ 'basedn' => ''
+ )
+ )
);
$this->assertType(
'Horde_Kolab_Session_Logged',
{
$session = $this->getMock('Horde_Kolab_Session');
$auth = $this->getMock('Horde_Kolab_Session_Auth');
- $validator = $this->getMock('Horde_Kolab_Session_Valid');
- $factory = $this->getMock('Horde_Kolab_Session_Factory');
- $factory->expects($this->once())
- ->method('getSessionValidator')
- ->will($this->returnValue($validator));
$factory = new Horde_Kolab_Session_Factory_Configuration(
- $factory, array('logger' => $this->logger)
+ array(
+ 'logger' => $this->logger,
+ 'server' => array(
+ 'basedn' => ''
+ )
+ )
);
$this->assertType(
'Horde_Kolab_Session_Valid_Logged',
);
}
- public function testMethodGetserverGetsDelegated()
+ public function testMethodGetserverHasResultServercomposite()
{
- $server = $this->getMock('Horde_Kolab_Server');
- $factory = $this->getMock('Horde_Kolab_Session_Factory');
- $factory->expects($this->once())
- ->method('getServer')
- ->will($this->returnValue($server));
$factory = new Horde_Kolab_Session_Factory_Configuration(
- $factory, array()
+ array(
+ 'server' => array(
+ 'basedn' => ''
+ )
+ )
+ );
+ $this->assertType(
+ 'Horde_Kolab_Server_Composite',
+ $factory->getServer()
);
- $this->assertType('Horde_Kolab_Server', $factory->getServer());
}
- public function testMethodGetsessionauthGetsDelegated()
+ public function testMethodGetsessionauthHasResultSessionauth()
{
- $auth = $this->getMock('Horde_Kolab_Session_Auth');
- $factory = $this->getMock('Horde_Kolab_Session_Factory');
- $factory->expects($this->once())
- ->method('getSessionAuth')
- ->will($this->returnValue($auth));
$factory = new Horde_Kolab_Session_Factory_Configuration(
- $factory, array()
+ array(
+ 'server' => array(
+ 'basedn' => ''
+ )
+ )
);
$this->assertType(
'Horde_Kolab_Session_Auth',
);
}
- public function testMethodGetsessionconfigurationGetsDelegated()
+ public function testMethodGetsessionconfigurationHasResultArray()
{
- $factory = $this->getMock('Horde_Kolab_Session_Factory');
- $factory->expects($this->once())
- ->method('getSessionConfiguration')
- ->will($this->returnValue(array()));
$factory = new Horde_Kolab_Session_Factory_Configuration(
- $factory, array()
+ array(
+ 'server' => array(
+ 'basedn' => ''
+ )
+ )
);
$this->assertType('array', $factory->getSessionConfiguration());
}
- public function testMethodGetsessionstorageGetsDelegated()
+ public function testMethodGetsessionstorageHasresultSessionstorage()
{
- $storage = $this->getMock('Horde_Kolab_Session_Storage');
- $factory = $this->getMock('Horde_Kolab_Session_Factory');
- $factory->expects($this->once())
- ->method('getSessionStorage')
- ->will($this->returnValue($storage));
$factory = new Horde_Kolab_Session_Factory_Configuration(
- $factory, array()
+ array(
+ 'server' => array(
+ 'basedn' => ''
+ )
+ )
);
$this->assertType(
'Horde_Kolab_Session_Storage',
);
}
- public function testMethodGetsessionvalidatorGetsDelegated()
+ public function testMethodGetsessionvalidatorHasResultSessionvalid()
{
$session = $this->getMock('Horde_Kolab_Session');
$auth = $this->getMock('Horde_Kolab_Session_Auth');
- $validator = $this->getMock('Horde_Kolab_Session_Valid');
- $factory = $this->getMock('Horde_Kolab_Session_Factory');
- $factory->expects($this->once())
- ->method('getSessionValidator')
- ->will($this->returnValue($validator));
$factory = new Horde_Kolab_Session_Factory_Configuration(
- $factory, array()
+ array(
+ 'server' => array(
+ 'basedn' => ''
+ )
+ )
);
$this->assertType(
'Horde_Kolab_Session_Valid',
);
}
- public function testMethodValidateGetsDelegated()
+ public function testMethodValidateHasResultBooleanTrueIfTheSessionIsStillValid()
{
$session = $this->getMock('Horde_Kolab_Session');
- $factory = $this->getMock('Horde_Kolab_Session_Factory');
- $factory->expects($this->once())
- ->method('validate')
- ->will($this->returnValue(true));
$factory = new Horde_Kolab_Session_Factory_Configuration(
- $factory, array()
+ array(
+ 'server' => array(
+ 'basedn' => ''
+ )
+ )
);
- $this->assertTrue($factory->validate($session, 'test'));
+ $this->assertTrue($factory->validate($session, ''));
}
- public function testMethodCreatesessionGetsDelegated()
+ public function testMethodCreatesessionHasResultSession()
{
- $session = $this->getMock('Horde_Kolab_Session');
- $factory = $this->getMock('Horde_Kolab_Session_Factory');
- $factory->expects($this->once())
- ->method('createSession')
- ->will($this->returnValue($session));
$factory = new Horde_Kolab_Session_Factory_Configuration(
- $factory, array()
+ array(
+ 'server' => array(
+ 'basedn' => ''
+ )
+ )
);
$this->assertType('Horde_Kolab_Session', $factory->createSession());
}
- public function testMethodGetsessionGetsDelegated()
+ public function testMethodGetsessionHasResultSession()
{
- $session = $this->getMock('Horde_Kolab_Session');
- $factory = $this->getMock('Horde_Kolab_Session_Factory');
- $factory->expects($this->once())
- ->method('getSession')
- ->will($this->returnValue($session));
$factory = new Horde_Kolab_Session_Factory_Configuration(
- $factory, array()
+ array(
+ 'server' => array(
+ 'basedn' => ''
+ )
+ )
);
$this->assertType('Horde_Kolab_Session', $factory->getSession());
}
{
public function testMethodGetserverHasResultHordekolabserver()
{
- $this->markTestIncomplete('The factory in the Kolab_Server package needs to be fixed.');
- $server = $this->getMock('Horde_Kolab_Server');
+ $server = $this->getMock(
+ 'Horde_Kolab_Server_Composite', array(), array(), '', false, false
+ );
$server_factory = $this->getMock('Horde_Kolab_Server_Factory');
$server_factory->expects($this->once())
- ->method('getServer')
+ ->method('getComposite')
->will($this->returnValue($server));
$factory = new Horde_Kolab_Session_Factory_Default(
array('server' => array()),
$server_factory
);
- $this->assertType('Horde_Kolab_Server', $factory->getServer());
+ $this->assertType('Horde_Kolab_Server_Composite', $factory->getServer());
}
public function testMethodGetsessionauthHasResultHordekolabsessionauth()
public function setUp()
{
$this->injector = new Horde_Injector(new Horde_Injector_TopLevel());
- $this->markTestIncomplete('This needs an injector factory in the Kolab_Server package.');
+ Horde_Kolab_Session_Factory_Injector::setupMockServerFactory($this->injector);
}
public function testMethodGetserverHasResultHordekolabserver()
$factory = new Horde_Kolab_Session_Factory_Injector(
array('server' => array()), $this->injector
);
- $this->assertType('Horde_Kolab_Server', $factory->getServer());
+ $this->assertType('Horde_Kolab_Server_Composite', $factory->getServer());
}
public function testMethodGetsessionauthHasResultHordekolabsessionauth()
*/
class Horde_Kolab_Session_Class_SingletonTest extends Horde_Kolab_Session_SessionTestCase
{
+ public function setUp()
+ {
+ global $conf;
+
+ /** Provide a minimal configuration for the server */
+ $conf['kolab']['ldap']['basedn'] = '';
+ }
+
public function testMethodSingletonHasResultHordekolabsession()
{
- $this->markTestIncomplete('The factory in the Kolab_Server package needs to be fixed.');
$this->assertType(
'Horde_Kolab_Session',
Horde_Kolab_Session_Singleton::singleton(
public function testMethodSingletonHasResultHordekolabsessionAlwaysTheSameIfTheSessionIsValid()
{
- $this->markTestIncomplete('The factory in the Kolab_Server package needs to be fixed.');
$session1 = Horde_Kolab_Session_Singleton::singleton(
'user', array('password' => 'pass')
);
--- /dev/null
+<?php
+/**
+ * Test the Kolab session handler.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package Kolab_Session
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Session
+ */
+
+/**
+ * Prepare the test setup.
+ */
+require_once dirname(__FILE__) . '/Autoload.php';
+
+/**
+ * Test the Kolab session handler.
+ *
+ * Copyright 2008-2009 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Kolab
+ * @package Kolab_Session
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Session
+ */
+class Horde_Kolab_Session_Integration_SessionTest extends Horde_Kolab_Session_SessionTestCase
+{
+ /**
+ * Setup function.
+ *
+ * @return NULL.
+ */
+ protected function setUp()
+ {
+ $this->markTestIncomplete('Needs to be fixed');
+ }
+
+ /**
+ * Test class construction.
+ *
+ * @return NULL
+ */
+ public function testConstructEmpty()
+ {
+ global $conf;
+ $conf['kolab']['imap']['allow_special_users'] = true;
+
+ $session = Horde_Kolab_Session::singleton();
+
+ $this->assertEquals('anonymous', $session->user_mail);
+
+ $params = $session->getImapParams();
+ $this->assertNoError($params);
+ $this->assertEquals('localhost', $params['hostspec']);
+ $this->assertEquals(143, $params['port']);
+ }
+
+ /**
+ * Test old style class construction.
+ *
+ * @return NULL
+ */
+ public function testConstructSimple()
+ {
+ global $conf;
+ $conf['kolab']['imap']['server'] = 'example.com';
+ $conf['kolab']['imap']['port'] = 200;
+ $conf['kolab']['freebusy']['server'] = 'fb.example.com';
+
+ $session = new Horde_Kolab_Session();
+ $params = $session->getImapParams();
+ if (is_a($params, 'PEAR_Error')) {
+ $this->assertEquals('', $params->getMessage());
+ }
+ $this->assertEquals('example.com', $params['hostspec']);
+ $this->assertEquals(200, $params['port']);
+ }
+
+ /**
+ * Test IMAP server retrieval.
+ *
+ * @return NULL
+ */
+ public function testGetSession()
+ {
+ $this->markTestSkipped();
+ $server = &$this->prepareEmptyKolabServer();
+ $result = $server->add($this->provideBasicUserTwo());
+ $this->assertNoError($result);
+ $this->assertEquals(1, count($GLOBALS['KOLAB_SERVER_TEST_DATA']));
+
+ $session = Horde_Kolab_Session::singleton('test',
+ array('password' => 'test'));
+
+ $this->assertNoError($session->auth);
+ $this->assertEquals('test@example.org', $session->user_mail);
+
+ $params = $session->getImapParams();
+ $this->assertNoError($params);
+ $this->assertEquals('home.example.org', $params['hostspec']);
+ $this->assertEquals(143, $params['port']);
+ $this->assertEquals('test@example.org', $session->user_mail);
+
+ $session->shutdown();
+
+ $hs = Horde_SessionObjects::singleton();
+
+ $recovered_session = &$hs->query('kolab_session');
+ $params = $recovered_session->getImapParams();
+ $this->assertNoError($params);
+ $this->assertEquals('home.example.org', $params['hostspec']);
+ $this->assertEquals(143, $params['port']);
+ $this->assertEquals('test@example.org', $session->user_mail);
+
+ $this->assertEquals('https://fb.example.org/freebusy', $session->freebusy_server);
+ }
+
+ /**
+ * Test retrieving the FreeBusy server for the unauthenticated state.
+ *
+ * @return NULL
+ */
+ public function testGetFreeBusySession()
+ {
+ $this->markTestSkipped();
+ $server = $this->prepareEmptyKolabServer();
+ $result = $server->add($this->provideBasicUserTwo());
+ $this->assertNoError($result);
+ $session = Horde_Kolab_Session::singleton();
+ $this->assertEquals('', $session->freebusy_server);
+ }
+
+ /**
+ * Test group based login allow implemention.
+ *
+ * @return NULL
+ */
+ public function testLoginAllow()
+ {
+ global $conf;
+ $conf['kolab']['server']['allow_group'] = 'group2@example.org';
+ $conf['kolab']['server']['deny_group'] = null;
+
+ $this->markTestSkipped();
+ $server = &$this->prepareEmptyKolabServer();
+ $result = $server->add($this->provideBasicUserOne());
+ $this->assertNoError($result);
+ $result = $server->add($this->provideBasicUserTwo());
+ $this->assertNoError($result);
+ $groups = $this->validGroups();
+ foreach ($groups as $group) {
+ $result = $server->add($group[0]);
+ $this->assertNoError($result);
+ }
+
+ $session = Horde_Kolab_Session::singleton('wrobel',
+ array('password' => 'none'),
+ true);
+
+ $this->assertNoError($session->auth);
+ $this->assertEquals('wrobel@example.org', $session->user_mail);
+
+ try {
+ $session = Horde_Kolab_Session::singleton('test',
+ array('password' => 'test'),
+ true);
+ } catch (Horde_Kolab_Session_Exception $e) {
+ $this->assertError($e, 'You are no member of a group that may login on this server.');
+ }
+ // FIXME: Ensure that the session gets overwritten
+ //$this->assertTrue(empty($session->user_mail));
+ }
+
+ /**
+ * Test group based login deny implemention.
+ *
+ * @return NULL
+ */
+ public function testLoginDeny()
+ {
+ global $conf;
+ $conf['kolab']['server']['deny_group'] = 'group2@example.org';
+ unset($conf['kolab']['server']['allow_group']);
+
+ $this->markTestSkipped();
+ $server = &$this->prepareEmptyKolabServer();
+ $result = $server->add($this->provideBasicUserOne());
+ $this->assertNoError($result);
+ $result = $server->add($this->provideBasicUserTwo());
+ $this->assertNoError($result);
+ $groups = $this->validGroups();
+ foreach ($groups as $group) {
+ $result = $server->add($group[0]);
+ $this->assertNoError($result);
+ }
+
+ $session = Horde_Kolab_Session::singleton('test',
+ array('password' => 'test'),
+ true);
+
+ $this->assertNoError($session->auth);
+ $this->assertEquals('test@example.org', $session->user_mail);
+
+ try {
+ $session = Horde_Kolab_Session::singleton('wrobel',
+ array('password' => 'none'),
+ true);
+ } catch (Horde_Kolab_Session_Exception $e) {
+ $this->assertError($e, 'You are member of a group that may not login on this server.');
+ }
+ // FIXME: Ensure that the session gets overwritten
+ //$this->assertTrue(empty($session->user_mail));
+ }
+
+}
+++ /dev/null
-<?php
-/**
- * Test the Kolab session handler.
- *
- * PHP version 5
- *
- * @category Kolab
- * @package Kolab_Session
- * @author Gunnar Wrobel <wrobel@pardus.de>
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Kolab_Session
- */
-
-/**
- * Prepare the test setup.
- */
-require_once dirname(__FILE__) . '/Autoload.php';
-
-/**
- * Test the Kolab session handler.
- *
- * Copyright 2008-2009 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @category Kolab
- * @package Kolab_Session
- * @author Gunnar Wrobel <wrobel@pardus.de>
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Kolab_Session
- */
-class Horde_Kolab_Session_SessionTest extends Horde_Kolab_Session_SessionTestCase
-{
- /**
- * Setup function.
- *
- * @return NULL.
- */
- protected function setUp()
- {
- $this->markTestIncomplete('Needs to be fixed');
- }
-
- /**
- * Test class construction.
- *
- * @return NULL
- */
- public function testConstructEmpty()
- {
- global $conf;
- $conf['kolab']['imap']['allow_special_users'] = true;
-
- $session = Horde_Kolab_Session::singleton();
-
- $this->assertEquals('anonymous', $session->user_mail);
-
- $params = $session->getImapParams();
- $this->assertNoError($params);
- $this->assertEquals('localhost', $params['hostspec']);
- $this->assertEquals(143, $params['port']);
- }
-
- /**
- * Test old style class construction.
- *
- * @return NULL
- */
- public function testConstructSimple()
- {
- global $conf;
- $conf['kolab']['imap']['server'] = 'example.com';
- $conf['kolab']['imap']['port'] = 200;
- $conf['kolab']['freebusy']['server'] = 'fb.example.com';
-
- $session = new Horde_Kolab_Session();
- $params = $session->getImapParams();
- if (is_a($params, 'PEAR_Error')) {
- $this->assertEquals('', $params->getMessage());
- }
- $this->assertEquals('example.com', $params['hostspec']);
- $this->assertEquals(200, $params['port']);
- }
-
- /**
- * Test IMAP server retrieval.
- *
- * @return NULL
- */
- public function testGetSession()
- {
- $this->markTestSkipped();
- $server = &$this->prepareEmptyKolabServer();
- $result = $server->add($this->provideBasicUserTwo());
- $this->assertNoError($result);
- $this->assertEquals(1, count($GLOBALS['KOLAB_SERVER_TEST_DATA']));
-
- $session = Horde_Kolab_Session::singleton('test',
- array('password' => 'test'));
-
- $this->assertNoError($session->auth);
- $this->assertEquals('test@example.org', $session->user_mail);
-
- $params = $session->getImapParams();
- $this->assertNoError($params);
- $this->assertEquals('home.example.org', $params['hostspec']);
- $this->assertEquals(143, $params['port']);
- $this->assertEquals('test@example.org', $session->user_mail);
-
- $session->shutdown();
-
- $hs = Horde_SessionObjects::singleton();
-
- $recovered_session = &$hs->query('kolab_session');
- $params = $recovered_session->getImapParams();
- $this->assertNoError($params);
- $this->assertEquals('home.example.org', $params['hostspec']);
- $this->assertEquals(143, $params['port']);
- $this->assertEquals('test@example.org', $session->user_mail);
-
- $this->assertEquals('https://fb.example.org/freebusy', $session->freebusy_server);
- }
-
- /**
- * Test retrieving the FreeBusy server for the unauthenticated state.
- *
- * @return NULL
- */
- public function testGetFreeBusySession()
- {
- $this->markTestSkipped();
- $server = $this->prepareEmptyKolabServer();
- $result = $server->add($this->provideBasicUserTwo());
- $this->assertNoError($result);
- $session = Horde_Kolab_Session::singleton();
- $this->assertEquals('', $session->freebusy_server);
- }
-
- /**
- * Test group based login allow implemention.
- *
- * @return NULL
- */
- public function testLoginAllow()
- {
- global $conf;
- $conf['kolab']['server']['allow_group'] = 'group2@example.org';
- $conf['kolab']['server']['deny_group'] = null;
-
- $this->markTestSkipped();
- $server = &$this->prepareEmptyKolabServer();
- $result = $server->add($this->provideBasicUserOne());
- $this->assertNoError($result);
- $result = $server->add($this->provideBasicUserTwo());
- $this->assertNoError($result);
- $groups = $this->validGroups();
- foreach ($groups as $group) {
- $result = $server->add($group[0]);
- $this->assertNoError($result);
- }
-
- $session = Horde_Kolab_Session::singleton('wrobel',
- array('password' => 'none'),
- true);
-
- $this->assertNoError($session->auth);
- $this->assertEquals('wrobel@example.org', $session->user_mail);
-
- try {
- $session = Horde_Kolab_Session::singleton('test',
- array('password' => 'test'),
- true);
- } catch (Horde_Kolab_Session_Exception $e) {
- $this->assertError($e, 'You are no member of a group that may login on this server.');
- }
- // FIXME: Ensure that the session gets overwritten
- //$this->assertTrue(empty($session->user_mail));
- }
-
- /**
- * Test group based login deny implemention.
- *
- * @return NULL
- */
- public function testLoginDeny()
- {
- global $conf;
- $conf['kolab']['server']['deny_group'] = 'group2@example.org';
- unset($conf['kolab']['server']['allow_group']);
-
- $this->markTestSkipped();
- $server = &$this->prepareEmptyKolabServer();
- $result = $server->add($this->provideBasicUserOne());
- $this->assertNoError($result);
- $result = $server->add($this->provideBasicUserTwo());
- $this->assertNoError($result);
- $groups = $this->validGroups();
- foreach ($groups as $group) {
- $result = $server->add($group[0]);
- $this->assertNoError($result);
- }
-
- $session = Horde_Kolab_Session::singleton('test',
- array('password' => 'test'),
- true);
-
- $this->assertNoError($session->auth);
- $this->assertEquals('test@example.org', $session->user_mail);
-
- try {
- $session = Horde_Kolab_Session::singleton('wrobel',
- array('password' => 'none'),
- true);
- } catch (Horde_Kolab_Session_Exception $e) {
- $this->assertError($e, 'You are member of a group that may not login on this server.');
- }
- // FIXME: Ensure that the session gets overwritten
- //$this->assertTrue(empty($session->user_mail));
- }
-
-}