fixes tests for samba ad
authorPhilipp Schüle <p.schuele@metaways.de>
Tue, 5 Apr 2016 16:18:07 +0000 (18:18 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Tue, 19 Apr 2016 13:12:28 +0000 (15:12 +0200)
* use getDefaultGroup fns instead of hard coded group names
* skip some tests that try to create multiple users with same CN
* obey to default ad password complexity
* users and groups can't have the same name in ad default setup
 (same base dn)
* disabled some test (users have no account
 email addresses with samba ad)

... and makes sure that users/groups are deleted
 in TestCase::tearDown, too

Change-Id: I80440ac13006bd0942c43daefabfbe289fb7ea19
Reviewed-on: http://gerrit.tine20.com/customers/3007
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
35 files changed:
tests/tine20/Admin/CliTest.php
tests/tine20/Admin/ControllerTest.php
tests/tine20/Admin/JsonTest.php
tests/tine20/Admin/files/test.csv
tests/tine20/Admin/files/testHeadline.csv
tests/tine20/Admin/files/tine_user3.csv
tests/tine20/Calendar/Controller/EventTests.php
tests/tine20/Calendar/Convert/Event/VCalendar/GenericTest.php
tests/tine20/Calendar/Frontend/ActiveSyncTest.php
tests/tine20/Calendar/Frontend/WebDAV/EventTest.php
tests/tine20/Calendar/Frontend/iMIPTest.php
tests/tine20/Calendar/Model/AttenderTests.php
tests/tine20/Calendar/Setup/DemoDataTests.php
tests/tine20/Courses/JsonTest.php
tests/tine20/Crm/Acl/RolesTest.php
tests/tine20/Sales/InvoiceControllerTests.php
tests/tine20/Tasks/Frontend/WebDAV/TaskTest.php
tests/tine20/Tasks/JsonTest.php
tests/tine20/TestCase.php
tests/tine20/Timetracker/JsonTest.php
tests/tine20/Tinebase/AccountTest.php
tests/tine20/Tinebase/Acl/RolesTest.php
tests/tine20/Tinebase/ControllerTest.php
tests/tine20/Tinebase/GroupTest.php
tests/tine20/Tinebase/TagsTest.php
tests/tine20/Tinebase/User/AbstractTest.php
tests/tine20/Tinebase/User/EmailUser/Imap/DovecotTest.php
tests/tine20/Tinebase/User/EmailUser/Smtp/PostfixTest.php
tests/tine20/Tinebase/UserTest.php
tests/tine20/Tinebase/WebDav/Plugin/PrincipalSearchTest.php
tests/tine20/Tinebase/WebDav/PrincipalBackendTest.php
tine20/Calendar/Setup/DemoData.php
tine20/Courses/Config.php
tine20/Courses/Controller/Course.php
tine20/Tinebase/Setup/DemoData/Abstract.php

index e557bdc..b07538a 100644 (file)
@@ -4,16 +4,11 @@
  * 
  * @package     Admin
  * @license     http://www.gnu.org/licenses/agpl.html
- * @copyright   Copyright (c) 2009-2013 Metaways Infosystems GmbH (http://www.metaways.de)
+ * @copyright   Copyright (c) 2009-2016 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Philipp Schüle <p.schuele@metaways.de>
  */
 
 /**
- * Test helper
- */
-require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'TestHelper.php';
-
-/**
  * Test class for Tinebase_Admin
  */
 class Admin_CliTest extends TestCase
@@ -29,14 +24,8 @@ class Admin_CliTest extends TestCase
      * @var array test objects
      */
     protected $objects = array();
-    
-    /**
-     * Sets up the fixture.
-     * This method is called before a test is executed.
-     *
-     * @access protected
-     */
-    
+
+
     /**
      * config groups
      * 
@@ -47,7 +36,13 @@ class Admin_CliTest extends TestCase
      * @var Tinebase_Record_RecordSet
      */
     protected $_groupsToDelete = null;
-    
+
+    /**
+     * Sets up the fixture.
+     * This method is called before a test is executed.
+     *
+     * @access protected
+     */
     protected function setUp()
     {
         parent::setUp();
index f37c808..4da5e3a 100644 (file)
@@ -47,7 +47,7 @@ class Admin_ControllerTest extends TestCase
 //            'accountLoginName'      => 'tine20phpunit',
 //            'accountStatus'         => 'enabled',
 //            'accountExpires'        => NULL,
-//            'accountPrimaryGroup'   => Tinebase_Group::getInstance()->getGroupByName('Users')->id,
+//            'accountPrimaryGroup'   => Tinebase_Group::getInstance()->getDefaultGroup()->id,
 //            'accountLastName'       => 'Tine 2.0',
 //            'accountFirstName'      => 'PHPUnit',
 //            'accountEmailAddress'   => 'phpunit@metaways.de'
@@ -57,7 +57,7 @@ class Admin_ControllerTest extends TestCase
 //            'accountLoginName'      => 'tine20phpunit-updated',
 //            'accountStatus'         => 'disabled',
 //            'accountExpires'        => NULL,
-//            'accountPrimaryGroup'   => Tinebase_Group::getInstance()->getGroupByName('Users')->id,
+//            'accountPrimaryGroup'   => Tinebase_Group::getInstance()->getDefaultGroup()->id,
 //            'accountLastName'       => 'Tine 2.0 Updated',
 //            'accountFirstName'      => 'PHPUnit Updated',
 //            'accountEmailAddress'   => 'phpunit@tine20.org'
index 4051d44..d41fb97 100644 (file)
@@ -38,21 +38,21 @@ class Admin_JsonTest extends TestCase
         $this->_json = new Admin_Frontend_Json();
         
         $this->objects['initialGroup'] = new Tinebase_Model_Group(array(
-            'name'          => 'tine20phpunit',
+            'name'          => 'tine20phpunitgroup',
             'description'   => 'initial group'
         ));
         
         $this->objects['updatedGroup'] = new Tinebase_Model_Group(array(
-            'name'          => 'tine20phpunit',
+            'name'          => 'tine20phpunitgroup',
             'description'   => 'updated group'
         ));
-        
+
         $this->objects['user'] = new Tinebase_Model_FullUser(array(
             'accountLoginName'      => 'tine20phpunit',
             'accountDisplayName'    => 'tine20phpunit',
             'accountStatus'         => 'enabled',
             'accountExpires'        => NULL,
-            'accountPrimaryGroup'   => Tinebase_Group::getInstance()->getGroupByName('Users')->getId(),
+            'accountPrimaryGroup'   => Tinebase_Group::getInstance()->getDefaultGroup()->getId(),
             'accountLastName'       => 'Tine 2.0',
             'accountFirstName'      => 'PHPUnit',
             'accountEmailAddress'   => 'phpunit@' . $this->_getMailDomain()
@@ -103,26 +103,33 @@ class Admin_JsonTest extends TestCase
     public function testSaveAccount()
     {
         $this->testAddGroup();
-        
-        $accountData = $this->objects['user']->toArray();
-        $accountData['accountPrimaryGroup'] = Tinebase_Group::getInstance()->getGroupByName('tine20phpunit')->getId();
-        $accountData['accountPassword'] = 'test';
-        $accountData['accountPassword2'] = 'test';
+
+        $accountData = $this->_getUserArrayWithPw();
+        $accountData['accountPrimaryGroup'] = Tinebase_Group::getInstance()->getGroupByName('tine20phpunitgroup')->getId();
         $accountData['accountFirstName'] = 'PHPUnitup';
         
         $account = $this->_createUser($accountData);
         
         $this->assertTrue(is_array($account));
         $this->assertEquals('PHPUnitup', $account['accountFirstName']);
-        $this->assertEquals(Tinebase_Group::getInstance()->getGroupByName('tine20phpunit')->getId(), $account['accountPrimaryGroup']['id']);
+        $this->assertEquals(Tinebase_Group::getInstance()->getGroupByName('tine20phpunitgroup')->getId(), $account['accountPrimaryGroup']['id']);
         $this->assertTrue(! empty($account['accountId']), 'no account id');
         // check password
-        $authResult = Tinebase_Auth::getInstance()->authenticate($account['accountLoginName'], 'test');
+        $authResult = Tinebase_Auth::getInstance()->authenticate($account['accountLoginName'], $accountData['accountPassword']);
         $this->assertTrue($authResult->isValid());
         
         $account['accountPrimaryGroup'] = $accountData['accountPrimaryGroup'];
         return $account;
     }
+
+    protected function _getUserArrayWithPw()
+    {
+        $accountData = $this->objects['user']->toArray();
+        $pw = 'test7652BA';
+        $accountData['accountPassword'] = $pw;
+        $accountData['accountPassword2'] = $pw;
+        return $accountData;
+    }
     
     /**
      * create user account
@@ -133,7 +140,7 @@ class Admin_JsonTest extends TestCase
     protected function _createUser($data = null)
     {
         if ($data === null) {
-            $data = $this->objects['user']->toArray();
+            $data = $this->_getUserArrayWithPw();
         }
         $this->_usernamesToDelete[] = $data['accountLoginName'];
         $user = $this->_json->saveUser($data);
@@ -227,10 +234,10 @@ class Admin_JsonTest extends TestCase
      */
     public function testSaveHiddenAccount()
     {
-        $accountData = $this->objects['user']->toArray();
+        $accountData = $this->_getUserArrayWithPw();
         $accountData['visibility'] = Tinebase_Model_User::VISIBILITY_HIDDEN;
         $accountData['container_id'] = 0;
-        
+
         $account = $this->_createUser($accountData);
         
         $this->assertTrue(is_array($account));
@@ -250,7 +257,7 @@ class Admin_JsonTest extends TestCase
         $internalContainer = Tinebase_Container::getInstance()->get($account['container_id']['id']);
         Tinebase_Container::getInstance()->setGrants($internalContainer, new Tinebase_Record_RecordSet('Tinebase_Model_Grants'), TRUE, FALSE);
         
-        $account['groups'] = array($account['accountPrimaryGroup'], Tinebase_Group::getInstance()->getDefaultAdminGroup()->getId());
+        $account['groups'] = array(Tinebase_Group::getInstance()->getDefaultAdminGroup()->getId(), $account['groups']['results'][0]['id']);
         $account['container_id'] = $internalContainer->getId();
         $account = $this->_json->saveUser($account);
         
@@ -301,8 +308,8 @@ class Admin_JsonTest extends TestCase
     {
         $this->testAddGroup();
         
-        $accountData = $this->objects['user']->toArray();
-        $accountData['accountPrimaryGroup'] = Tinebase_Group::getInstance()->getGroupByName('tine20phpunit')->getId();
+        $accountData = $this->_getUserArrayWithPw();
+        $accountData['accountPrimaryGroup'] = Tinebase_Group::getInstance()->getGroupByName('tine20phpunitgroup')->getId();
         
         Admin_Controller_Group::getInstance()->delete(array($accountData['accountPrimaryGroup']));
         
@@ -376,10 +383,11 @@ class Admin_JsonTest extends TestCase
     public function testResetPassword()
     {
         $userArray = $this->testSaveAccount();
+
+        $pw = 'dpIg6komP';
+        $this->_json->resetPassword($userArray, $pw, false);
         
-        $this->_json->resetPassword($userArray, 'password', false);
-        
-        $authResult = Tinebase_Auth::getInstance()->authenticate($this->objects['user']->accountLoginName, 'password');
+        $authResult = Tinebase_Auth::getInstance()->authenticate($this->objects['user']->accountLoginName, $pw);
         $this->assertTrue($authResult->isValid());
     }
     
@@ -390,16 +398,7 @@ class Admin_JsonTest extends TestCase
      */
     public function testAccountContactModlog()
     {
-        $user = $this->_createUser(array(
-            'accountLoginName'      => 'tine20phpunit',
-            'accountDisplayName'    => 'tine20phpunit',
-            'accountStatus'         => 'enabled',
-            'accountExpires'        => NULL,
-            'accountPrimaryGroup'   => Tinebase_Group::getInstance()->getGroupByName('Users')->getId(),
-            'accountLastName'       => 'Tine 2.0',
-            'accountFirstName'      => 'PHPUnit',
-            'accountEmailAddress'   => 'phpunit@' . $this->_getMailDomain()
-        ));
+        $user = $this->_createUser();
         
         $contact = Addressbook_Controller_Contact::getInstance()->getContactByUserId($user['accountId']);
         
@@ -1202,7 +1201,7 @@ class Admin_JsonTest extends TestCase
         Admin_Controller_User::getInstance()->setAccountStatus($userArray['accountId'], Tinebase_Model_User::ACCOUNT_STATUS_DISABLED);
 
         // save group
-        $group = Tinebase_Group::getInstance()->getGroupByName('tine20phpunit');
+        $group = Tinebase_Group::getInstance()->getGroupByName('tine20phpunitgroup');
         $groupArray = $this->_json->getGroup($group->getId());
         $this->assertEquals(1, $groupArray['groupMembers']['totalcount']);
         $groupArray['container_id'] = $groupArray['container_id']['id'];
@@ -1224,7 +1223,7 @@ class Admin_JsonTest extends TestCase
 
         // save group
         // TODO generalize
-        $group = Tinebase_Group::getInstance()->getGroupByName('tine20phpunit');
+        $group = Tinebase_Group::getInstance()->getGroupByName('tine20phpunitgroup');
         $groupArray = $this->_json->getGroup($group->getId());
         $this->assertEquals(1, $groupArray['groupMembers']['totalcount']);
         $groupArray['container_id'] = $groupArray['container_id']['id'];
index b76f743..79a1003 100644 (file)
@@ -1,3 +1,3 @@
-Hans,Meister,hmeister,xyz,hmeister@tine20.org
-Heins,Master,hmaster,123,hmaster@tine20.org
-Hins,M�ster,hmoster,abc,hmoster@tine20.org
+Hans,Meister,hmeister,xyz5426+?,hmeister@tine20.org
+Heins,Master,hmaster,xyz5426+?,hmaster@tine20.org
+Hins,M�ster,hmoster,xyz5426+?,hmoster@tine20.org
index 1728ad0..9738088 100644 (file)
@@ -1,4 +1,4 @@
 firstname,lastname,loginname,password,email
-Hans,Meister,hmeister,xyz,hmeister@tine20.org
-Heins,Master,hmaster,123,hmaster@tine20.org
-Hins,M�ster,hmoster,abc,hmoster@tine20.org
+Hans,Meister,hmeister,xyz5426+?,hmeister@tine20.org
+Heins,Master,hmaster,xyz5426+?,hmaster@tine20.org
+Hins,M�ster,hmoster,xyz5426+?,hmoster@tine20.org
index b158258..82c56ae 100644 (file)
@@ -1 +1 @@
-firstname;lastname;loginname;password;email \r\rAnneli;Irmeli;irmeli;irmeli123;irmeli@tine20.org    \r\r
\ No newline at end of file
+firstname;lastname;loginname;password;email \r\rAnneli;Irmeli;irmeli;irmeli123!;irmeli@tine20.org\r\r
\ No newline at end of file
index 0a7b169..2842d36 100644 (file)
@@ -4,7 +4,7 @@
  * 
  * @package     Calendar
  * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
- * @copyright   Copyright (c) 2009-2014 Metaways Infosystems GmbH (http://www.metaways.de)
+ * @copyright   Copyright (c) 2009-2016 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Cornelius Weiss <c.weiss@metaways.de>
  */
 
@@ -28,7 +28,6 @@ class Calendar_Controller_EventTests extends Calendar_TestCase
     {
         parent::setUp();
         $this->_controller = Calendar_Controller_Event::getInstance();
-
     }
     
     /**
@@ -621,6 +620,10 @@ class Calendar_Controller_EventTests extends Calendar_TestCase
     
     public function testAttendeeGroupMembersResolving()
     {
+        if (Tinebase_User::getConfiguredBackend() === Tinebase_User::ACTIVEDIRECTORY) {
+            $this->markTestSkipped('only working in non-AD setups');
+        }
+
         $defaultUserGroup = Tinebase_Group::getInstance()->getDefaultGroup();
         Tinebase_Group::getInstance()->getDefaultAdminGroup();
         
@@ -731,7 +734,7 @@ class Calendar_Controller_EventTests extends Calendar_TestCase
     public function testAttendeeGroupMembersAddUser()
     {
         try {
-            // clenup if exists
+            // clean up if exists
             $cleanupUser = Tinebase_User::getInstance()->getFullUserByLoginName('testAttendeeGroupMembersAddUser');
             Tinebase_User::getInstance()->deleteUser($cleanupUser);
         } catch (Exception $e) {
@@ -756,17 +759,7 @@ class Calendar_Controller_EventTests extends Calendar_TestCase
         ));
         $persistentEvent = $this->_controller->create($event);
         
-        // create a new user
-        $newUser = Admin_Controller_User::getInstance()->create(new Tinebase_Model_FullUser(array(
-//            'accountId'             => 'dflkjgldfgdfgd',
-            'accountLoginName'      => 'testAttendeeGroupMembersAddUser',
-            'accountStatus'         => 'enabled',
-            'accountExpires'        => NULL,
-            'accountPrimaryGroup'   => $defaultGroup->getId(),
-            'accountLastName'       => 'Tine 2.0',
-            'accountFirstName'      => 'PHPUnit',
-            'accountEmailAddress'   => 'phpunit@metaways.de'
-        )), Zend_Registry::get('testConfig')->password, Zend_Registry::get('testConfig')->password);
+        $newUser = $this->_createNewUser();
         if (isset(Tinebase_Core::getConfig()->actionqueue)) {
             Tinebase_ActionQueue::getInstance()->processQueue(10000);
         }
@@ -822,17 +815,8 @@ class Calendar_Controller_EventTests extends Calendar_TestCase
             'role'      => Calendar_Model_Attender::ROLE_REQUIRED
         ));
         $persistentEvent = $this->_controller->create($event);
-        
-        // create a new user
-        $newUser = Admin_Controller_User::getInstance()->create(new Tinebase_Model_FullUser(array(
-            'accountLoginName'      => 'testAttendeeGroupMembersAddUser',
-            'accountStatus'         => 'enabled',
-            'accountExpires'        => NULL,
-            'accountPrimaryGroup'   => $defaultGroup->getId(),
-            'accountLastName'       => 'Tine 2.0',
-            'accountFirstName'      => 'PHPUnit',
-            'accountEmailAddress'   => 'phpunit@metaways.de'
-        )), Zend_Registry::get('testConfig')->password, Zend_Registry::get('testConfig')->password);
+
+        $newUser = $this->_createNewUser();
         if (isset(Tinebase_Core::getConfig()->actionqueue)) {
             Tinebase_ActionQueue::getInstance()->processQueue(10000);
         }
@@ -874,7 +858,22 @@ class Calendar_Controller_EventTests extends Calendar_TestCase
             ->filter('user_id', $newUser->contact_id);
         $this->assertEquals(0, count($user), 'deleted user is attender of new event, but should not be');
     }
-    
+
+    protected function _createNewUser()
+    {
+        $pw = Tinebase_Record_Abstract::generateUID(10) . '*A53x';
+        $newUser = Admin_Controller_User::getInstance()->create(new Tinebase_Model_FullUser(array(
+            'accountLoginName'      => 'testAttendeeGroupMembersAddUser',
+            'accountStatus'         => 'enabled',
+            'accountExpires'        => NULL,
+            'accountPrimaryGroup'   => Tinebase_Group::getInstance()->getDefaultGroup()->getId(),
+            'accountLastName'       => 'Tine 2.0',
+            'accountFirstName'      => 'PHPUnit',
+            'accountEmailAddress'   => 'phpunit@metaways.de'
+        )), $pw, $pw);
+        return $newUser;
+    }
+
     public function testRruleUntil()
     {
         $event = $this->_getEvent();
index 489b579..a3b16d9 100644 (file)
@@ -4,7 +4,7 @@
  * 
  * @package     Calendar
  * @license     http://www.gnu.org/licenses/agpl.html
- * @copyright   Copyright (c) 2011-2015 Metaways Infosystems GmbH (http://www.metaways.de)
+ * @copyright   Copyright (c) 2011-2016 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Lars Kneschke <l.kneschke@metaways.de>
  */
 
@@ -31,18 +31,6 @@ class Calendar_Convert_Event_VCalendar_GenericTest extends PHPUnit_Framework_Tes
     protected $_converter = null;
     
     /**
-     * Runs the test methods of this class.
-     *
-     * @access public
-     * @static
-     */
-    public static function main()
-    {
-        $suite  = new PHPUnit_Framework_TestSuite('Tine 2.0 Calendar WebDAV Generic Event Tests');
-        PHPUnit_TextUI_TestRunner::run($suite);
-    }
-
-    /**
      * Sets up the fixture.
      * This method is called before a test is executed.
      *
@@ -50,6 +38,11 @@ class Calendar_Convert_Event_VCalendar_GenericTest extends PHPUnit_Framework_Tes
      */
     protected function setUp()
     {
+        if (Tinebase_User::getConfiguredBackend() === Tinebase_User::ACTIVEDIRECTORY) {
+            // account email addresses are empty with AD backend
+            $this->markTestSkipped('skipped for ad backend');
+        }
+
         Calendar_Controller_Event::getInstance()->sendNotifications(false);
         Tinebase_TransactionManager::getInstance()->startTransaction(Tinebase_Core::getDb());
     }
index 0df9de5..9e28731 100644 (file)
@@ -794,6 +794,10 @@ Zeile 3</AirSyncBase:Data>
 
     public function testStatusUpdate($syncrotonFolder = null)
     {
+        if (Tinebase_User::getConfiguredBackend() === Tinebase_User::ACTIVEDIRECTORY) {
+            $this->markTestSkipped('only working in non-AD setups');
+        }
+
         if ($syncrotonFolder === null) {
             $syncrotonFolder = $this->testCreateFolder();
         }
index 2e21e40..2814525 100644 (file)
@@ -4,7 +4,7 @@
  * 
  * @package     Calendar
  * @license     http://www.gnu.org/licenses/agpl.html
- * @copyright   Copyright (c) 2011-2014 Metaways Infosystems GmbH (http://www.metaways.de)
+ * @copyright   Copyright (c) 2011-2016 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Lars Kneschke <l.kneschke@metaways.de>
  */
 
@@ -24,6 +24,11 @@ class Calendar_Frontend_WebDAV_EventTest extends Calendar_TestCase
      */
     public function setUp()
     {
+        if (Tinebase_User::getConfiguredBackend() === Tinebase_User::ACTIVEDIRECTORY) {
+            // account email addresses are empty with AD backend
+            $this->markTestSkipped('skipped for ad backend');
+        }
+
         parent::setUp();
         
         $this->objects['initialContainer'] = Tinebase_Container::getInstance()->addContainer(new Tinebase_Model_Container(array(
@@ -449,7 +454,7 @@ class Calendar_Frontend_WebDAV_EventTest extends Calendar_TestCase
         $vcalendar = stream_get_contents($event->get());
         
         //var_dump($vcalendar);
-        
+
         $this->assertContains('SUMMARY:New Event', $vcalendar);
         $this->assertContains('ORGANIZER;CN=', $vcalendar);
     }
index 209e9c7..afb88de 100644 (file)
@@ -4,7 +4,7 @@
  * 
  * @package     Calendar
  * @license     http://www.gnu.org/licenses/agpl.html
- * @copyright   Copyright (c) 2011-2015 Metaways Infosystems GmbH (http://www.metaways.de)
+ * @copyright   Copyright (c) 2011-2016 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Philipp Schüle <p.schuele@metaways.de>
  * 
  * @todo        add test testOrganizerSendBy
@@ -43,18 +43,6 @@ class Calendar_Frontend_iMIPTest extends TestCase
     * @var Felamimail_Controller_MessageTest
     */
     protected $_emailTestClass;
-        
-    /**
-     * Runs the test methods of this class.
-     *
-     * @access public
-     * @static
-     */
-    public static function main()
-    {
-        $suite  = new PHPUnit_Framework_TestSuite('Tine 2.0 Calendar iMIP Tests');
-        PHPUnit_TextUI_TestRunner::run($suite);
-    }
 
     /**
      * Sets up the fixture.
@@ -64,6 +52,11 @@ class Calendar_Frontend_iMIPTest extends TestCase
      */
     protected function setUp()
     {
+        if (Tinebase_User::getConfiguredBackend() === Tinebase_User::ACTIVEDIRECTORY) {
+            // account email addresses are empty with AD backend
+            $this->markTestSkipped('skipped for ad backend');
+        }
+
         Calendar_Controller_Event::getInstance()->sendNotifications(true);
         
         Calendar_Config::getInstance()->set(Calendar_Config::DISABLE_EXTERNAL_IMIP, false);
index 3343c32..477ad05 100644 (file)
@@ -45,6 +45,10 @@ class Calendar_Model_AttenderTests extends Calendar_TestCase
      */
     public function testEmailsToAttendee()
     {
+        if (Tinebase_User::getConfiguredBackend() === Tinebase_User::ACTIVEDIRECTORY) {
+            $this->markTestSkipped('only working in non-AD setups');
+        }
+
         $event = $this->_getEvent();
         
         $persistentEvent = Calendar_Controller_Event::getInstance()->create($event);
@@ -94,8 +98,10 @@ class Calendar_Model_AttenderTests extends Calendar_TestCase
      */
     public function testEmailsToAttendeeWithGroups()
     {
-        if (Tinebase_User::getConfiguredBackend() === Tinebase_User::LDAP) {
-            $this->markTestSkipped('FIXME: Does not work with LDAP backend (full test suite run only)');
+        if (Tinebase_User::getConfiguredBackend() === Tinebase_User::LDAP ||
+            Tinebase_User::getConfiguredBackend() === Tinebase_User::ACTIVEDIRECTORY
+        ) {
+            $this->markTestSkipped('FIXME: Does not work with LDAP/AD backend');
         }
 
         $event = $this->_getEvent();
index cdc009b..7b4849f 100644 (file)
@@ -24,14 +24,20 @@ class Calendar_Setup_DemoDataTests extends TestCase
         
         $pwulf = Tinebase_User::getInstance()->getFullUserByLoginName('pwulf');
         
-        $businessCalendar = Tinebase_Container::getInstance()->getContainerByName('Calendar', 'Business', Tinebase_Model_Container::TYPE_PERSONAL, $pwulf->getId());
-        $sharedCalendar = Tinebase_Container::getInstance()->getContainerByName('Calendar', 'Shared Calendar', Tinebase_Model_Container::TYPE_SHARED);
+        $businessCalendar = Tinebase_Container::getInstance()->getContainerByName(
+            'Calendar', 'Business', Tinebase_Model_Container::TYPE_PERSONAL, $pwulf->getId());
+        $sharedCalendar = Tinebase_Container::getInstance()->getContainerByName(
+            'Calendar', 'Shared Calendar', Tinebase_Model_Container::TYPE_SHARED);
         $cce = Calendar_Controller_Event::getInstance();
-        $filter = new Calendar_Model_EventFilter(array(array('field' => 'container_id', 'operator' => 'equals', 'value' => $businessCalendar->getId())),'AND');
+        $filter = new Calendar_Model_EventFilter(array(
+            array('field' => 'container_id', 'operator' => 'equals', 'value' => $businessCalendar->getId())
+        ),'AND');
         $businessEvents = $cce->search($filter);
         $cce->deleteByFilter($filter);
         
-        $filter = new Calendar_Model_EventFilter(array(array('field' => 'container_id', 'operator' => 'equals', 'value' => $sharedCalendar->getId())),'AND');
+        $filter = new Calendar_Model_EventFilter(array(
+            array('field' => 'container_id', 'operator' => 'equals', 'value' => $sharedCalendar->getId())
+        ),'AND');
         $sharedEvents = $cce->search($filter);
         $cce->deleteByFilter($filter);
         
index 9684308..3b92ce3 100644 (file)
@@ -4,16 +4,11 @@
  * 
  * @package     Courses
  * @license     http://www.gnu.org/licenses/agpl.html
- * @copyright   Copyright (c) 2009-2013 Metaways Infosystems GmbH (http://www.metaways.de)
+ * @copyright   Copyright (c) 2009-2016 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Philipp Schüle <p.schuele@metaways.de>
  */
 
 /**
- * Test helper
- */
-require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'TestHelper.php';
-
-/**
  * Test class for Courses_Frontend_Json
  */
 class Courses_JsonTest extends TestCase
@@ -90,7 +85,11 @@ class Courses_JsonTest extends TestCase
         )));
         
         $this->_groupsToDelete = new Tinebase_Record_RecordSet('Tinebase_Model_Group');
-        foreach (array(Courses_Config::INTERNET_ACCESS_GROUP_ON, Courses_Config::INTERNET_ACCESS_GROUP_FILTERED, Courses_Config::STUDENTS_GROUP) as $configgroup) {
+        foreach (array(
+                     Courses_Config::INTERNET_ACCESS_GROUP_ON,
+                     Courses_Config::INTERNET_ACCESS_GROUP_FILTERED,
+                     Courses_Config::STUDENTS_GROUP
+                 ) as $configgroup) {
             $this->_configGroups[$configgroup] = Tinebase_Group::getInstance()->create(new Tinebase_Model_Group(array(
                 'name'   => $configgroup
             )));
@@ -105,7 +104,12 @@ class Courses_JsonTest extends TestCase
             'logonscript_postfix_member' => '.cmd',
             'baseprofilepath' => '\\\\jo\\profiles\\',
         )));
-        
+
+        // set some complex default pws (to make AD happy)
+        $pwConfig = Tinebase_Record_Abstract::generateUID(8) . 'B{]';
+        Courses_Config::getInstance()->set(Courses_Config::STUDENT_PASSWORD_SUFFIX, $pwConfig);
+        Courses_Config::getInstance()->set(Courses_Config::TEACHER_PASSWORD, $pwConfig);
+
         $this->_schemaConfig = Courses_Config::getInstance()->get(Courses_Config::STUDENTS_USERNAME_SCHEMA);
         $this->_usernameLengthConfig = Tinebase_Config::getInstance()->get(Tinebase_Config::MAX_USERNAME_LENGTH);
         $this->_defaultDepartmentConfig = Courses_Config::getInstance()->get(Courses_Config::DEFAULT_DEPARTMENT);
index 735e11b..8be260c 100644 (file)
@@ -5,17 +5,12 @@
  * @package     Tinebase
  * @subpackage  Acl
  * @license     http://www.gnu.org/licenses/agpl.html
- * @copyright   Copyright (c) 2008-2013 Metaways Infosystems GmbH (http://www.metaways.de)
+ * @copyright   Copyright (c) 2008-2016 Metaways Infosystems GmbH (http://www.metaways.de)
  * @copyright   Copyright (c) 2014 Serpro (http://www.serpro.gov.br)
  * @author      Flávio Gomes da Silva Lisboa <flavio.lisboa@serpro.gov.br>
  */
 
 /**
- * Test helper
- */
-require_once dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'TestHelper.php';
-
-/**
  * Test class for Tinebase_Acl_Roles
  */
 class Crm_Acl_RolesTest extends TestCase
@@ -37,14 +32,14 @@ class Crm_Acl_RolesTest extends TestCase
         
         $this->objects['application'] = Tinebase_Application::getInstance()->getApplicationByName('Crm');
         $this->objects['user'] = new Tinebase_Model_FullUser(array(
-            'accountLoginName'      => 'tine20phpunit',
-            'accountDisplayName'    => 'tine20phpunit',
+            'accountLoginName'      => 'crmtine20phpunit',
+            'accountDisplayName'    => 'crmtine20phpunit',
             'accountStatus'         => 'enabled',
             'accountExpires'        => NULL,
-            'accountPrimaryGroup'   => Tinebase_Group::getInstance()->getGroupByName('Users')->getId(),
+            'accountPrimaryGroup'   => Tinebase_Group::getInstance()->getDefaultGroup()->getId(),
             'accountLastName'       => 'Tine 2.0',
-            'accountFirstName'      => 'PHPUnit',
-            'accountEmailAddress'   => 'phpunit@metaways.de'
+            'accountFirstName'      => 'crmPHPUnit',
+            'accountEmailAddress'   => 'crmphpunit@metaways.de'
         ));
         $this->objects['role'] = new Tinebase_Model_Role(array(
             'id'                    => 10,
@@ -60,7 +55,7 @@ class Crm_Acl_RolesTest extends TestCase
         // add account for group / role member tests
         $this->objects['user'] = Tinebase_User::getInstance()->addUser($this->objects['user']);
         Tinebase_Group::getInstance()->addGroupMember($this->objects['user']->accountPrimaryGroup, $this->objects['user']);
-        
+
         return;
     }
 
index 71740d3..f28f884 100644 (file)
@@ -9,7 +9,6 @@
  * 
  */
 
-
 /**
  * Test class for Sales Invoice Controller
  */
@@ -701,7 +700,7 @@ class Sales_InvoiceControllerTests extends Sales_InvoiceTestCase
         )));
         
         // fetch user group
-        $group   = Tinebase_Group::getInstance()->getGroupByName('Users');
+        $group   = Tinebase_Group::getInstance()->getDefaultGroup();
         $groupId = $group->getId();
         
         // create new user
@@ -715,7 +714,7 @@ class Sales_InvoiceControllerTests extends Sales_InvoiceTestCase
             'accountEmailAddress'   => 'unittestx8@tine20.org',
         ));
         
-        $user = Admin_Controller_User::getInstance()->create($user, 'pw', 'pw');
+        $user = Admin_Controller_User::getInstance()->create($user, 'pw5823H132', 'pw5823H132');
         $this->_testUser = Tinebase_Core::getUser();
 
         Tinebase_Core::set(Tinebase_Core::USER, $user);
index fc5bfbf..4af1656 100644 (file)
@@ -24,18 +24,6 @@ class Tasks_Frontend_WebDAV_TaskTest extends Tasks_TestCase
     protected $objects = array();
     
     /**
-     * Runs the test methods of this class.
-     *
-     * @access public
-     * @static
-     */
-    public static function main()
-    {
-        $suite  = new PHPUnit_Framework_TestSuite('Tine 2.0 Tasks WebDAV Task Tests');
-        PHPUnit_TextUI_TestRunner::run($suite);
-    }
-
-    /**
      * Sets up the fixture.
      * This method is called before a test is executed.
      */
@@ -161,6 +149,7 @@ class Tasks_Frontend_WebDAV_TaskTest extends Tasks_TestCase
     
     /**
      * test get vcard
+     *
      * @depends testCreateTask
      */
     public function testGetVCalendar()
@@ -169,10 +158,12 @@ class Tasks_Frontend_WebDAV_TaskTest extends Tasks_TestCase
         
         $vcalendar = stream_get_contents($task->get());
         
-        //var_dump($vcalendar);
-        
         $this->assertContains('SUMMARY:New Task', $vcalendar);
-        $this->assertContains('ORGANIZER;CN=', $vcalendar);
+
+        if (Tinebase_User::getConfiguredBackend() !== Tinebase_User::ACTIVEDIRECTORY) {
+            // non-AD only because AD setup currently doesn't have user email address
+            $this->assertContains('ORGANIZER;CN=', $vcalendar);
+        }
     }
     
     /**
index e5333af..4975ced 100644 (file)
@@ -378,7 +378,7 @@ class Tasks_JsonTest extends TestCase
                 'accountLoginName'      => 'creator',
                 'accountStatus'         => 'enabled',
                 'accountExpires'        => NULL,
-                'accountPrimaryGroup'   => Tinebase_Group::getInstance()->getGroupByName('Users')->id,
+                'accountPrimaryGroup'   => Tinebase_Group::getInstance()->getDefaultGroup()->id,
                 'accountLastName'       => 'Tine 2.0',
                 'accountFirstName'      => 'Creator',
                 'accountEmailAddress'   => 'phpunit@metaways.de'
index c82e8fc..d78fec6 100644 (file)
@@ -109,7 +109,7 @@ abstract class TestCase extends PHPUnit_Framework_TestCase
      */
     protected function tearDown()
     {
-        if (Tinebase_User::getConfiguredBackend() === Tinebase_User::LDAP) {
+        if (in_array(Tinebase_User::getConfiguredBackend(), array(Tinebase_User::LDAP, Tinebase_User::ACTIVEDIRECTORY))) {
             $this->_deleteUsers();
             $this->_deleteGroups();
         }
index d4cfbfc..470f2e4 100644 (file)
@@ -913,7 +913,7 @@ class Timetracker_JsonTest extends Timetracker_AbstractTest
         $taController       = Timetracker_Controller_Timeaccount::getInstance();
         
         // fetch user group
-        $group   = Tinebase_Group::getInstance()->getGroupByName('Users');
+        $group   = Tinebase_Group::getInstance()->getDefaultGroup();
         $groupId = $group->getId();
         
         // create new user
@@ -1194,7 +1194,7 @@ class Timetracker_JsonTest extends Timetracker_AbstractTest
         )));
         
         // fetch user group 
-        $group   = Tinebase_Group::getInstance()->getGroupByName('Users');
+        $group   = Tinebase_Group::getInstance()->getDefaultGroup();
         $groupId = $group->getId();
         
         // create new user 
index 8611b5a..db1d095 100644 (file)
@@ -143,12 +143,13 @@ class Tinebase_AccountTest extends TestCase
     public function testUpdateAccount()
     {
         $account = $this->testAddAccount();
-        
+
         $account->accountLoginName = 'tine20phpunit-updated';
         $account->accountStatus    = Tinebase_User::STATUS_DISABLED;
         $account->accountLastName  = 'Tine 2.0 Updated';
         $account->accountFirstName = 'PHPUnit Updated';
-        
+
+        $this->_usernamesToDelete[] = $account->accountLoginName;
         $testAccount = Tinebase_User::getInstance()->updateUser($account);
         
         $this->assertEquals('tine20phpunit-updated',        $testAccount->accountLoginName);
index d07c702..47d1926 100644 (file)
@@ -35,7 +35,7 @@ class Tinebase_Acl_RolesTest extends TestCase
             'accountDisplayName'    => 'tine20phpunit',
             'accountStatus'         => 'enabled',
             'accountExpires'        => NULL,
-            'accountPrimaryGroup'   => Tinebase_Group::getInstance()->getGroupByName('Users')->getId(),
+            'accountPrimaryGroup'   => Tinebase_Group::getInstance()->getDefaultGroup()->getId(),
             'accountLastName'       => 'Tine 2.0',
             'accountFirstName'      => 'PHPUnit',
             'accountEmailAddress'   => 'phpunit@metaways.de'
index c1b8a77..3eee2ad 100644 (file)
@@ -55,8 +55,9 @@ class Tinebase_ControllerTest extends PHPUnit_Framework_TestCase
      */
     public function testMaintenanceModeLoginFail()
     {
-        if (Tinebase_User::getConfiguredBackend() === Tinebase_User::LDAP) {
-            $this->markTestSkipped('FIXME: Does not work with LDAP backend (full test suite run)');
+        if (Tinebase_User::getConfiguredBackend() === Tinebase_User::LDAP ||
+            Tinebase_User::getConfiguredBackend() === Tinebase_User::ACTIVEDIRECTORY) {
+            $this->markTestSkipped('FIXME: Does not work with LDAP/AD backend (full test suite run)');
         }
 
         Tinebase_Config::getInstance()->maintenanceMode = 1;
index 9399580..4403f44 100644 (file)
@@ -5,7 +5,7 @@
  * @package     Tinebase
  * @subpackage  Group
  * @license     http://www.gnu.org/licenses/agpl.html
- * @copyright   Copyright (c) 2008-2015 Metaways Infosystems GmbH (http://www.metaways.de)
+ * @copyright   Copyright (c) 2008-2016 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Philipp Schüle <p.schuele@metaways.de>
  */
 
@@ -86,7 +86,7 @@ class Tinebase_GroupTest extends TestCase
      */
     public function testGetGroupById()
     {
-        $adminGroup = Tinebase_Group::getInstance()->getGroupByName('Administrators');
+        $adminGroup = Tinebase_Group::getInstance()->getDefaultAdminGroup();
         
         $group = Tinebase_Group::getInstance()->getGroupById($adminGroup->id);
         
index e20ca72..f0060a7 100644 (file)
@@ -26,15 +26,6 @@ class Tinebase_TagsTest extends TestCase
     protected $_instance;
 
     /**
-     * Runs the test methods of this class.
-     */
-    public static function main()
-    {
-        $suite  = new PHPUnit_Framework_TestSuite('Tinebase_TagsTest');
-        PHPUnit_TextUI_TestRunner::run($suite);
-    }
-
-    /**
      * (non-PHPdoc)
      * @see PHPUnit_Framework_TestCase::setUp()
      */
@@ -260,9 +251,15 @@ class Tinebase_TagsTest extends TestCase
      * testMergeDuplicateTags
      * 
      * @see 0007354: function for merging duplicate tags
+     *
+     * TODO test should be improved: it is very dependent on the current number of contacts in the adb
      */
     public function testMergeDuplicateTags()
     {
+        if (Tinebase_User::getConfiguredBackend() === Tinebase_User::ACTIVEDIRECTORY) {
+            $this->markTestSkipped('AD setup has different number of contacts');
+        }
+
         $sharedTag1 = $this->_createSharedTag();
         // sleep to make sure, $sharedTag1 is always chosen as 'master'
         sleep(1);
index f29bd67..2c76177 100644 (file)
@@ -5,20 +5,11 @@
  * @package     Tinebase
  * @subpackage  User
  * @license     http://www.gnu.org/licenses/agpl.html
- * @copyright   Copyright (c) 2009 Metaways Infosystems GmbH (http://www.metaways.de)
+ * @copyright   Copyright (c) 2009-2016 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Cornelius Weiss <c.weiss@metaways.de>
  */
 
 /**
- * Test helper
- */
-require_once dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'TestHelper.php';
-
-if (!defined('PHPUnit_MAIN_METHOD')) {
-    define('PHPUnit_MAIN_METHOD', 'Tinebase_User_AbstractTest::main');
-}
-
-/**
  * Test class for Tinebase_User_Abstract
  */
 class Tinebase_User_AbstractTest extends PHPUnit_Framework_TestCase
@@ -36,18 +27,6 @@ class Tinebase_User_AbstractTest extends PHPUnit_Framework_TestCase
     protected $_objects = array();
 
     /**
-     * Runs the test methods of this class.
-     *
-     * @access public
-     * @static
-     */
-    public static function main()
-    {
-        $suite  = new PHPUnit_Framework_TestSuite('Tinebase_User_AbstractTest');
-        PHPUnit_TextUI_TestRunner::run($suite);
-    }
-
-    /**
      * Sets up the fixture.
      * This method is called before a test is executed.
      *
@@ -70,10 +49,17 @@ class Tinebase_User_AbstractTest extends PHPUnit_Framework_TestCase
     }
     
     /**
-     * test generation of loginnames
+     * test generation of login names
      */
     public function testGenerateUserName()
     {
+        if (Tinebase_User::getConfiguredBackend() === Tinebase_User::ACTIVEDIRECTORY) {
+            // error: Zend_Ldap_Exception: 0x44 (Already exists;
+            // Entry CN=Leonie Weiss,CN=Users,DC=example,DC=org already exists):
+            // adding: cn=Leonie Weiss,cn=Users,dc=example,dc=org
+            $this->markTestSkipped('skipped for ad backends as it does not allow duplicate CNs');
+        }
+
         $user = new Tinebase_Model_FullUser(array(
             'accountFirstName' => 'Leonie',
             'accountLastName'  => 'Weiss',
@@ -205,7 +191,7 @@ class Tinebase_User_AbstractTest extends PHPUnit_Framework_TestCase
                 'accountLoginName'      => 'dummy_'.$i,
                 'accountStatus'         => 'enabled',
                 'accountExpires'        => NULL,
-                'accountPrimaryGroup'   => Tinebase_Group::getInstance()->getGroupByName('Users')->id,
+                'accountPrimaryGroup'   => Tinebase_Group::getInstance()->getDefaultGroup()->id,
                 'accountLastName'       => 'Dummy',
                 'accountFirstName'      => 'No.'.$i,
                 'accountEmailAddress'   => 'phpunit@metaways.de'
index 66b2cc8..fdcda02 100644 (file)
@@ -48,7 +48,13 @@ class Tinebase_User_EmailUser_Imap_DovecotTest extends PHPUnit_Framework_TestCas
         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');
index fc6da3e..51ed930 100644 (file)
@@ -39,18 +39,6 @@ class Tinebase_User_EmailUser_Smtp_PostfixTest extends PHPUnit_Framework_TestCas
     protected $_mailDomain = 'tine20.org';
     
     /**
-     * Runs the test methods of this class.
-     *
-     * @access public
-     * @static
-     */
-    public static function main()
-    {
-        $suite  = new PHPUnit_Framework_TestSuite('Tinebase_User_EmailUser_Smtp_PostfixTest');
-        PHPUnit_TextUI_TestRunner::run($suite);
-    }
-
-    /**
      * Sets up the fixture.
      * This method is called before a test is executed.
      *
@@ -63,7 +51,13 @@ class Tinebase_User_EmailUser_Smtp_PostfixTest extends PHPUnit_Framework_TestCas
         if (! array_key_exists('Tinebase_EmailUser_Smtp_Postfix', $this->_backend->getPlugins())) {
             $this->markTestSkipped('Postfix SQL plugin 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->objects['users'] = array();
         
         $this->_mailDomain = TestServer::getPrimaryMailDomain();
index 444c788..7c8c3f6 100644 (file)
@@ -5,16 +5,11 @@
  * @package     Tinebase
  * @subpackage  User
  * @license     http://www.gnu.org/licenses/agpl.html
- * @copyright   Copyright (c) 2009-2013 Metaways Infosystems GmbH (http://www.metaways.de)
+ * @copyright   Copyright (c) 2009-2016 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Jonas Fischer <j.fischer@metaways.de>
  */
 
 /**
- * Test helper
- */
-require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'TestHelper.php';
-
-/**
  * Test class for Tinebase_User_Abstract
  */
 class Tinebase_UserTest extends PHPUnit_Framework_TestCase
@@ -245,8 +240,16 @@ class Tinebase_UserTest extends PHPUnit_Framework_TestCase
         $this->_assertPolicy('clever', 'pwPolicyForbidUsername');
         $this->_assertPolicy('cle', 'pwPolicyForbidUsername');
         $this->_assertPolicy('ver', 'pwPolicyForbidUsername');
-        $this->_assertPolicy('sclever123', '', TRUE); // valid
-        $this->_assertPolicy('', '', TRUE); // valid
+        $this->_assertPolicy('sClever123!', '', TRUE); // valid
+
+        // skip this test for AD backends because it has some strict pws policies
+        // TODO this should be improved: catch AD policy exceptions and convert to Tinebase_Exception_PasswordPolicyViolation
+        // like this:
+        //   Zend_Ldap_Exception: 0x13 (Constraint violation; 0000052D: Constraint violation -
+        //   check_password_restrictions: the password is too short. It should be equal or longer than 7 characters!)
+        if (Tinebase_User::getConfiguredBackend() !== Tinebase_User::ACTIVEDIRECTORY) {
+            $this->_assertPolicy('', '', TRUE); // valid
+        }
     }
     
     /**
@@ -254,6 +257,10 @@ class Tinebase_UserTest extends PHPUnit_Framework_TestCase
      */
     public function testPasswordPolicyUsernameNotSet()
     {
+        if (Tinebase_User::getConfiguredBackend() === Tinebase_User::ACTIVEDIRECTORY) {
+            $this->markTestSkipped('skipped for ad backends - see testPasswordPolicyUsername()');
+        }
+
         $this->_setPwPolicies(array(
             Tinebase_Config::PASSWORD_POLICY_FORBID_USERNAME => false
         ));
index d865fe6..2d8b703 100644 (file)
@@ -27,6 +27,10 @@ class Tinebase_WebDav_Plugin_PrincipalSearchTest extends Tinebase_WebDav_Plugin_
      */
     protected function setUp()
     {
+        if (Tinebase_User::getConfiguredBackend() === Tinebase_User::ACTIVEDIRECTORY) {
+            $this->markTestSkipped('only working in non-AD setups');
+        }
+
         parent::setUp();
         
         $mockBackend = new Sabre\DAV\Auth\Backend\Mock();
index db9cbf8..1714874 100644 (file)
@@ -99,6 +99,11 @@ class Tinebase_WebDav_PrincipalBackendTest extends TestCase
     
     public function testSearchPrincipalsByEMail()
     {
+        if (Tinebase_User::getConfiguredBackend() === Tinebase_User::ACTIVEDIRECTORY) {
+            // account email addresses are empty with AD backend
+            $this->markTestSkipped('skipped for ad backend');
+        }
+
         $uris = $this->_backend->searchPrincipals(Tinebase_WebDav_PrincipalBackend::PREFIX_USERS, array(
             '{http://sabredav.org/ns}email-address' => Tinebase_Core::getUser()->accountEmailAddress)
         );
@@ -109,11 +114,16 @@ class Tinebase_WebDav_PrincipalBackendTest extends TestCase
     
     public function testSearchPrincipalsByFirstName()
     {
+        if (Tinebase_User::getConfiguredBackend() === Tinebase_User::ACTIVEDIRECTORY) {
+            // account email addresses are empty with AD backend
+            $this->markTestSkipped('skipped for ad backend');
+        }
+
         $uris = $this->_backend->searchPrincipals(Tinebase_WebDav_PrincipalBackend::PREFIX_USERS, array(
             '{' . \Sabre\CalDAV\Plugin::NS_CALENDARSERVER . '}first-name' => Tinebase_Core::getUser()->accountFirstName)
         );
         
-        $this->assertEquals(1, count($uris), 'could not find user by email address ' . Tinebase_Core::getUser()->accountEmailAddress);
+        $this->assertEquals(1, count($uris), 'could not find user by first name ' . Tinebase_Core::getUser()->accountFirstName);
         $this->assertContains('principals/users/' . Tinebase_Core::getUser()->contact_id, $uris);
     }
     
index abf98cd..1208e8d 100644 (file)
@@ -134,7 +134,7 @@ class Calendar_Setup_DemoData extends Tinebase_Setup_DemoData_Abstract
             'color'          => '#00FF00'
         ), true));
 
-        $group = Tinebase_Group::getInstance()->getGroupByName(Tinebase_Group::DEFAULT_USER_GROUP);
+        $group = Tinebase_Group::getInstance()->getDefaultGroup();
         Tinebase_Container::getInstance()->addGrants($this->sharedCalendar->getId(), 'group', $group->getId(), $this->_userGrants, true);
         Tinebase_Container::getInstance()->addGrants($this->sharedCalendar->getId(), 'user', $this->_personas['sclever']->getId(), $this->_secretaryGrants, true);
 
index 602c3ba..3e35fdd 100644 (file)
@@ -72,7 +72,14 @@ class Courses_Config extends Tinebase_Config_Abstract
     * @var string
     */
     const STUDENT_LOGINNAME_PREFIX = 'student_loginname_prefix';
-    
+
+    /**
+     * students loginname prefix
+     *
+     * @var string
+     */
+    const TEACHER_PASSWORD = 'teacher_password';
+
     /**
      * students password suffix
      *
@@ -148,11 +155,20 @@ class Courses_Config extends Tinebase_Config_Abstract
             'clientRegistryInclude' => TRUE,
         ),
         self::STUDENT_PASSWORD_SUFFIX => array(
-                //_('Students password suffix')
-                'label'                 => 'Students password suffix',
-                'description'           => 'Students password suffix',
-                'type'                  => 'string',
-                'clientRegistryInclude' => TRUE,
+            //_('Students password suffix')
+            'label'                 => 'Students password suffix',
+            'description'           => 'Students password suffix',
+            'type'                  => 'string',
+            'clientRegistryInclude' => TRUE,
+        ),
+        self::TEACHER_PASSWORD => array(
+            //_('Teacher password')
+            'label'                 => 'Teacher password',
+            'description'           => 'Teacher password',
+            'type'                  => 'string',
+            'clientRegistryInclude' => false,
+            'setBySetupModule'      => true,
+            'setByAdminModule'      => false,
         ),
         self::STUDENTS_USERNAME_SCHEMA => array(
         //_('Student username schema')
index a8b6ac9..f11b406 100644 (file)
@@ -51,7 +51,7 @@ class Courses_Controller_Course extends Tinebase_Controller_Record_Abstract
     /**
      * config of courses
      *
-     * @var Zend_Config
+     * @var Courses_Config
      */
     protected $_config = NULL;
     
@@ -207,7 +207,7 @@ class Courses_Controller_Course extends Tinebase_Controller_Record_Abstract
                     . ' ' . $tenf);
                 if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__
                     . ' Removing member from course / group ' . $course->name . ' / group id: ' . $course->group_id);
-                $this->_groupController->removeGroupMemberFromSqlBackend($course->group_id, $memberId);
+                Tinebase_Group::getInstance()->removeGroupMemberFromSqlBackend($course->group_id, $memberId);
             }
         }
     }
@@ -275,7 +275,7 @@ class Courses_Controller_Course extends Tinebase_Controller_Record_Abstract
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Created teacher account for course '
             . $course->name . ': ' . print_r($account->toArray(), true));
         
-        $password = $this->_config->get('teacher_password', $account->accountLoginName);
+        $password = $this->_config->get(Courses_Config::TEACHER_PASSWORD, $account->accountLoginName);
         $account = $this->_userController->create($account, $password, $password);
         $this->_groupController->addGroupMember(Tinebase_Group::getInstance()->getDefaultGroup()->getId(), $account->getId());
         
index eee786e..19f7611 100644 (file)
@@ -741,7 +741,7 @@ abstract class Tinebase_Setup_DemoData_Abstract
             ), true)
         );
 
-        $group = Tinebase_Group::getInstance()->getGroupByName(Tinebase_Group::DEFAULT_USER_GROUP);
+        $group = Tinebase_Group::getInstance()->getDefaultGroup();
         Tinebase_Container::getInstance()->addGrants($container->getId(), 'group', $group->getId(), $this->_userGrants, true);
         Tinebase_Container::getInstance()->addGrants($container->getId(), 'user', $this->_personas['sclever']->getId(), $this->_secretaryGrants, true);
         Tinebase_Container::getInstance()->addGrants($container->getId(), 'user', $this->_personas['pwulf']->getId(),   $this->_adminGrants, true);