mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 18:48:51 +02:00
Merge remote-tracking branch 'refs/remotes/origin/support/3.0' into support/3.1
This commit is contained in:
@@ -8,36 +8,38 @@ use TokenValidation;
|
|||||||
|
|
||||||
class TokenValidationTest extends ItopDataTestCase
|
class TokenValidationTest extends ItopDataTestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param string $sSetupToken
|
* @param string $sSetupToken
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function createSetupTokenFile(string $sSetupToken): string
|
public function createSetupTokenFile(string $sSetupToken): string
|
||||||
{
|
{
|
||||||
$sSetupTokenFile = APPROOT.'data/.setup';
|
$sSetupTokenFile = APPROOT . 'data/.setup';
|
||||||
file_put_contents($sSetupTokenFile, $sSetupToken);
|
file_put_contents($sSetupTokenFile, $sSetupToken);
|
||||||
|
|
||||||
return $sSetupTokenFile;
|
return $sSetupTokenFile;
|
||||||
}protected function setUp(): void
|
}
|
||||||
{
|
|
||||||
parent::setUp();
|
|
||||||
$this->RequireOnceItopFile('datamodels/2.x/itop-hub-connector/TokenValidation.php');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testLaunch()
|
/**
|
||||||
{
|
* @group itop-community
|
||||||
$oTokenValidation = new TokenValidation();
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testLaunch()
|
||||||
|
{
|
||||||
|
$this->RequireOnceItopFile('datamodels/2.x/itop-hub-connector/TokenValidation.php');
|
||||||
|
|
||||||
$sSetupToken = bin2hex(random_bytes(12));
|
$oTokenValidation = new TokenValidation();
|
||||||
$this->assertFalse($oTokenValidation->isSetupTokenValid('lol'));
|
|
||||||
$this->assertFalse($oTokenValidation->isSetupTokenValid(''));
|
$sSetupToken = bin2hex(random_bytes(12));
|
||||||
$this->assertFalse($oTokenValidation->isSetupTokenValid($sSetupToken));
|
$this->assertFalse($oTokenValidation->isSetupTokenValid('lol'));
|
||||||
$this->createSetupTokenFile($sSetupToken);
|
$this->assertFalse($oTokenValidation->isSetupTokenValid(''));
|
||||||
$this->assertFalse($oTokenValidation->isSetupTokenValid('lol'));
|
$this->assertFalse($oTokenValidation->isSetupTokenValid($sSetupToken));
|
||||||
$this->createSetupTokenFile($sSetupToken);
|
$this->createSetupTokenFile($sSetupToken);
|
||||||
$this->assertFalse($oTokenValidation->isSetupTokenValid(''));
|
$this->assertFalse($oTokenValidation->isSetupTokenValid('lol'));
|
||||||
$this->createSetupTokenFile($sSetupToken);
|
$this->createSetupTokenFile($sSetupToken);
|
||||||
$this->assertTrue($oTokenValidation->isSetupTokenValid($sSetupToken));
|
$this->assertFalse($oTokenValidation->isSetupTokenValid(''));
|
||||||
}
|
$this->createSetupTokenFile($sSetupToken);
|
||||||
|
$this->assertTrue($oTokenValidation->isSetupTokenValid($sSetupToken));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user