From 7c0cada014e596ff8851e0ef40a2d7a9491e9f59 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sat, 2 Jan 2016 13:39:28 +0000 Subject: [PATCH] PHPunit --- lam/lib/config.inc | 4 +-- lam/tests/lib/modules/sudoRoleTest.php | 10 ++++---- lam/tests/lib/securityTest.php | 34 +++++++++++++------------- lam/tests/utils/configuration.inc | 2 +- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/lam/lib/config.inc b/lam/lib/config.inc index 8870a9cd..94582cb1 100644 --- a/lam/lib/config.inc +++ b/lam/lib/config.inc @@ -230,7 +230,7 @@ function deleteConfigProfile($name) { } } // delete config file - $confFile = $dir . $_POST['delfilename'] . ".conf"; + $confFile = $dir . $name . ".conf"; if (!@unlink($confFile)) { logNewMessage(LOG_ERR, 'Unable to delete ' . $confFile); return _("Unable to delete profile!"); @@ -386,7 +386,7 @@ class LAMLanguage { } /** -* This class manages .conf files. +* This class manages conf files. * * @package configuration */ diff --git a/lam/tests/lib/modules/sudoRoleTest.php b/lam/tests/lib/modules/sudoRoleTest.php index d2988ebe..0c542e3e 100644 --- a/lam/tests/lib/modules/sudoRoleTest.php +++ b/lam/tests/lib/modules/sudoRoleTest.php @@ -1,3 +1,4 @@ +assertNotTrue(sudoRole::isValidDate($testDate), $testDate); } } - + public function testEncodeDate() { $dates = array( '1.2.2014' => '20140201000000Z', @@ -59,7 +59,7 @@ class SudoRoleTest extends PHPUnit_Framework_TestCase { $this->assertEquals($output, sudoRole::encodeDate($input), $input . ' ' . $output); } } - + public function testDecodeDate() { $dates = array( '01.02.2014 00:00' => '20140201000000Z', @@ -75,7 +75,7 @@ class SudoRoleTest extends PHPUnit_Framework_TestCase { $this->assertEquals($output, sudoRole::decodeDate($input), $input . ' ' . $output); } } - + } ?> \ No newline at end of file diff --git a/lam/tests/lib/securityTest.php b/lam/tests/lib/securityTest.php index 3be52b04..869a5b3f 100644 --- a/lam/tests/lib/securityTest.php +++ b/lam/tests/lib/securityTest.php @@ -1,3 +1,4 @@ +cfg = &$_SESSION ['cfgMain']; $this->resetPasswordRules(); } - + public function testMinLength() { $this->cfg->passwordMinLength = 5; $this->checkPwd(array('55555', '666666'), array('1', '22', '333', '4444')); } - + public function testMinUpper() { $this->cfg->passwordMinUpper = 3; $this->checkPwd(array('55A5AA55', '6BB666BB66', 'ABC'), array ('1A', '2C2C', 'AB3', '44BB')); } - + public function testMinLower() { $this->cfg->passwordMinLower = 3; $this->checkPwd(array('55a5aa55', '6bb666bb66', 'abc'), array ('1a', '2c2c', 'ab3', '44bbABC')); } - + public function testMinNumeric() { $this->cfg->passwordMinNumeric = 3; $this->checkPwd(array('333', '4444'), array('1', '22', '33A', '44bb')); } - + public function testMinSymbol() { $this->cfg->passwordMinSymbol = 3; $this->checkPwd(array('---', '++++'), array('1.', '2.2.', '3+3+A', '44bb')); } - + public function testMinClasses() { $this->cfg->passwordMinClasses = 3; $this->checkPwd(array('aB.', 'aB.1', 'aa.B99'), array('1', '2.', '3+-', '44bb')); } - + public function testRulesCount() { $this->cfg->passwordMinUpper = 3; $this->cfg->passwordMinLower = 3; @@ -85,12 +85,12 @@ class SecurityTest extends PHPUnit_Framework_TestCase { $this->cfg->checkedRulesCount = 3; $this->checkPwd(array('ABC---abc', 'ABC123.-.-', 'ABCabc-'), array('1', '2.', '3+-', '44bb', 'ABC--22')); } - + public function testUser() { $this->cfg->passwordMustNotContainUser = 'true'; $this->checkPwd(array('u', 'us', 'use', 'use1r'), array('user', '2user', 'user3'), 'user'); } - + public function testUserAttributes() { $this->cfg->passwordMustNotContain3Chars = 'true'; $this->checkPwd(array('u', 'us', 'us1e', 'us1er'), array('use', 'user', '2user', 'user3'), 'user'); @@ -100,7 +100,7 @@ class SecurityTest extends PHPUnit_Framework_TestCase { 'user', array('first', 'last')); } - + /** * Resets the password rules to do no checks at all. */ @@ -115,10 +115,10 @@ class SecurityTest extends PHPUnit_Framework_TestCase { $this->cfg->passwordMustNotContainUser = 'false'; $this->cfg->passwordMustNotContain3Chars = 'false'; } - + /** * Checks if the given passwords are correctly accepted/rejected. - * + * * @param array $pwdsToAccept passwords that must be accepted * @param array $pwdsToReject passwords that must be rejected * @param String $userName user name diff --git a/lam/tests/utils/configuration.inc b/lam/tests/utils/configuration.inc index 2e3d3242..1c5acec0 100644 --- a/lam/tests/utils/configuration.inc +++ b/lam/tests/utils/configuration.inc @@ -1,3 +1,4 @@ +