Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ protected function configure(): void
;
}


Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/**
* @params array<string, list<string>> $algorithms
* @params array<string, list<string>> $issuers
Expand Down Expand Up @@ -80,19 +79,19 @@ protected function execute(InputInterface $input, OutputInterface $output): int

private function getGenerator(?string $firewall): OidcTokenGenerator
{
if (0 === count($this->generators)) {
if (0 === \count($this->generators)) {
throw new \InvalidArgumentException('No OIDC token generator configured.');
}

if ($firewall) {
return $this->generators[$firewall] ?? throw new \InvalidArgumentException(sprintf('Invalid firewall. Available firewalls: "%s".', implode('", "', array_keys($this->generators))));
return $this->generators[$firewall] ?? throw new \InvalidArgumentException(\sprintf('Invalid firewall. Available firewalls: "%s".', implode('", "', array_keys($this->generators))));
}

if (1 === count($this->generators)) {
if (1 === \count($this->generators)) {
return end($this->generators);
}

throw new \InvalidArgumentException(sprintf('Please choose an firewall. Available firewalls: "%s".', implode('", "', array_keys($this->generators))));
throw new \InvalidArgumentException(\sprintf('Please choose an firewall. Available firewalls: "%s".', implode('", "', array_keys($this->generators))));
}

public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
Expand All @@ -103,13 +102,13 @@ public function complete(CompletionInput $input, CompletionSuggestions $suggesti

if ($input->mustSuggestOptionValuesFor('algorithm')) {
foreach ($this->algorithms as $algorithm => $firewalls) {
$suggestions->suggestValue(new Suggestion($algorithm, sprintf('Available firewalls: "%s".', implode('", "', $firewalls))));
$suggestions->suggestValue(new Suggestion($algorithm, \sprintf('Available firewalls: "%s".', implode('", "', $firewalls))));
}
}

if ($input->mustSuggestOptionValuesFor('issuer')) {
foreach ($this->issuers as $issuer => $firewalls) {
$suggestions->suggestValue(new Suggestion($issuer, sprintf('Available firewalls: "%s".', implode('", "', $firewalls))));
$suggestions->suggestValue(new Suggestion($issuer, \sprintf('Available firewalls: "%s".', implode('", "', $firewalls))));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,21 @@
* file that was distributed with this source code.
*/

namespace AccessToken\Oidc;
namespace Symfony\Component\Security\Http\Tests\AccessToken\Oidc;

use Jose\Component\Core\AlgorithmManager;
use Jose\Component\Core\JWK;
use Jose\Component\Core\JWKSet;
use Jose\Component\Signature\Algorithm\ES256;
use Jose\Component\Signature\Algorithm\ES512;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Clock\MockClock;
use Symfony\Component\Security\Http\AccessToken\Oidc\OidcTokenGenerator;
use Symfony\Component\Security\Http\AccessToken\Oidc\OidcTokenHandler;

/**
* @requires extension openssl
*/
#[RequiresPhpExtension('openssl')]
class OidcTokenGeneratorTest extends TestCase
{
public function testGenerate()
Expand Down