Passage en Namespace et tous les tests fonctionnels OK

This commit is contained in:
2021-05-10 11:48:15 +02:00
parent 536dd0d56b
commit eb30d8ef97
56 changed files with 1091 additions and 964 deletions

View File

@@ -7,8 +7,10 @@
namespace Domframework\Tests;
/** Test the authjwt.php file */
class authjwtTest extends \PHPUnit_Framework_TestCase
use Domframework\Authjwt;
/** Test the Authjwt.php file */
class AuthjwtTest extends \PHPUnit_Framework_TestCase
{
public function __construct ()
{
@@ -29,7 +31,7 @@ class authjwtTest extends \PHPUnit_Framework_TestCase
public function testJWT1 ()
// {{{
{
$authjwt = new authjwt ();
$authjwt = new Authjwt ();
$authjwt->cacheDir = $this->cacheDir;
$authjwt->serverKey = $this->serverKey;
$authjwt->cipherKey = $this->cipherKey;
@@ -44,7 +46,7 @@ class authjwtTest extends \PHPUnit_Framework_TestCase
public function testAuthValid1 ()
// {{{
{
$authjwt = new authjwt ();
$authjwt = new Authjwt ();
$_SERVER["HTTP_AUTHENTICATION"] = "Bearer ".$this->token;
$authjwt->cacheDir = $this->cacheDir;
$authjwt->serverKey = $this->serverKey;
@@ -62,7 +64,7 @@ class authjwtTest extends \PHPUnit_Framework_TestCase
// {{{
{
$this->expectException ("Exception", "JWT Signature not readable", 403);
$authjwt = new authjwt ();
$authjwt = new Authjwt ();
$_SERVER["HTTP_AUTHENTICATION"] = "Bearer ".$this->token."NO";
$authjwt->cacheDir = $this->cacheDir;
$authjwt->serverKey = $this->serverKey;
@@ -78,7 +80,7 @@ class authjwtTest extends \PHPUnit_Framework_TestCase
// {{{
{
$this->expectException ("Exception", "JWT with Empty algorithm", 403);
$authjwt = new authjwt ();
$authjwt = new Authjwt ();
$_SERVER["HTTP_AUTHENTICATION"] = "Bearer "."NO".$this->token;
$authjwt->cacheDir = $this->cacheDir;
$authjwt->serverKey = $this->serverKey;
@@ -94,7 +96,7 @@ class authjwtTest extends \PHPUnit_Framework_TestCase
// {{{
{
$this->expectException ("Exception", "No Authentication available", 401);
$authjwt = new authjwt ();
$authjwt = new Authjwt ();
unset ($_SERVER["HTTP_AUTHENTICATION"]);
$authjwt->cacheDir = $this->cacheDir;
$authjwt->serverKey = $this->serverKey;
@@ -111,7 +113,7 @@ class authjwtTest extends \PHPUnit_Framework_TestCase
{
$this->expectException ("Exception", "No Bearer Authentication available",
401);
$authjwt = new authjwt ();
$authjwt = new Authjwt ();
$_SERVER["HTTP_AUTHENTICATION"] = "Bearer";
$authjwt->cacheDir = $this->cacheDir;
$authjwt->serverKey = $this->serverKey;
@@ -129,7 +131,7 @@ class authjwtTest extends \PHPUnit_Framework_TestCase
$this->expectException ("Exception",
"AuthJWT : No email available in auth", 403);
$auth = ["password" => "ToTo"];
$authjwt = new authjwt ();
$authjwt = new Authjwt ();
$authjwt->cacheDir = $this->cacheDir;
$authjwt->serverKey = $this->serverKey;
$authjwt->cipherKey = $this->cipherKey;
@@ -148,7 +150,7 @@ class authjwtTest extends \PHPUnit_Framework_TestCase
$this->expectException ("Exception",
"AuthJWT : can not create token for anonymous", 403);
$auth = ["email" => "anonymous"];
$authjwt = new authjwt ();
$authjwt = new Authjwt ();
$authjwt->cacheDir = $this->cacheDir;
$authjwt->serverKey = $this->serverKey;
$authjwt->cipherKey = $this->cipherKey;
@@ -164,7 +166,7 @@ class authjwtTest extends \PHPUnit_Framework_TestCase
public function testLogout1 ()
// {{{
{
$authjwt = new authjwt ();
$authjwt = new Authjwt ();
$authjwt->cacheDir = $this->cacheDir;
$authjwt->serverKey = $this->serverKey;
$authjwt->cipherKey = $this->cipherKey;
@@ -180,7 +182,7 @@ class authjwtTest extends \PHPUnit_Framework_TestCase
// {{{
{
$this->expectException ("Exception", "No Authentication available", 401);
$authjwt = new authjwt ();
$authjwt = new Authjwt ();
$authjwt->cacheDir = $this->cacheDir;
$authjwt->serverKey = $this->serverKey;
$authjwt->cipherKey = $this->cipherKey;
@@ -196,7 +198,7 @@ class authjwtTest extends \PHPUnit_Framework_TestCase
{
$this->expectException ("Exception", "No Bearer Authentication available",
401);
$authjwt = new authjwt ();
$authjwt = new Authjwt ();
$authjwt->cacheDir = $this->cacheDir;
$authjwt->serverKey = $this->serverKey;
$authjwt->cipherKey = $this->cipherKey;
@@ -211,7 +213,7 @@ class authjwtTest extends \PHPUnit_Framework_TestCase
public function testUnusedFunctions1 ()
// {{{
{
$authjwt = new authjwt ();
$authjwt = new Authjwt ();
$res = $authjwt->connect ();
$this->assertSame ($res, true);
}
@@ -224,7 +226,7 @@ class authjwtTest extends \PHPUnit_Framework_TestCase
{
$this->expectException ("Exception",
"The password can't be change for JWT users", 405);
$authjwt = new authjwt ();
$authjwt = new Authjwt ();
$res = $authjwt->changepassword ("unused", "unused");
}
// }}}
@@ -236,7 +238,7 @@ class authjwtTest extends \PHPUnit_Framework_TestCase
{
$this->expectException ("Exception",
"The password can't be overwrite for JWT users", 405);
$authjwt = new authjwt ();
$authjwt = new Authjwt ();
$res = $authjwt->overwritepassword ("unused", "unused");
}
// }}}