public function __construct(
Horde_Injector $injector
) {
- $this->_injector = $injector;
- $this->_setup();
- }
-
- /**
- * Setup the machinery to create Horde_Kolab_Session objects.
- *
- * @return NULL
- */
- private function _setup()
- {
- $this->_setupConfiguration();
- $this->_setupAuth();
- $this->_setupStorage();
- }
-
- /**
- * Provide configuration settings for Horde_Kolab_Session.
- *
- * @return NULL
- */
- private function _setupConfiguration()
- {
- $configuration = array();
- if (!empty($GLOBALS['conf']['kolab']['session'])) {
- $configuration = $GLOBALS['conf']['kolab']['session'];
- }
- $this->_injector->setInstance(
- 'Horde_Kolab_Session_Configuration', $configuration
- );
- }
-
- /**
- * Setup the machinery to create a Horde_Kolab_Session_Auth handler.
- *
- * @return NULL
- */
- private function _setupAuth()
- {
+ $this->_injector = $injector;
$this->_injector->bindImplementation(
- 'Horde_Kolab_Session_Auth_Interface',
- 'Horde_Kolab_Session_Auth_Horde'
- );
- }
-
- /**
- * Setup the machinery to create a Horde_Kolab_Session_Storage handlers.
- *
- * @return NULL
- */
- private function _setupStorage()
- {
- $this->_injector->bindFactory(
- 'Horde_Kolab_Session_Storage_Interface',
- 'Horde_Core_Factory_KolabSession',
- 'getStorage'
- );
- }
-
- /**
- * Return the session storage driver.
- *
- * @return Horde_Kolab_Session_Storage The driver for storing sessions.
- */
- public function getStorage()
- {
- return new Horde_Kolab_Session_Storage_Session(
- $GLOBALS['session']
+ 'Horde_Kolab_Session_Storage',
+ 'Horde_Kolab_Session_Storage_Session'
);
}
* @return Horde_Kolab_Session_Valid_Interface The driver for validating
* sessions.
*/
- public function getSessionValidator(
+ public function createSessionValidator(
Horde_Kolab_Session $session,
$auth
) {
- $configuration = $this->_injector->getInstance('Horde_Kolab_Session_Configuration');
-
$validator = new Horde_Kolab_Session_Valid_Base(
$session, $auth
);
- if (isset($configuration['debug']) || isset($configuration['log'])) {
+ if (isset($GLOBALS['conf']['kolab']['session']['debug'])) {
$validator = new Horde_Kolab_Session_Valid_Decorator_Logged(
$validator, $this->_injector->getInstance('Horde_Log_Logger')
);
}
/**
- * Validate the given session.
- *
- * @param Horde_Kolab_Session $session The session to validate.
- *
- * @return boolean True if the given session is valid.
- */
- public function validate(
- Horde_Kolab_Session $session
- ) {
- return $this->getSessionValidator(
- $session,
- $this->_injector->getInstance('Horde_Registry')->getAuth()
- )->isValid();
- }
-
- /**
* Returns a new session handler.
*
* @return Horde_Kolab_Session The concrete Kolab session reference.
{
$session = new Horde_Kolab_Session_Base(
$this->_injector->getInstance('Horde_Kolab_Server_Composite'),
- $this->_injector->getInstance('Horde_Kolab_Session_Configuration')
+ $GLOBALS['conf']['kolab']['session']
);
- //@todo: Fix validation
- /** If we created a new session handler it needs to be stored once */
+ if (isset($GLOBALS['conf']['kolab']['session']['debug'])) {
+ $session = new Horde_Kolab_Session_Decorator_Logged(
+ $session, $this->_injector->getInstance('Horde_Log_Logger')
+ );
+ }
+
$session = new Horde_Kolab_Session_Decorator_Stored(
$session,
- $this->_injector->getInstance('Horde_Kolab_Session_Storage_Interface')
+ $this->_injector->getInstance('Horde_Kolab_Session_Storage')
);
+
return $session;
}
*/
public function create()
{
- $storage = $this->_injector->getInstance('Horde_Kolab_Session_Storage_Interface');
- $session = $storage->load();
-
- if (empty($session) || !$this->validate($session)) {
- $session = $this->createSession();
- }
-
- $configuration = $this->_injector->getInstance('Horde_Kolab_Session_Configuration');
+ $session = $this->createSession();
+ $this->createSessionValidator(
+ $session,
+ $this->_injector->getInstance('Horde_Registry')->getAuth()
+ )->validate();
- if (isset($configuration['debug']) || isset($configuration['log'])) {
- $session = new Horde_Kolab_Session_Decorator_Logged(
- $session, $this->_injector->getInstance('Horde_Log_Logger')
- );
- }
-
- if (isset($configuration['anonymous']['user'])
- && isset($configuration['anonymous']['pass'])
+ if (isset($GLOBALS['conf']['kolab']['session']['anonymous']['user'])
+ && isset($GLOBALS['conf']['kolab']['session']['anonymous']['pass'])
) {
$session = new Horde_Kolab_Session_Decorator_Anonymous(
$session,
- $configuration['anonymous']['user'],
- $configuration['anonymous']['pass']
+ $GLOBALS['conf']['kolab']['session']['anonymous']['user'],
+ $GLOBALS['conf']['kolab']['session']['anonymous']['pass']
);
}
* @return string The freebusy host for the current user.
*/
public function getFreebusyServer();
+
+ /**
+ * Import the session data from an array.
+ *
+ * @param array The session data.
+ *
+ * @return NULL
+ */
+ public function import(array $session_data);
+
+ /**
+ * Export the session data as array.
+ *
+ * @return array The session data.
+ */
+ public function export();
+
+ /**
+ * Clear the session data.
+ *
+ * @return NULL
+ */
+ public function purge();
}
private $_params;
/**
+ * The session data.
+ *
+ * @var array
+ */
+ private $_data;
+
+ /**
* User ID.
*
* @var string
private $_server;
/**
- * Mark the session as connected.
- *
- * @var true
- */
- private $_connected = false;
-
- /**
* Constructor.
*
* @param Horde_Kolab_Server $server The connection to the Kolab user
*/
public function connect($user_id = null, array $credentials = null)
{
- $this->_user_id = $user_id;
+ $this->_data['user']['id'] = $user_id;
if (isset($credentials['password'])) {
$password = $credentials['password'];
} else {
}
try {
- $this->_server->connect($this->_user_id, $password);
+ $this->_server->connect($this->_data['user']['id'], $password);
$user_object = $this->_server->objects->fetch();
} catch (Horde_Kolab_Server_Exception_Bindfailed $e) {
throw new Horde_Kolab_Session_Exception_Badlogin('Invalid credentials!', 0, $e);
$this->_initName($user_object);
$this->_initImapServer($user_object);
$this->_initFreebusyServer($user_object);
-
- $this->_connected = true;
}
/**
Horde_Kolab_Server_Object_Hash $user
) {
try {
- $this->_user_mail = $user->getSingle('mail');;
+ $this->_data['user']['mail'] = $user->getSingle('mail');;
} catch (Horde_Kolab_Server_Exception_Novalue $e) {
- $this->_user_mail = $this->_user_id;
+ $this->_data['user']['mail'] = $this->_data['user']['id'];
}
}
Horde_Kolab_Server_Object_Hash $user
) {
try {
- $this->_user_uid = $user->getSingle('uid');
+ $this->_data['user']['uid'] = $user->getSingle('uid');
} catch (Horde_Kolab_Server_Exception_Novalue $e) {
- $this->_user_uid = $this->_user_id;
+ $this->_data['user']['uid'] = $this->_data['user']['id'];
}
}
Horde_Kolab_Server_Object_Hash $user
) {
try {
- $this->_user_name = $user->getSingle('Firstnamelastname');
+ $this->_data['user']['name'] = $user->getSingle('Firstnamelastname');
} catch (Horde_Kolab_Server_Exception_Novalue $e) {
- $this->_user_name = $this->_user_id;
+ $this->_data['user']['name'] = $this->_data['user']['id'];
}
}
Horde_Kolab_Server_Object_Hash $user
) {
try {
- $this->_imap_server = $user->getSingle('kolabHomeServer');
+ $this->_data['imap']['server'] = $user->getSingle('kolabHomeServer');
} catch (Horde_Kolab_Server_Exception_Novalue $e) {
if (isset($this->_params['imap']['server'])) {
- $this->_imap_server = $this->_params['imap']['server'];
+ $this->_data['imap']['server'] = $this->_params['imap']['server'];
} else {
- $this->_imap_server = 'localhost';
+ $this->_data['imap']['server'] = 'localhost';
}
}
}
$fb_server = $user->getSingle('kolabFreebusyHost');
} catch (Horde_Kolab_Server_Exception_Novalue $e) {
if (isset($this->_params['freebusy']['url'])) {
- $this->_freebusy_server = $this->_params['freebusy']['url'];
+ $this->_data['fb']['server'] = $this->_params['freebusy']['url'];
return;
} else {
- $fb_server = $this->_imap_server;
+ $fb_server = $this->_data['imap']['server'];
}
}
$fb_format = 'http://%s/freebusy';
}
- $this->_freebusy_server = sprintf($fb_format, $fb_server);
- }
-
- /**
- * Returns the properties that need to be serialized.
- *
- * @return array List of serializable properties.
- */
- public function __sleep()
- {
- $properties = get_object_vars($this);
- unset($properties['_server']);
- $properties = array_keys($properties);
- return $properties;
+ $this->_data['fb']['server'] = sprintf($fb_format, $fb_server);
}
/**
*/
public function getId()
{
- return $this->_user_id;
+ if (isset($this->_data['user']['id'])) {
+ return $this->_data['user']['id'];
+ }
}
/**
*/
public function getMail()
{
- return $this->_user_mail;
+ if (isset($this->_data['user']['mail'])) {
+ return $this->_data['user']['mail'];
+ }
}
/**
*/
public function getUid()
{
- return $this->_user_uid;
+ if (isset($this->_data['user']['uid'])) {
+ return $this->_data['user']['uid'];
+ }
}
/**
*/
public function getName()
{
- return $this->_user_name;
+ if (isset($this->_data['user']['name'])) {
+ return $this->_data['user']['name'];
+ }
}
/**
*/
public function getImapServer()
{
- return $this->_imap_server;
+ if (isset($this->_data['imap']['server'])) {
+ return $this->_data['imap']['server'];
+ }
}
/**
*/
public function getFreebusyServer()
{
- return $this->_freebusy_server;
+ if (isset($this->_data['fb']['server'])) {
+ return $this->_data['fb']['server'];
+ }
+ }
+
+ /**
+ * Import the session data from an array.
+ *
+ * @param array The session data.
+ *
+ * @return NULL
+ */
+ public function import(array $session_data)
+ {
+ $this->_data = $session_data;
+ }
+
+ /**
+ * Export the session data as array.
+ *
+ * @return array The session data.
+ */
+ public function export()
+ {
+ return $this->_data;
+ }
+
+ /**
+ * Clear the session data.
+ *
+ * @return NULL
+ */
+ public function purge()
+ {
+ $this->_data = array();
}
}
public function __construct(
Horde_Kolab_Session $session
) {
- $this->_session = $session;
+ $this->_session = $session;
}
/**
{
return $this->_session->getFreebusyServer();
}
+
+ /**
+ * Import the session data from an array.
+ *
+ * @param array The session data.
+ *
+ * @return NULL
+ */
+ public function import(array $session_data)
+ {
+ $this->_session->import($session_data);
+ }
+
+ /**
+ * Export the session data as array.
+ *
+ * @return array The session data.
+ */
+ public function export()
+ {
+ return $this->_session->export();
+ }
+
+ /**
+ * Clear the session data.
+ *
+ * @return NULL
+ */
+ public function purge()
+ {
+ $this->_session->purge();
+ }
}
$this->_logger->err(
sprintf(
"Failed to connect Kolab session for \"%s\". Error was: %s",
- $this->_session->getId(), $e->getMessage()
+ $this->_session->getMail(), $e->getMessage()
)
);
throw $e;
}
}
+
+ /**
+ * Export the session data as array.
+ *
+ * @return array The session data.
+ */
+ public function export()
+ {
+ $session_data = $this->_session->export();
+ $this->_logger->info(
+ sprintf(
+ "Exported session data for \"%s\" (%s). [%s]",
+ $this->_session->getMail(), serialize($session_data), new Horde_Support_Backtrace()
+ )
+ );
+ return $session_data;
+ }
+
+ /**
+ * Import the session data from an array.
+ *
+ * @param array The session data.
+ *
+ * @return NULL
+ */
+ public function import(array $session_data)
+ {
+ $this->_session->import($session_data);
+ $this->_logger->info(
+ sprintf(
+ "Imported session data for \"%s\" (%s). [%s]",
+ $this->_session->getMail(), serialize($session_data), new Horde_Support_Backtrace()
+ )
+ );
+ }
+
+ /**
+ * Clear the session data.
+ *
+ * @return NULL
+ */
+ public function purge()
+ {
+ $this->_logger->warn(
+ sprintf(
+ "Purged session data for \"%s\". [%s]",
+ $this->_session->getMail(), new Horde_Support_Backtrace()
+ )
+ );
+ $this->_session->purge();
+ }
}
private $_storage;
/**
- * Has the storage been connected successfully?
+ * Has the session information changed?
*
* @var boolean
*/
- private $_connected = false;
+ private $_modified = false;
/**
* Constructor.
*/
public function __construct(
Horde_Kolab_Session $session,
- Horde_Kolab_Session_Storage_Interface $storage
+ Horde_Kolab_Session_Storage $storage
) {
parent::__construct($session);
$this->_storage = $storage;
- }
-
- /**
- * Destructor.
- *
- * Save the session in the storage on shutdown.
- */
- public function __destruct()
- {
- $this->_storage->save($this->_session);
+ $this->_session->import($this->_storage->load());
+ register_shutdown_function(array($this, 'shutdown'));
}
/**
* this must contain a "password" entry.
*
* @return NULL
+ *
+ * @throws Horde_Kolab_Session_Exception If the connection failed.
*/
public function connect($user_id = null, array $credentials = null)
{
$this->_session->connect($user_id, $credentials);
- $this->_connected = true;
+ $this->_modified = $this->_session->export();
+ }
+
+ /**
+ * Import the session data from an array.
+ *
+ * @param array The session data.
+ *
+ * @return NULL
+ */
+ public function import(array $session_data)
+ {
+ throw new Horde_Kolab_Session_Exception('Data import of stored session data is handled via the session.');
+ }
+
+ /**
+ * Clear the session data.
+ *
+ * @return NULL
+ */
+ public function purge()
+ {
+ $this->_session->purge();
+ $this->_modified = array();
+ }
+
+ /**
+ * Write any modified data to the session.
+ *
+ * @return NULL
+ */
+ public function shutdown()
+ {
+ if ($this->_modified !== false) {
+ $this->_storage->save($this->_modified);
+ }
}
}
--- /dev/null
+<?php
+/**
+ * Defines storage containers for the Kolab session information.
+ *
+ * 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
+ */
+
+/**
+ * Defines storage containers for the Kolab session information.
+ *
+ * Copyright 2009-2010 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
+ */
+interface Horde_Kolab_Session_Storage
+{
+ /**
+ * Load the session information.
+ *
+ * @return array The session data or an empty array if no information was
+ * found.
+ */
+ public function load();
+
+ /**
+ * Save the session information.
+ *
+ * @param array $session_data The session data that should be stored.
+ *
+ * @return NULL
+ */
+ public function save(array $session_data);
+}
+++ /dev/null
-<?php
-/**
- * Defines storage containers for the Kolab session information.
- *
- * 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
- */
-
-/**
- * Defines storage containers for the Kolab session information.
- *
- * Copyright 2009-2010 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
- */
-interface Horde_Kolab_Session_Storage_Interface
-{
- /**
- * Load the session information.
- *
- * @return Horde_Kolab_Session|boolean The session information or false if
- * it could not be loaded.
- */
- public function load();
-
- /**
- * Lave the session information.
- *
- * @param Horde_Kolab_Session $session The session information.
- *
- * @return NULL
- */
- public function save(Horde_Kolab_Session $session);
-}
* @link http://pear.horde.org/index.php?package=Kolab_Session
*/
class Horde_Kolab_Session_Storage_Mock
-implements Horde_Kolab_Session_Storage_Interface
+implements Horde_Kolab_Session_Storage
{
/**
* The session information.
/**
* Load the session information.
*
- * @return Horde_Kolab_Session|boolean The session information or false if
- * it could not be loaded.
+ * @return array The session data or an empty array if no information was
+ * found.
*/
public function load()
{
/**
* Save the session information.
*
- * @param Horde_Kolab_Session $session The session information.
+ * @param array $session_data The session data that should be stored.
*
* @return NULL
*/
- public function save(Horde_Kolab_Session $session)
+ public function save(array $session_data)
{
- $this->session = $session;
+ $this->session = $session_data;
}
}
* @link http://pear.horde.org/index.php?package=Kolab_Session
*/
class Horde_Kolab_Session_Storage_Session
-implements Horde_Kolab_Session_Storage_Interface
+implements Horde_Kolab_Session_Storage
{
/**
- * The handler for session objects.
- *
- * @var array
- */
- private $_session;
-
- /**
- * Constructor
- *
- * @param array $session The session handler.
- */
- public function __construct($session)
- {
- $this->_session = $session;
- }
-
- /**
* Load the session information.
*
- * @return Horde_Kolab_Session|boolean The session information or false if
- * it could not be loaded.
+ * @return array The session data or an empty array if no information was
+ * found.
*/
public function load()
{
- return $this->_session->get('horde', 'kolab_session');
+ if (isset($_SESSION['kolab_session'])) {
+ return $_SESSION['kolab_session'];
+ } else {
+ return array();
+ }
}
/**
* Save the session information.
*
- * @param Horde_Kolab_Session $session The session information.
+ * @param array $session_data The session data that should be stored.
*
* @return NULL
*/
- public function save(Horde_Kolab_Session $session)
+ public function save(array $session_data)
{
- $this->_session->set('horde', 'kolab_session', $session);
+ $_SESSION['kolab_session'] = $session_data;
}
}
--- /dev/null
+<?php
+/**
+ * Interface for session validators.
+ *
+ * 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
+ */
+
+/**
+ * Interface for session validators.
+ *
+ * Copyright 2009-2010 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
+ */
+interface Horde_Kolab_Session_Valid
+{
+ /**
+ * Reset the current session information in case it does not match the
+ * authentication information anymore.
+ *
+ * @param string $user The user the session information is being requested
+ * for. This is usually empty, indicating the current
+ * user.
+ *
+ * @return boolean True if the session is still valid.
+ */
+ public function validate($user = null);
+
+ /**
+ * Return the session this validator checks.
+ *
+ * @return Horde_Kolab_Session The session checked by this
+ * validator.
+ */
+ public function getSession();
+
+ /**
+ * Return the auth driver of this validator.
+ *
+ * @return mixed The user ID or false if no user is logged in.
+ */
+ public function getAuth();
+}
\ No newline at end of file
* @link http://pear.horde.org/index.php?package=Kolab_Session
*/
class Horde_Kolab_Session_Valid_Base
-implements Horde_Kolab_Session_Valid_Interface
+implements Horde_Kolab_Session_Valid
{
/**
* The session handler this instance provides with anonymous access.
}
/**
- * Does the current session still match the authentication information?
+ * Reset the current session information in case it does not match the
+ * authentication information anymore.
*
* @param string $user The user the session information is being requested
* for. This is usually empty, indicating the current
*
* @return boolean True if the session is still valid.
*/
- public function isValid($user = null)
+ public function validate($user = null)
{
$mail = $this->_session->getMail();
if ($this->_auth != $mail) {
+ $this->_session->purge();
return false;
}
if (empty($user)) {
return true;
}
if ($user != $mail && $user != $this->_session->getUid()) {
+ $this->_session->purge();
return false;
}
return true;
* @link http://pear.horde.org/index.php?package=Kolab_Session
*/
class Horde_Kolab_Session_Valid_Decorator_Logged
-implements Horde_Kolab_Session_Valid_Interface
+implements Horde_Kolab_Session_Valid
{
/**
* The valid handler.
* @param mixed $logger The logger instance.
*/
public function __construct(
- Horde_Kolab_Session_Valid_Interface $valid,
+ Horde_Kolab_Session_Valid $valid,
$logger
) {
$this->_valid = $valid;
}
/**
- * Does the current session still match the authentication information?
+ * Reset the current session information in case it does not match the
+ * authentication information anymore.
*
* @param string $user The user the session information is being requested
* for. This is usually empty, indicating the current
*
* @return boolean True if the session is still valid.
*/
- public function isValid($user = null)
+ public function validate($user = null)
{
- $result = $this->_valid->isValid($user);
+ $this->_logger->info(
+ sprintf(
+ "Validating Kolab session for current user \"%s\", requested"
+ . " user \"%s\", and stored user \"%s\".",
+ $this->_valid->getAuth(),
+ $user,
+ $this->_valid->getSession()->getMail()
+ )
+ );
+ $result = $this->_valid->validate($user);
if ($result === false) {
$this->_logger->info(
sprintf(
- "Invalid Kolab session for current user \"%s\", requested"
- . " user \"%s\" and stored user \"%s\".",
+ "Invalid Kolab session for current user \"%s\" and requested"
+ . " user \"%s\".",
$this->_valid->getAuth(),
- $user,
- $this->_valid->getSession()->getMail()
+ $user
)
);
}
+++ /dev/null
-<?php
-/**
- * Interface for session validators.
- *
- * 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
- */
-
-/**
- * Interface for session validators.
- *
- * Copyright 2009-2010 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
- */
-interface Horde_Kolab_Session_Valid_Interface
-{
- /**
- * Does the current session still match the authentication information?
- *
- * @param string $user The user the session information is being requested
- * for. This is usually empty, indicating the current
- * user.
- *
- * @return boolean True if the session is still valid.
- */
- public function isValid($user = null);
-
- /**
- * Return the session this validator checks.
- *
- * @return Horde_Kolab_Session The session checked by this
- * validator.
- */
- public function getSession();
-
- /**
- * Return the auth driver of this validator.
- *
- * @return mixed The user ID or false if no user is logged in.
- */
- public function getAuth();
-}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
-<package packagerversion="1.9.0" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd">
+<package packagerversion="1.9.1" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd">
<name>Kolab_Session</name>
<channel>pear.horde.org</channel>
<summary>A package managing an active Kolab session.</summary>
<email>jan@horde.org</email>
<active>yes</active>
</lead>
- <date>2010-10-26</date>
- <time>05:16:11</time>
+ <date>2010-12-01</date>
+ <time>14:54:05</time>
<version>
<release>0.1.0</release>
<api>0.1.0</api>
<file name="Badlogin.php" role="php" />
</dir> <!-- /lib/Horde/Kolab/Session/Exception -->
<dir name="Storage">
- <file name="Interface.php" role="php" />
<file name="Mock.php" role="php" />
<file name="Session.php" role="php" />
</dir> <!-- /lib/Horde/Kolab/Session/Storage -->
<file name="Logged.php" role="php" />
</dir> <!-- /lib/Horde/Kolab/Session/Valid/Decorator -->
<file name="Base.php" role="php" />
- <file name="Interface.php" role="php" />
</dir> <!-- /lib/Horde/Kolab/Session/Valid -->
<file name="Base.php" role="php" />
<file name="Exception.php" role="php" />
+ <file name="Storage.php" role="php" />
+ <file name="Valid.php" role="php" />
</dir> <!-- /lib/Horde/Kolab/Session -->
<file name="Session.php" role="php" />
</dir> <!-- /lib/Horde/Kolab -->
<dir name="Horde">
<dir name="Kolab">
<dir name="Session">
- <dir name="Class">
+ <dir name="Integration">
+ <file name="AnonymousTest.php" role="test" />
+ <file name="SessionTest.php" role="test" />
+ <file name="ValidTest.php" role="test" />
+ </dir> <!-- /test/Horde/Kolab/Session/Integration -->
+ <dir name="Unit">
<dir name="Decorator">
<file name="AnonymousTest.php" role="test" />
<file name="BaseTest.php" role="test" />
<file name="LoggedTest.php" role="test" />
<file name="StoredTest.php" role="test" />
- </dir> <!-- /test/Horde/Kolab/Session/Class/Decorator -->
+ </dir> <!-- /test/Horde/Kolab/Session/Unit/Decorator -->
<dir name="Storage">
<file name="MockTest.php" role="test" />
<file name="SessionTest.php" role="test" />
- </dir> <!-- /test/Horde/Kolab/Session/Class/Storage -->
+ </dir> <!-- /test/Horde/Kolab/Session/Unit/Storage -->
<dir name="Valid">
<dir name="Decorator">
<file name="LoggedTest.php" role="test" />
- </dir> <!-- /test/Horde/Kolab/Session/Class/Valid/Decorator -->
+ </dir> <!-- /test/Horde/Kolab/Session/Unit/Valid/Decorator -->
<file name="BaseTest.php" role="test" />
- </dir> <!-- /test/Horde/Kolab/Session/Class/Valid -->
+ </dir> <!-- /test/Horde/Kolab/Session/Unit/Valid -->
<file name="BaseTest.php" role="test" />
- </dir> <!-- /test/Horde/Kolab/Session/Class -->
- <dir name="Integration">
- <file name="AnonymousTest.php" role="test" />
- <file name="ValidTest.php" role="test" />
- </dir> <!-- /test/Horde/Kolab/Session/Integration -->
+ </dir> <!-- /test/Horde/Kolab/Session/Unit -->
<file name="AllTests.php" role="test" />
<file name="Autoload.php" role="test" />
<file name="phpunit.xml" role="test" />
- <file name="SessionTestCase.php" role="test" />
+ <file name="TestCase.php" role="test" />
</dir> <!-- /test/Horde/Kolab/Session -->
</dir> <!-- /test/Horde/Kolab -->
</dir> <!-- /test/Horde -->
<name>Kolab_Server</name>
<channel>pear.horde.org</channel>
</package>
- <package>
- <name>Kolab_Storage</name>
- <channel>pear.horde.org</channel>
- </package>
</required>
<optional>
<package>
<install as="Horde/Kolab/Session.php" name="lib/Horde/Kolab/Session.php" />
<install as="Horde/Kolab/Session/Base.php" name="lib/Horde/Kolab/Session/Base.php" />
<install as="Horde/Kolab/Session/Exception.php" name="lib/Horde/Kolab/Session/Exception.php" />
+ <install as="Horde/Kolab/Session/Storage.php" name="lib/Horde/Kolab/Session/Storage.php" />
+ <install as="Horde/Kolab/Session/Valid.php" name="lib/Horde/Kolab/Session/Valid.php" />
<install as="Horde/Kolab/Session/Decorator/Anonymous.php" name="lib/Horde/Kolab/Session/Decorator/Anonymous.php" />
<install as="Horde/Kolab/Session/Decorator/Base.php" name="lib/Horde/Kolab/Session/Decorator/Base.php" />
<install as="Horde/Kolab/Session/Decorator/Logged.php" name="lib/Horde/Kolab/Session/Decorator/Logged.php" />
<install as="Horde/Kolab/Session/Decorator/Stored.php" name="lib/Horde/Kolab/Session/Decorator/Stored.php" />
<install as="Horde/Kolab/Session/Exception/Badlogin.php" name="lib/Horde/Kolab/Session/Exception/Badlogin.php" />
- <install as="Horde/Kolab/Session/Storage/Interface.php" name="lib/Horde/Kolab/Session/Storage/Interface.php" />
<install as="Horde/Kolab/Session/Storage/Mock.php" name="lib/Horde/Kolab/Session/Storage/Mock.php" />
<install as="Horde/Kolab/Session/Storage/Session.php" name="lib/Horde/Kolab/Session/Storage/Session.php" />
<install as="Horde/Kolab/Session/Valid/Base.php" name="lib/Horde/Kolab/Session/Valid/Base.php" />
- <install as="Horde/Kolab/Session/Valid/Interface.php" name="lib/Horde/Kolab/Session/Valid/Interface.php" />
<install as="Horde/Kolab/Session/Valid/Decorator/Logged.php" name="lib/Horde/Kolab/Session/Valid/Decorator/Logged.php" />
<install as="Horde/Kolab/Session/AllTests.php" name="test/Horde/Kolab/Session/AllTests.php" />
<install as="Horde/Kolab/Session/Autoload.php" name="test/Horde/Kolab/Session/Autoload.php" />
<install as="Horde/Kolab/Session/phpunit.xml" name="test/Horde/Kolab/Session/phpunit.xml" />
- <install as="Horde/Kolab/Session/SessionTestCase.php" name="test/Horde/Kolab/Session/SessionTestCase.php" />
- <install as="Horde/Kolab/Session/Class/BaseTest.php" name="test/Horde/Kolab/Session/Class/BaseTest.php" />
- <install as="Horde/Kolab/Session/Class/Decorator/AnonymousTest.php" name="test/Horde/Kolab/Session/Class/Decorator/AnonymousTest.php" />
- <install as="Horde/Kolab/Session/Class/Decorator/BaseTest.php" name="test/Horde/Kolab/Session/Class/Decorator/BaseTest.php" />
- <install as="Horde/Kolab/Session/Class/Decorator/LoggedTest.php" name="test/Horde/Kolab/Session/Class/Decorator/LoggedTest.php" />
- <install as="Horde/Kolab/Session/Class/Decorator/StoredTest.php" name="test/Horde/Kolab/Session/Class/Decorator/StoredTest.php" />
- <install as="Horde/Kolab/Session/Class/Storage/MockTest.php" name="test/Horde/Kolab/Session/Class/Storage/MockTest.php" />
- <install as="Horde/Kolab/Session/Class/Storage/SessionTest.php" name="test/Horde/Kolab/Session/Class/Storage/SessionTest.php" />
- <install as="Horde/Kolab/Session/Class/Valid/BaseTest.php" name="test/Horde/Kolab/Session/Class/Valid/BaseTest.php" />
- <install as="Horde/Kolab/Session/Class/Valid/Decorator/LoggedTest.php" name="test/Horde/Kolab/Session/Class/Valid/Decorator/LoggedTest.php" />
+ <install as="Horde/Kolab/Session/TestCase.php" name="test/Horde/Kolab/Session/TestCase.php" />
<install as="Horde/Kolab/Session/Integration/AnonymousTest.php" name="test/Horde/Kolab/Session/Integration/AnonymousTest.php" />
+ <install as="Horde/Kolab/Session/Integration/SessionTest.php" name="test/Horde/Kolab/Session/Integration/SessionTest.php" />
<install as="Horde/Kolab/Session/Integration/ValidTest.php" name="test/Horde/Kolab/Session/Integration/ValidTest.php" />
+ <install as="Horde/Kolab/Session/Unit/BaseTest.php" name="test/Horde/Kolab/Session/Unit/BaseTest.php" />
+ <install as="Horde/Kolab/Session/Unit/Decorator/AnonymousTest.php" name="test/Horde/Kolab/Session/Unit/Decorator/AnonymousTest.php" />
+ <install as="Horde/Kolab/Session/Unit/Decorator/BaseTest.php" name="test/Horde/Kolab/Session/Unit/Decorator/BaseTest.php" />
+ <install as="Horde/Kolab/Session/Unit/Decorator/LoggedTest.php" name="test/Horde/Kolab/Session/Unit/Decorator/LoggedTest.php" />
+ <install as="Horde/Kolab/Session/Unit/Decorator/StoredTest.php" name="test/Horde/Kolab/Session/Unit/Decorator/StoredTest.php" />
+ <install as="Horde/Kolab/Session/Unit/Storage/MockTest.php" name="test/Horde/Kolab/Session/Unit/Storage/MockTest.php" />
+ <install as="Horde/Kolab/Session/Unit/Storage/SessionTest.php" name="test/Horde/Kolab/Session/Unit/Storage/SessionTest.php" />
+ <install as="Horde/Kolab/Session/Unit/Valid/BaseTest.php" name="test/Horde/Kolab/Session/Unit/Valid/BaseTest.php" />
+ <install as="Horde/Kolab/Session/Unit/Valid/Decorator/LoggedTest.php" name="test/Horde/Kolab/Session/Unit/Valid/Decorator/LoggedTest.php" />
</filelist>
</phprelease>
<changelog>
<release>alpha</release>
<api>alpha</api>
</stability>
- <date>2010-10-26</date>
+ <date>2010-12-01</date>
<license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
<notes>
* Split package from Kolab_Server
* @link http://pear.horde.org/index.php?package=Kolab_Session
*/
-if (!spl_autoload_functions()) {
- spl_autoload_register(
- create_function(
- '$class',
- '$filename = str_replace(array(\'::\', \'_\'), \'/\', $class);'
- . '$err_mask = E_ALL ^ E_WARNING;'
- . '$oldErrorReporting = error_reporting($err_mask);'
- . 'include "$filename.php";'
- . 'error_reporting($oldErrorReporting);'
- )
- );
-}
+require_once 'Horde/Test/Autoload.php';
/** Catch strict standards */
error_reporting(E_ALL | E_STRICT);
/** Load the basic test definition */
-require_once dirname(__FILE__) . '/SessionTestCase.php';
+require_once dirname(__FILE__) . '/TestCase.php';
+++ /dev/null
-<?php
-/**
- * Test the Kolab session handler base implementation.
- *
- * 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 base implementation.
- *
- * Copyright 2009-2010 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_Class_BaseTest extends Horde_Kolab_Session_SessionTestCase
-{
- public function setUp()
- {
- $this->user = $this->getMock(
- 'Horde_Kolab_Server_Object_Hash', array(), array(), '', false, false
- );
- }
-
- public function testMethodConstructHasParameterServercompositeServer()
- {
- $session = new Horde_Kolab_Session_Base(
- $this->_getComposite(), array()
- );
- }
-
- public function testMethodConstructHasParameterArrayParams()
- {
- $session = new Horde_Kolab_Session_Base(
- $this->_getComposite(), array('params' => 'params')
- );
- }
-
- public function testMethodConnectHasParameterStringUserid()
- {
- $this->user->expects($this->exactly(5))
- ->method('getSingle')
- ->will($this->returnValue('mail@example.org'));
- $composite = $this->_getMockedComposite();
- $composite->objects->expects($this->once())
- ->method('fetch')
- ->will($this->returnValue($this->user));
- $session = new Horde_Kolab_Session_Base(
- $composite, array()
- );
- $session->connect('userid', array('password' => ''));
- }
-
- public function testMethodConnectHasParameterArrayCredentials()
- {
- $this->user->expects($this->exactly(5))
- ->method('getSingle')
- ->will($this->returnValue('mail@example.org'));
- $composite = $this->_getMockedComposite();
- $composite->objects->expects($this->once())
- ->method('fetch')
- ->will($this->returnValue($this->user));
- $session = new Horde_Kolab_Session_Base(
- $composite, array()
- );
- $session->connect('', array('password' => ''));
- }
-
- public function testMethodConnectHasPostconditionThatTheUserMailAddressIsKnown()
- {
- $this->user->expects($this->exactly(5))
- ->method('getSingle')
- ->will($this->returnValue('mail@example.org'));
- $composite = $this->_getMockedComposite();
- $composite->objects->expects($this->once())
- ->method('fetch')
- ->will($this->returnValue($this->user));
- $session = new Horde_Kolab_Session_Base(
- $composite, array()
- );
- $session->connect(array('password' => ''));
- $this->assertEquals('mail@example.org', $session->getMail());
- }
-
- public function testMethodConnectHasPostconditionThatTheUserUidIsKnown()
- {
- $this->user->expects($this->exactly(5))
- ->method('getSingle')
- ->will($this->returnValue('uid'));
- $composite = $this->_getMockedComposite();
- $composite->objects->expects($this->once())
- ->method('fetch')
- ->will($this->returnValue($this->user));
- $session = new Horde_Kolab_Session_Base(
- $composite, array()
- );
- $session->connect(array('password' => ''));
- $this->assertEquals('uid', $session->getUid());
- }
-
- public function testMethodConnectHasPostconditionThatTheUserNameIsKnown()
- {
- $this->user->expects($this->exactly(5))
- ->method('getSingle')
- ->will($this->returnValue('name'));
- $composite = $this->_getMockedComposite();
- $composite->objects->expects($this->once())
- ->method('fetch')
- ->will($this->returnValue($this->user));
- $session = new Horde_Kolab_Session_Base(
- $composite, array()
- );
- $session->connect(array('password' => ''));
- $this->assertEquals('name', $session->getName());
- }
-
- public function testMethodConnectHasPostconditionThatTheUsersImapHostIsKnown()
- {
- $this->user->expects($this->exactly(5))
- ->method('getSingle')
- ->will($this->returnValue('home.example.org'));
- $composite = $this->_getMockedComposite();
- $composite->objects->expects($this->once())
- ->method('fetch')
- ->will($this->returnValue($this->user));
- $session = new Horde_Kolab_Session_Base(
- $composite, array()
- );
- $session->connect('userid', array('password' => ''));
- $this->assertEquals('home.example.org', $session->getImapServer());
- }
-
- public function testMethodConnectHasPostconditionThatTheUsersFreebusyHostIsKnown()
- {
- $this->user->expects($this->exactly(5))
- ->method('getSingle')
- ->will($this->returnValue('freebusy.example.org'));
- $composite = $this->_getMockedComposite();
- $composite->objects->expects($this->once())
- ->method('fetch')
- ->will($this->returnValue($this->user));
- $session = new Horde_Kolab_Session_Base(
- $composite,
- array('freebusy' => array('url_format' => 'https://%s/fb'))
- );
- $session->connect('userid', array('password' => ''));
- $this->assertEquals('https://freebusy.example.org/fb', $session->getFreebusyServer());
- }
-
- public function testMethodConnectThrowsExceptionIfTheConnectionFailed()
- {
- $composite = $this->_getMockedComposite();
- $composite->server->expects($this->exactly(1))
- ->method('connectGuid')
- ->will($this->throwException(new Horde_Kolab_Server_Exception('Error')));
- $session = new Horde_Kolab_Session_Base(
- $composite, array()
- );
- try {
- $session->connect('user', array('password' => 'pass'));
- } catch (Horde_Kolab_Session_Exception $e) {
- $this->assertEquals('Login failed!', $e->getMessage());
- }
- }
-
- public function testMethodConnectThrowsExceptionIfTheCredentialsWereInvalid()
- {
- $composite = $this->_getMockedComposite();
- $composite->server->expects($this->exactly(1))
- ->method('connectGuid')
- ->will($this->throwException(new Horde_Kolab_Server_Exception_Bindfailed('Error')));
- $session = new Horde_Kolab_Session_Base(
- $composite, array()
- );
- try {
- $session->connect('user', array('password' => 'pass'));
- } catch (Horde_Kolab_Session_Exception_Badlogin $e) {
- $this->assertEquals('Invalid credentials!', $e->getMessage());
- }
- }
-
- public function testMethodSleepHasResultArrayThePropertiesToSerialize()
- {
- $session = new Horde_Kolab_Session_Base(
- $this->_getComposite(), array()
- );
- $this->assertEquals(
- array(
- '_params',
- '_user_id',
- '_user_uid',
- '_user_mail',
- '_user_name',
- '_imap_server',
- '_freebusy_server',
- '_connected'
- ), $session->__sleep()
- );
- }
-
- public function testMethodGetidHasResultStringTheIdOfTheUserUserUsedForConnecting()
- {
- $this->user->expects($this->exactly(5))
- ->method('getSingle')
- ->will($this->returnValue('mail@example.org'));
- $composite = $this->_getMockedComposite();
- $composite->objects->expects($this->once())
- ->method('fetch')
- ->will($this->returnValue($this->user));
- $session = new Horde_Kolab_Session_Base(
- $composite, array()
- );
- $session->connect('userid', array('password' => 'pass'));
- $this->assertEquals('userid', $session->getId());
- }
-
- public function testMethodGetmailHasResultStringTheMailOfTheConnectedUser()
- {
- $this->user->expects($this->exactly(5))
- ->method('getSingle')
- ->will($this->throwException(new Horde_Kolab_Server_Exception_Novalue()));
- $composite = $this->_getMockedComposite();
- $composite->objects->expects($this->once())
- ->method('fetch')
- ->will($this->returnValue($this->user));
- $session = new Horde_Kolab_Session_Base(
- $composite, array()
- );
- $session->connect('userid', array('password' => ''));
- $this->assertEquals('userid', $session->getMail());
- }
-
- public function testMethodGetuidHasResultStringTheUidOfTheConnectedUser()
- {
- $this->user->expects($this->exactly(5))
- ->method('getSingle')
- ->will($this->throwException(new Horde_Kolab_Server_Exception_Novalue()));
- $composite = $this->_getMockedComposite();
- $composite->objects->expects($this->once())
- ->method('fetch')
- ->will($this->returnValue($this->user));
- $session = new Horde_Kolab_Session_Base(
- $composite, array()
- );
- $session->connect('userid', array('password' => ''));
- $this->assertEquals('userid', $session->getUid());
- }
-
- public function testMethodGetnameHasResultStringTheNameOfTheConnectedUser()
- {
- $this->user->expects($this->exactly(5))
- ->method('getSingle')
- ->will($this->throwException(new Horde_Kolab_Server_Exception_Novalue()));
- $composite = $this->_getMockedComposite();
- $composite->objects->expects($this->once())
- ->method('fetch')
- ->will($this->returnValue($this->user));
- $session = new Horde_Kolab_Session_Base(
- $composite, array()
- );
- $session->connect('userid', array('password' => ''));
- $this->assertEquals('userid', $session->getName());
- }
-
- public function testMethodGetfreebusyserverHasResultStringTheUsersFreebusyServerConverterdToACompleteUrlUsingParametersIfAvailable()
- {
- $this->user->expects($this->exactly(5))
- ->method('getSingle')
- ->will($this->returnValue('freebusy.example.org'));
- $composite = $this->_getMockedComposite();
- $composite->objects->expects($this->once())
- ->method('fetch')
- ->will($this->returnValue($this->user));
- $session = new Horde_Kolab_Session_Base(
- $composite,
- array('freebusy' => array('url_format' => 'https://%s/fb'))
- );
- $session->connect('userid', array('password' => ''));
- $this->assertEquals('https://freebusy.example.org/fb', $session->getFreebusyServer());
- }
-
- public function testMethodGetfreebusyserverHasResultStringTheUsersFreebusyServerConverterdToACompleteUrlUsingFreebusyIfAvailable()
- {
- $this->user->expects($this->exactly(5))
- ->method('getSingle')
- ->will($this->returnValue('freebusy.example.org'));
- $composite = $this->_getMockedComposite();
- $composite->objects->expects($this->once())
- ->method('fetch')
- ->will($this->returnValue($this->user));
- $session = new Horde_Kolab_Session_Base(
- $composite, array()
- );
- $session->connect('userid', array('password' => ''));
- $this->assertEquals('http://freebusy.example.org/freebusy', $session->getFreebusyServer());
- }
-
- public function testMethodGetfreebusyserverHasResultStringTheConfiguredServerIfAvailable()
- {
- $this->user->expects($this->exactly(5))
- ->method('getSingle')
- ->will($this->throwException(new Horde_Kolab_Server_Exception_Novalue()));
- $composite = $this->_getMockedComposite();
- $composite->objects->expects($this->once())
- ->method('fetch')
- ->will($this->returnValue($this->user));
- $session = new Horde_Kolab_Session_Base(
- $composite,
- array('freebusy' => array('url' => 'https://freebusy2.example.org/fb'))
- );
- $session->connect('userid', array('password' => ''));
- $this->assertEquals('https://freebusy2.example.org/fb', $session->getFreebusyServer());
- }
-
- public function testMethodGetfreebusyserverHasResultStringTheUsersHomeServerConverterdToACompleteUrlUsingParametersIfAvailable()
- {
- $this->user->expects($this->exactly(5))
- ->method('getSingle')
- ->will($this->throwException(new Horde_Kolab_Server_Exception_Novalue()));
- $composite = $this->_getMockedComposite();
- $composite->objects->expects($this->once())
- ->method('fetch')
- ->will($this->returnValue($this->user));
- $session = new Horde_Kolab_Session_Base(
- $composite,
- array('freebusy' => array('url_format' => 'https://%s/fb'))
- );
- $session->connect('userid', array('password' => ''));
- $this->assertEquals('https://localhost/fb', $session->getFreebusyServer());
- }
-
- public function testMethodGetfreebusyserverHasResultStringTheUsersHomeServerConverterdToACompleteUrlUsingFreebusyIfAvailable()
- {
- $this->user->expects($this->exactly(5))
- ->method('getSingle')
- ->will($this->throwException(new Horde_Kolab_Server_Exception_Novalue()));
- $composite = $this->_getMockedComposite();
- $composite->objects->expects($this->once())
- ->method('fetch')
- ->will($this->returnValue($this->user));
- $session = new Horde_Kolab_Session_Base(
- $composite, array()
- );
- $session->connect('userid', array('password' => ''));
- $this->assertEquals('http://localhost/freebusy', $session->getFreebusyServer());
- }
-
- public function testMethodGetfreebusyserverHasResultStringLocalhostConvertedToACompleteUrlUsingParametersIfAvailable()
- {
- $this->user->expects($this->exactly(5))
- ->method('getSingle')
- ->will($this->throwException(new Horde_Kolab_Server_Exception_Novalue()));
- $composite = $this->_getMockedComposite();
- $composite->objects->expects($this->once())
- ->method('fetch')
- ->will($this->returnValue($this->user));
- $session = new Horde_Kolab_Session_Base(
- $composite,
- array('freebusy' => array('url_format' => 'https://%s/fb'))
- );
- $session->connect('userid', array('password' => ''));
- $this->assertEquals('https://localhost/fb', $session->getFreebusyServer());
- }
-
- public function testMethodGetfreebusyserverHasResultStringLocalhostConvertedToACompleteUrlUsingFreebusy()
- {
- $this->user->expects($this->exactly(5))
- ->method('getSingle')
- ->will($this->throwException(new Horde_Kolab_Server_Exception_Novalue()));
- $composite = $this->_getMockedComposite();
- $composite->objects->expects($this->once())
- ->method('fetch')
- ->will($this->returnValue($this->user));
- $session = new Horde_Kolab_Session_Base(
- $composite, array()
- );
- $session->connect('userid', array('password' => ''));
- $this->assertEquals('http://localhost/freebusy', $session->getFreebusyServer());
- }
-
- public function testMethodGetimapserverHasResultStringTheUsersHomeServerIfAvailable()
- {
- $this->user->expects($this->exactly(5))
- ->method('getSingle')
- ->will($this->returnValue('home.example.org'));
- $composite = $this->_getMockedComposite();
- $composite->objects->expects($this->once())
- ->method('fetch')
- ->will($this->returnValue($this->user));
- $session = new Horde_Kolab_Session_Base(
- $composite, array()
- );
- $session->connect('userid', array('password' => ''));
- $this->assertEquals('home.example.org', $session->getImapServer());
- }
-
- public function testMethodGetimapserverHasResultStringTheConfiguredServerIfAvailable()
- {
- $this->user->expects($this->exactly(5))
- ->method('getSingle')
- ->will($this->throwException(new Horde_Kolab_Server_Exception_Novalue()));
- $composite = $this->_getMockedComposite();
- $composite->objects->expects($this->once())
- ->method('fetch')
- ->will($this->returnValue($this->user));
- $session = new Horde_Kolab_Session_Base(
- $composite,
- array('imap' => array('server' => 'imap.example.org'))
- );
- $session->connect('userid', array('password' => ''));
- $this->assertEquals('imap.example.org', $session->getImapServer());
- }
-
- public function testMethodGetimapserverHasResultStringLocalhostIfNoAlternative()
- {
- $this->user->expects($this->exactly(5))
- ->method('getSingle')
- ->will($this->throwException(new Horde_Kolab_Server_Exception_Novalue()));
- $composite = $this->_getMockedComposite();
- $composite->objects->expects($this->once())
- ->method('fetch')
- ->will($this->returnValue($this->user));
- $session = new Horde_Kolab_Session_Base(
- $composite, array()
- );
- $session->connect('userid', array('password' => ''));
- $this->assertEquals('localhost', $session->getImapServer());
- }
-}
\ No newline at end of file
+++ /dev/null
-<?php
-/**
- * Test the anonymous decorator.
- *
- * 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 anonymous decorator.
- *
- * Copyright 2009-2010 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_Class_Decorator_AnonymousTest
-extends Horde_Kolab_Session_SessionTestCase
-{
- public function testMethodConnectHasPostconditionThatTheConnectionHasBeenEstablishedAsAnonymousUserIfRequired()
- {
- $session = $this->getMock('Horde_Kolab_Session');
- $session->expects($this->once())
- ->method('connect')
- ->with('anonymous', array('password' => 'pass'));
- $anonymous = new Horde_Kolab_Session_Decorator_Anonymous(
- $session, 'anonymous', 'pass'
- );
- $anonymous->connect();
- }
-
- public function testMethodGetidReturnsNullIfConnectedUserIsAnonymousUser()
- {
- $session = $this->getMock('Horde_Kolab_Session');
- $session->expects($this->once())
- ->method('getId')
- ->will($this->returnValue('anonymous'));
- $anonymous = new Horde_Kolab_Session_Decorator_Anonymous(
- $session, 'anonymous', 'pass'
- );
- $this->assertNull($anonymous->getId());
- }
-
- public function testMethodConnectGetsDelegated()
- {
- $session = $this->getMock('Horde_Kolab_Session');
- $session->expects($this->once())
- ->method('connect')
- ->with(array('password' => 'pass'));
- $anonymous = new Horde_Kolab_Session_Decorator_Anonymous(
- $session, 'anonymous', 'pass'
- );
- $anonymous->connect(array('password' => 'pass'));
- }
-
- public function testMethodGetidGetsDelegated()
- {
- $session = $this->getMock('Horde_Kolab_Session');
- $session->expects($this->once())
- ->method('getId')
- ->will($this->returnValue('1'));
- $anonymous = new Horde_Kolab_Session_Decorator_Anonymous(
- $session, 'anonymous', 'pass'
- );
- $anonymous->getId();
- }
-}
\ No newline at end of file
+++ /dev/null
-<?php
-/**
- * Test the base decorator.
- *
- * 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 base decorator.
- *
- * Copyright 2009-2010 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_Class_Decorator_BaseTest
-extends Horde_Kolab_Session_SessionTestCase
-{
- public function testMethodConnectGetsDelegated()
- {
- $session = $this->getMock('Horde_Kolab_Session');
- $session->expects($this->once())
- ->method('connect')
- ->with(array('password' => 'pass'));
- $anonymous = new Horde_Kolab_Session_Decorator_Base(
- $session
- );
- $anonymous->connect(array('password' => 'pass'));
- }
-
- public function testMethodGetidGetsDelegated()
- {
- $session = $this->getMock('Horde_Kolab_Session');
- $session->expects($this->once())
- ->method('getId')
- ->will($this->returnValue('1'));
- $anonymous = new Horde_Kolab_Session_Decorator_Base(
- $session
- );
- $anonymous->getId();
- }
-
- public function testMethodGetmailGetsDelegated()
- {
- $session = $this->getMock('Horde_Kolab_Session');
- $session->expects($this->once())
- ->method('getMail')
- ->will($this->returnValue('1'));
- $anonymous = new Horde_Kolab_Session_Decorator_Base(
- $session
- );
- $anonymous->getMail();
- }
-
- public function testMethodGetuidGetsDelegated()
- {
- $session = $this->getMock('Horde_Kolab_Session');
- $session->expects($this->once())
- ->method('getUid')
- ->will($this->returnValue('1'));
- $anonymous = new Horde_Kolab_Session_Decorator_Base(
- $session
- );
- $anonymous->getUid();
- }
-
- public function testMethodGetnameGetsDelegated()
- {
- $session = $this->getMock('Horde_Kolab_Session');
- $session->expects($this->once())
- ->method('getName')
- ->will($this->returnValue('1'));
- $anonymous = new Horde_Kolab_Session_Decorator_Base(
- $session
- );
- $anonymous->getName();
- }
-
- public function testMethodGetimapserverGetsDelegated()
- {
- $session = $this->getMock('Horde_Kolab_Session');
- $session->expects($this->once())
- ->method('getImapServer')
- ->will($this->returnValue('1'));
- $anonymous = new Horde_Kolab_Session_Decorator_Base(
- $session
- );
- $anonymous->getImapServer();
- }
-
- public function testMethodGetfreebusyserverGetsDelegated()
- {
- $session = $this->getMock('Horde_Kolab_Session');
- $session->expects($this->once())
- ->method('getFreebusyServer')
- ->will($this->returnValue('1'));
- $anonymous = new Horde_Kolab_Session_Decorator_Base(
- $session
- );
- $anonymous->getFreebusyServer();
- }
-}
\ No newline at end of file
+++ /dev/null
-<?php
-/**
- * Test the log decorator.
- *
- * 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 log decorator.
- *
- * Copyright 2009-2010 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_Class_Decorator_LoggedTest
-extends Horde_Kolab_Session_SessionTestCase
-{
- public function setUp()
- {
- parent::setUp();
-
- $this->setupLogger();
- }
-
- public function testMethodConnectHasPostconditionThatASuccessfulConnectionGetsLogged()
- {
- $session = $this->getMock('Horde_Kolab_Session');
- $session->expects($this->once())
- ->method('connect')
- ->with(array('password' => 'pass'));
- $session->expects($this->once())
- ->method('getId')
- ->will($this->returnValue('somebody@example.org'));
- $this->logger->expects($this->once())
- ->method('__call')
- ->with(
- 'info',
- array(
- 'Connected Kolab session for "somebody@example.org".'
- )
- );
- $logged = new Horde_Kolab_Session_Decorator_Logged(
- $session, $this->logger
- );
- $logged->connect(array('password' => 'pass'));
- }
-
- public function testMethodConnectHasPostconditionThatAnUnsuccessfulConnectionGetsLogged()
- {
- $session = $this->getMock('Horde_Kolab_Session');
- $session->expects($this->once())
- ->method('connect')
- ->will($this->throwException(new Horde_Kolab_Session_Exception('Error.')));
- $session->expects($this->once())
- ->method('getId')
- ->will($this->returnValue('somebody@example.org'));
- $this->logger->expects($this->once())
- ->method('__call')
- ->with(
- 'err',
- array(
- 'Failed to connect Kolab session for "somebody@example.org". Error was: Error.'
- )
- );
- $logged = new Horde_Kolab_Session_Decorator_Logged(
- $session, $this->logger
- );
- try {
- $logged->connect(array('password' => 'pass'));
- $this->fail('No Exception!');
- } catch (Horde_Kolab_Session_Exception $e) {
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-<?php
-/**
- * Test the storing decorator.
- *
- * 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 storing decorator.
- *
- * Copyright 2009-2010 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_Class_Decorator_StoredTest
-extends Horde_Kolab_Session_SessionTestCase
-{
- public function setUp()
- {
- parent::setUp();
-
- $this->setupStorage();
- }
-
- public function testMethodDestructHasPostconditionThatTheSessionWasSaved()
- {
- $this->storage->expects($this->once())
- ->method('save')
- ->with($this->isInstanceOf('Horde_Kolab_Session'));
- $session = $this->getMock('Horde_Kolab_Session');
- $stored = new Horde_Kolab_Session_Decorator_Stored($session, $this->storage);
- $stored = null;
- }
-
- public function testMethodConnectGetsDelegated()
- {
- $session = $this->getMock('Horde_Kolab_Session');
- $session->expects($this->once())
- ->method('connect')
- ->with(array('password' => 'pass'));
- $stored = new Horde_Kolab_Session_Decorator_Stored($session, $this->storage);
- $stored->connect(array('password' => 'pass'));
- }
-}
\ No newline at end of file
+++ /dev/null
-<?php
-/**
- * Test the mock storage driver.
- *
- * 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 mock storage driver.
- *
- * Copyright 2009-2010 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_Class_Storage_MockTest extends Horde_Kolab_Session_SessionTestCase
-{
- public function testMethodLoadHasResultBooleanFalse()
- {
- $storage = new Horde_Kolab_Session_Storage_Mock('test');
- $this->assertFalse($storage->load());
- }
-
- public function testMethodSaveHasPostconditionThatTheSessionDataWasSaved()
- {
- $session = $this->getMock('Horde_Kolab_Session');
- $storage = new Horde_Kolab_Session_Storage_Mock('test');
- $storage->save($session);
- $this->assertSame($session, $storage->session);
- }
-}
\ No newline at end of file
+++ /dev/null
-<?php
-/**
- * Test the session based storage driver.
- *
- * 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 session based storage driver.
- *
- * Copyright 2009-2010 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_Class_Storage_SessionTest extends Horde_Kolab_Session_SessionTestCase
-{
- public function testMethodLoadHasResultQueriedObject()
- {
- $session = $this->getMock('Horde_Session', array(), array(), '', false, false);
- $session->expects($this->once())
- ->method('get')
- ->with('horde', 'kolab_session');
- $storage = new Horde_Kolab_Session_Storage_Session($session);
- $storage->load();
- }
-
- public function testMethodSaveHasPostconditionThatTheSessionDataWasSaved()
- {
- $session = $this->getMock('Horde_Session', array(), array(), '', false, false);
- $session->expects($this->once())
- ->method('set')
- ->with('horde', 'kolab_session', $this->isInstanceOf('Horde_Kolab_Session'));
- $kolab_session = $this->getMock('Horde_Kolab_Session');
- $storage = new Horde_Kolab_Session_Storage_Session($session);
- $storage->save($kolab_session);
- }
-}
\ No newline at end of file
+++ /dev/null
-<?php
-/**
- * Test the valid check.
- *
- * 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 valid check.
- *
- * Copyright 2009-2010 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_Class_Valid_BaseTest extends Horde_Kolab_Session_SessionTestCase
-{
- public function testMethodIsvalidHasResultBooleanTrueIfTheSessionIsNotConnectedAndTheCurrentUserIsAnonymous()
- {
- $auth = false;
- $session = $this->getMock('Horde_Kolab_Session');
- $session->expects($this->once())
- ->method('getMail')
- ->will($this->returnValue(''));
- $valid = new Horde_Kolab_Session_Valid_Base($session, $auth);
- $this->assertTrue($valid->isValid());
- }
-
- public function testMethodIsvalidHasResultBooleanFalseIfTheSessionIsNotConnected()
- {
- $auth = 'mail@example.org';
- $session = $this->getMock('Horde_Kolab_Session');
- $session->expects($this->once())
- ->method('getMail')
- ->will($this->returnValue(''));
- $valid = new Horde_Kolab_Session_Valid_Base($session, $auth);
- $this->assertFalse($valid->isValid());
- }
-
- public function testMethodIsvalidHasResultBooleanFalseIfTheMailOfTheCurrentUserDoesNotMatchTheCurrentUserOfTheSession()
- {
- $auth = 'somebody@example.org';
- $session = $this->getMock('Horde_Kolab_Session');
- $session->expects($this->once())
- ->method('getMail')
- ->will($this->returnValue('mail@example.org'));
- $valid = new Horde_Kolab_Session_Valid_Base($session, $auth);
- $this->assertFalse($valid->isValid());
- }
-
- public function testMethodIsvalidHasResultBooleanTrueIfTheMailOfTheCurrentUserMatchesTheCurrentUserOfTheSessionAndNoNewUserWasSet()
- {
- $auth = 'mail@example.org';
- $session = $this->getMock('Horde_Kolab_Session');
- $session->expects($this->once())
- ->method('getMail')
- ->will($this->returnValue('mail@example.org'));
- $valid = new Horde_Kolab_Session_Valid_Base($session, $auth);
- $this->assertTrue($valid->isValid());
- }
-
- public function testMethodIsvalidHasResultBooleanFalseIfTheMailOfTheCurrentUserMatchesTheCurrentUserOfTheSessionAndTheNewUserMatchesNeitherTheCurrentUserMailAndUid()
- {
- $auth = 'mail@example.org';
- $session = $this->getMock('Horde_Kolab_Session');
- $session->expects($this->once())
- ->method('getMail')
- ->will($this->returnValue('mail@example.org'));
- $valid = new Horde_Kolab_Session_Valid_Base($session, $auth);
- $this->assertFalse($valid->isValid('somebody@example.org'));
- }
-
- public function testMethodIsvalidHasResultBooleanTrueIfTheMailOfTheCurrentUserMatchesTheCurrentUserOfTheSessionAndTheNewUserMatchesEitherTheCurrentUserMailAndUid()
- {
- $auth = 'mail@example.org';
- $session = $this->getMock('Horde_Kolab_Session');
- $session->expects($this->once())
- ->method('getMail')
- ->will($this->returnValue('mail@example.org'));
- $valid = new Horde_Kolab_Session_Valid_Base($session, $auth);
- $this->assertTrue($valid->isValid('mail@example.org'));
- }
-}
\ No newline at end of file
+++ /dev/null
-<?php
-/**
- * Test the log decorator for validators.
- *
- * 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 log decorator for validators.
- *
- * Copyright 2009-2010 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_Class_Valid_Decorator_LoggedTest
-extends Horde_Kolab_Session_SessionTestCase
-{
- public function setUp()
- {
- parent::setUp();
-
- $this->setupLogger();
- }
-
- public function testMethodIsvalidHasPostconditionThatAnInvalidSessionGetsLogged()
- {
- $auth = 'auth@example.org';
- $session = $this->getMock('Horde_Kolab_Session');
- $session->expects($this->exactly(2))
- ->method('getMail')
- ->will($this->returnValue('somebody@example.org'));
- $this->logger->expects($this->once())
- ->method('__call')
- ->with(
- 'info',
- array('Invalid Kolab session for current user "auth@example.org", requested user "nobody@example.org" and stored user "somebody@example.org".')
- );
- $logged = new Horde_Kolab_Session_Decorator_Logged(
- $session, $this->logger
- );
- $valid = new Horde_Kolab_Session_Valid_Base($session, $auth);
- $logged = new Horde_Kolab_Session_Valid_Decorator_Logged(
- $valid, $this->logger
- );
- $this->assertFalse($logged->isValid('nobody@example.org'));
- }
-
- public function testMethodIsvalidGetsDelegated()
- {
- $valid = $this->getMock('Horde_Kolab_Session_Valid_Interface');
- $valid->expects($this->once())
- ->method('isValid')
- ->will($this->returnValue(true));
- $logged = new Horde_Kolab_Session_Valid_Decorator_Logged(
- $valid, $this->logger
- );
- $this->assertTrue($logged->isValid());
- }
-
- public function testMethodGetsessionGetsDelegated()
- {
- $valid = $this->getMock('Horde_Kolab_Session_Valid_Interface');
- $valid->expects($this->once())
- ->method('getSession');
- $logged = new Horde_Kolab_Session_Valid_Decorator_Logged($valid, $this->logger);
- $logged->getSession();
- }
-
- public function testMethodGetauthGetsDelegated()
- {
- $valid = $this->getMock('Horde_Kolab_Session_Valid_Interface');
- $valid->expects($this->once())
- ->method('getAuth');
- $logged = new Horde_Kolab_Session_Valid_Decorator_Logged($valid, $this->logger);
- $logged->getAuth();
- }
-}
\ No newline at end of file
* @license http://www.fsf.org/copyleft/lgpl.html LGPL
* @link http://pear.horde.org/index.php?package=Kolab_Session
*/
-class Horde_Kolab_Session_Integration_AnonymousTest extends Horde_Kolab_Session_SessionTestCase
+class Horde_Kolab_Session_Integration_AnonymousTest extends Horde_Kolab_Session_TestCase
{
public function testMethodConnectHasPostconditionThatTheConnectionHasBeenEstablishedAsAnonymousUserIfRequired()
{
--- /dev/null
+<?php
+/**
+ * Test the valid check with the Kolab session handler implementation.
+ *
+ * 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 valid check with the Kolab session handler implementation.
+ *
+ * Copyright 2009-2010 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_TestCase
+{
+ public function test()
+ {
+ }
+}
\ No newline at end of file
* @license http://www.fsf.org/copyleft/lgpl.html LGPL
* @link http://pear.horde.org/index.php?package=Kolab_Session
*/
-class Horde_Kolab_Session_Integration_ValidTest extends Horde_Kolab_Session_SessionTestCase
+class Horde_Kolab_Session_Integration_ValidTest extends Horde_Kolab_Session_TestCase
{
public function setUp()
{
$composite, array()
);
$valid = new Horde_Kolab_Session_Valid_Base($session, $auth);
- $this->assertTrue($valid->isValid());
+ $this->assertTrue($valid->validate());
}
public function testMethodIsvalidHasResultBooleanFalseIfTheSessionIsNotConnected()
$composite, array()
);
$valid = new Horde_Kolab_Session_Valid_Base($session, $auth);
- $this->assertFalse($valid->isValid());
+ $this->assertFalse($valid->validate());
}
public function testMethodIsvalidHasResultBooleanFalseIfTheMailOfTheCurrentUserDoesNotMatchTheCurrentUserOfTheSession()
);
$session->connect('', array('password' => ''));
$valid = new Horde_Kolab_Session_Valid_Base($session, $auth);
- $this->assertFalse($valid->isValid());
+ $this->assertFalse($valid->validate());
}
public function testMethodIsvalidHasResultBooleanTrueIfTheMailOfTheCurrentUserMatchesTheCurrentUserOfTheSessionAndNoNewUserWasSet()
);
$session->connect('', array('password' => ''));
$valid = new Horde_Kolab_Session_Valid_Base($session, $auth);
- $this->assertTrue($valid->isValid());
+ $this->assertTrue($valid->validate());
}
public function testMethodIsvalidHasResultBooleanFalseIfTheMailOfTheCurrentUserMatchesTheCurrentUserOfTheSessionAndTheNewUserMatchesNeitherTheCurrentUserMailAndUid()
);
$session->connect('', array('password' => ''));
$valid = new Horde_Kolab_Session_Valid_Base($session, $auth);
- $this->assertFalse($valid->isValid('somebody@example.org'));
+ $this->assertFalse($valid->validate('somebody@example.org'));
}
public function testMethodIsvalidHasResultBooleanTrueIfTheMailOfTheCurrentUserMatchesTheCurrentUserOfTheSessionAndTheNewUserMatchesEitherTheCurrentUserMailAndUid()
);
$session->connect('', array('password' => ''));
$valid = new Horde_Kolab_Session_Valid_Base($session, $auth);
- $this->assertTrue($valid->isValid('mail@example.org'));
+ $this->assertTrue($valid->validate('mail@example.org'));
}
}
\ No newline at end of file
+++ /dev/null
-<?php
-/**
- * Base for session testing.
- *
- * 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
- */
-
-/**
- * Base for session testing.
- *
- * Copyright 2009-2010 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_SessionTestCase extends PHPUnit_Framework_TestCase
-{
- protected function _getComposite()
- {
- return $this->getMock('Horde_Kolab_Server_Composite', array(), array(), '', false, false);
- }
-
- protected function _getMockedComposite()
- {
- return new Horde_Kolab_Server_Composite(
- $this->getMock('Horde_Kolab_Server_Interface'),
- $this->getMock('Horde_Kolab_Server_Objects_Interface'),
- $this->getMock('Horde_Kolab_Server_Structure_Interface'),
- $this->getMock('Horde_Kolab_Server_Search_Interface'),
- $this->getMock('Horde_Kolab_Server_Schema_Interface')
- );
- }
-
- protected function setupLogger()
- {
- $this->logger = $this->getMock('Horde_Log_Logger');
- }
-
- protected function setupStorage()
- {
- $this->storage = $this->getMock('Horde_Kolab_Session_Storage_Interface');
- }
-
- protected function setupFactoryMocks()
- {
- $this->server = $this->_getMockedComposite();
- $this->session_auth = $this->getMock('Horde_Kolab_Session_Auth_Interface');
- $this->session_storage = $this->getMock('Horde_Kolab_Session_Storage_Interface');
- }
-}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Base for session testing.
+ *
+ * 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
+ */
+
+/**
+ * Base for session testing.
+ *
+ * Copyright 2009-2010 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_TestCase extends PHPUnit_Framework_TestCase
+{
+ protected function _getComposite()
+ {
+ return $this->getMock('Horde_Kolab_Server_Composite', array(), array(), '', false, false);
+ }
+
+ protected function _getMockedComposite()
+ {
+ return new Horde_Kolab_Server_Composite(
+ $this->getMock('Horde_Kolab_Server_Interface'),
+ $this->getMock('Horde_Kolab_Server_Objects_Interface'),
+ $this->getMock('Horde_Kolab_Server_Structure_Interface'),
+ $this->getMock('Horde_Kolab_Server_Search_Interface'),
+ $this->getMock('Horde_Kolab_Server_Schema_Interface')
+ );
+ }
+
+ protected function setupLogger()
+ {
+ $this->logger = $this->getMock('Horde_Log_Logger');
+ }
+
+ protected function setupStorage()
+ {
+ $this->storage = $this->getMock('Horde_Kolab_Session_Storage');
+ }
+
+ protected function setupFactoryMocks()
+ {
+ $this->server = $this->_getMockedComposite();
+ $this->session_storage = $this->getMock('Horde_Kolab_Session_Storage');
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Test the Kolab session handler base implementation.
+ *
+ * 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 base implementation.
+ *
+ * Copyright 2009-2010 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_Unit_BaseTest extends Horde_Kolab_Session_TestCase
+{
+ public function setUp()
+ {
+ $this->user = $this->getMock(
+ 'Horde_Kolab_Server_Object_Hash', array(), array(), '', false, false
+ );
+ }
+
+ public function testMethodConstructHasParameterServercompositeServer()
+ {
+ $session = new Horde_Kolab_Session_Base(
+ $this->_getComposite(), array()
+ );
+ }
+
+ public function testMethodConstructHasParameterArrayParams()
+ {
+ $session = new Horde_Kolab_Session_Base(
+ $this->_getComposite(), array('params' => 'params')
+ );
+ }
+
+ public function testMethodConnectHasParameterStringUserid()
+ {
+ $this->user->expects($this->exactly(5))
+ ->method('getSingle')
+ ->will($this->returnValue('mail@example.org'));
+ $composite = $this->_getMockedComposite();
+ $composite->objects->expects($this->once())
+ ->method('fetch')
+ ->will($this->returnValue($this->user));
+ $session = new Horde_Kolab_Session_Base(
+ $composite, array()
+ );
+ $session->connect('userid', array('password' => ''));
+ }
+
+ public function testMethodConnectHasParameterArrayCredentials()
+ {
+ $this->user->expects($this->exactly(5))
+ ->method('getSingle')
+ ->will($this->returnValue('mail@example.org'));
+ $composite = $this->_getMockedComposite();
+ $composite->objects->expects($this->once())
+ ->method('fetch')
+ ->will($this->returnValue($this->user));
+ $session = new Horde_Kolab_Session_Base(
+ $composite, array()
+ );
+ $session->connect('', array('password' => ''));
+ }
+
+ public function testMethodConnectHasPostconditionThatTheUserMailAddressIsKnown()
+ {
+ $this->user->expects($this->exactly(5))
+ ->method('getSingle')
+ ->will($this->returnValue('mail@example.org'));
+ $composite = $this->_getMockedComposite();
+ $composite->objects->expects($this->once())
+ ->method('fetch')
+ ->will($this->returnValue($this->user));
+ $session = new Horde_Kolab_Session_Base(
+ $composite, array()
+ );
+ $session->connect(array('password' => ''));
+ $this->assertEquals('mail@example.org', $session->getMail());
+ }
+
+ public function testMethodConnectHasPostconditionThatTheUserUidIsKnown()
+ {
+ $this->user->expects($this->exactly(5))
+ ->method('getSingle')
+ ->will($this->returnValue('uid'));
+ $composite = $this->_getMockedComposite();
+ $composite->objects->expects($this->once())
+ ->method('fetch')
+ ->will($this->returnValue($this->user));
+ $session = new Horde_Kolab_Session_Base(
+ $composite, array()
+ );
+ $session->connect(array('password' => ''));
+ $this->assertEquals('uid', $session->getUid());
+ }
+
+ public function testMethodConnectHasPostconditionThatTheUserNameIsKnown()
+ {
+ $this->user->expects($this->exactly(5))
+ ->method('getSingle')
+ ->will($this->returnValue('name'));
+ $composite = $this->_getMockedComposite();
+ $composite->objects->expects($this->once())
+ ->method('fetch')
+ ->will($this->returnValue($this->user));
+ $session = new Horde_Kolab_Session_Base(
+ $composite, array()
+ );
+ $session->connect(array('password' => ''));
+ $this->assertEquals('name', $session->getName());
+ }
+
+ public function testMethodConnectHasPostconditionThatTheUsersImapHostIsKnown()
+ {
+ $this->user->expects($this->exactly(5))
+ ->method('getSingle')
+ ->will($this->returnValue('home.example.org'));
+ $composite = $this->_getMockedComposite();
+ $composite->objects->expects($this->once())
+ ->method('fetch')
+ ->will($this->returnValue($this->user));
+ $session = new Horde_Kolab_Session_Base(
+ $composite, array()
+ );
+ $session->connect('userid', array('password' => ''));
+ $this->assertEquals('home.example.org', $session->getImapServer());
+ }
+
+ public function testMethodConnectHasPostconditionThatTheUsersFreebusyHostIsKnown()
+ {
+ $this->user->expects($this->exactly(5))
+ ->method('getSingle')
+ ->will($this->returnValue('freebusy.example.org'));
+ $composite = $this->_getMockedComposite();
+ $composite->objects->expects($this->once())
+ ->method('fetch')
+ ->will($this->returnValue($this->user));
+ $session = new Horde_Kolab_Session_Base(
+ $composite,
+ array('freebusy' => array('url_format' => 'https://%s/fb'))
+ );
+ $session->connect('userid', array('password' => ''));
+ $this->assertEquals('https://freebusy.example.org/fb', $session->getFreebusyServer());
+ }
+
+ public function testMethodConnectThrowsExceptionIfTheConnectionFailed()
+ {
+ $composite = $this->_getMockedComposite();
+ $composite->server->expects($this->exactly(1))
+ ->method('connectGuid')
+ ->will($this->throwException(new Horde_Kolab_Server_Exception('Error')));
+ $session = new Horde_Kolab_Session_Base(
+ $composite, array()
+ );
+ try {
+ $session->connect('user', array('password' => 'pass'));
+ } catch (Horde_Kolab_Session_Exception $e) {
+ $this->assertEquals('Login failed!', $e->getMessage());
+ }
+ }
+
+ public function testMethodConnectThrowsExceptionIfTheCredentialsWereInvalid()
+ {
+ $composite = $this->_getMockedComposite();
+ $composite->server->expects($this->exactly(1))
+ ->method('connectGuid')
+ ->will($this->throwException(new Horde_Kolab_Server_Exception_Bindfailed('Error')));
+ $session = new Horde_Kolab_Session_Base(
+ $composite, array()
+ );
+ try {
+ $session->connect('user', array('password' => 'pass'));
+ } catch (Horde_Kolab_Session_Exception_Badlogin $e) {
+ $this->assertEquals('Invalid credentials!', $e->getMessage());
+ }
+ }
+
+ public function testMethodGetidHasResultStringTheIdOfTheUserUserUsedForConnecting()
+ {
+ $this->user->expects($this->exactly(5))
+ ->method('getSingle')
+ ->will($this->returnValue('mail@example.org'));
+ $composite = $this->_getMockedComposite();
+ $composite->objects->expects($this->once())
+ ->method('fetch')
+ ->will($this->returnValue($this->user));
+ $session = new Horde_Kolab_Session_Base(
+ $composite, array()
+ );
+ $session->connect('userid', array('password' => 'pass'));
+ $this->assertEquals('userid', $session->getId());
+ }
+
+ public function testMethodGetmailHasResultStringTheMailOfTheConnectedUser()
+ {
+ $this->user->expects($this->exactly(5))
+ ->method('getSingle')
+ ->will($this->throwException(new Horde_Kolab_Server_Exception_Novalue()));
+ $composite = $this->_getMockedComposite();
+ $composite->objects->expects($this->once())
+ ->method('fetch')
+ ->will($this->returnValue($this->user));
+ $session = new Horde_Kolab_Session_Base(
+ $composite, array()
+ );
+ $session->connect('userid', array('password' => ''));
+ $this->assertEquals('userid', $session->getMail());
+ }
+
+ public function testMethodGetuidHasResultStringTheUidOfTheConnectedUser()
+ {
+ $this->user->expects($this->exactly(5))
+ ->method('getSingle')
+ ->will($this->throwException(new Horde_Kolab_Server_Exception_Novalue()));
+ $composite = $this->_getMockedComposite();
+ $composite->objects->expects($this->once())
+ ->method('fetch')
+ ->will($this->returnValue($this->user));
+ $session = new Horde_Kolab_Session_Base(
+ $composite, array()
+ );
+ $session->connect('userid', array('password' => ''));
+ $this->assertEquals('userid', $session->getUid());
+ }
+
+ public function testMethodGetnameHasResultStringTheNameOfTheConnectedUser()
+ {
+ $this->user->expects($this->exactly(5))
+ ->method('getSingle')
+ ->will($this->throwException(new Horde_Kolab_Server_Exception_Novalue()));
+ $composite = $this->_getMockedComposite();
+ $composite->objects->expects($this->once())
+ ->method('fetch')
+ ->will($this->returnValue($this->user));
+ $session = new Horde_Kolab_Session_Base(
+ $composite, array()
+ );
+ $session->connect('userid', array('password' => ''));
+ $this->assertEquals('userid', $session->getName());
+ }
+
+ public function testMethodGetfreebusyserverHasResultStringTheUsersFreebusyServerConverterdToACompleteUrlUsingParametersIfAvailable()
+ {
+ $this->user->expects($this->exactly(5))
+ ->method('getSingle')
+ ->will($this->returnValue('freebusy.example.org'));
+ $composite = $this->_getMockedComposite();
+ $composite->objects->expects($this->once())
+ ->method('fetch')
+ ->will($this->returnValue($this->user));
+ $session = new Horde_Kolab_Session_Base(
+ $composite,
+ array('freebusy' => array('url_format' => 'https://%s/fb'))
+ );
+ $session->connect('userid', array('password' => ''));
+ $this->assertEquals('https://freebusy.example.org/fb', $session->getFreebusyServer());
+ }
+
+ public function testMethodGetfreebusyserverHasResultStringTheUsersFreebusyServerConverterdToACompleteUrlUsingFreebusyIfAvailable()
+ {
+ $this->user->expects($this->exactly(5))
+ ->method('getSingle')
+ ->will($this->returnValue('freebusy.example.org'));
+ $composite = $this->_getMockedComposite();
+ $composite->objects->expects($this->once())
+ ->method('fetch')
+ ->will($this->returnValue($this->user));
+ $session = new Horde_Kolab_Session_Base(
+ $composite, array()
+ );
+ $session->connect('userid', array('password' => ''));
+ $this->assertEquals('http://freebusy.example.org/freebusy', $session->getFreebusyServer());
+ }
+
+ public function testMethodGetfreebusyserverHasResultStringTheConfiguredServerIfAvailable()
+ {
+ $this->user->expects($this->exactly(5))
+ ->method('getSingle')
+ ->will($this->throwException(new Horde_Kolab_Server_Exception_Novalue()));
+ $composite = $this->_getMockedComposite();
+ $composite->objects->expects($this->once())
+ ->method('fetch')
+ ->will($this->returnValue($this->user));
+ $session = new Horde_Kolab_Session_Base(
+ $composite,
+ array('freebusy' => array('url' => 'https://freebusy2.example.org/fb'))
+ );
+ $session->connect('userid', array('password' => ''));
+ $this->assertEquals('https://freebusy2.example.org/fb', $session->getFreebusyServer());
+ }
+
+ public function testMethodGetfreebusyserverHasResultStringTheUsersHomeServerConverterdToACompleteUrlUsingParametersIfAvailable()
+ {
+ $this->user->expects($this->exactly(5))
+ ->method('getSingle')
+ ->will($this->throwException(new Horde_Kolab_Server_Exception_Novalue()));
+ $composite = $this->_getMockedComposite();
+ $composite->objects->expects($this->once())
+ ->method('fetch')
+ ->will($this->returnValue($this->user));
+ $session = new Horde_Kolab_Session_Base(
+ $composite,
+ array('freebusy' => array('url_format' => 'https://%s/fb'))
+ );
+ $session->connect('userid', array('password' => ''));
+ $this->assertEquals('https://localhost/fb', $session->getFreebusyServer());
+ }
+
+ public function testMethodGetfreebusyserverHasResultStringTheUsersHomeServerConverterdToACompleteUrlUsingFreebusyIfAvailable()
+ {
+ $this->user->expects($this->exactly(5))
+ ->method('getSingle')
+ ->will($this->throwException(new Horde_Kolab_Server_Exception_Novalue()));
+ $composite = $this->_getMockedComposite();
+ $composite->objects->expects($this->once())
+ ->method('fetch')
+ ->will($this->returnValue($this->user));
+ $session = new Horde_Kolab_Session_Base(
+ $composite, array()
+ );
+ $session->connect('userid', array('password' => ''));
+ $this->assertEquals('http://localhost/freebusy', $session->getFreebusyServer());
+ }
+
+ public function testMethodGetfreebusyserverHasResultStringLocalhostConvertedToACompleteUrlUsingParametersIfAvailable()
+ {
+ $this->user->expects($this->exactly(5))
+ ->method('getSingle')
+ ->will($this->throwException(new Horde_Kolab_Server_Exception_Novalue()));
+ $composite = $this->_getMockedComposite();
+ $composite->objects->expects($this->once())
+ ->method('fetch')
+ ->will($this->returnValue($this->user));
+ $session = new Horde_Kolab_Session_Base(
+ $composite,
+ array('freebusy' => array('url_format' => 'https://%s/fb'))
+ );
+ $session->connect('userid', array('password' => ''));
+ $this->assertEquals('https://localhost/fb', $session->getFreebusyServer());
+ }
+
+ public function testMethodGetfreebusyserverHasResultStringLocalhostConvertedToACompleteUrlUsingFreebusy()
+ {
+ $this->user->expects($this->exactly(5))
+ ->method('getSingle')
+ ->will($this->throwException(new Horde_Kolab_Server_Exception_Novalue()));
+ $composite = $this->_getMockedComposite();
+ $composite->objects->expects($this->once())
+ ->method('fetch')
+ ->will($this->returnValue($this->user));
+ $session = new Horde_Kolab_Session_Base(
+ $composite, array()
+ );
+ $session->connect('userid', array('password' => ''));
+ $this->assertEquals('http://localhost/freebusy', $session->getFreebusyServer());
+ }
+
+ public function testMethodGetimapserverHasResultStringTheUsersHomeServerIfAvailable()
+ {
+ $this->user->expects($this->exactly(5))
+ ->method('getSingle')
+ ->will($this->returnValue('home.example.org'));
+ $composite = $this->_getMockedComposite();
+ $composite->objects->expects($this->once())
+ ->method('fetch')
+ ->will($this->returnValue($this->user));
+ $session = new Horde_Kolab_Session_Base(
+ $composite, array()
+ );
+ $session->connect('userid', array('password' => ''));
+ $this->assertEquals('home.example.org', $session->getImapServer());
+ }
+
+ public function testMethodGetimapserverHasResultStringTheConfiguredServerIfAvailable()
+ {
+ $this->user->expects($this->exactly(5))
+ ->method('getSingle')
+ ->will($this->throwException(new Horde_Kolab_Server_Exception_Novalue()));
+ $composite = $this->_getMockedComposite();
+ $composite->objects->expects($this->once())
+ ->method('fetch')
+ ->will($this->returnValue($this->user));
+ $session = new Horde_Kolab_Session_Base(
+ $composite,
+ array('imap' => array('server' => 'imap.example.org'))
+ );
+ $session->connect('userid', array('password' => ''));
+ $this->assertEquals('imap.example.org', $session->getImapServer());
+ }
+
+ public function testMethodGetimapserverHasResultStringLocalhostIfNoAlternative()
+ {
+ $this->user->expects($this->exactly(5))
+ ->method('getSingle')
+ ->will($this->throwException(new Horde_Kolab_Server_Exception_Novalue()));
+ $composite = $this->_getMockedComposite();
+ $composite->objects->expects($this->once())
+ ->method('fetch')
+ ->will($this->returnValue($this->user));
+ $session = new Horde_Kolab_Session_Base(
+ $composite, array()
+ );
+ $session->connect('userid', array('password' => ''));
+ $this->assertEquals('localhost', $session->getImapServer());
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Test the anonymous decorator.
+ *
+ * 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 anonymous decorator.
+ *
+ * Copyright 2009-2010 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_Unit_Decorator_AnonymousTest
+extends Horde_Kolab_Session_TestCase
+{
+ public function testMethodConnectHasPostconditionThatTheConnectionHasBeenEstablishedAsAnonymousUserIfRequired()
+ {
+ $session = $this->getMock('Horde_Kolab_Session');
+ $session->expects($this->once())
+ ->method('connect')
+ ->with('anonymous', array('password' => 'pass'));
+ $anonymous = new Horde_Kolab_Session_Decorator_Anonymous(
+ $session, 'anonymous', 'pass'
+ );
+ $anonymous->connect();
+ }
+
+ public function testMethodGetidReturnsNullIfConnectedUserIsAnonymousUser()
+ {
+ $session = $this->getMock('Horde_Kolab_Session');
+ $session->expects($this->once())
+ ->method('getId')
+ ->will($this->returnValue('anonymous'));
+ $anonymous = new Horde_Kolab_Session_Decorator_Anonymous(
+ $session, 'anonymous', 'pass'
+ );
+ $this->assertNull($anonymous->getId());
+ }
+
+ public function testMethodConnectGetsDelegated()
+ {
+ $session = $this->getMock('Horde_Kolab_Session');
+ $session->expects($this->once())
+ ->method('connect')
+ ->with(array('password' => 'pass'));
+ $anonymous = new Horde_Kolab_Session_Decorator_Anonymous(
+ $session, 'anonymous', 'pass'
+ );
+ $anonymous->connect(array('password' => 'pass'));
+ }
+
+ public function testMethodGetidGetsDelegated()
+ {
+ $session = $this->getMock('Horde_Kolab_Session');
+ $session->expects($this->once())
+ ->method('getId')
+ ->will($this->returnValue('1'));
+ $anonymous = new Horde_Kolab_Session_Decorator_Anonymous(
+ $session, 'anonymous', 'pass'
+ );
+ $anonymous->getId();
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Test the base decorator.
+ *
+ * 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 base decorator.
+ *
+ * Copyright 2009-2010 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_Unit_Decorator_BaseTest
+extends Horde_Kolab_Session_TestCase
+{
+ public function testMethodConnectGetsDelegated()
+ {
+ $session = $this->getMock('Horde_Kolab_Session');
+ $session->expects($this->once())
+ ->method('connect')
+ ->with(array('password' => 'pass'));
+ $anonymous = new Horde_Kolab_Session_Decorator_Base(
+ $session
+ );
+ $anonymous->connect(array('password' => 'pass'));
+ }
+
+ public function testMethodGetidGetsDelegated()
+ {
+ $session = $this->getMock('Horde_Kolab_Session');
+ $session->expects($this->once())
+ ->method('getId')
+ ->will($this->returnValue('1'));
+ $anonymous = new Horde_Kolab_Session_Decorator_Base(
+ $session
+ );
+ $anonymous->getId();
+ }
+
+ public function testMethodGetmailGetsDelegated()
+ {
+ $session = $this->getMock('Horde_Kolab_Session');
+ $session->expects($this->once())
+ ->method('getMail')
+ ->will($this->returnValue('1'));
+ $anonymous = new Horde_Kolab_Session_Decorator_Base(
+ $session
+ );
+ $anonymous->getMail();
+ }
+
+ public function testMethodGetuidGetsDelegated()
+ {
+ $session = $this->getMock('Horde_Kolab_Session');
+ $session->expects($this->once())
+ ->method('getUid')
+ ->will($this->returnValue('1'));
+ $anonymous = new Horde_Kolab_Session_Decorator_Base(
+ $session
+ );
+ $anonymous->getUid();
+ }
+
+ public function testMethodGetnameGetsDelegated()
+ {
+ $session = $this->getMock('Horde_Kolab_Session');
+ $session->expects($this->once())
+ ->method('getName')
+ ->will($this->returnValue('1'));
+ $anonymous = new Horde_Kolab_Session_Decorator_Base(
+ $session
+ );
+ $anonymous->getName();
+ }
+
+ public function testMethodGetimapserverGetsDelegated()
+ {
+ $session = $this->getMock('Horde_Kolab_Session');
+ $session->expects($this->once())
+ ->method('getImapServer')
+ ->will($this->returnValue('1'));
+ $anonymous = new Horde_Kolab_Session_Decorator_Base(
+ $session
+ );
+ $anonymous->getImapServer();
+ }
+
+ public function testMethodGetfreebusyserverGetsDelegated()
+ {
+ $session = $this->getMock('Horde_Kolab_Session');
+ $session->expects($this->once())
+ ->method('getFreebusyServer')
+ ->will($this->returnValue('1'));
+ $anonymous = new Horde_Kolab_Session_Decorator_Base(
+ $session
+ );
+ $anonymous->getFreebusyServer();
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Test the log decorator.
+ *
+ * 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 log decorator.
+ *
+ * Copyright 2009-2010 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_Unit_Decorator_LoggedTest
+extends Horde_Kolab_Session_TestCase
+{
+ public function setUp()
+ {
+ parent::setUp();
+
+ $this->setupLogger();
+ }
+
+ public function testMethodConnectHasPostconditionThatASuccessfulConnectionGetsLogged()
+ {
+ $session = $this->getMock('Horde_Kolab_Session');
+ $session->expects($this->once())
+ ->method('connect')
+ ->with(array('password' => 'pass'));
+ $session->expects($this->once())
+ ->method('getId')
+ ->will($this->returnValue('somebody@example.org'));
+ $this->logger->expects($this->once())
+ ->method('__call')
+ ->with(
+ 'info',
+ array(
+ 'Connected Kolab session for "somebody@example.org".'
+ )
+ );
+ $logged = new Horde_Kolab_Session_Decorator_Logged(
+ $session, $this->logger
+ );
+ $logged->connect(array('password' => 'pass'));
+ }
+
+ public function testMethodConnectHasPostconditionThatAnUnsuccessfulConnectionGetsLogged()
+ {
+ $session = $this->getMock('Horde_Kolab_Session');
+ $session->expects($this->once())
+ ->method('connect')
+ ->will($this->throwException(new Horde_Kolab_Session_Exception('Error.')));
+ $session->expects($this->once())
+ ->method('getMail')
+ ->will($this->returnValue('somebody@example.org'));
+ $this->logger->expects($this->once())
+ ->method('__call')
+ ->with(
+ 'err',
+ array(
+ 'Failed to connect Kolab session for "somebody@example.org". Error was: Error.'
+ )
+ );
+ $logged = new Horde_Kolab_Session_Decorator_Logged(
+ $session, $this->logger
+ );
+ try {
+ $logged->connect(array('password' => 'pass'));
+ $this->fail('No Exception!');
+ } catch (Horde_Kolab_Session_Exception $e) {
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Test the storing decorator.
+ *
+ * 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 storing decorator.
+ *
+ * Copyright 2009-2010 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_Unit_Decorator_StoredTest
+extends Horde_Kolab_Session_TestCase
+{
+ public function setUp()
+ {
+ parent::setUp();
+
+ $this->setupStorage();
+ }
+
+ public function testShutdownSavesExport()
+ {
+ $this->storage->expects($this->once())
+ ->method('load')
+ ->will($this->returnValue(array()));
+ $this->storage->expects($this->once())
+ ->method('save')
+ ->with(array('export'));
+ $session = $this->getMock('Horde_Kolab_Session');
+ $session->expects($this->once())
+ ->method('export')
+ ->will($this->returnValue(array('export')));
+ $stored = new Horde_Kolab_Session_Decorator_Stored($session, $this->storage);
+ $stored->connect();
+ $stored->shutdown();
+ }
+
+ /**
+ * @expectedException Horde_Kolab_Session_Exception
+ */
+ public function testImportException()
+ {
+ $this->storage->expects($this->once())
+ ->method('load')
+ ->will($this->returnValue(array()));
+ $session = $this->getMock('Horde_Kolab_Session');
+ $stored = new Horde_Kolab_Session_Decorator_Stored($session, $this->storage);
+ $stored->import(array('import'));
+ }
+
+ public function testShutdownSavesPurged()
+ {
+ $this->storage->expects($this->once())
+ ->method('load')
+ ->will($this->returnValue(array()));
+ $this->storage->expects($this->once())
+ ->method('save')
+ ->with(array());
+ $session = $this->getMock('Horde_Kolab_Session');
+ $stored = new Horde_Kolab_Session_Decorator_Stored($session, $this->storage);
+ $stored->purge();
+ $stored->shutdown();
+ }
+
+ public function testMethodConnectGetsDelegated()
+ {
+ $this->storage->expects($this->once())
+ ->method('load')
+ ->will($this->returnValue(array()));
+ $session = $this->getMock('Horde_Kolab_Session');
+ $session->expects($this->once())
+ ->method('export')
+ ->will($this->returnValue(array()));
+ $session->expects($this->once())
+ ->method('connect')
+ ->with(array('password' => 'pass'));
+ $stored = new Horde_Kolab_Session_Decorator_Stored($session, $this->storage);
+ $stored->connect(array('password' => 'pass'));
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Test the mock storage driver.
+ *
+ * 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 mock storage driver.
+ *
+ * Copyright 2009-2010 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_Unit_Storage_MockTest extends Horde_Kolab_Session_TestCase
+{
+ public function testMethodLoadHasResultBooleanFalse()
+ {
+ $storage = new Horde_Kolab_Session_Storage_Mock('test');
+ $this->assertFalse($storage->load());
+ }
+
+ public function testMethodSaveHasPostconditionThatTheSessionDataWasSaved()
+ {
+ $array = array(1);
+ $storage = new Horde_Kolab_Session_Storage_Mock('test');
+ $storage->save($array);
+ $this->assertSame($array, $storage->session);
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Test the session based storage driver.
+ *
+ * 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 session based storage driver.
+ *
+ * Copyright 2009-2010 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_Unit_Storage_SessionTest extends Horde_Kolab_Session_TestCase
+{
+ public function testLoad()
+ {
+ $_SESSION['kolab_session'] = array('data');
+ $storage = new Horde_Kolab_Session_Storage_Session($session);
+ $this->assertEquals($storage->load(), array('data'));
+
+ }
+
+ public function testEmpty()
+ {
+ $storage = new Horde_Kolab_Session_Storage_Session($session);
+ $this->assertEquals($storage->load(), array());
+
+ }
+
+ public function testSave()
+ {
+ $storage = new Horde_Kolab_Session_Storage_Session($session);
+ $storage->save(array('data'));
+ $this->assertEquals($_SESSION['kolab_session'], array('data'));
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Test the valid check.
+ *
+ * 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 valid check.
+ *
+ * Copyright 2009-2010 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_Unit_Valid_BaseTest extends Horde_Kolab_Session_TestCase
+{
+ public function testMethodIsvalidHasResultBooleanTrueIfTheSessionIsNotConnectedAndTheCurrentUserIsAnonymous()
+ {
+ $auth = false;
+ $session = $this->getMock('Horde_Kolab_Session');
+ $session->expects($this->once())
+ ->method('getMail')
+ ->will($this->returnValue(''));
+ $valid = new Horde_Kolab_Session_Valid_Base($session, $auth);
+ $this->assertTrue($valid->validate());
+ }
+
+ public function testMethodIsvalidHasResultBooleanFalseIfTheSessionIsNotConnected()
+ {
+ $auth = 'mail@example.org';
+ $session = $this->getMock('Horde_Kolab_Session');
+ $session->expects($this->once())
+ ->method('getMail')
+ ->will($this->returnValue(''));
+ $valid = new Horde_Kolab_Session_Valid_Base($session, $auth);
+ $this->assertFalse($valid->validate());
+ }
+
+ public function testMethodIsvalidHasResultBooleanFalseIfTheMailOfTheCurrentUserDoesNotMatchTheCurrentUserOfTheSession()
+ {
+ $auth = 'somebody@example.org';
+ $session = $this->getMock('Horde_Kolab_Session');
+ $session->expects($this->once())
+ ->method('getMail')
+ ->will($this->returnValue('mail@example.org'));
+ $valid = new Horde_Kolab_Session_Valid_Base($session, $auth);
+ $this->assertFalse($valid->validate());
+ }
+
+ public function testMethodIsvalidHasResultBooleanTrueIfTheMailOfTheCurrentUserMatchesTheCurrentUserOfTheSessionAndNoNewUserWasSet()
+ {
+ $auth = 'mail@example.org';
+ $session = $this->getMock('Horde_Kolab_Session');
+ $session->expects($this->once())
+ ->method('getMail')
+ ->will($this->returnValue('mail@example.org'));
+ $valid = new Horde_Kolab_Session_Valid_Base($session, $auth);
+ $this->assertTrue($valid->validate());
+ }
+
+ public function testMethodIsvalidHasResultBooleanFalseIfTheMailOfTheCurrentUserMatchesTheCurrentUserOfTheSessionAndTheNewUserMatchesNeitherTheCurrentUserMailAndUid()
+ {
+ $auth = 'mail@example.org';
+ $session = $this->getMock('Horde_Kolab_Session');
+ $session->expects($this->once())
+ ->method('getMail')
+ ->will($this->returnValue('mail@example.org'));
+ $valid = new Horde_Kolab_Session_Valid_Base($session, $auth);
+ $this->assertFalse($valid->validate('somebody@example.org'));
+ }
+
+ public function testMethodIsvalidHasResultBooleanTrueIfTheMailOfTheCurrentUserMatchesTheCurrentUserOfTheSessionAndTheNewUserMatchesEitherTheCurrentUserMailAndUid()
+ {
+ $auth = 'mail@example.org';
+ $session = $this->getMock('Horde_Kolab_Session');
+ $session->expects($this->once())
+ ->method('getMail')
+ ->will($this->returnValue('mail@example.org'));
+ $valid = new Horde_Kolab_Session_Valid_Base($session, $auth);
+ $this->assertTrue($valid->validate('mail@example.org'));
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Test the log decorator for validators.
+ *
+ * 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 log decorator for validators.
+ *
+ * Copyright 2009-2010 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_Unit_Valid_Decorator_LoggedTest
+extends Horde_Kolab_Session_TestCase
+{
+ public function setUp()
+ {
+ parent::setUp();
+
+ $this->setupLogger();
+ }
+
+ public function testMethodValidateHasPostconditionThatAnInvalidSessionGetsLogged()
+ {
+ $auth = 'auth@example.org';
+ $session = $this->getMock('Horde_Kolab_Session');
+ $session->expects($this->exactly(2))
+ ->method('getMail')
+ ->will($this->returnValue('somebody@example.org'));
+ $this->logger->expects($this->exactly(2))
+ ->method('__call')
+ ->with(
+ 'info',
+ $this->logicalOr(
+ array('Invalid Kolab session for current user "auth@example.org" and requested user "nobody@example.org".'),
+ array('Validating Kolab session for current user "auth@example.org", requested user "nobody@example.org", and stored user "somebody@example.org".')
+ )
+ );
+ $logged = new Horde_Kolab_Session_Decorator_Logged(
+ $session, $this->logger
+ );
+ $valid = new Horde_Kolab_Session_Valid_Base($session, $auth);
+ $logged = new Horde_Kolab_Session_Valid_Decorator_Logged(
+ $valid, $this->logger
+ );
+ $this->assertFalse($logged->validate('nobody@example.org'));
+ }
+
+ public function testMethodValidateGetsDelegated()
+ {
+ $valid = $this->getMock('Horde_Kolab_Session_Valid');
+ $valid->expects($this->once())
+ ->method('validate')
+ ->will($this->returnValue(true));
+ $valid->expects($this->once())
+ ->method('getSession')
+ ->will($this->returnValue($this->getMock('Horde_Kolab_Session')));
+ $logged = new Horde_Kolab_Session_Valid_Decorator_Logged(
+ $valid, $this->logger
+ );
+ $this->assertTrue($logged->validate());
+ }
+
+ public function testMethodGetsessionGetsDelegated()
+ {
+ $valid = $this->getMock('Horde_Kolab_Session_Valid');
+ $valid->expects($this->once())
+ ->method('getSession');
+ $logged = new Horde_Kolab_Session_Valid_Decorator_Logged($valid, $this->logger);
+ $logged->getSession();
+ }
+
+ public function testMethodGetauthGetsDelegated()
+ {
+ $valid = $this->getMock('Horde_Kolab_Session_Valid');
+ $valid->expects($this->once())
+ ->method('getAuth');
+ $logged = new Horde_Kolab_Session_Valid_Decorator_Logged($valid, $this->logger);
+ $logged->getAuth();
+ }
+}
\ No newline at end of file