-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[SecurityBundle][2.8] Support autowiring for AccessDecisionManagerInterface #19941
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Bundle\SecurityBundle\Tests\Functional; | ||
|
||
class AutowiringTypesTest extends WebTestCase | ||
{ | ||
public function testAccessDecisionManagerAutowiring() | ||
{ | ||
static::bootKernel(array('debug' => false)); | ||
10000 $container = static::$kernel->getContainer(); | ||
|
||
$accessDecisionManager = $container->get('test.autowiring_types.autowired_services')->getAccessDecisionManager(); | ||
$this->assertInstanceOf('Symfony\Component\Security\Core\Authorization\AccessDecisionManager', $accessDecisionManager); | ||
} | ||
|
||
public function testDebugAccessDecisionManagerAutowiring() | ||
{ | ||
static::bootKernel(array('debug' => true)); | ||
$container = static::$kernel->getContainer(); | ||
|
||
$accessDecisionManager = $container->get('test.autowiring_types.autowired_services')->getAccessDecisionManager(); | ||
$this->assertInstanceOf('Symfony\Component\Security\Core\Authorization\AccessDecisionManager', $accessDecisionManager); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When in debug, it should be an instance of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, this case exist in #19684 (targeted 3.1). see #19684 (comment),
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah I thought this was a feature, nevertheless, good to have this test so we will notice it breaks in 3.1 and it can be fixed there. I think it's correct that autowiring are allowed in lower versions, but I'm not sure. Following semver it would not be allowed because if you rely on the functionality and you go back 1 patch due to a bug fix bug, you also break this "feature". |
||
} | ||
|
||
protected static function createKernel(array $options = array()) | ||
{ | ||
return parent::createKernel(array('test_case' => 'AutowiringTypes') + $options); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\TestBundle\AutowiringTypes; | ||
|
||
use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface; | ||
|
||
class AutowiredServices | ||
{ | ||
private $accessDecisionManager; | ||
|
||
public function __construct(AccessDecisionManagerInterface $accessDecisionManager) | ||
{ | ||
$this->accessDecisionManager = $accessDecisionManager; | ||
} | ||
|
||
public function getAccessDecisionManager() | ||
{ | ||
return $this->accessDecisionManager; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\TestBundle; | ||
|
||
use Symfony\Component\HttpKernel\Bundle\Bundle; | ||
|
||
class TestBundle extends Bundle | ||
{ | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE 6D47 td> | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
return array( | ||
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(), | ||
new Symfony\Bundle\SecurityBundle\SecurityBundle(), | ||
new Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\TestBundle\TestBundle(), | ||
); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
imports: | ||
- { resource: ../config/framework.yml } | ||
|
||
|
||
security: | ||
providers: | ||
in_memory: | ||
memory: ~ | ||
|
||
firewalls: | ||
test: | ||
pattern: ^/ | ||
security: false | ||
|
||
services: | ||
test.autowiring_types.autowired_services: | ||
class: Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\TestBundle\AutowiringTypes\AutowiredServices | ||
autowire: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also add a test-case where the debug variant is retrieved in debug/dev?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added, 2f6a92b.