Merge pull request #14 from LDAPAccountManager/type_api_tmp

Type api tmp
This commit is contained in:
gruberroland 2016-12-26 19:33:09 +01:00 committed by GitHub
commit 8a432792ee
19 changed files with 576 additions and 511 deletions

View File

@ -1,6 +1,6 @@
{ {
"require-dev" : { "require-dev" : {
"phpunit/phpunit" : "5.5.*", "phpunit/phpunit" : "4.5.0",
"squizlabs/php_codesniffer" : "2.7.1" "squizlabs/php_codesniffer" : "2.7.1"
} }
} }

View File

@ -1,9 +1,10 @@
<?php <?php
namespace LAM\TOOLS\UPLOAD;
/* /*
$Id$ $Id$
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2009 - 2011 Roland Gruber Copyright (C) 2009 - 2016 Roland Gruber
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@ -33,7 +34,7 @@ $Id$
* *
* @package tools * @package tools
*/ */
class toolFileUpload implements LAMTool { class toolFileUpload implements \LAMTool {
/** /**
* Returns the name of the tool. * Returns the name of the tool.
@ -114,7 +115,9 @@ class toolFileUpload implements LAMTool {
* @return boolean visible * @return boolean visible
*/ */
function isVisible() { function isVisible() {
return (sizeof($_SESSION['config']->get_ActiveTypes()) > 0); $typeManager = new \LAM\TYPES\TypeManager();
$types = $typeManager->getConfiguredTypes();
return (sizeof($types) > 0);
} }
/** /**

View File

@ -1,20 +1,21 @@
<?php <?php
namespace LAM\TOOLS\MULTI_EDIT;
/* /*
$Id$ $Id$
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2013 Roland Gruber Copyright (C) 2013 - 2016 Roland Gruber
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@ -30,56 +31,56 @@ $Id$
/** /**
* Multi edit tool that allows LDAP operations on multiple entries. * Multi edit tool that allows LDAP operations on multiple entries.
* *
* @package tools * @package tools
*/ */
class toolMultiEdit implements LAMTool { class toolMultiEdit implements \LAMTool {
/** /**
* Returns the name of the tool. * Returns the name of the tool.
* *
* @return string name * @return string name
*/ */
function getName() { function getName() {
return _("Multi edit"); return _("Multi edit");
} }
/** /**
* returns a description text for the tool. * returns a description text for the tool.
* *
* @return string description * @return string description
*/ */
function getDescription() { function getDescription() {
return _("Performs modifications on multiple LDAP entries."); return _("Performs modifications on multiple LDAP entries.");
} }
/** /**
* Returns a link to the tool page (relative to templates/). * Returns a link to the tool page (relative to templates/).
* *
* @return string link * @return string link
*/ */
function getLink() { function getLink() {
return "multiEdit.php"; return "multiEdit.php";
} }
/** /**
* Returns if the tool requires write access to LDAP. * Returns if the tool requires write access to LDAP.
* *
* @return boolean true if write access is needed * @return boolean true if write access is needed
*/ */
function getRequiresWriteAccess() { function getRequiresWriteAccess() {
return true; return true;
} }
/** /**
* Returns if the tool requires password change rights. * Returns if the tool requires password change rights.
* *
* @return boolean true if password change rights are needed * @return boolean true if password change rights are needed
*/ */
function getRequiresPasswordChangeRights() { function getRequiresPasswordChangeRights() {
return true; return true;
} }
/** /**
* Returns the link to the tool image (relative to graphics/) * Returns the link to the tool image (relative to graphics/)
* *
@ -88,7 +89,7 @@ class toolMultiEdit implements LAMTool {
function getImageLink() { function getImageLink() {
return 'edit.png'; return 'edit.png';
} }
/** /**
* Returns the prefered position of this tool on the tools page. * Returns the prefered position of this tool on the tools page.
* The position may be between 0 and 1000. 0 is the top position. * The position may be between 0 and 1000. 0 is the top position.
@ -98,16 +99,16 @@ class toolMultiEdit implements LAMTool {
function getPosition() { function getPosition() {
return 400; return 400;
} }
/** /**
* Returns a list of sub tools or an empty array. * Returns a list of sub tools or an empty array.
* *
* @return array list of subtools (LAMTool) * @return array list of subtools (LAMTool)
*/ */
function getSubTools() { function getSubTools() {
return array(); return array();
} }
/** /**
* Returns if the tool is visible in the menu. * Returns if the tool is visible in the menu.
* *
@ -116,16 +117,16 @@ class toolMultiEdit implements LAMTool {
function isVisible() { function isVisible() {
return true; return true;
} }
/** /**
* Returns if a tool may be hidden by configuration in the LAM server profile. * Returns if a tool may be hidden by configuration in the LAM server profile.
* *
* @return boolean hideable * @return boolean hideable
*/ */
function isHideable() { function isHideable() {
return true; return true;
} }
} }
?> ?>

View File

@ -1,20 +1,21 @@
<?php <?php
namespace LAM\TOOLS\OU_EDIT;
/* /*
$Id$ $Id$
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2009 - 2011 Roland Gruber Copyright (C) 2009 - 2016 Roland Gruber
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@ -30,56 +31,56 @@ $Id$
/** /**
* OU editor * OU editor
* *
* @package tools * @package tools
*/ */
class toolOUEditor implements LAMTool { class toolOUEditor implements \LAMTool {
/** /**
* Returns the name of the tool. * Returns the name of the tool.
* *
* @return string name * @return string name
*/ */
function getName() { function getName() {
return _("OU editor"); return _("OU editor");
} }
/** /**
* returns a description text for the tool. * returns a description text for the tool.
* *
* @return string description * @return string description
*/ */
function getDescription() { function getDescription() {
return _("Manages OU objects in your LDAP tree."); return _("Manages OU objects in your LDAP tree.");
} }
/** /**
* Returns a link to the tool page (relative to templates/). * Returns a link to the tool page (relative to templates/).
* *
* @return string link * @return string link
*/ */
function getLink() { function getLink() {
return "ou_edit.php"; return "ou_edit.php";
} }
/** /**
* Returns if the tool requires write access to LDAP. * Returns if the tool requires write access to LDAP.
* *
* @return boolean true if write access is needed * @return boolean true if write access is needed
*/ */
function getRequiresWriteAccess() { function getRequiresWriteAccess() {
return true; return true;
} }
/** /**
* Returns if the tool requires password change rights. * Returns if the tool requires password change rights.
* *
* @return boolean true if password change rights are needed * @return boolean true if password change rights are needed
*/ */
function getRequiresPasswordChangeRights() { function getRequiresPasswordChangeRights() {
return true; return true;
} }
/** /**
* Returns the link to the tool image (relative to graphics/) * Returns the link to the tool image (relative to graphics/)
* *
@ -88,7 +89,7 @@ class toolOUEditor implements LAMTool {
function getImageLink() { function getImageLink() {
return 'ou.png'; return 'ou.png';
} }
/** /**
* Returns the prefered position of this tool on the tools page. * Returns the prefered position of this tool on the tools page.
* The position may be between 0 and 1000. 0 is the top position. * The position may be between 0 and 1000. 0 is the top position.
@ -98,34 +99,36 @@ class toolOUEditor implements LAMTool {
function getPosition() { function getPosition() {
return 500; return 500;
} }
/** /**
* Returns a list of sub tools or an empty array. * Returns a list of sub tools or an empty array.
* *
* @return array list of subtools (LAMTool) * @return array list of subtools (LAMTool)
*/ */
function getSubTools() { function getSubTools() {
return array(); return array();
} }
/** /**
* Returns if the tool is visible in the menu. * Returns if the tool is visible in the menu.
* *
* @return boolean visible * @return boolean visible
*/ */
function isVisible() { function isVisible() {
return (sizeof($_SESSION['config']->get_ActiveTypes()) > 0); $typeManager = new \LAM\TYPES\TypeManager();
$types = $typeManager->getConfiguredTypes();
return (sizeof($types) > 0);
} }
/** /**
* Returns if a tool may be hidden by configuration in the LAM server profile. * Returns if a tool may be hidden by configuration in the LAM server profile.
* *
* @return boolean hideable * @return boolean hideable
*/ */
function isHideable() { function isHideable() {
return true; return true;
} }
} }
?> ?>

View File

@ -1,20 +1,21 @@
<?php <?php
namespace LAM\TOOLS\PDF_EDITOR;
/* /*
$Id$ $Id$
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2009 - 2011 Roland Gruber Copyright (C) 2009 - 2016 Roland Gruber
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@ -30,56 +31,56 @@ $Id$
/** /**
* PDF editor * PDF editor
* *
* @package tools * @package tools
*/ */
class toolPDFEditor implements LAMTool { class toolPDFEditor implements \LAMTool {
/** /**
* Returns the name of the tool. * Returns the name of the tool.
* *
* @return string name * @return string name
*/ */
function getName() { function getName() {
return _("PDF editor"); return _("PDF editor");
} }
/** /**
* returns a description text for the tool. * returns a description text for the tool.
* *
* @return string description * @return string description
*/ */
function getDescription() { function getDescription() {
return _("This tool allows you to customize the PDF pages."); return _("This tool allows you to customize the PDF pages.");
} }
/** /**
* Returns a link to the tool page (relative to templates/). * Returns a link to the tool page (relative to templates/).
* *
* @return string link * @return string link
*/ */
function getLink() { function getLink() {
return "pdfedit/pdfmain.php"; return "pdfedit/pdfmain.php";
} }
/** /**
* Returns if the tool requires write access to LDAP. * Returns if the tool requires write access to LDAP.
* *
* @return boolean true if write access is needed * @return boolean true if write access is needed
*/ */
function getRequiresWriteAccess() { function getRequiresWriteAccess() {
return true; return true;
} }
/** /**
* Returns if the tool requires password change rights. * Returns if the tool requires password change rights.
* *
* @return boolean true if password change rights are needed * @return boolean true if password change rights are needed
*/ */
function getRequiresPasswordChangeRights() { function getRequiresPasswordChangeRights() {
return true; return true;
} }
/** /**
* Returns the link to the tool image (relative to graphics/) * Returns the link to the tool image (relative to graphics/)
* *
@ -88,7 +89,7 @@ class toolPDFEditor implements LAMTool {
function getImageLink() { function getImageLink() {
return 'pdf.png'; return 'pdf.png';
} }
/** /**
* Returns the prefered position of this tool on the tools page. * Returns the prefered position of this tool on the tools page.
* The position may be between 0 and 1000. 0 is the top position. * The position may be between 0 and 1000. 0 is the top position.
@ -98,34 +99,36 @@ class toolPDFEditor implements LAMTool {
function getPosition() { function getPosition() {
return 200; return 200;
} }
/** /**
* Returns a list of sub tools or an empty array. * Returns a list of sub tools or an empty array.
* *
* @return array list of subtools (LAMTool) * @return array list of subtools (LAMTool)
*/ */
function getSubTools() { function getSubTools() {
return array(); return array();
} }
/** /**
* Returns if the tool is visible in the menu. * Returns if the tool is visible in the menu.
* *
* @return boolean visible * @return boolean visible
*/ */
function isVisible() { function isVisible() {
return (sizeof($_SESSION['config']->get_ActiveTypes()) > 0); $typeManager = new \LAM\TYPES\TypeManager();
$types = $typeManager->getConfiguredTypes();
return (sizeof($types) > 0);
} }
/** /**
* Returns if a tool may be hidden by configuration in the LAM server profile. * Returns if a tool may be hidden by configuration in the LAM server profile.
* *
* @return boolean hideable * @return boolean hideable
*/ */
function isHideable() { function isHideable() {
return true; return true;
} }
} }
?> ?>

View File

@ -1,20 +1,21 @@
<?php <?php
namespace LAM\TOOLS\PROFILE_EDITOR;
/* /*
$Id$ $Id$
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2009 - 2011 Roland Gruber Copyright (C) 2009 - 2016 Roland Gruber
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@ -30,56 +31,56 @@ $Id$
/** /**
* Profile editor * Profile editor
* *
* @package tools * @package tools
*/ */
class toolProfileEditor implements LAMTool { class toolProfileEditor implements \LAMTool {
/** /**
* Returns the name of the tool. * Returns the name of the tool.
* *
* @return string name * @return string name
*/ */
function getName() { function getName() {
return _("Profile editor"); return _("Profile editor");
} }
/** /**
* returns a description text for the tool. * returns a description text for the tool.
* *
* @return string description * @return string description
*/ */
function getDescription() { function getDescription() {
return _("Here you can manage your account profiles."); return _("Here you can manage your account profiles.");
} }
/** /**
* Returns a link to the tool page (relative to templates/). * Returns a link to the tool page (relative to templates/).
* *
* @return string link * @return string link
*/ */
function getLink() { function getLink() {
return "profedit/profilemain.php"; return "profedit/profilemain.php";
} }
/** /**
* Returns if the tool requires write access to LDAP. * Returns if the tool requires write access to LDAP.
* *
* @return boolean true if write access is needed * @return boolean true if write access is needed
*/ */
function getRequiresWriteAccess() { function getRequiresWriteAccess() {
return true; return true;
} }
/** /**
* Returns if the tool requires password change rights. * Returns if the tool requires password change rights.
* *
* @return boolean true if password change rights are needed * @return boolean true if password change rights are needed
*/ */
function getRequiresPasswordChangeRights() { function getRequiresPasswordChangeRights() {
return true; return true;
} }
/** /**
* Returns the link to the tool image (relative to graphics/) * Returns the link to the tool image (relative to graphics/)
* *
@ -88,7 +89,7 @@ class toolProfileEditor implements LAMTool {
function getImageLink() { function getImageLink() {
return 'edit.png'; return 'edit.png';
} }
/** /**
* Returns the prefered position of this tool on the tools page. * Returns the prefered position of this tool on the tools page.
* The position may be between 0 and 1000. 0 is the top position. * The position may be between 0 and 1000. 0 is the top position.
@ -98,34 +99,36 @@ class toolProfileEditor implements LAMTool {
function getPosition() { function getPosition() {
return 100; return 100;
} }
/** /**
* Returns a list of sub tools or an empty array. * Returns a list of sub tools or an empty array.
* *
* @return array list of subtools (LAMTool) * @return array list of subtools (LAMTool)
*/ */
function getSubTools() { function getSubTools() {
return array(); return array();
} }
/** /**
* Returns if the tool is visible in the menu. * Returns if the tool is visible in the menu.
* *
* @return boolean visible * @return boolean visible
*/ */
function isVisible() { function isVisible() {
return (sizeof($_SESSION['config']->get_ActiveTypes()) > 0); $typeManager = new \LAM\TYPES\TypeManager();
$types = $typeManager->getConfiguredTypes();
return (sizeof($types) > 0);
} }
/** /**
* Returns if a tool may be hidden by configuration in the LAM server profile. * Returns if a tool may be hidden by configuration in the LAM server profile.
* *
* @return boolean hideable * @return boolean hideable
*/ */
function isHideable() { function isHideable() {
return true; return true;
} }
} }
?> ?>

View File

@ -1,4 +1,5 @@
<?php <?php
namespace LAM\TOOLS\SCHEMA;
/* /*
$Id$ $Id$
@ -9,12 +10,12 @@ $Id$
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@ -30,56 +31,56 @@ $Id$
/** /**
* Schema browser * Schema browser
* *
* @package tools * @package tools
*/ */
class toolSchemaBrowser implements LAMTool { class toolSchemaBrowser implements \LAMTool {
/** /**
* Returns the name of the tool. * Returns the name of the tool.
* *
* @return string name * @return string name
*/ */
function getName() { function getName() {
return _("Schema browser"); return _("Schema browser");
} }
/** /**
* returns a description text for the tool. * returns a description text for the tool.
* *
* @return string description * @return string description
*/ */
function getDescription() { function getDescription() {
return _("Here you can browse LDAP object classes and attributes."); return _("Here you can browse LDAP object classes and attributes.");
} }
/** /**
* Returns a link to the tool page (relative to templates/). * Returns a link to the tool page (relative to templates/).
* *
* @return string link * @return string link
*/ */
function getLink() { function getLink() {
return "schema/schema.php"; return "schema/schema.php";
} }
/** /**
* Returns if the tool requires write access to LDAP. * Returns if the tool requires write access to LDAP.
* *
* @return boolean true if write access is needed * @return boolean true if write access is needed
*/ */
function getRequiresWriteAccess() { function getRequiresWriteAccess() {
return false; return false;
} }
/** /**
* Returns if the tool requires password change rights. * Returns if the tool requires password change rights.
* *
* @return boolean true if password change rights are needed * @return boolean true if password change rights are needed
*/ */
function getRequiresPasswordChangeRights() { function getRequiresPasswordChangeRights() {
return false; return false;
} }
/** /**
* Returns the link to the tool image (relative to graphics/) * Returns the link to the tool image (relative to graphics/)
* *
@ -88,7 +89,7 @@ class toolSchemaBrowser implements LAMTool {
function getImageLink() { function getImageLink() {
return 'schemaBrowser.png'; return 'schemaBrowser.png';
} }
/** /**
* Returns the prefered position of this tool on the tools page. * Returns the prefered position of this tool on the tools page.
* The position may be between 0 and 1000. 0 is the top position. * The position may be between 0 and 1000. 0 is the top position.
@ -98,16 +99,16 @@ class toolSchemaBrowser implements LAMTool {
function getPosition() { function getPosition() {
return 600; return 600;
} }
/** /**
* Returns a list of sub tools or an empty array. * Returns a list of sub tools or an empty array.
* *
* @return array list of subtools (LAMTool) * @return array list of subtools (LAMTool)
*/ */
function getSubTools() { function getSubTools() {
return array(); return array();
} }
/** /**
* Returns if the tool is visible in the menu. * Returns if the tool is visible in the menu.
* *
@ -116,16 +117,16 @@ class toolSchemaBrowser implements LAMTool {
function isVisible() { function isVisible() {
return true; return true;
} }
/** /**
* Returns if a tool may be hidden by configuration in the LAM server profile. * Returns if a tool may be hidden by configuration in the LAM server profile.
* *
* @return boolean hideable * @return boolean hideable
*/ */
function isHideable() { function isHideable() {
return true; return true;
} }
} }
?> ?>

View File

@ -1,20 +1,21 @@
<?php <?php
namespace LAM\TOOLS\SERVER_INFO;
/* /*
$Id$ $Id$
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2009 - 2011 Roland Gruber Copyright (C) 2009 - 2016 Roland Gruber
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@ -30,56 +31,56 @@ $Id$
/** /**
* Server information * Server information
* *
* @package tools * @package tools
*/ */
class toolServerInformation implements LAMTool { class toolServerInformation implements \LAMTool {
/** /**
* Returns the name of the tool. * Returns the name of the tool.
* *
* @return string name * @return string name
*/ */
function getName() { function getName() {
return _("Server information"); return _("Server information");
} }
/** /**
* returns a description text for the tool. * returns a description text for the tool.
* *
* @return string description * @return string description
*/ */
function getDescription() { function getDescription() {
return _("Information about the LDAP server."); return _("Information about the LDAP server.");
} }
/** /**
* Returns a link to the tool page (relative to templates/). * Returns a link to the tool page (relative to templates/).
* *
* @return string link * @return string link
*/ */
function getLink() { function getLink() {
return "serverInfo.php"; return "serverInfo.php";
} }
/** /**
* Returns if the tool requires write access to LDAP. * Returns if the tool requires write access to LDAP.
* *
* @return boolean true if write access is needed * @return boolean true if write access is needed
*/ */
function getRequiresWriteAccess() { function getRequiresWriteAccess() {
return false; return false;
} }
/** /**
* Returns if the tool requires password change rights. * Returns if the tool requires password change rights.
* *
* @return boolean true if password change rights are needed * @return boolean true if password change rights are needed
*/ */
function getRequiresPasswordChangeRights() { function getRequiresPasswordChangeRights() {
return true; return true;
} }
/** /**
* Returns the link to the tool image (relative to graphics/) * Returns the link to the tool image (relative to graphics/)
* *
@ -88,7 +89,7 @@ class toolServerInformation implements LAMTool {
function getImageLink() { function getImageLink() {
return 'tree_info.png'; return 'tree_info.png';
} }
/** /**
* Returns the prefered position of this tool on the tools page. * Returns the prefered position of this tool on the tools page.
* The position may be between 0 and 1000. 0 is the top position. * The position may be between 0 and 1000. 0 is the top position.
@ -98,16 +99,16 @@ class toolServerInformation implements LAMTool {
function getPosition() { function getPosition() {
return 700; return 700;
} }
/** /**
* Returns a list of sub tools or an empty array. * Returns a list of sub tools or an empty array.
* *
* @return array list of subtools (LAMTool) * @return array list of subtools (LAMTool)
*/ */
function getSubTools() { function getSubTools() {
return array(); return array();
} }
/** /**
* Returns if the tool is visible in the menu. * Returns if the tool is visible in the menu.
* *
@ -116,16 +117,16 @@ class toolServerInformation implements LAMTool {
function isVisible() { function isVisible() {
return true; return true;
} }
/** /**
* Returns if a tool may be hidden by configuration in the LAM server profile. * Returns if a tool may be hidden by configuration in the LAM server profile.
* *
* @return boolean hideable * @return boolean hideable
*/ */
function isHideable() { function isHideable() {
return true; return true;
} }
} }
?> ?>

View File

@ -1,20 +1,21 @@
<?php <?php
namespace LAM\TOOLS\TESTS;
/* /*
$Id$ $Id$
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2009 - 2011 Roland Gruber Copyright (C) 2009 - 2016 Roland Gruber
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@ -30,56 +31,56 @@ $Id$
/** /**
* Tests page * Tests page
* *
* @package tools * @package tools
*/ */
class toolTests implements LAMTool { class toolTests implements \LAMTool {
/** /**
* Returns the name of the tool. * Returns the name of the tool.
* *
* @return string name * @return string name
*/ */
function getName() { function getName() {
return _("Tests"); return _("Tests");
} }
/** /**
* returns a description text for the tool. * returns a description text for the tool.
* *
* @return string description * @return string description
*/ */
function getDescription() { function getDescription() {
return _("Here you can test if certain LAM features work on your installation."); return _("Here you can test if certain LAM features work on your installation.");
} }
/** /**
* Returns a link to the tool page (relative to templates/). * Returns a link to the tool page (relative to templates/).
* *
* @return string link * @return string link
*/ */
function getLink() { function getLink() {
return "tests/index.php"; return "tests/index.php";
} }
/** /**
* Returns if the tool requires write access to LDAP. * Returns if the tool requires write access to LDAP.
* *
* @return boolean true if write access is needed * @return boolean true if write access is needed
*/ */
function getRequiresWriteAccess() { function getRequiresWriteAccess() {
return true; return true;
} }
/** /**
* Returns if the tool requires password change rights. * Returns if the tool requires password change rights.
* *
* @return boolean true if password change rights are needed * @return boolean true if password change rights are needed
*/ */
function getRequiresPasswordChangeRights() { function getRequiresPasswordChangeRights() {
return true; return true;
} }
/** /**
* Returns the link to the tool image (relative to graphics/) * Returns the link to the tool image (relative to graphics/)
* *
@ -88,7 +89,7 @@ class toolTests implements LAMTool {
function getImageLink() { function getImageLink() {
return 'tests.png'; return 'tests.png';
} }
/** /**
* Returns the prefered position of this tool on the tools page. * Returns the prefered position of this tool on the tools page.
* The position may be between 0 and 1000. 0 is the top position. * The position may be between 0 and 1000. 0 is the top position.
@ -98,21 +99,21 @@ class toolTests implements LAMTool {
function getPosition() { function getPosition() {
return 1000; return 1000;
} }
/** /**
* Returns a list of sub tools or an empty array. * Returns a list of sub tools or an empty array.
* *
* @return array list of subtools (LAMTool) * @return array list of subtools (LAMTool)
*/ */
function getSubTools() { function getSubTools() {
$return = array(); $return = array();
$lamdaemonTest = new LAMSubTool(); $lamdaemonTest = new \LAMSubTool();
$lamdaemonTest->name = _("Lamdaemon test"); $lamdaemonTest->name = _("Lamdaemon test");
$lamdaemonTest->link = 'tests/lamdaemonTest.php'; $lamdaemonTest->link = 'tests/lamdaemonTest.php';
$lamdaemonTest->description = _("Check if quotas and homedirectories can be managed."); $lamdaemonTest->description = _("Check if quotas and homedirectories can be managed.");
$lamdaemonTest->image = 'lamdaemonSmall.png'; $lamdaemonTest->image = 'lamdaemonSmall.png';
$return[] = $lamdaemonTest; $return[] = $lamdaemonTest;
$schemaTest = new LAMSubTool(); $schemaTest = new \LAMSubTool();
$schemaTest->name = _("Schema test"); $schemaTest->name = _("Schema test");
$schemaTest->link = 'tests/schemaTest.php'; $schemaTest->link = 'tests/schemaTest.php';
$schemaTest->description = _("Check if the LDAP schema fits the requirements of the selected account modules."); $schemaTest->description = _("Check if the LDAP schema fits the requirements of the selected account modules.");
@ -120,25 +121,27 @@ class toolTests implements LAMTool {
$return[] = $schemaTest; $return[] = $schemaTest;
return $return; return $return;
} }
/** /**
* Returns if the tool is visible in the menu. * Returns if the tool is visible in the menu.
* *
* @return boolean visible * @return boolean visible
*/ */
function isVisible() { function isVisible() {
return (sizeof($_SESSION['config']->get_ActiveTypes()) > 0); $typeManager = new \LAM\TYPES\TypeManager();
$types = $typeManager->getConfiguredTypes();
return (sizeof($types) > 0);
} }
/** /**
* Returns if a tool may be hidden by configuration in the LAM server profile. * Returns if a tool may be hidden by configuration in the LAM server profile.
* *
* @return boolean hideable * @return boolean hideable
*/ */
function isHideable() { function isHideable() {
return true; return true;
} }
} }
?> ?>

View File

@ -1,4 +1,22 @@
<?php <?php
namespace LAM\TOOLS\MULTI_EDIT;
use \htmlTable;
use \htmlTitle;
use \htmlSelect;
use \htmlOutputText;
use \htmlHelpLink;
use \htmlInputField;
use \htmlSubTitle;
use \htmlTableExtendedInputField;
use \htmlButton;
use \htmlStatusMessage;
use \htmlSpacer;
use \htmlHiddenInput;
use \htmlGroup;
use \htmlDiv;
use \htmlJavaScript;
use \htmlLink;
use \htmlInputTextarea;
/* /*
$Id$ $Id$
@ -85,11 +103,15 @@ function displayStartPage() {
$hideRules = array(); $hideRules = array();
$container->addElement(new htmlOutputText(_('LDAP suffix'))); $container->addElement(new htmlOutputText(_('LDAP suffix')));
$suffixGroup = new htmlTable(); $suffixGroup = new htmlTable();
$types = $_SESSION['config']->get_ActiveTypes(); $typeManager = new \LAM\TYPES\TypeManager();
$types = $typeManager->getConfiguredTypes();
$suffixes = array(); $suffixes = array();
foreach ($types as $type) { foreach ($types as $type) {
$suffixes[LAM\TYPES\getTypeAlias($type)] = $_SESSION['config']->get_Suffix($type); if ($type->isHidden()) {
$hideRules[$_SESSION['config']->get_Suffix($type)] = array('otherSuffix'); continue;
}
$suffixes[$type->getAlias()] = $type->getSuffix();
$hideRules[$type->getSuffix()] = array('otherSuffix');
} }
$treeSuffix = $_SESSION['config']->get_Suffix('tree'); $treeSuffix = $_SESSION['config']->get_Suffix('tree');
if (!empty($treeSuffix)) { if (!empty($treeSuffix)) {

View File

@ -1,4 +1,15 @@
<?php <?php
namespace LAM\TOOLS\OU_EDIT;
use \htmlTable;
use \htmlSpacer;
use \htmlOutputText;
use \htmlButton;
use \htmlHiddenInput;
use \htmlSubTitle;
use \htmlStatusMessage;
use \htmlSelect;
use \htmlHelpLink;
use \htmlInputField;
/* /*
$Id$ $Id$
@ -51,8 +62,6 @@ if (!empty($_POST)) {
validateSecurityToken(); validateSecurityToken();
} }
$types = $_SESSION['config']->get_ActiveTypes();
// check if deletion was canceled // check if deletion was canceled
if (isset($_POST['abort'])) { if (isset($_POST['abort'])) {
display_main(null, null); display_main(null, null);
@ -166,13 +175,14 @@ function display_main($message, $error) {
$container->addElement($msg, true); $container->addElement($msg, true);
} }
$typeManager = new \LAM\TYPES\TypeManager();
$typeList = $typeManager->getConfiguredTypes();
$types = array(); $types = array();
$typeList = $_SESSION['config']->get_ActiveTypes(); foreach ($typeList as $type) {
for ($i = 0; $i < sizeof($typeList); $i++) { if ($type->isHidden() || !checkIfWriteAccessIsAllowed($type->getId())) {
if (isAccountTypeHidden($typeList[$i]) || !checkIfWriteAccessIsAllowed($typeList[$i])) {
continue; continue;
} }
$types[$typeList[$i]] = LAM\TYPES\getTypeAlias($typeList[$i]); $types[$type->getId()] = $type->getAlias();
} }
natcasesort($types); natcasesort($types);
$options = array(); $options = array();

View File

@ -21,7 +21,7 @@
*/ */
include_once (dirname ( __FILE__ ) . '/../utils/configuration.inc'); include_once 'lam/tests/utils/configuration.inc';
/** /**
* LAMConfig test case. * LAMConfig test case.

View File

@ -21,200 +21,203 @@
*/ */
include_once '../../../lib/baseModule.inc'; if (is_readable('lam/lib/modules/ppolicyUser.inc')) {
include_once '../../../lib/modules.inc';
include_once '../../../lib/passwordExpirationJob.inc';
include_once '../../../lib/modules/ppolicyUser.inc';
/** include_once 'lam/lib/baseModule.inc';
* Checks the ppolicy expire job. include_once 'lam/lib/modules.inc';
* include_once 'lam/lib/passwordExpirationJob.inc';
* @author Roland Gruber include_once 'lam/lib/modules/ppolicyUser.inc';
*
*/
class PPolicyUserPasswordNotifyJobTest extends PHPUnit_Framework_TestCase {
private $job; /**
* Checks the ppolicy expire job.
*
* @author Roland Gruber
*
*/
class PPolicyUserPasswordNotifyJobTest extends PHPUnit_Framework_TestCase {
const JOB_ID = 'jobID'; private $job;
const WARNING = '14';
const DEFAULT_POLICY = 'cn=default,dc=test';
const NOEXPIRE_POLICY = 'cn=noexpire,dc=test';
const ONE_YEAR_POLICY = 'cn=policy1,dc=test';
private $options = array(); const JOB_ID = 'jobID';
const WARNING = '14';
const DEFAULT_POLICY = 'cn=default,dc=test';
const NOEXPIRE_POLICY = 'cn=noexpire,dc=test';
const ONE_YEAR_POLICY = 'cn=policy1,dc=test';
public function setUp() { private $options = array();
$this->job = $this->getMockBuilder('PPolicyPasswordNotifyJob')
->setMethods(array('getDBLastPwdChangeTime', 'setDBLastPwdChangeTime', 'sendMail',
'findUsers', 'getConfigPrefix', 'getPolicyOptions'))
->getMock();
$this->job->method('getConfigPrefix')->willReturn('test');
$this->job->method('sendMail')->willReturn(true);
$this->job->method('getPolicyOptions')->willReturn(array(
PPolicyUserPasswordNotifyJobTest::ONE_YEAR_POLICY => array('pwdmaxage' => 365 * 3600 * 24),
PPolicyUserPasswordNotifyJobTest::DEFAULT_POLICY => array('pwdmaxage' => 14 * 3600 * 24),
PPolicyUserPasswordNotifyJobTest::NOEXPIRE_POLICY => array('pwdmaxage' => 0),
));
$this->options['test_mailNotificationPeriod' . PPolicyUserPasswordNotifyJobTest::JOB_ID][0] = PPolicyUserPasswordNotifyJobTest::WARNING;
$this->options['test_mailDefaultPolicy' . PPolicyUserPasswordNotifyJobTest::JOB_ID][0] = PPolicyUserPasswordNotifyJobTest::DEFAULT_POLICY;
}
public function testNoAccounts() { public function setUp() {
$this->job->method('findUsers')->willReturn(array()); $this->job = $this->getMockBuilder('PPolicyPasswordNotifyJob')
->setMethods(array('getDBLastPwdChangeTime', 'setDBLastPwdChangeTime', 'sendMail',
'findUsers', 'getConfigPrefix', 'getPolicyOptions'))
->getMock();
$this->job->method('getConfigPrefix')->willReturn('test');
$this->job->method('sendMail')->willReturn(true);
$this->job->method('getPolicyOptions')->willReturn(array(
PPolicyUserPasswordNotifyJobTest::ONE_YEAR_POLICY => array('pwdmaxage' => 365 * 3600 * 24),
PPolicyUserPasswordNotifyJobTest::DEFAULT_POLICY => array('pwdmaxage' => 14 * 3600 * 24),
PPolicyUserPasswordNotifyJobTest::NOEXPIRE_POLICY => array('pwdmaxage' => 0),
));
$this->options['test_mailNotificationPeriod' . PPolicyUserPasswordNotifyJobTest::JOB_ID][0] = PPolicyUserPasswordNotifyJobTest::WARNING;
$this->options['test_mailDefaultPolicy' . PPolicyUserPasswordNotifyJobTest::JOB_ID][0] = PPolicyUserPasswordNotifyJobTest::DEFAULT_POLICY;
}
$this->job->expects($this->never())->method('setDBLastPwdChangeTime'); public function testNoAccounts() {
$this->job->expects($this->never())->method('sendMail'); $this->job->method('findUsers')->willReturn(array());
$pdo = array(); $this->job->expects($this->never())->method('setDBLastPwdChangeTime');
$this->job->execute(PPolicyUserPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false); $this->job->expects($this->never())->method('sendMail');
}
public function testAccountDoesNotExpire() { $pdo = array();
$this->job->method('findUsers')->willReturn(array(array( $this->job->execute(PPolicyUserPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false);
'dn' => 'cn=noexpire,dc=dn', }
'pwdpolicysubentry' => array(PPolicyUserPasswordNotifyJobTest::NOEXPIRE_POLICY),
'pwdchangedtime' => array('20000101112233Z')
)));
$this->job->expects($this->never())->method('setDBLastPwdChangeTime'); public function testAccountDoesNotExpire() {
$this->job->expects($this->never())->method('sendMail'); $this->job->method('findUsers')->willReturn(array(array(
'dn' => 'cn=noexpire,dc=dn',
'pwdpolicysubentry' => array(PPolicyUserPasswordNotifyJobTest::NOEXPIRE_POLICY),
'pwdchangedtime' => array('20000101112233Z')
)));
$pdo = array(); $this->job->expects($this->never())->method('setDBLastPwdChangeTime');
$this->job->execute(PPolicyUserPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false); $this->job->expects($this->never())->method('sendMail');
}
public function testAccountLocked() { $pdo = array();
$this->job->method('findUsers')->willReturn(array(array( $this->job->execute(PPolicyUserPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false);
'dn' => 'cn=locked,dc=dn', }
'pwdpolicysubentry' => array(PPolicyUserPasswordNotifyJobTest::ONE_YEAR_POLICY),
'pwdaccountlockedtime' => array('20010101112233Z'),
'pwdchangedtime' => array('20000101112233Z')
)));
$this->job->expects($this->never())->method('setDBLastPwdChangeTime'); public function testAccountLocked() {
$this->job->expects($this->never())->method('sendMail'); $this->job->method('findUsers')->willReturn(array(array(
'dn' => 'cn=locked,dc=dn',
'pwdpolicysubentry' => array(PPolicyUserPasswordNotifyJobTest::ONE_YEAR_POLICY),
'pwdaccountlockedtime' => array('20010101112233Z'),
'pwdchangedtime' => array('20000101112233Z')
)));
$pdo = array(); $this->job->expects($this->never())->method('setDBLastPwdChangeTime');
$this->job->execute(PPolicyUserPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false); $this->job->expects($this->never())->method('sendMail');
}
public function testAccountExpired() { $pdo = array();
$this->job->method('findUsers')->willReturn(array(array( $this->job->execute(PPolicyUserPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false);
'dn' => 'cn=expired,dc=dn', }
'pwdpolicysubentry' => array(PPolicyUserPasswordNotifyJobTest::ONE_YEAR_POLICY),
'pwdchangedtime' => array('20000101112233Z'),
)));
$this->job->expects($this->never())->method('setDBLastPwdChangeTime'); public function testAccountExpired() {
$this->job->expects($this->never())->method('sendMail'); $this->job->method('findUsers')->willReturn(array(array(
'dn' => 'cn=expired,dc=dn',
'pwdpolicysubentry' => array(PPolicyUserPasswordNotifyJobTest::ONE_YEAR_POLICY),
'pwdchangedtime' => array('20000101112233Z'),
)));
$pdo = array(); $this->job->expects($this->never())->method('setDBLastPwdChangeTime');
$this->job->execute(PPolicyUserPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false); $this->job->expects($this->never())->method('sendMail');
}
public function testWarningNotReached() { $pdo = array();
$now = new DateTime('now', getTimeZone()); $this->job->execute(PPolicyUserPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false);
$lastChangeNow = floor($now->format('U')/3600/24); }
$this->job->method('getDBLastPwdChangeTime')->willReturn($lastChangeNow);
$date = new DateTime('now', new DateTimeZone('UTC'));
$this->job->method('findUsers')->willReturn(array(array(
'dn' => 'cn=notReached,dc=dn',
'pwdpolicysubentry' => array(PPolicyUserPasswordNotifyJobTest::ONE_YEAR_POLICY),
'pwdchangedtime' => array($date->format('YmdHis') . 'Z'),
)));
$this->job->expects($this->never())->method('setDBLastPwdChangeTime'); public function testWarningNotReached() {
$this->job->expects($this->never())->method('sendMail'); $now = new DateTime('now', getTimeZone());
$lastChangeNow = floor($now->format('U')/3600/24);
$this->job->method('getDBLastPwdChangeTime')->willReturn($lastChangeNow);
$date = new DateTime('now', new DateTimeZone('UTC'));
$this->job->method('findUsers')->willReturn(array(array(
'dn' => 'cn=notReached,dc=dn',
'pwdpolicysubentry' => array(PPolicyUserPasswordNotifyJobTest::ONE_YEAR_POLICY),
'pwdchangedtime' => array($date->format('YmdHis') . 'Z'),
)));
$pdo = array(); $this->job->expects($this->never())->method('setDBLastPwdChangeTime');
$this->job->execute(PPolicyUserPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false); $this->job->expects($this->never())->method('sendMail');
}
public function testAlreadyWarned() { $pdo = array();
$now = new DateTime('now', getTimeZone()); $this->job->execute(PPolicyUserPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false);
$date = new DateTime('now', new DateTimeZone('UTC')); }
$date->sub(new DateInterval('P360D'));
$this->job->method('getDBLastPwdChangeTime')->willReturn($date->format('YmdHis') . 'Z');
$this->job->method('findUsers')->willReturn(array(array(
'dn' => 'cn=alreadyWarned,dc=dn',
'pwdpolicysubentry' => array(PPolicyUserPasswordNotifyJobTest::ONE_YEAR_POLICY),
'pwdchangedtime' => array($date->format('YmdHis') . 'Z'),
)));
$this->job->expects($this->once())->method('getDBLastPwdChangeTime'); public function testAlreadyWarned() {
$this->job->expects($this->never())->method('setDBLastPwdChangeTime'); $now = new DateTime('now', getTimeZone());
$this->job->expects($this->never())->method('sendMail'); $date = new DateTime('now', new DateTimeZone('UTC'));
$date->sub(new DateInterval('P360D'));
$this->job->method('getDBLastPwdChangeTime')->willReturn($date->format('YmdHis') . 'Z');
$this->job->method('findUsers')->willReturn(array(array(
'dn' => 'cn=alreadyWarned,dc=dn',
'pwdpolicysubentry' => array(PPolicyUserPasswordNotifyJobTest::ONE_YEAR_POLICY),
'pwdchangedtime' => array($date->format('YmdHis') . 'Z'),
)));
$pdo = array(); $this->job->expects($this->once())->method('getDBLastPwdChangeTime');
$this->job->execute(PPolicyUserPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false); $this->job->expects($this->never())->method('setDBLastPwdChangeTime');
} $this->job->expects($this->never())->method('sendMail');
public function testWarning() { $pdo = array();
$now = new DateTime('now', getTimeZone()); $this->job->execute(PPolicyUserPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false);
$date = new DateTime('now', new DateTimeZone('UTC')); }
$date->sub(new DateInterval('P360D'));
$this->job->method('getDBLastPwdChangeTime')->willReturn('20001111101010Z');
$this->job->method('findUsers')->willReturn(array(array(
'dn' => 'cn=alreadyWarned,dc=dn',
'pwdpolicysubentry' => array(PPolicyUserPasswordNotifyJobTest::ONE_YEAR_POLICY),
'pwdchangedtime' => array($date->format('YmdHis') . 'Z'),
)));
$this->job->expects($this->once())->method('getDBLastPwdChangeTime'); public function testWarning() {
$this->job->expects($this->once())->method('setDBLastPwdChangeTime'); $now = new DateTime('now', getTimeZone());
$this->job->expects($this->once())->method('sendMail'); $date = new DateTime('now', new DateTimeZone('UTC'));
$date->sub(new DateInterval('P360D'));
$this->job->method('getDBLastPwdChangeTime')->willReturn('20001111101010Z');
$this->job->method('findUsers')->willReturn(array(array(
'dn' => 'cn=alreadyWarned,dc=dn',
'pwdpolicysubentry' => array(PPolicyUserPasswordNotifyJobTest::ONE_YEAR_POLICY),
'pwdchangedtime' => array($date->format('YmdHis') . 'Z'),
)));
$pdo = array(); $this->job->expects($this->once())->method('getDBLastPwdChangeTime');
$this->job->execute(PPolicyUserPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false); $this->job->expects($this->once())->method('setDBLastPwdChangeTime');
} $this->job->expects($this->once())->method('sendMail');
public function testWarningDryRun() { $pdo = array();
$now = new DateTime('now', getTimeZone()); $this->job->execute(PPolicyUserPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false);
$date = new DateTime('now', new DateTimeZone('UTC')); }
$date->sub(new DateInterval('P360D'));
$this->job->method('getDBLastPwdChangeTime')->willReturn('20001111101010Z');
$this->job->method('findUsers')->willReturn(array(array(
'dn' => 'cn=alreadyWarned,dc=dn',
'pwdpolicysubentry' => array(PPolicyUserPasswordNotifyJobTest::ONE_YEAR_POLICY),
'pwdchangedtime' => array($date->format('YmdHis') . 'Z'),
)));
$this->job->expects($this->once())->method('getDBLastPwdChangeTime'); public function testWarningDryRun() {
$this->job->expects($this->never())->method('setDBLastPwdChangeTime'); $now = new DateTime('now', getTimeZone());
$this->job->expects($this->never())->method('sendMail'); $date = new DateTime('now', new DateTimeZone('UTC'));
$date->sub(new DateInterval('P360D'));
$this->job->method('getDBLastPwdChangeTime')->willReturn('20001111101010Z');
$this->job->method('findUsers')->willReturn(array(array(
'dn' => 'cn=alreadyWarned,dc=dn',
'pwdpolicysubentry' => array(PPolicyUserPasswordNotifyJobTest::ONE_YEAR_POLICY),
'pwdchangedtime' => array($date->format('YmdHis') . 'Z'),
)));
$pdo = array(); $this->job->expects($this->once())->method('getDBLastPwdChangeTime');
$this->job->execute(PPolicyUserPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, true); $this->job->expects($this->never())->method('setDBLastPwdChangeTime');
} $this->job->expects($this->never())->method('sendMail');
public function testGetWarningTimeInSeconds() { $pdo = array();
$confDays = 7; $this->job->execute(PPolicyUserPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, true);
$policy = array('pwdmaxage' => 365 * 3600 * 24, 'pwdexpirewarning' => 10000); }
$seconds = $this->job->getWarningTimeInSeconds($confDays, $policy); public function testGetWarningTimeInSeconds() {
$confDays = 7;
$policy = array('pwdmaxage' => 365 * 3600 * 24, 'pwdexpirewarning' => 10000);
$this->assertEquals((7*3600*24 + 10000), $seconds); $seconds = $this->job->getWarningTimeInSeconds($confDays, $policy);
$this->assertEquals((7*3600*24 + 10000), $seconds);
$confDays = 0; $confDays = 0;
$policy = array('pwdmaxage' => 365 * 3600 * 24, 'pwdexpirewarning' => 10000); $policy = array('pwdmaxage' => 365 * 3600 * 24, 'pwdexpirewarning' => 10000);
$seconds = $this->job->getWarningTimeInSeconds($confDays, $policy); $seconds = $this->job->getWarningTimeInSeconds($confDays, $policy);
$this->assertEquals(10000, $seconds); $this->assertEquals(10000, $seconds);
$confDays = 7; $confDays = 7;
$policy = array('pwdmaxage' => 365 * 3600 * 24); $policy = array('pwdmaxage' => 365 * 3600 * 24);
$seconds = $this->job->getWarningTimeInSeconds($confDays, $policy); $seconds = $this->job->getWarningTimeInSeconds($confDays, $policy);
$this->assertEquals(7*3600*24, $seconds); $this->assertEquals(7*3600*24, $seconds);
}
} }
} }
?> ?>

View File

@ -21,10 +21,9 @@
*/ */
include_once (dirname ( __FILE__ ) . '/../../../lib/baseModule.inc'); include_once 'lam/lib/baseModule.inc';
include_once (dirname ( __FILE__ ) . '/../../../lib/modules.inc'); include_once 'lam/lib/modules.inc';
include_once (dirname ( __FILE__ ) . '/../../../lib/passwordExpirationJob.inc'); include_once 'lam/lib/modules/sambaSamAccount.inc';
include_once (dirname ( __FILE__ ) . '/../../../lib/modules/sambaSamAccount.inc');
/** /**
* Checks the shadow expire job. * Checks the shadow expire job.

View File

@ -21,145 +21,148 @@
*/ */
include_once (dirname ( __FILE__ ) . '/../../../lib/baseModule.inc'); if (is_readable('lam/lib/passwordExpirationJob.inc')) {
include_once (dirname ( __FILE__ ) . '/../../../lib/modules.inc');
include_once (dirname ( __FILE__ ) . '/../../../lib/passwordExpirationJob.inc');
include_once (dirname ( __FILE__ ) . '/../../../lib/modules/shadowAccount.inc');
/** include_once 'lam/lib/baseModule.inc';
* Checks the shadow expire job. include_once 'lam/lib/modules.inc';
* include_once 'lam/lib/passwordExpirationJob.inc';
* @author Roland Gruber include_once 'lam/lib/modules/shadowAccount.inc';
*
*/
class ShadowAccountPasswordNotifyJobTest extends PHPUnit_Framework_TestCase {
private $job; /**
* Checks the shadow expire job.
*
* @author Roland Gruber
*
*/
class ShadowAccountPasswordNotifyJobTest extends PHPUnit_Framework_TestCase {
const JOB_ID = 'jobID'; private $job;
const WARNING = '14';
private $options = array(); const JOB_ID = 'jobID';
const WARNING = '14';
public function setUp() { private $options = array();
$this->job = $this->getMockBuilder('ShadowAccountPasswordNotifyJob')
->setMethods(array('getDBLastPwdChangeTime', 'setDBLastPwdChangeTime', 'sendMail', 'findUsers', 'getConfigPrefix'))
->getMock();
$this->job->method('getConfigPrefix')->willReturn('test');
$this->job->method('sendMail')->willReturn(true);
$this->options['test_mailNotificationPeriod' . ShadowAccountPasswordNotifyJobTest::JOB_ID][0] = ShadowAccountPasswordNotifyJobTest::WARNING;
}
public function testNoAccounts() { public function setUp() {
$this->job->method('findUsers')->willReturn(array()); $this->job = $this->getMockBuilder('ShadowAccountPasswordNotifyJob')
->setMethods(array('getDBLastPwdChangeTime', 'setDBLastPwdChangeTime', 'sendMail', 'findUsers', 'getConfigPrefix'))
->getMock();
$this->job->method('getConfigPrefix')->willReturn('test');
$this->job->method('sendMail')->willReturn(true);
$this->options['test_mailNotificationPeriod' . ShadowAccountPasswordNotifyJobTest::JOB_ID][0] = ShadowAccountPasswordNotifyJobTest::WARNING;
}
$this->job->expects($this->never())->method('setDBLastPwdChangeTime'); public function testNoAccounts() {
$this->job->expects($this->never())->method('sendMail'); $this->job->method('findUsers')->willReturn(array());
$pdo = array(); $this->job->expects($this->never())->method('setDBLastPwdChangeTime');
$this->job->execute(ShadowAccountPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false); $this->job->expects($this->never())->method('sendMail');
}
public function testAccountDoesNotExpire() { $pdo = array();
$this->job->method('findUsers')->willReturn(array(array( $this->job->execute(ShadowAccountPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false);
'dn' => 'cn=some,dc=dn', }
'shadowmax' => array('0'),
'shadowlastchange' => array('1')
)));
$this->job->expects($this->never())->method('setDBLastPwdChangeTime'); public function testAccountDoesNotExpire() {
$this->job->expects($this->never())->method('sendMail'); $this->job->method('findUsers')->willReturn(array(array(
'dn' => 'cn=some,dc=dn',
'shadowmax' => array('0'),
'shadowlastchange' => array('1')
)));
$pdo = array(); $this->job->expects($this->never())->method('setDBLastPwdChangeTime');
$this->job->execute(ShadowAccountPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false); $this->job->expects($this->never())->method('sendMail');
}
public function testAccountExpired() { $pdo = array();
$this->job->method('findUsers')->willReturn(array(array( $this->job->execute(ShadowAccountPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false);
'dn' => 'cn=some,dc=dn', }
'shadowmax' => array('10'),
'shadowlastchange' => array('1')
)));
$this->job->expects($this->never())->method('setDBLastPwdChangeTime'); public function testAccountExpired() {
$this->job->expects($this->never())->method('sendMail'); $this->job->method('findUsers')->willReturn(array(array(
'dn' => 'cn=some,dc=dn',
'shadowmax' => array('10'),
'shadowlastchange' => array('1')
)));
$pdo = array(); $this->job->expects($this->never())->method('setDBLastPwdChangeTime');
$this->job->execute(ShadowAccountPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false); $this->job->expects($this->never())->method('sendMail');
}
public function testWarningNotReached() { $pdo = array();
$now = new DateTime('now', getTimeZone()); $this->job->execute(ShadowAccountPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false);
$lastChangeNow = floor($now->format('U')/3600/24); }
$this->job->method('getDBLastPwdChangeTime')->willReturn($lastChangeNow);
$this->job->method('findUsers')->willReturn(array(array(
'dn' => 'cn=some,dc=dn',
'shadowmax' => array('300'),
'shadowlastchange' => array($lastChangeNow)
)));
$this->job->expects($this->never())->method('setDBLastPwdChangeTime'); public function testWarningNotReached() {
$this->job->expects($this->never())->method('sendMail'); $now = new DateTime('now', getTimeZone());
$lastChangeNow = floor($now->format('U')/3600/24);
$this->job->method('getDBLastPwdChangeTime')->willReturn($lastChangeNow);
$this->job->method('findUsers')->willReturn(array(array(
'dn' => 'cn=some,dc=dn',
'shadowmax' => array('300'),
'shadowlastchange' => array($lastChangeNow)
)));
$pdo = array(); $this->job->expects($this->never())->method('setDBLastPwdChangeTime');
$this->job->execute(ShadowAccountPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false); $this->job->expects($this->never())->method('sendMail');
}
public function testAlreadyWarned() { $pdo = array();
$now = new DateTime('now', getTimeZone()); $this->job->execute(ShadowAccountPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false);
$lastChangeNow = floor($now->format('U')/3600/24); }
$this->job->method('getDBLastPwdChangeTime')->willReturn($lastChangeNow);
$this->job->method('findUsers')->willReturn(array(array(
'dn' => 'cn=some,dc=dn',
'shadowmax' => array('10'),
'shadowlastchange' => array($lastChangeNow)
)));
$this->job->expects($this->once())->method('getDBLastPwdChangeTime'); public function testAlreadyWarned() {
$this->job->expects($this->never())->method('setDBLastPwdChangeTime'); $now = new DateTime('now', getTimeZone());
$this->job->expects($this->never())->method('sendMail'); $lastChangeNow = floor($now->format('U')/3600/24);
$this->job->method('getDBLastPwdChangeTime')->willReturn($lastChangeNow);
$this->job->method('findUsers')->willReturn(array(array(
'dn' => 'cn=some,dc=dn',
'shadowmax' => array('10'),
'shadowlastchange' => array($lastChangeNow)
)));
$pdo = array(); $this->job->expects($this->once())->method('getDBLastPwdChangeTime');
$this->job->execute(ShadowAccountPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false); $this->job->expects($this->never())->method('setDBLastPwdChangeTime');
} $this->job->expects($this->never())->method('sendMail');
public function testWarning() { $pdo = array();
$now = new DateTime('now', getTimeZone()); $this->job->execute(ShadowAccountPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false);
$lastChangeNow = floor($now->format('U')/3600/24); }
$this->job->method('getDBLastPwdChangeTime')->willReturn('1');
$this->job->method('findUsers')->willReturn(array(array(
'dn' => 'cn=some,dc=dn',
'shadowmax' => array('10'),
'shadowlastchange' => array($lastChangeNow)
)));
$this->job->expects($this->once())->method('getDBLastPwdChangeTime'); public function testWarning() {
$this->job->expects($this->once())->method('setDBLastPwdChangeTime'); $now = new DateTime('now', getTimeZone());
$this->job->expects($this->once())->method('sendMail'); $lastChangeNow = floor($now->format('U')/3600/24);
$this->job->method('getDBLastPwdChangeTime')->willReturn('1');
$this->job->method('findUsers')->willReturn(array(array(
'dn' => 'cn=some,dc=dn',
'shadowmax' => array('10'),
'shadowlastchange' => array($lastChangeNow)
)));
$pdo = array(); $this->job->expects($this->once())->method('getDBLastPwdChangeTime');
$this->job->execute(ShadowAccountPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false); $this->job->expects($this->once())->method('setDBLastPwdChangeTime');
} $this->job->expects($this->once())->method('sendMail');
public function testWarningDryRun() { $pdo = array();
$now = new DateTime('now', getTimeZone()); $this->job->execute(ShadowAccountPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, false);
$lastChangeNow = floor($now->format('U')/3600/24); }
$this->job->method('getDBLastPwdChangeTime')->willReturn('1');
$this->job->method('findUsers')->willReturn(array(array(
'dn' => 'cn=some,dc=dn',
'shadowmax' => array('10'),
'shadowlastchange' => array($lastChangeNow)
)));
$this->job->expects($this->once())->method('getDBLastPwdChangeTime'); public function testWarningDryRun() {
$this->job->expects($this->never())->method('setDBLastPwdChangeTime'); $now = new DateTime('now', getTimeZone());
$this->job->expects($this->never())->method('sendMail'); $lastChangeNow = floor($now->format('U')/3600/24);
$this->job->method('getDBLastPwdChangeTime')->willReturn('1');
$this->job->method('findUsers')->willReturn(array(array(
'dn' => 'cn=some,dc=dn',
'shadowmax' => array('10'),
'shadowlastchange' => array($lastChangeNow)
)));
$this->job->expects($this->once())->method('getDBLastPwdChangeTime');
$this->job->expects($this->never())->method('setDBLastPwdChangeTime');
$this->job->expects($this->never())->method('sendMail');
$pdo = array();
$this->job->execute(ShadowAccountPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, true);
}
$pdo = array();
$this->job->execute(ShadowAccountPasswordNotifyJobTest::JOB_ID, $this->options, $pdo, true);
} }
} }
?> ?>

View File

@ -3,7 +3,7 @@
$Id$ $Id$
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2014 Roland Gruber Copyright (C) 2014 - 2016 Roland Gruber
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@ -21,59 +21,63 @@ $Id$
*/ */
include_once (dirname ( __FILE__ ) . '/../../../lib/baseModule.inc'); if (is_readable('lam/lib/modules/sudoRole.inc')) {
include_once (dirname ( __FILE__ ) . '/../../../lib/modules/sudoRole.inc');
/** include_once 'lam/lib/baseModule.inc';
* Checks sudo role functions. include_once 'lam/lib/modules/sudoRole.inc';
*
* @author Roland Gruber
*
*/
class SudoRoleTest extends PHPUnit_Framework_TestCase {
public function testIsValidDate() { /**
$valid = array('22.10.2014', '05.01.2013', '1.3.2014', '10.5.2014', '4.12.2015', * Checks sudo role functions.
'05.01.2013 22:15', '1.3.2014 5:1', '10.5.2014 13:3', '4.12.2015 5:22'); *
foreach ($valid as $testDate) { * @author Roland Gruber
$this->assertTrue(sudoRole::isValidDate($testDate)); *
} */
$invalid = array('10.25.2014', 'abc', '2014-10-12', '10.022014', '10:12', '22.10.2014 12'); class SudoRoleTest extends PHPUnit_Framework_TestCase {
foreach ($invalid as $testDate) {
$this->assertNotTrue(sudoRole::isValidDate($testDate), $testDate);
}
}
public function testEncodeDate() { public function testIsValidDate() {
$dates = array( $valid = array('22.10.2014', '05.01.2013', '1.3.2014', '10.5.2014', '4.12.2015',
'1.2.2014' => '20140201000000Z', '05.01.2013 22:15', '1.3.2014 5:1', '10.5.2014 13:3', '4.12.2015 5:22');
'10.2.2014' => '20140210000000Z', foreach ($valid as $testDate) {
'1.11.2014' => '20141101000000Z', $this->assertTrue(sudoRole::isValidDate($testDate));
'20.12.2014' => '20141220000000Z', }
'1.2.2014 1:2' => '20140201010200Z', $invalid = array('10.25.2014', 'abc', '2014-10-12', '10.022014', '10:12', '22.10.2014 12');
'10.2.2014 1:10' => '20140210011000Z', foreach ($invalid as $testDate) {
'1.11.2014 10:2' => '20141101100200Z', $this->assertNotTrue(sudoRole::isValidDate($testDate), $testDate);
'20.12.2014 10:12' => '20141220101200Z', }
);
foreach ($dates as $input => $output) {
$this->assertEquals($output, sudoRole::encodeDate($input), $input . ' ' . $output);
} }
}
public function testDecodeDate() { public function testEncodeDate() {
$dates = array( $dates = array(
'01.02.2014 00:00' => '20140201000000Z', '1.2.2014' => '20140201000000Z',
'10.02.2014 00:00' => '20140210000000Z', '10.2.2014' => '20140210000000Z',
'01.11.2014 00:00' => '20141101000000Z', '1.11.2014' => '20141101000000Z',
'20.12.2014 00:00' => '20141220000000Z', '20.12.2014' => '20141220000000Z',
'01.02.2014 01:02' => '20140201010200Z', '1.2.2014 1:2' => '20140201010200Z',
'10.02.2014 01:10' => '20140210011000Z', '10.2.2014 1:10' => '20140210011000Z',
'01.11.2014 10:02' => '20141101100200Z', '1.11.2014 10:2' => '20141101100200Z',
'20.12.2014 10:12' => '20141220101200Z', '20.12.2014 10:12' => '20141220101200Z',
); );
foreach ($dates as $output => $input) { foreach ($dates as $input => $output) {
$this->assertEquals($output, sudoRole::decodeDate($input), $input . ' ' . $output); $this->assertEquals($output, sudoRole::encodeDate($input), $input . ' ' . $output);
}
} }
public function testDecodeDate() {
$dates = array(
'01.02.2014 00:00' => '20140201000000Z',
'10.02.2014 00:00' => '20140210000000Z',
'01.11.2014 00:00' => '20141101000000Z',
'20.12.2014 00:00' => '20141220000000Z',
'01.02.2014 01:02' => '20140201010200Z',
'10.02.2014 01:10' => '20140210011000Z',
'01.11.2014 10:02' => '20141101100200Z',
'20.12.2014 10:12' => '20141220101200Z',
);
foreach ($dates as $output => $input) {
$this->assertEquals($output, sudoRole::decodeDate($input), $input . ' ' . $output);
}
}
} }
} }

View File

@ -23,8 +23,8 @@ $Id$
$_SERVER ['REMOTE_ADDR'] = '127.0.0.1'; $_SERVER ['REMOTE_ADDR'] = '127.0.0.1';
include_once (dirname ( __FILE__ ) . '/../utils/configuration.inc'); include_once 'lam/tests/utils/configuration.inc';
include_once (dirname ( __FILE__ ) . '/../../lib/security.inc'); include_once 'lam/lib/security.inc';
/** /**
* Checks password checking functions. * Checks password checking functions.

View File

@ -21,7 +21,7 @@ $Id$
*/ */
require_once '../../lib/types.inc'; require_once 'lam/lib/types.inc';
/** /**
* Checks ListAttribute. * Checks ListAttribute.

View File

@ -5,4 +5,10 @@
<directory>lam/tests</directory> <directory>lam/tests</directory>
</testsuite> </testsuite>
</testsuites> </testsuites>
<php>
<includePath>.</includePath>
</php>
<logging>
<log type="coverage-html" target="../code-coverage/html"/>
</logging>
</phpunit> </phpunit>