From 5f69ceee4c3b4cc858414e8a7d2683465772735b Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Thu, 31 Oct 2024 11:48:04 +0100 Subject: [PATCH] [Security] Dropped obsolete InteractiveLoginToken --- .../Security/InteractiveLoginToken.php | 87 ------------------- .../Security/InteractiveLoginTokenTest.php | 54 ------------ 2 files changed, 141 deletions(-) delete mode 100644 src/lib/MVC/Symfony/Security/InteractiveLoginToken.php delete mode 100644 tests/lib/MVC/Symfony/Security/InteractiveLoginTokenTest.php diff --git a/src/lib/MVC/Symfony/Security/InteractiveLoginToken.php b/src/lib/MVC/Symfony/Security/InteractiveLoginToken.php deleted file mode 100644 index a8e4417b6b..0000000000 --- a/src/lib/MVC/Symfony/Security/InteractiveLoginToken.php +++ /dev/null @@ -1,87 +0,0 @@ -originalTokenType = $originalTokenType; - } - - public function getOriginalTokenType(): string - { - return $this->originalTokenType; - } - - /** - * @return array{ - * string, - * mixed, - * null|\Symfony\Component\Security\Core\Authentication\Token\TokenInterface - * } $data - */ - public function __serialize(): array - { - return [ - $this->originalTokenType, - parent::__serialize(), - $this->originalToken, - ]; - } - - /** - * @param array{ - * string, - * mixed, - * 2?: \Symfony\Component\Security\Core\Authentication\Token\TokenInterface - * } $data - */ - public function __unserialize(array $data): void - { - if (isset($data[2])) { - [$this->originalTokenType, $parentData, $this->originalToken] = $data; - } else { - [$this->originalTokenType, $parentData] = $data; - } - - parent::__unserialize($parentData); - } - - public function setOriginalToken(TokenInterface $token): void - { - $this->originalToken = $token; - } - - public function getOriginalToken(): ?TokenInterface - { - return $this->originalToken; - } - - public function isAuthenticated(): bool - { - if (null !== $this->originalToken) { - return $this->originalToken->isAuthenticated(); - } - - return parent::isAuthenticated(); - } -} diff --git a/tests/lib/MVC/Symfony/Security/InteractiveLoginTokenTest.php b/tests/lib/MVC/Symfony/Security/InteractiveLoginTokenTest.php deleted file mode 100644 index e029d0f3c1..0000000000 --- a/tests/lib/MVC/Symfony/Security/InteractiveLoginTokenTest.php +++ /dev/null @@ -1,54 +0,0 @@ -createMock(UserInterface::class); - $originalTokenType = 'FooBar'; - $credentials = 'my_credentials'; - $providerKey = 'key'; - $roles = ['ROLE_USER', 'ROLE_TEST', 'ROLE_FOO']; - $expectedRoles = []; - foreach ($roles as $role) { - if (is_string($role)) { - $expectedRoles[] = $role; - } else { - $expectedRoles[] = $role; - } - } - - $token = new InteractiveLoginToken($user, $originalTokenType, $credentials, $providerKey, $roles); - self::assertSame($user, $token->getUser()); - self::assertTrue($token->isAuthenticated()); - self::assertSame($originalTokenType, $token->getOriginalTokenType()); - self::assertSame($credentials, $token->getCredentials()); - self::assertSame($providerKey, $token->getFirewallName()); - self::assertEquals($expectedRoles, $token->getRoleNames()); - } - - public function testSerialize() - { - $user = $this->createMock(UserInterface::class); - $originalTokenType = 'FooBar'; - $credentials = 'my_credentials'; - $providerKey = 'key'; - $roles = ['ROLE_USER', 'ROLE_TEST', 'ROLE_FOO']; - - $token = new InteractiveLoginToken($user, $originalTokenType, $credentials, $providerKey, $roles); - $serialized = serialize($token); - $unserializedToken = unserialize($serialized); - self::assertEquals($token, $unserializedToken); - } -}