@@ -191,4 +191,51 @@ public function testAdminGroupRolesFormMayDisplay()
191191 $ crawler ->filter ('form#edit-admingroup-form .field-easyadmin_admin_roles input[type="checkbox"] ' )->count ()
192192 );
193193 }
194+
195+ public function testEntityActionsAreForbiddenOnCaseInsensitiveSpecificRoles ()
196+ {
197+ $ this ->logIn (['ROLE_ADMIN ' ]);
198+
199+ $ this ->client ->followRedirects ();
200+
201+ // Edit
202+ $ crawler = $ this ->getBackendPage (['entity ' => 'Product ' , 'action ' => 'edit ' , 'id ' => 1 ]);
203+ $ this ->assertSame (403 , $ this ->client ->getResponse ()->getStatusCode ());
204+ $ this ->assertSame (
205+ 'You must be granted ROLE_TEST_EDIT_PRODUCT role to perform this entity action ! (403 Forbidden) ' ,
206+ trim ($ crawler ->filterXPath ('//head/title ' )->text ())
207+ );
208+ $ crawler = $ this ->getBackendPage (['entity ' => 'Product ' , 'action ' => 'Edit ' , 'id ' => 1 ]);
209+ $ this ->assertSame (403 , $ this ->client ->getResponse ()->getStatusCode ());
210+ $ this ->assertSame (
211+ 'You must be granted ROLE_TEST_EDIT_PRODUCT role to perform this entity action ! (403 Forbidden) ' ,
212+ trim ($ crawler ->filterXPath ('//head/title ' )->text ())
213+ );
214+ $ crawler = $ this ->getBackendPage (['entity ' => 'Product ' , 'action ' => 'EDIT ' , 'id ' => 1 ]);
215+ $ this ->assertSame (403 , $ this ->client ->getResponse ()->getStatusCode ());
216+ $ this ->assertSame (
217+ 'You must be granted ROLE_TEST_EDIT_PRODUCT role to perform this entity action ! (403 Forbidden) ' ,
218+ trim ($ crawler ->filterXPath ('//head/title ' )->text ())
219+ );
220+
221+ // Show
222+ $ crawler = $ this ->getBackendPage (['entity ' => 'Product ' , 'action ' => 'show ' , 'id ' => 1 ]);
223+ $ this ->assertSame (403 , $ this ->client ->getResponse ()->getStatusCode ());
224+ $ this ->assertSame (
225+ 'You must be granted ROLE_TEST_SHOW_PRODUCT role to perform this entity action ! (403 Forbidden) ' ,
226+ trim ($ crawler ->filterXPath ('//head/title ' )->text ())
227+ );
228+ $ crawler = $ this ->getBackendPage (['entity ' => 'Product ' , 'action ' => 'Show ' , 'id ' => 1 ]);
229+ $ this ->assertSame (403 , $ this ->client ->getResponse ()->getStatusCode ());
230+ $ this ->assertSame (
231+ 'You must be granted ROLE_TEST_SHOW_PRODUCT role to perform this entity action ! (403 Forbidden) ' ,
232+ trim ($ crawler ->filterXPath ('//head/title ' )->text ())
233+ );
234+ $ crawler = $ this ->getBackendPage (['entity ' => 'Product ' , 'action ' => 'SHOW ' , 'id ' => 1 ]);
235+ $ this ->assertSame (403 , $ this ->client ->getResponse ()->getStatusCode ());
236+ $ this ->assertSame (
237+ 'You must be granted ROLE_TEST_SHOW_PRODUCT role to perform this entity action ! (403 Forbidden) ' ,
238+ trim ($ crawler ->filterXPath ('//head/title ' )->text ())
239+ );
240+ }
194241}
0 commit comments