authentication.php
2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
require_once("../../config/dmsDefaults.php");
/**
* $Id$
*
* Contains unit test code for authentication classes: lib/authentication
*
* Tests are:
* - creation of document subscription object
* - setting/getting of values
* - storing of object
* - updating of object
* - deletion of object
*
* Licensed under the GNU GPL. For full terms see the file COPYING.
*
* @version $Revision$
* @author Michael Joseph <michael@jamwarehouse.com>, Jam Warehouse (Pty) Ltd, South Africa
* @package tests.authentication
*/
if (checkSession()) {
require_once("$default->fileSystemRoot/lib/authentication/DBAuthenticator.inc");
echo "<b>Testing DB searching</b>";
// user attributes to search for
$aAttributes = array ("username", "name", "email", "mobile", "email_notification", "sms_notification");
$oDbAuth = new DBAuthenticator();
$sSearch = "user";
echo "<ul><li>searching for $sSearch with attributes=<pre>" . arrayToString($aAttributes) . "</pre></li>";
$aResults = $oDbAuth->searchUsers($sSearch, $aAttributes);
echo "<li><pre>" . arrayToString($aResults) . "</pre></li></ul>";
require_once("$default->fileSystemRoot/lib/authentication/LDAPAuthenticator.inc");
echo "<b>Testing LDAP searching</b>";
// user attributes to search for
$aAttributes = array ("dn", "uid", "givenname", "sn", "mail", "mobile");
$oLdapAuth = new LDAPAuthenticator();
$sSearch = "michael";
echo "<ul><li>searching for $sSearch with attributes=<pre>" . arrayToSTring($aAttributes) . "</pre></li>";
$aResults = $oLdapAuth->searchUsers($sSearch, $aAttributes);
echo "<li><pre>" . arrayToString($aResults) . "</pre></li></ul>";
echo "<b>Testing LDAP authentication</b>";
// user credentials to authenticate
$sUserName = "michael"; $sPassword = "pass123";
echo "<ul><li>Authenticating ($sUserName, $sPassword) : " . ($oLdapAuth->checkPassword($sUserName, $sPassword) ? "true" : "false") . "</li></ul>";
$sUserName = "rob"; $sPassword = "rob123";
echo "<ul><li>Authenticating ($sUserName, $sPassword) : " . ($oLdapAuth->checkPassword($sUserName, $sPassword) ? "true" : "false") . "</li></ul>";
$sUserName = "mukhtar"; $sPassword = "mukhtar123";
echo "<ul><li>Authenticating ($sUserName, $sPassword) : " . ($oLdapAuth->checkPassword($sUserName, $sPassword) ? "true" : "false") . "</li></ul>";
}
?>