authhtpasswd : Add support to authenticate the user from a .htpasswd file, created by "htpasswd" command. Allow to add easily a new user if the admin password is lost
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2279 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
59
Tests/authhtpasswdTest.php
Normal file
59
Tests/authhtpasswdTest.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/** DomFramework - Tests
|
||||
@package domframework
|
||||
@author Dominique Fournier <dominique@fournier38.fr> */
|
||||
|
||||
/** Test the authhtpasswd.php file */
|
||||
class test_authhtpasswd extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function test_clean ()
|
||||
{
|
||||
@unlink ("/tmp/htpasswd.file");
|
||||
file_put_contents ("/tmp/htpasswd.file",
|
||||
'toto@toto.com:$2y$05$dO7qyX4simzg3pMgWyqHgeAjFauXEyUdPdyrwDMVNj4fTuE24TGuq'
|
||||
."\n".
|
||||
'titi@titi.com:$2y$05$dO7qyX4simzg3pMgWyqHgeAjFauXEyUdPdyrwDMVNj4fTuE24TGuq'
|
||||
."\n"
|
||||
);
|
||||
}
|
||||
|
||||
public function test_connect ()
|
||||
{
|
||||
$authhtpasswd = new authhtpasswd ();
|
||||
$authhtpasswd->htpasswdFile = "/tmp/htpasswd.file";
|
||||
$res = $authhtpasswd->connect ();
|
||||
$this->assertEquals ($res, null);
|
||||
}
|
||||
|
||||
public function test_authentication1 ()
|
||||
{
|
||||
$authhtpasswd = new authhtpasswd ();
|
||||
$authhtpasswd->htpasswdFile = "/tmp/htpasswd.file";
|
||||
$res = $authhtpasswd->authentication ("toto@toto.com", "toto123");
|
||||
$this->assertEquals ($res, true);
|
||||
}
|
||||
|
||||
public function test_authentication2 ()
|
||||
{
|
||||
$authhtpasswd = new authhtpasswd ();
|
||||
$authhtpasswd->htpasswdFile = "/tmp/htpasswd.file";
|
||||
$this->setExpectedException ("Exception");
|
||||
$res = $authhtpasswd->authentication ("UNKNOWN@toto.com", "toto123");
|
||||
}
|
||||
|
||||
public function test_authentication3 ()
|
||||
{
|
||||
$authhtpasswd = new authhtpasswd ();
|
||||
$authhtpasswd->htpasswdFile = "/tmp/htpasswd.file";
|
||||
$this->setExpectedException ("Exception");
|
||||
$res = $authhtpasswd->authentication ("toto@toto.com", "BAD PASSWD");
|
||||
}
|
||||
|
||||
public function test_authentication4 ()
|
||||
{
|
||||
$authhtpasswd = new authhtpasswd ();
|
||||
$authhtpasswd->htpasswdFile = "/tmp/htpasswd.file";
|
||||
$res = $authhtpasswd->authentication ("titi@titi.com", "toto123");
|
||||
$this->assertEquals ($res, true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user