private function GivenAFullApacheConf()
 {
     $backend = TestHelper::getPartialMock('LDAP_BackendSVN', array('_getServiceDao', 'getLdap', 'getLDAPProjectManager', 'getSVNApacheAuthFactory'));
     $dar = TestHelper::arrayToDar(array('unix_group_name' => 'gpig', 'group_name' => 'Guinea Pig', 'group_id' => 101), array('unix_group_name' => 'garden', 'group_name' => 'The Garden Project', 'group_id' => 102));
     $dao = new MockServiceDao();
     $dao->setReturnValue('searchActiveUnixGroupByUsedService', $dar);
     $backend->setReturnValue('_getServiceDao', $dao);
     $factory = TestHelper::getPartialMock('SVN_Apache_Auth_Factory', array('getEventManager'));
     $factory->setReturnValue('getEventManager', new LDAP_BackendSVNTestEventManager());
     $backend->setReturnValue('getSVNApacheAuthFactory', $factory);
     return $backend->getApacheConf();
 }
Example #2
0
 private function GivenAFullApacheConf()
 {
     $backend = TestHelper::getPartialMock('LDAP_BackendSVN', array('_getServiceDao', 'getLdap', 'getLDAPProjectManager', 'getSVNApacheAuthFactory'));
     $project_array_01 = array('unix_group_name' => 'gpig', 'group_name' => 'Guinea Pig', 'group_id' => 101);
     $project_array_02 = array('unix_group_name' => 'garden', 'group_name' => 'The Garden Project', 'group_id' => 102);
     $dar = TestHelper::arrayToDar($project_array_01, $project_array_02);
     $dao = new MockServiceDao();
     $dao->setReturnValue('searchActiveUnixGroupByUsedService', $dar);
     $backend->setReturnValue('_getServiceDao', $dao);
     $ldap = mock('LDAP');
     stub($ldap)->getLDAPParam('server')->returns('ldap://ldap.tuleap.com');
     stub($ldap)->getLDAPParam('dn')->returns('dc=tuleap,dc=com');
     $project_manager = mock('ProjectManager');
     $event_manager = new LDAP_BackendSVNTestEventManager();
     $token_manager = mock('SVN_TokenUsageManager');
     $factory = new SVN_Apache_Auth_Factory($project_manager, $event_manager, $token_manager);
     $backend->setReturnValue('getSVNApacheAuthFactory', $factory);
     return $backend->getApacheConf();
 }
Example #3
0
 function testCVSRootListUpdate()
 {
     $backend = new BackendCVSTestVersion($this);
     $service_dao = new MockServiceDao($this);
     $service_dao->setReturnValue('searchActiveUnixGroupByUsedService', array(array('unix_group_name' => 'TestProj'), array('unix_group_name' => 'gpig')));
     $backend->setReturnReference('_getServiceDao', $service_dao);
     $backend->setCVSRootListNeedUpdate();
     $this->assertTrue($backend->getCVSRootListNeedUpdate(), "Need to update the repo list");
     $this->assertEqual($backend->CVSRootListUpdate(), True);
     // Now test CVSRootListUpdate
     $this->assertTrue(is_file($GLOBALS['cvs_root_allow_file']), "cvs_root_allow file should be created");
     $cvs_config_array1 = file($GLOBALS['cvs_root_allow_file']);
     $this->assertTrue(in_array("/cvsroot/gpig\n", $cvs_config_array1), "Project gpig should be listed in root file");
     $this->assertTrue(in_array("/cvsroot/TestProj\n", $cvs_config_array1), "Project TestProj should be listed in root file");
     $service_dao->setReturnValue('searchActiveUnixGroupByUsedService', array(array('unix_group_name' => 'TestProj'), array('unix_group_name' => 'gpig')));
     $backend->setCVSRootListNeedUpdate();
     $this->assertTrue($backend->getCVSRootListNeedUpdate(), "Need to update the repo list");
     $this->assertEqual($backend->CVSRootListUpdate(), True);
     $this->assertTrue(is_file($GLOBALS['cvs_root_allow_file'] . ".new"), "cvs_root_allow.new file should be created");
     $this->assertFalse(is_file($GLOBALS['cvs_root_allow_file'] . ".old"), "cvs_root_allow.old file should not be created (same files)");
     $cvs_config_array2 = file($GLOBALS['cvs_root_allow_file'] . ".new");
     $this->assertTrue(in_array("/cvsroot/gpig\n", $cvs_config_array2), "Project gpig should be listed in root.new file");
     $this->assertTrue(in_array("/cvsroot/TestProj\n", $cvs_config_array2), "Project TestProj should be listed in root.new file");
     // A project was added
     $service_dao2 = new MockServiceDao($this);
     $service_dao2->setReturnValue('searchActiveUnixGroupByUsedService', array(array('unix_group_name' => 'TestProj'), array('unix_group_name' => 'gpig'), array('unix_group_name' => 'newProj')));
     $backend2 = new BackendCVSTestVersion($this);
     $backend2->setReturnReference('_getServiceDao', $service_dao2);
     $backend2->setCVSRootListNeedUpdate();
     $this->assertTrue($backend2->getCVSRootListNeedUpdate(), "Need to update the repo list");
     $this->assertEqual($backend2->CVSRootListUpdate(), True);
     $this->assertFalse(is_file($GLOBALS['cvs_root_allow_file'] . ".new"), "cvs_root_allow.new file should not be created (moved because different files)");
     $this->assertTrue(is_file($GLOBALS['cvs_root_allow_file'] . ".old"), "cvs_root_allow.old file should be created (different files)");
     // Again
     $backend2->setCVSRootListNeedUpdate();
     $this->assertTrue($backend2->getCVSRootListNeedUpdate(), "Need to update the repo list");
     $this->assertEqual($backend2->CVSRootListUpdate(), True);
     $this->assertTrue(is_file($GLOBALS['cvs_root_allow_file'] . ".new"), "cvs_root_allow.new file should be created (same files)");
     $this->assertTrue(is_file($GLOBALS['cvs_root_allow_file'] . ".old"), "cvs_root_allow.old file should be there");
     // Cleanup
     unlink($GLOBALS['cvs_root_allow_file']);
     unlink($GLOBALS['cvs_root_allow_file'] . ".old");
     unlink($GLOBALS['cvs_root_allow_file'] . ".new");
 }
Example #4
0
 function testGenerateSVNApacheConf()
 {
     $backend = new BackendSVNTestVersion($this);
     $service_dao = new MockServiceDao($this);
     $active_groups = array("0" => array("group_id" => "101", "group_name" => "Guinea Pig", "unix_group_name" => "gpig"), "1" => array("group_id" => "102", "group_name" => "Guinea Pig is \"back\"", "unix_group_name" => "gpig2"), "2" => array("group_id" => "103", "group_name" => "Guinea Pig is 'angry'", "unix_group_name" => "gpig3"));
     $service_dao->setReturnValue('searchActiveUnixGroupByUsedService', $active_groups);
     $backend->setReturnReference('_getServiceDao', $service_dao);
     $this->assertEqual($backend->generateSVNApacheConf(), True);
     $svnroots = file_get_contents($GLOBALS['svn_root_file']);
     $this->assertFalse($svnroots === false);
     $this->assertPattern("/gpig2/", $svnroots, "Project name not found in SVN root");
     $this->assertPattern("/AuthName \"Subversion Authorization \\(Guinea Pig is 'back'\\)\"/", $svnroots, "Group name double quotes in realm");
     // Cleanup
     unlink($GLOBALS['svn_root_file']);
 }