From 5814dc495b29833b9df6c23bbef40cbf274ec268 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sat, 3 May 2014 18:48:11 +0000 Subject: [PATCH] sudo roles: added "not before", "not after" and order --- lam/tests/lib/modules/sudoRoleTest.php | 80 ++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 lam/tests/lib/modules/sudoRoleTest.php diff --git a/lam/tests/lib/modules/sudoRoleTest.php b/lam/tests/lib/modules/sudoRoleTest.php new file mode 100644 index 00000000..e38f67c1 --- /dev/null +++ b/lam/tests/lib/modules/sudoRoleTest.php @@ -0,0 +1,80 @@ +/* +$Id$ + + This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) + Copyright (C) 2014 Roland Gruber + + 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. + + 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. + + 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 + +*/ +assertTrue(sudoRole::isValidDate($testDate)); + } + $invalid = array('10.25.2014', 'abc', '2014-10-12', '10.022014', '10:12', '22.10.2014 12'); + foreach ($invalid as $testDate) { + $this->assertNotTrue(sudoRole::isValidDate($testDate), $testDate); + } + } + + public function testEncodeDate() { + $dates = array( + '1.2.2014' => '20140201000000Z', + '10.2.2014' => '20140210000000Z', + '1.11.2014' => '20141101000000Z', + '20.12.2014' => '20141220000000Z', + '1.2.2014 1:2' => '20140201010200Z', + '10.2.2014 1:10' => '20140210011000Z', + '1.11.2014 10:2' => '20141101100200Z', + '20.12.2014 10:12' => '20141220101200Z', + ); + foreach ($dates as $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); + } + } + +} + +?> \ No newline at end of file