mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-22 09:53:35 +02:00
Fixed unit tests
This commit is contained in:
parent
720903c46a
commit
5773073e8d
1 changed files with 22 additions and 5 deletions
|
@ -44,8 +44,12 @@ namespace App\Tests\Entity\UserSystem;
|
||||||
|
|
||||||
use App\Entity\UserSystem\U2FKey;
|
use App\Entity\UserSystem\U2FKey;
|
||||||
use App\Entity\UserSystem\User;
|
use App\Entity\UserSystem\User;
|
||||||
|
use App\Entity\UserSystem\WebauthnKey;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
use Doctrine\Common\Collections\Collection;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Ramsey\Uuid\Uuid;
|
||||||
|
use Webauthn\TrustPath\EmptyTrustPath;
|
||||||
|
|
||||||
class UserTest extends TestCase
|
class UserTest extends TestCase
|
||||||
{
|
{
|
||||||
|
@ -142,13 +146,26 @@ class UserTest extends TestCase
|
||||||
$this->assertGreaterThan($old_value, $user->getTrustedTokenVersion());
|
$this->assertGreaterThan($old_value, $user->getTrustedTokenVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIsU2fEnabled(): void
|
public function testIsWebauthnEnabled(): void
|
||||||
{
|
{
|
||||||
$user = new User();
|
$user = new User();
|
||||||
$user->addU2FKey(new U2FKey());
|
$user->addWebauthnKey(new WebauthnKey(
|
||||||
$this->assertTrue($user->isU2FAuthEnabled());
|
"Test",
|
||||||
|
"Test",
|
||||||
|
[],
|
||||||
|
"Test",
|
||||||
|
new EmptyTrustPath(),
|
||||||
|
Uuid::fromDateTime(new \DateTime()),
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
0
|
||||||
|
));
|
||||||
|
$this->assertTrue($user->isWebAuthnAuthenticatorEnabled());
|
||||||
|
|
||||||
$user->getU2FKeys()->clear();
|
$result = $user->getWebauthnKeys();
|
||||||
$this->assertFalse($user->isU2FAuthEnabled());
|
if($result instanceof Collection){
|
||||||
|
$result->clear();
|
||||||
|
}
|
||||||
|
$this->assertFalse($user->isWebAuthnAuthenticatorEnabled());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue