PHP 8.2 Deprecated cleaning
This commit is contained in:
@@ -13,6 +13,15 @@ use Domframework\Authjwt;
|
|||||||
/** Test the Authjwt.php file */
|
/** Test the Authjwt.php file */
|
||||||
class AuthjwtTest extends \PHPUnit_Framework_TestCase
|
class AuthjwtTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
|
/** @var string */
|
||||||
|
private $cacheDir;
|
||||||
|
/** @var string */
|
||||||
|
private $serverKey;
|
||||||
|
/** @var string */
|
||||||
|
private $cipherKey;
|
||||||
|
/** @var string */
|
||||||
|
private $token;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->cacheDir = "/tmp/testDFWJWT-" . time();
|
$this->cacheDir = "/tmp/testDFWJWT-" . time();
|
||||||
@@ -26,11 +35,11 @@ class AuthjwtTest extends \PHPUnit_Framework_TestCase
|
|||||||
exec("rm -rf $this->cacheDir");
|
exec("rm -rf $this->cacheDir");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Create a valid token as email is provided
|
/**
|
||||||
|
* Create a valid token as email is provided
|
||||||
* payload = ["email" => "toto@example.com", "password" => "ToTo"];
|
* payload = ["email" => "toto@example.com", "password" => "ToTo"];
|
||||||
*/
|
*/
|
||||||
public function testJWT1()
|
public function testJWT1()
|
||||||
// {{{
|
|
||||||
{
|
{
|
||||||
$authjwt = new Authjwt();
|
$authjwt = new Authjwt();
|
||||||
$authjwt->cacheDir = $this->cacheDir;
|
$authjwt->cacheDir = $this->cacheDir;
|
||||||
@@ -40,12 +49,11 @@ class AuthjwtTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->token = $authjwt->createJwtToken($auth);
|
$this->token = $authjwt->createJwtToken($auth);
|
||||||
$this->assertSame(strlen($this->token), 145);
|
$this->assertSame(strlen($this->token), 145);
|
||||||
}
|
}
|
||||||
// }}}
|
|
||||||
|
|
||||||
/** Check if the authentication work
|
/**
|
||||||
*/
|
* Check if the authentication work
|
||||||
|
*/
|
||||||
public function testAuthValid1()
|
public function testAuthValid1()
|
||||||
// {{{
|
|
||||||
{
|
{
|
||||||
$authjwt = new Authjwt();
|
$authjwt = new Authjwt();
|
||||||
$_SERVER["HTTP_AUTHENTICATION"] = "Bearer " . $this->token;
|
$_SERVER["HTTP_AUTHENTICATION"] = "Bearer " . $this->token;
|
||||||
@@ -59,12 +67,11 @@ class AuthjwtTest extends \PHPUnit_Framework_TestCase
|
|||||||
["email" => "toto@example.com", "password" => "ToTo"]
|
["email" => "toto@example.com", "password" => "ToTo"]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// }}}
|
|
||||||
|
|
||||||
/** Invalid Token : reject with invalid signature
|
/**
|
||||||
*/
|
* Invalid Token : reject with invalid signature
|
||||||
|
*/
|
||||||
public function testInvalidToken1()
|
public function testInvalidToken1()
|
||||||
// {{{
|
|
||||||
{
|
{
|
||||||
$this->expectException("Exception", "JWT Signature not readable", 403);
|
$this->expectException("Exception", "JWT Signature not readable", 403);
|
||||||
$authjwt = new Authjwt();
|
$authjwt = new Authjwt();
|
||||||
@@ -75,12 +82,11 @@ class AuthjwtTest extends \PHPUnit_Framework_TestCase
|
|||||||
$authjwt->authentication("unused", "unused");
|
$authjwt->authentication("unused", "unused");
|
||||||
$res = $authjwt->getdetails();
|
$res = $authjwt->getdetails();
|
||||||
}
|
}
|
||||||
// }}}
|
|
||||||
|
|
||||||
/** Invalid Token : reject with bad algorithm
|
/**
|
||||||
*/
|
* Invalid Token : reject with bad algorithm
|
||||||
|
*/
|
||||||
public function testInvalidToken2()
|
public function testInvalidToken2()
|
||||||
// {{{
|
|
||||||
{
|
{
|
||||||
$this->expectException("Exception", "JWT with Empty algorithm", 403);
|
$this->expectException("Exception", "JWT with Empty algorithm", 403);
|
||||||
$authjwt = new Authjwt();
|
$authjwt = new Authjwt();
|
||||||
@@ -91,12 +97,11 @@ class AuthjwtTest extends \PHPUnit_Framework_TestCase
|
|||||||
$authjwt->authentication("unused", "unused");
|
$authjwt->authentication("unused", "unused");
|
||||||
$res = $authjwt->getdetails();
|
$res = $authjwt->getdetails();
|
||||||
}
|
}
|
||||||
// }}}
|
|
||||||
|
|
||||||
/** Invalid Token : No token provided
|
/**
|
||||||
*/
|
* Invalid Token : No token provided
|
||||||
|
*/
|
||||||
public function testInvalidToken3()
|
public function testInvalidToken3()
|
||||||
// {{{
|
|
||||||
{
|
{
|
||||||
$this->expectException("Exception", "No Authentication available", 401);
|
$this->expectException("Exception", "No Authentication available", 401);
|
||||||
$authjwt = new Authjwt();
|
$authjwt = new Authjwt();
|
||||||
@@ -107,12 +112,11 @@ class AuthjwtTest extends \PHPUnit_Framework_TestCase
|
|||||||
$authjwt->authentication("unused", "unused");
|
$authjwt->authentication("unused", "unused");
|
||||||
$res = $authjwt->getdetails();
|
$res = $authjwt->getdetails();
|
||||||
}
|
}
|
||||||
// }}}
|
|
||||||
|
|
||||||
/** Invalid Token : No Bearer authentication
|
/**
|
||||||
*/
|
* Invalid Token : No Bearer authentication
|
||||||
|
*/
|
||||||
public function testInvalidToken4()
|
public function testInvalidToken4()
|
||||||
// {{{
|
|
||||||
{
|
{
|
||||||
$this->expectException(
|
$this->expectException(
|
||||||
"Exception",
|
"Exception",
|
||||||
@@ -127,12 +131,11 @@ class AuthjwtTest extends \PHPUnit_Framework_TestCase
|
|||||||
$authjwt->authentication("unused", "unused");
|
$authjwt->authentication("unused", "unused");
|
||||||
$res = $authjwt->getdetails();
|
$res = $authjwt->getdetails();
|
||||||
}
|
}
|
||||||
// }}}
|
|
||||||
|
|
||||||
/** Invalid Token : no email in it
|
/**
|
||||||
*/
|
* Invalid Token : no email in it
|
||||||
|
*/
|
||||||
public function testInvalidToken5()
|
public function testInvalidToken5()
|
||||||
// {{{
|
|
||||||
{
|
{
|
||||||
$this->expectException(
|
$this->expectException(
|
||||||
"Exception",
|
"Exception",
|
||||||
@@ -149,12 +152,11 @@ class AuthjwtTest extends \PHPUnit_Framework_TestCase
|
|||||||
$authjwt->authentication("unused", "unused");
|
$authjwt->authentication("unused", "unused");
|
||||||
$res = $authjwt->getdetails();
|
$res = $authjwt->getdetails();
|
||||||
}
|
}
|
||||||
// }}}
|
|
||||||
|
|
||||||
/** Anonymous payload
|
/**
|
||||||
*/
|
* Anonymous payload
|
||||||
|
*/
|
||||||
public function testAnonymous1()
|
public function testAnonymous1()
|
||||||
// {{{
|
|
||||||
{
|
{
|
||||||
$this->expectException(
|
$this->expectException(
|
||||||
"Exception",
|
"Exception",
|
||||||
@@ -171,12 +173,11 @@ class AuthjwtTest extends \PHPUnit_Framework_TestCase
|
|||||||
$authjwt->authentication("unused", "unused");
|
$authjwt->authentication("unused", "unused");
|
||||||
$res = $authjwt->getdetails();
|
$res = $authjwt->getdetails();
|
||||||
}
|
}
|
||||||
// }}}
|
|
||||||
|
|
||||||
/** Logout
|
/**
|
||||||
*/
|
* Logout
|
||||||
|
*/
|
||||||
public function testLogout1()
|
public function testLogout1()
|
||||||
// {{{
|
|
||||||
{
|
{
|
||||||
$authjwt = new Authjwt();
|
$authjwt = new Authjwt();
|
||||||
$authjwt->cacheDir = $this->cacheDir;
|
$authjwt->cacheDir = $this->cacheDir;
|
||||||
@@ -186,12 +187,11 @@ class AuthjwtTest extends \PHPUnit_Framework_TestCase
|
|||||||
$res = $authjwt->logout();
|
$res = $authjwt->logout();
|
||||||
$this->assertSame($res, true);
|
$this->assertSame($res, true);
|
||||||
}
|
}
|
||||||
// }}}
|
|
||||||
|
|
||||||
/** Logout : No Auth provided
|
/**
|
||||||
*/
|
* Logout : No Auth provided
|
||||||
|
*/
|
||||||
public function testLogout2()
|
public function testLogout2()
|
||||||
// {{{
|
|
||||||
{
|
{
|
||||||
$this->expectException("Exception", "No Authentication available", 401);
|
$this->expectException("Exception", "No Authentication available", 401);
|
||||||
$authjwt = new Authjwt();
|
$authjwt = new Authjwt();
|
||||||
@@ -201,12 +201,11 @@ class AuthjwtTest extends \PHPUnit_Framework_TestCase
|
|||||||
unset($_SERVER["HTTP_AUTHENTICATION"]);
|
unset($_SERVER["HTTP_AUTHENTICATION"]);
|
||||||
$res = $authjwt->logout();
|
$res = $authjwt->logout();
|
||||||
}
|
}
|
||||||
// }}}
|
|
||||||
|
|
||||||
/** Logout : No Bearer available
|
/**
|
||||||
*/
|
* Logout : No Bearer available
|
||||||
|
*/
|
||||||
public function testLogout3()
|
public function testLogout3()
|
||||||
// {{{
|
|
||||||
{
|
{
|
||||||
$this->expectException(
|
$this->expectException(
|
||||||
"Exception",
|
"Exception",
|
||||||
@@ -220,24 +219,22 @@ class AuthjwtTest extends \PHPUnit_Framework_TestCase
|
|||||||
$_SERVER["HTTP_AUTHENTICATION"] = "Another auth";
|
$_SERVER["HTTP_AUTHENTICATION"] = "Another auth";
|
||||||
$res = $authjwt->logout();
|
$res = $authjwt->logout();
|
||||||
}
|
}
|
||||||
// }}}
|
|
||||||
|
|
||||||
|
|
||||||
/** Not needed function connect
|
/**
|
||||||
*/
|
* Not needed function connect
|
||||||
|
*/
|
||||||
public function testUnusedFunctions1()
|
public function testUnusedFunctions1()
|
||||||
// {{{
|
|
||||||
{
|
{
|
||||||
$authjwt = new Authjwt();
|
$authjwt = new Authjwt();
|
||||||
$res = $authjwt->connect();
|
$res = $authjwt->connect();
|
||||||
$this->assertSame($res, true);
|
$this->assertSame($res, true);
|
||||||
}
|
}
|
||||||
// }}}
|
|
||||||
|
|
||||||
/** Not needed function changepassword
|
/**
|
||||||
*/
|
* Not needed function changepassword
|
||||||
|
*/
|
||||||
public function testUnusedFunctions2()
|
public function testUnusedFunctions2()
|
||||||
// {{{
|
|
||||||
{
|
{
|
||||||
$this->expectException(
|
$this->expectException(
|
||||||
"Exception",
|
"Exception",
|
||||||
@@ -247,12 +244,11 @@ class AuthjwtTest extends \PHPUnit_Framework_TestCase
|
|||||||
$authjwt = new Authjwt();
|
$authjwt = new Authjwt();
|
||||||
$res = $authjwt->changepassword("unused", "unused");
|
$res = $authjwt->changepassword("unused", "unused");
|
||||||
}
|
}
|
||||||
// }}}
|
|
||||||
|
|
||||||
/** Not needed function overwritepassword
|
/**
|
||||||
*/
|
* Not needed function overwritepassword
|
||||||
|
*/
|
||||||
public function testUnusedFunctions3()
|
public function testUnusedFunctions3()
|
||||||
// {{{
|
|
||||||
{
|
{
|
||||||
$this->expectException(
|
$this->expectException(
|
||||||
"Exception",
|
"Exception",
|
||||||
@@ -262,5 +258,4 @@ class AuthjwtTest extends \PHPUnit_Framework_TestCase
|
|||||||
$authjwt = new Authjwt();
|
$authjwt = new Authjwt();
|
||||||
$res = $authjwt->overwritepassword("unused", "unused");
|
$res = $authjwt->overwritepassword("unused", "unused");
|
||||||
}
|
}
|
||||||
// }}}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -189,8 +189,8 @@ to this document.
|
|||||||
$date = date("Y-m-d H:i:s.u00");
|
$date = date("Y-m-d H:i:s.u00");
|
||||||
// DST must answer +0200 in winter and +0100 in summer
|
// DST must answer +0200 in winter and +0100 in summer
|
||||||
$dst = date("O");
|
$dst = date("O");
|
||||||
$this->assertSame($res, "--- Original ${date}0 $dst
|
$this->assertSame($res, "--- Original {$date}0 $dst
|
||||||
+++ New ${date}1 $dst
|
+++ New {$date}1 $dst
|
||||||
@@ -0,0 +1,6 @@
|
@@ -0,0 +1,6 @@
|
||||||
+This is an important
|
+This is an important
|
||||||
+notice! It should
|
+notice! It should
|
||||||
|
|||||||
@@ -12,7 +12,10 @@ namespace Domframework;
|
|||||||
user by its groups membership */
|
user by its groups membership */
|
||||||
class Authzgroups
|
class Authzgroups
|
||||||
{
|
{
|
||||||
/** The table prefix to use */
|
/**
|
||||||
|
* The table prefix to use
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
public $tableprefix = "";
|
public $tableprefix = "";
|
||||||
/** The dblayer object use to manage the Object table */
|
/** The dblayer object use to manage the Object table */
|
||||||
private $dbObject = null;
|
private $dbObject = null;
|
||||||
@@ -334,7 +337,7 @@ class Authzgroups
|
|||||||
$this->dbObject = new Dblayer($dsn, $username, $password, $driver_options);
|
$this->dbObject = new Dblayer($dsn, $username, $password, $driver_options);
|
||||||
$this->dbObject->debug = $this->debug;
|
$this->dbObject->debug = $this->debug;
|
||||||
$this->dbObject->table = "authzobject";
|
$this->dbObject->table = "authzobject";
|
||||||
$this->dbObject->prefix = $this->tableprefix;
|
$this->dbObject->tableprefix = $this->tableprefix;
|
||||||
$this->dbObject->fields = array(
|
$this->dbObject->fields = array(
|
||||||
"idobject" => array("integer", "not null", "autoincrement"),
|
"idobject" => array("integer", "not null", "autoincrement"),
|
||||||
"module" => array("varchar", "255", "not null"),
|
"module" => array("varchar", "255", "not null"),
|
||||||
@@ -351,7 +354,7 @@ class Authzgroups
|
|||||||
$this->dbGroup = new Dblayer($dsn, $username, $password, $driver_options);
|
$this->dbGroup = new Dblayer($dsn, $username, $password, $driver_options);
|
||||||
$this->dbGroup->debug = $this->debug;
|
$this->dbGroup->debug = $this->debug;
|
||||||
$this->dbGroup->table = "authzgroup";
|
$this->dbGroup->table = "authzgroup";
|
||||||
$this->dbGroup->prefix = $this->tableprefix;
|
$this->dbGroup->tableprefix = $this->tableprefix;
|
||||||
$this->dbGroup->fields = array(
|
$this->dbGroup->fields = array(
|
||||||
"idgroup" => array("integer", "not null", "autoincrement"),
|
"idgroup" => array("integer", "not null", "autoincrement"),
|
||||||
"module" => array("varchar", "255", "not null"),
|
"module" => array("varchar", "255", "not null"),
|
||||||
@@ -373,7 +376,7 @@ class Authzgroups
|
|||||||
);
|
);
|
||||||
$this->dbGroupMember->debug = $this->debug;
|
$this->dbGroupMember->debug = $this->debug;
|
||||||
$this->dbGroupMember->table = "authzgroupmember";
|
$this->dbGroupMember->table = "authzgroupmember";
|
||||||
$this->dbGroupMember->prefix = $this->tableprefix;
|
$this->dbGroupMember->tableprefix = $this->tableprefix;
|
||||||
$this->dbGroupMember->fields = array(
|
$this->dbGroupMember->fields = array(
|
||||||
"idgroupmember" => array("integer", "not null", "autoincrement"),
|
"idgroupmember" => array("integer", "not null", "autoincrement"),
|
||||||
"user" => array("varchar", "255", "not null"),
|
"user" => array("varchar", "255", "not null"),
|
||||||
@@ -394,7 +397,7 @@ class Authzgroups
|
|||||||
$this->dbRight = new Dblayer($dsn, $username, $password, $driver_options);
|
$this->dbRight = new Dblayer($dsn, $username, $password, $driver_options);
|
||||||
$this->dbRight->debug = $this->debug;
|
$this->dbRight->debug = $this->debug;
|
||||||
$this->dbRight->table = "authzright";
|
$this->dbRight->table = "authzright";
|
||||||
$this->dbRight->prefix = $this->tableprefix;
|
$this->dbRight->tableprefix = $this->tableprefix;
|
||||||
$this->dbRight->fields = array(
|
$this->dbRight->fields = array(
|
||||||
"idright" => array("integer", "not null", "autoincrement"),
|
"idright" => array("integer", "not null", "autoincrement"),
|
||||||
"idgroup" => array("integer", "not null"),
|
"idgroup" => array("integer", "not null"),
|
||||||
|
|||||||
@@ -234,6 +234,9 @@ extendedKeyUsage = serverAuth, clientAuth
|
|||||||
$days = 365,
|
$days = 365,
|
||||||
$altNames = array()
|
$altNames = array()
|
||||||
) {
|
) {
|
||||||
|
if ($days === null) {
|
||||||
|
$days = 365;
|
||||||
|
}
|
||||||
$conf = $this->opensslConf;
|
$conf = $this->opensslConf;
|
||||||
if (! empty($altNames)) {
|
if (! empty($altNames)) {
|
||||||
// Copy the commonName from CSR request into subjectAltName
|
// Copy the commonName from CSR request into subjectAltName
|
||||||
|
|||||||
@@ -1044,7 +1044,7 @@ class Dblayeroo
|
|||||||
if ($col["is_nullable"] === "NO") {
|
if ($col["is_nullable"] === "NO") {
|
||||||
$tmp[] = "not null";
|
$tmp[] = "not null";
|
||||||
}
|
}
|
||||||
if (substr($col["column_default"], 0, 7) === "nextval") {
|
if (is_string($col["column_default"]) && substr($col["column_default"], 0, 7) === "nextval") {
|
||||||
$tmp[] = "autoincrement";
|
$tmp[] = "autoincrement";
|
||||||
$primary = $col["column_name"];
|
$primary = $col["column_name"];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -362,7 +362,7 @@ class Mail
|
|||||||
$headersSplit = preg_split(
|
$headersSplit = preg_split(
|
||||||
"#([\r\n]+)#",
|
"#([\r\n]+)#",
|
||||||
$headersEML,
|
$headersEML,
|
||||||
null,
|
-1,
|
||||||
PREG_SPLIT_DELIM_CAPTURE
|
PREG_SPLIT_DELIM_CAPTURE
|
||||||
);
|
);
|
||||||
for ($i = 0; $i < count($headersSplit); $i = $i + 2) {
|
for ($i = 0; $i < count($headersSplit); $i = $i + 2) {
|
||||||
|
|||||||
Reference in New Issue
Block a user