/** * set database connection shared with Tinebase_EmailUser::DOVECOT_IMAP_COMBINED backend */ protected function _getDb() { $dovecotCombined = Tinebase_EmailUser::getInstance(Tinebase_Config::IMAP); if (!$dovecotCombined instanceof Tinebase_EmailUser_Imap_DovecotCombined) { throw new Tinebase_Exception_UnexpectedValue('IMAP backend must be instance of Tinebase_EmailUser_Imap_DovecotCombined'); } $this->_db = $dovecotCombined->getDb(); }
/** * Sets up the fixture. * This method is called before a test is executed. * * @access protected */ protected function setUp() { $this->_config = Tinebase_Config::getInstance()->getConfigAsArray(Tinebase_Config::IMAP); if (!isset($this->_config['backend']) || !(ucfirst($this->_config['backend']) == Tinebase_EmailUser::DOVECOT_IMAP) || $this->_config['active'] != true) { $this->markTestSkipped('Dovecot MySQL backend not configured or not enabled'); } $this->_backend = Tinebase_EmailUser::getInstance(Tinebase_Config::IMAP); $personas = Zend_Registry::get('personas'); $this->_objects['user'] = clone $personas['jsmith']; $this->_objects['addedUsers'] = array(); }
/** * Sets up the fixture. * This method is called before a test is executed. * * @access protected */ protected function setUp() { $this->_config = Tinebase_Config::getInstance()->get(Tinebase_Config::IMAP, new Tinebase_Config_Struct())->toArray(); if (!isset($this->_config['backend']) || !('Imap_' . ucfirst($this->_config['backend']) == Tinebase_EmailUser::IMAP_DOVECOT) || $this->_config['active'] != true) { $this->markTestSkipped('Dovecot MySQL backend not configured or not enabled'); } $this->_backend = Tinebase_EmailUser::getInstance(Tinebase_Config::IMAP); $personas = Zend_Registry::get('personas'); $this->_objects['user'] = clone $personas['jsmith']; //$this->_objects['user']->setId(Tinebase_Record_Abstract::generateUID()); $this->_objects['addedUsers'] = array(); $this->_objects['fullUsers'] = array(); }
/** * Sets up the fixture. * This method is called before a test is executed. * * @access protected */ protected function setUp() { $this->_config = Tinebase_Config::getInstance()->get(Tinebase_Config::IMAP, new Tinebase_Config_Struct())->toArray(); if (!isset($this->_config['backend']) || !('Imap_' . ucfirst($this->_config['backend']) == Tinebase_EmailUser::IMAP_DOVECOT) || $this->_config['active'] != true) { $this->markTestSkipped('Dovecot MySQL backend not configured or not enabled'); } if (Tinebase_User::getConfiguredBackend() === Tinebase_User::ACTIVEDIRECTORY) { // error: Zend_Ldap_Exception: 0x44 (Already exists; 00002071: samldb: Account name (sAMAccountName) // 'tine20phpunituser' already in use!): adding: cn=PHPUnit User Tine 2.0,cn=Users,dc=example,dc=org $this->markTestSkipped('skipped for ad backends as it does not allow duplicate CNs'); } $this->_backend = Tinebase_EmailUser::getInstance(Tinebase_Config::IMAP); $personas = Zend_Registry::get('personas'); $this->_objects['user'] = clone $personas['jsmith']; //$this->_objects['user']->setId(Tinebase_Record_Abstract::generateUID()); $this->_objects['addedUsers'] = array(); $this->_objects['fullUsers'] = array(); }
/** * return an instance of the current user backend * * @param string $backendType name of the user backend * @return Tinebase_User_Abstract * @throws Tinebase_Exception_InvalidArgument */ public static function factory($backendType) { $options = self::getBackendConfiguration(); // this is a dangerous TRACE as there might be passwords in here! //if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' // . print_r($options, TRUE)); $options['plugins'] = array(); // manage email user settings if (Tinebase_EmailUser::manages(Tinebase_Config::IMAP)) { try { $options['plugins'][] = Tinebase_EmailUser::getInstance(Tinebase_Config::IMAP); } catch (Exception $e) { if (Tinebase_Core::isLogLevel(Zend_Log::ERR)) { Tinebase_Core::getLogger()->err(__METHOD__ . '::' . __LINE__ . ' Could not add IMAP EmailUser plugin: ' . $e); } } } if (Tinebase_EmailUser::manages(Tinebase_Config::SMTP)) { try { $options['plugins'][] = Tinebase_EmailUser::getInstance(Tinebase_Config::SMTP); } catch (Exception $e) { if (Tinebase_Core::isLogLevel(Zend_Log::ERR)) { Tinebase_Core::getLogger()->err(__METHOD__ . '::' . __LINE__ . ' Could not add SMTP EmailUser plugin: ' . $e); } } } switch ($backendType) { case self::ACTIVEDIRECTORY: $result = new Tinebase_User_ActiveDirectory($options); break; case self::LDAP: // manage samba sam? if (isset(Tinebase_Core::getConfig()->samba) && Tinebase_Core::getConfig()->samba->get('manageSAM', FALSE) == true) { $options['plugins'][] = new Tinebase_User_Plugin_Samba(Tinebase_Core::getConfig()->samba->toArray()); } $result = new Tinebase_User_Ldap($options); break; case self::SQL: $result = new Tinebase_User_Sql($options); break; case self::TYPO3: $result = new Tinebase_User_Typo3($options); break; default: throw new Tinebase_Exception_InvalidArgument("User backend type {$backendType} not implemented."); } if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Created user backend of type ' . $backendType); } return $result; }
/** * testForwardedAlias * * @see 0007066: postfix email user: allow wildcard alias forwarding */ public function testForwardedAlias() { $user = $this->testAddUser(); // check destinations $db = Tinebase_EmailUser::getInstance(Tinebase_Config::SMTP)->getDb(); $select = $db->select()->from(array('smtp_destinations'))->where($db->quoteIdentifier('userid') . ' = ?', $user->getId()); $stmt = $db->query($select); $queryResult = $stmt->fetchAll(); $stmt->closeCursor(); $this->assertEquals(6, count($queryResult), print_r($queryResult, TRUE)); $expectedDestinations = array('bla@' . $this->_mailDomain => array('unittest@' . $this->_mailDomain, 'test@' . $this->_mailDomain), 'blubb@' . $this->_mailDomain => array('unittest@' . $this->_mailDomain, 'test@' . $this->_mailDomain), 'phpunit@' . $this->_mailDomain => array('unittest@' . $this->_mailDomain, 'test@' . $this->_mailDomain)); foreach ($expectedDestinations as $source => $destinations) { $foundDestinations = array(); foreach ($queryResult as $row) { if ($row['source'] === $source) { $foundDestinations[] = $row['destination']; } } $this->assertEquals(2, count($foundDestinations)); $this->assertTrue($foundDestinations == $destinations, print_r($destinations, TRUE)); } }
/** * return an instance of the current user backend * * @param string $backendType name of the user backend * @return Tinebase_User_Abstract * @throws Tinebase_Exception_InvalidArgument */ public static function factory($backendType) { $options = self::getBackendConfiguration(); if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) { Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r($options, TRUE)); } $options['plugins'] = array(); // manage email user settings if (Tinebase_EmailUser::manages(Tinebase_Config::IMAP)) { $options['plugins'][] = Tinebase_EmailUser::getInstance(Tinebase_Config::IMAP); } if (Tinebase_EmailUser::manages(Tinebase_Config::SMTP)) { $options['plugins'][] = Tinebase_EmailUser::getInstance(Tinebase_Config::SMTP); } switch ($backendType) { case self::LDAP: // manage samba sam? if (isset(Tinebase_Core::getConfig()->samba) && Tinebase_Core::getConfig()->samba->get('manageSAM', FALSE) == true) { $options['plugins'][] = new Tinebase_User_Plugin_Samba(Tinebase_Core::getConfig()->samba->toArray()); } $result = new Tinebase_User_Ldap($options); break; case self::SQL: $result = new Tinebase_User_Sql($options); break; case self::TYPO3: $result = new Tinebase_User_Typo3($options); break; default: throw new Tinebase_Exception_InvalidArgument("User backend type {$backendType} not implemented."); } if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) { Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Created user backend of type ' . $backendType); } return $result; }