From 5773073e8d09fa7a2edb5dd5098221ca7fab32bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Wed, 5 Oct 2022 22:21:34 +0200 Subject: [PATCH] Fixed unit tests --- tests/Entity/UserSystem/UserTest.php | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/tests/Entity/UserSystem/UserTest.php b/tests/Entity/UserSystem/UserTest.php index 38ca5420..f02f1f50 100644 --- a/tests/Entity/UserSystem/UserTest.php +++ b/tests/Entity/UserSystem/UserTest.php @@ -44,8 +44,12 @@ namespace App\Tests\Entity\UserSystem; use App\Entity\UserSystem\U2FKey; use App\Entity\UserSystem\User; +use App\Entity\UserSystem\WebauthnKey; use DateTime; +use Doctrine\Common\Collections\Collection; use PHPUnit\Framework\TestCase; +use Ramsey\Uuid\Uuid; +use Webauthn\TrustPath\EmptyTrustPath; class UserTest extends TestCase { @@ -142,13 +146,26 @@ class UserTest extends TestCase $this->assertGreaterThan($old_value, $user->getTrustedTokenVersion()); } - public function testIsU2fEnabled(): void + public function testIsWebauthnEnabled(): void { $user = new User(); - $user->addU2FKey(new U2FKey()); - $this->assertTrue($user->isU2FAuthEnabled()); + $user->addWebauthnKey(new WebauthnKey( + "Test", + "Test", + [], + "Test", + new EmptyTrustPath(), + Uuid::fromDateTime(new \DateTime()), + "", + "", + 0 + )); + $this->assertTrue($user->isWebAuthnAuthenticatorEnabled()); - $user->getU2FKeys()->clear(); - $this->assertFalse($user->isU2FAuthEnabled()); + $result = $user->getWebauthnKeys(); + if($result instanceof Collection){ + $result->clear(); + } + $this->assertFalse($user->isWebAuthnAuthenticatorEnabled()); } }