Skip to content

Commit

Permalink
Merge branch '5.4' into 6.4
Browse files Browse the repository at this point in the history
* 5.4:
  [Filesystem] Fix str_contains deprecation
  [Security] Correctly initialize the voter property
  [FrameworkBundle] Fix typo
  Update `changed-translation-files` step with native git diff command
  [Lock] Check the correct SQLSTATE error code for MySQL
  [ErrorHandler] Fix `ErrorHandlerTest::tearDown()` visibility
  [Lock] compatiblity with redis cluster 7
  fix: typo
  • Loading branch information
derrabus committed Mar 15, 2024
2 parents b7825ec + 411190c commit 232f25f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions DataCollector/SecurityDataCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ public function collect(Request $request, Response $response, ?\Throwable $excep
// collect voters and access decision manager information
if ($this->accessDecisionManager instanceof TraceableAccessDecisionManager) {
$this->data['voter_strategy'] = $this->accessDecisionManager->getStrategy();
$this->data['voters'] = [];

foreach ($this->accessDecisionManager->getVoters() as $voter) {
if ($voter instanceof TraceableVoter) {
Expand Down
30 changes: 30 additions & 0 deletions Tests/DataCollector/SecurityDataCollectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,36 @@ public function dispatch(object $event, ?string $eventName = null): object
$this->assertSame($dataCollector->getVoterStrategy(), $strategy, 'Wrong value returned by getVoterStrategy');
}

public function testGetVotersIfAccessDecisionManagerHasNoVoters()
{
$strategy = MainConfiguration::STRATEGY_AFFIRMATIVE;

$accessDecisionManager = $this->createMock(TraceableAccessDecisionManager::class);

$accessDecisionManager
->method('getStrategy')
->willReturn($strategy);

$accessDecisionManager
->method('getVoters')
->willReturn([]);

$accessDecisionManager
->method('getDecisionLog')
->willReturn([[
'attributes' => ['view'],
'object' => new \stdClass(),
'result' => true,
'voterDetails' => [],
]]);

$dataCollector = new SecurityDataCollector(null, null, null, $accessDecisionManager, null, null, true);

$dataCollector->collect(new Request(), new Response());

$this->assertEmpty($dataCollector->getVoters());
}

public static function provideRoles(): array
{
return [
Expand Down

0 comments on commit 232f25f

Please sign in to comment.