| 
									
										
										
										
											2003-03-15 00:04:45 +00:00
										 |  |  | <?php | 
					
						
							|  |  |  | /* | 
					
						
							|  |  |  | $Id$ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-27 18:47:12 +00:00
										 |  |  |   This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) | 
					
						
							| 
									
										
										
										
											2013-01-05 12:44:17 +00:00
										 |  |  |   Copyright (C) 2003 - 2013  Roland Gruber | 
					
						
							| 
									
										
										
										
											2003-03-15 00:04:45 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   This program is free software; you can redistribute it and/or modify | 
					
						
							|  |  |  |   it under the terms of the GNU General Public License as published by | 
					
						
							|  |  |  |   the Free Software Foundation; either version 2 of the License, or | 
					
						
							|  |  |  |   (at your option) any later version. | 
					
						
							| 
									
										
										
										
											2003-08-18 15:21:27 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-03-15 00:04:45 +00:00
										 |  |  |   This program is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |   but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  |   GNU General Public License for more details. | 
					
						
							| 
									
										
										
										
											2003-08-18 15:21:27 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-03-15 00:04:45 +00:00
										 |  |  |   You should have received a copy of the GNU General Public License | 
					
						
							|  |  |  |   along with this program; if not, write to the Free Software | 
					
						
							|  |  |  |   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-10-10 11:14:26 +00:00
										 |  |  | /** | 
					
						
							|  |  |  | * This test reads all preferences from lam.conf. Then it writes new values and verifies | 
					
						
							|  |  |  | * if they were written. At last the old values are restored. | 
					
						
							|  |  |  | * | 
					
						
							|  |  |  | * @author Roland Gruber | 
					
						
							|  |  |  | * @package tests | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** access to configuration functions */ | 
					
						
							| 
									
										
										
										
											2003-04-26 18:40:12 +00:00
										 |  |  | include ("../lib/config.inc"); | 
					
						
							| 
									
										
										
										
											2004-10-10 11:14:26 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-09-24 14:19:50 +00:00
										 |  |  | $conf = new LAMConfig('test'); | 
					
						
							| 
									
										
										
										
											2013-01-05 12:44:17 +00:00
										 |  |  | echo "<html><head><title></title><link rel=\"stylesheet\" type=\"text/css\" href=\"../style/500_layout.css\"></head><body>"; | 
					
						
							| 
									
										
										
										
											2003-03-15 00:04:45 +00:00
										 |  |  | echo ("<br><br><big><b> Starting Test...</b></big><br><br>"); | 
					
						
							| 
									
										
										
										
											2004-07-18 10:18:25 +00:00
										 |  |  | // now all preferences are loaded
 | 
					
						
							| 
									
										
										
										
											2003-03-15 00:04:45 +00:00
										 |  |  | echo ("Loading preferences..."); | 
					
						
							| 
									
										
										
										
											2003-04-23 07:33:18 +00:00
										 |  |  | $ServerURL = $conf->get_ServerURL(); | 
					
						
							| 
									
										
										
										
											2003-09-19 19:29:02 +00:00
										 |  |  | $cachetimeout = $conf->get_cacheTimeout(); | 
					
						
							| 
									
										
										
										
											2003-03-15 00:04:45 +00:00
										 |  |  | $Adminstring = $conf->get_Adminstring(); | 
					
						
							| 
									
										
										
										
											2005-03-10 20:20:00 +00:00
										 |  |  | $Suff_users = $conf->get_Suffix('user'); | 
					
						
							|  |  |  | $Suff_groups = $conf->get_Suffix('group'); | 
					
						
							|  |  |  | $Suff_hosts = $conf->get_Suffix('host'); | 
					
						
							| 
									
										
										
										
											2006-01-01 16:30:05 +00:00
										 |  |  | $Suff_domains = $conf->get_Suffix('smbDomain'); | 
					
						
							| 
									
										
										
										
											2005-04-14 17:42:15 +00:00
										 |  |  | $userlistAttributes = $conf->get_listAttributes('user'); | 
					
						
							|  |  |  | $grouplistAttributes = $conf->get_listAttributes('group'); | 
					
						
							|  |  |  | $hostlistAttributes = $conf->get_listAttributes('host'); | 
					
						
							| 
									
										
										
										
											2003-05-09 16:22:46 +00:00
										 |  |  | $defaultlanguage = $conf->get_defaultlanguage(); | 
					
						
							| 
									
										
										
										
											2003-05-12 17:52:54 +00:00
										 |  |  | $scriptpath = $conf->get_scriptPath(); | 
					
						
							| 
									
										
										
										
											2007-02-22 17:16:14 +00:00
										 |  |  | $scriptServer = $conf->get_scriptServers(); | 
					
						
							|  |  |  | $scriptRights = $conf->get_scriptRights(); | 
					
						
							| 
									
										
										
										
											2004-07-18 10:18:25 +00:00
										 |  |  | $moduleSettings = $conf->get_moduleSettings(); | 
					
						
							| 
									
										
										
										
											2003-03-15 00:04:45 +00:00
										 |  |  | echo ("done<br>"); | 
					
						
							|  |  |  | // next we modify them and save lam.conf
 | 
					
						
							|  |  |  | echo ("Changing preferences..."); | 
					
						
							| 
									
										
										
										
											2003-04-23 07:33:18 +00:00
										 |  |  | $conf->set_ServerURL("ldap://123.345.678.123:777"); | 
					
						
							| 
									
										
										
										
											2003-08-18 15:21:27 +00:00
										 |  |  | $conf->set_cacheTimeout("33"); | 
					
						
							| 
									
										
										
										
											2003-03-15 00:04:45 +00:00
										 |  |  | $conf->set_Passwd("123456abcde"); | 
					
						
							|  |  |  | $conf->set_Adminstring("uid=test,o=test,dc=org;uid=root,o=test2,c=de"); | 
					
						
							| 
									
										
										
										
											2005-03-10 20:20:00 +00:00
										 |  |  | $conf->set_Suffix('user', "ou=test,o=test,c=de"); | 
					
						
							|  |  |  | $conf->set_Suffix('group', "ou=testgrp,o=test,c=de"); | 
					
						
							|  |  |  | $conf->set_Suffix('host', "ou=testhst,o=test,c=de"); | 
					
						
							| 
									
										
										
										
											2006-01-01 16:30:05 +00:00
										 |  |  | $conf->set_Suffix('smbDomain', "ou=testdom,o=test,c=de"); | 
					
						
							| 
									
										
										
										
											2005-04-14 17:42:15 +00:00
										 |  |  | $conf->set_listAttributes("#uid;#cn", 'user'); | 
					
						
							|  |  |  | $conf->set_listAttributes("#gidNumber;#cn;#memberUID", 'group'); | 
					
						
							|  |  |  | $conf->set_listAttributes("#cn;#uid;#description", 'host'); | 
					
						
							| 
									
										
										
										
											2003-05-09 16:22:46 +00:00
										 |  |  | $conf->set_defaultlanguage("de_AT:iso639_de:Deutsch (Oesterreich)"); | 
					
						
							| 
									
										
										
										
											2003-05-12 17:52:54 +00:00
										 |  |  | $conf->set_scriptPath("/var/www/lam/lib/script"); | 
					
						
							| 
									
										
										
										
											2007-02-22 17:16:14 +00:00
										 |  |  | $conf->set_scriptServers("127.0.0.1"); | 
					
						
							|  |  |  | $conf->set_scriptRights('775'); | 
					
						
							| 
									
										
										
										
											2004-07-26 15:15:30 +00:00
										 |  |  | $conf->set_moduleSettings(array("test1" => array(11), "test2" => array("abc"), 'test3' => array(3))); | 
					
						
							| 
									
										
										
										
											2003-03-15 00:04:45 +00:00
										 |  |  | $conf->save(); | 
					
						
							|  |  |  | echo ("done<br>"); | 
					
						
							|  |  |  | // at last all preferences are read from lam.conf and compared
 | 
					
						
							|  |  |  | echo ("Loading and comparing..."); | 
					
						
							| 
									
										
										
										
											2006-09-24 14:19:50 +00:00
										 |  |  | $conf2 = new LAMConfig('test'); | 
					
						
							| 
									
										
										
										
											2003-08-18 15:21:27 +00:00
										 |  |  | if ($conf2->get_ServerURL() != "ldap://123.345.678.123:777") echo ("<br><font color=\"#FF0000\">Saving ServerURL failed!</font><br>"); | 
					
						
							|  |  |  | if ($conf2->get_cacheTimeout() != "33") echo ("<br><font color=\"#FF0000\">Saving Cache timeout failed!</font><br>"); | 
					
						
							| 
									
										
										
										
											2007-11-08 19:19:50 +00:00
										 |  |  | if (!$conf2->check_Passwd("123456abcde")) echo ("<br><font color=\"#FF0000\">Saving password failed!</font><br>"); | 
					
						
							| 
									
										
										
										
											2003-08-18 15:21:27 +00:00
										 |  |  | if ($conf2->get_Adminstring() != "uid=test,o=test,dc=org;uid=root,o=test2,c=de") echo ("<br><font color=\"#FF0000\">Saving admin string failed!</font><br>"); | 
					
						
							| 
									
										
										
										
											2005-03-10 20:20:00 +00:00
										 |  |  | if ($conf2->get_Suffix('user') != "ou=test,o=test,c=de") echo ("<br><font color=\"#FF0000\">Saving user suffix failed!</font><br>"); | 
					
						
							|  |  |  | if ($conf2->get_Suffix('group') != "ou=testgrp,o=test,c=de") echo ("<br><font color=\"#FF0000\">Saving group suffix failed!</font><br>"); | 
					
						
							|  |  |  | if ($conf2->get_Suffix('host') != "ou=testhst,o=test,c=de") echo ("<br><font color=\"#FF0000\">Saving host suffix failed!</font><br>"); | 
					
						
							| 
									
										
										
										
											2006-01-01 16:30:05 +00:00
										 |  |  | if ($conf2->get_Suffix('smbDomain') != "ou=testdom,o=test,c=de") echo ("<br><font color=\"#FF0000\">Saving domain suffix failed!</font><br>"); | 
					
						
							| 
									
										
										
										
											2005-04-14 17:42:15 +00:00
										 |  |  | if ($conf2->get_listAttributes('user') != "#uid;#cn") echo ("<br><font color=\"#FF0000\">Saving userlistAttributes failed!</font><br>"); | 
					
						
							|  |  |  | if ($conf2->get_listAttributes('group') != "#gidNumber;#cn;#memberUID") echo ("<br><font color=\"#FF0000\">Saving grouplistAttributes failed!</font><br>"); | 
					
						
							|  |  |  | if ($conf2->get_listAttributes('host') != "#cn;#uid;#description") echo ("<br><font color=\"#FF0000\">Saving hostlistAttributes failed!</font><br>"); | 
					
						
							| 
									
										
										
										
											2003-08-18 15:21:27 +00:00
										 |  |  | if ($conf2->get_defaultlanguage() != "de_AT:iso639_de:Deutsch (Oesterreich)") echo ("<br><font color=\"#FF0000\">Saving default language failed!</font><br>"); | 
					
						
							|  |  |  | if ($conf2->get_scriptPath() != "/var/www/lam/lib/script") echo ("<br><font color=\"#FF0000\">Saving script path failed!</font><br>"); | 
					
						
							| 
									
										
										
										
											2007-02-22 17:16:14 +00:00
										 |  |  | if ($conf2->get_scriptServers() != "127.0.0.1") echo ("<br><font color=\"#FF0000\">Saving script server failed!</font><br>"); | 
					
						
							|  |  |  | if ($conf2->get_scriptRights() != '775') echo ("<br><font color=\"#FF0000\">Saving script rights failed!</font><br>"); | 
					
						
							| 
									
										
										
										
											2004-07-18 10:18:25 +00:00
										 |  |  | $msettings = $conf2->get_moduleSettings(); | 
					
						
							| 
									
										
										
										
											2004-07-26 15:15:30 +00:00
										 |  |  | if (($msettings['test1'][0] != 11) || ($msettings['test2'][0] != 'abc') || ($msettings['test3'][0] != '3')) echo ("<br><font color=\"#FF0000\">Saving module settings failed!</font><br>"); | 
					
						
							| 
									
										
										
										
											2003-03-15 00:04:45 +00:00
										 |  |  | echo ("done<br>"); | 
					
						
							|  |  |  | // restore old values
 | 
					
						
							|  |  |  | echo ("Restoring old preferences..."); | 
					
						
							| 
									
										
										
										
											2003-08-18 15:21:27 +00:00
										 |  |  | $conf2->set_ServerURL($ServerURL); | 
					
						
							| 
									
										
										
										
											2003-09-19 19:29:02 +00:00
										 |  |  | $conf2->set_cacheTimeout($cachetimeout); | 
					
						
							| 
									
										
										
										
											2007-11-08 19:19:50 +00:00
										 |  |  | $conf2->set_Passwd('lam'); | 
					
						
							| 
									
										
										
										
											2003-08-18 15:21:27 +00:00
										 |  |  | $conf2->set_Adminstring($Adminstring); | 
					
						
							| 
									
										
										
										
											2005-03-10 20:20:00 +00:00
										 |  |  | $conf2->set_Suffix('user', $Suff_users); | 
					
						
							|  |  |  | $conf2->set_Suffix('group', $Suff_groups); | 
					
						
							|  |  |  | $conf2->set_Suffix('host', $Suff_hosts); | 
					
						
							| 
									
										
										
										
											2006-01-01 16:30:05 +00:00
										 |  |  | $conf2->set_Suffix('smbDomain', $Suff_domains); | 
					
						
							| 
									
										
										
										
											2005-04-14 17:42:15 +00:00
										 |  |  | $conf2->set_listAttributes($userlistAttributes, 'user'); | 
					
						
							|  |  |  | $conf2->set_listAttributes($grouplistAttributes, 'group'); | 
					
						
							|  |  |  | $conf2->set_listAttributes($hostlistAttributes, 'host'); | 
					
						
							| 
									
										
										
										
											2003-08-18 15:21:27 +00:00
										 |  |  | $conf2->set_defaultLanguage($defaultlanguage); | 
					
						
							|  |  |  | $conf2->set_scriptPath($scriptpath); | 
					
						
							| 
									
										
										
										
											2007-02-22 17:16:14 +00:00
										 |  |  | $conf2->set_scriptServers($scriptServer); | 
					
						
							| 
									
										
										
										
											2004-07-18 10:18:25 +00:00
										 |  |  | $conf2->set_moduleSettings($moduleSettings); | 
					
						
							| 
									
										
										
										
											2007-02-22 17:16:14 +00:00
										 |  |  | $conf2->set_scriptRights($scriptRights); | 
					
						
							| 
									
										
										
										
											2003-08-18 15:21:27 +00:00
										 |  |  | $conf2->save(); | 
					
						
							| 
									
										
										
										
											2003-03-15 00:04:45 +00:00
										 |  |  | echo ("done<br>"); | 
					
						
							|  |  |  | // finished
 | 
					
						
							|  |  |  | echo ("<br><b><font color=\"#00C000\">Test is complete.</font></b>"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-04-23 07:33:18 +00:00
										 |  |  | ?>
 |