Skip to content

Commit 3485028

Browse files
committed
security: Fix tests and legacy check
1 parent 320316a commit 3485028

File tree

5 files changed

+15
-10
lines changed

5 files changed

+15
-10
lines changed

src/Test/DoctrineOrmFilterTestCase.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,6 @@ abstract class DoctrineOrmFilterTestCase extends KernelTestCase
5555
*/
5656
protected $filterClass;
5757

58-
/**
59-
* @group legacy
60-
*/
6158
protected function setUp(): void
6259
{
6360
self::bootKernel();

tests/Annotation/ApiResourceTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,17 @@ public function testConstructWithInvalidAttribute()
143143
'invalidAttribute' => 'exception',
144144
]);
145145
}
146+
147+
/**
148+
* @group legacy
149+
* @expectedDeprecation Attribute "accessControl" is deprecated in annotation since API Platform 2.5, prefer using "security" attribute instead
150+
* @expectedDeprecation Attribute "accessControlMessage" is deprecated in annotation since API Platform 2.5, prefer using "securityMessage" attribute instead
151+
*/
152+
public function testWithDeprecatedAttributes()
153+
{
154+
new ApiResource([
155+
'accessControl' => "is_granted('ROLE_USER')",
156+
'accessControlMessage' => 'Nope!',
157+
]);
158+
}
146159
}

tests/Bridge/Symfony/Bundle/Command/SwaggerCommandTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ protected function setUp(): void
4141
$this->tester = new ApplicationTester($application);
4242
}
4343

44-
/**
45-
* @group legacy
46-
*/
4744
public function testExecuteWithAliasVersion3()
4845
{
4946
$this->tester->run(['command' => 'api:swagger:export', '--spec-version' => 3]);

tests/Fixtures/TestBundle/Document/LegacySecuredDummy.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
* @author Vincent Chalamon <[email protected]>
2424
*
2525
* @ApiResource(
26-
* accessControl="is_granted('ROLE_USER')",
27-
* accessControlMessage="Nope!",
26+
* attributes={"access_control"="is_granted('ROLE_USER')"},
2827
* collectionOperations={
2928
* "get",
3029
* "post"={"access_control"="is_granted('ROLE_ADMIN')"}

tests/Fixtures/TestBundle/Entity/LegacySecuredDummy.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
* @author Vincent Chalamon <[email protected]>
2424
*
2525
* @ApiResource(
26-
* accessControl="is_granted('ROLE_USER')",
27-
* accessControlMessage="Nope!",
26+
* attributes={"access_control"="is_granted('ROLE_USER')"},
2827
* collectionOperations={
2928
* "get",
3029
* "post"={"access_control"="is_granted('ROLE_ADMIN')"}

0 commit comments

Comments
 (0)