Commit ea9c617ba431b76e0b5a6ab8c086890e8f8ce71a
1 parent
229d5662
Exists in
master
IN PROGRESS - issue FWK-92: Redirecionamento ao usar
securityContext.hasRole/hasPermissions com propriedade desativada https://demoiselle.atlassian.net/browse/FWK-92
Showing
3 changed files
with
30 additions
and
36 deletions
Show diff stats
impl/core/src/test/java/security/authorization/custom/CustomAuthorizer.java
impl/core/src/test/java/security/authorization/custom/CustomAuthorizerTest.java
| ... | ... | @@ -36,9 +36,10 @@ |
| 36 | 36 | */ |
| 37 | 37 | package security.authorization.custom; |
| 38 | 38 | |
| 39 | -import javax.inject.Inject; | |
| 39 | +import static junit.framework.Assert.assertFalse; | |
| 40 | +import static junit.framework.Assert.assertTrue; | |
| 40 | 41 | |
| 41 | -import junit.framework.Assert; | |
| 42 | +import javax.inject.Inject; | |
| 42 | 43 | |
| 43 | 44 | import org.jboss.arquillian.container.test.api.Deployment; |
| 44 | 45 | import org.jboss.arquillian.junit.Arquillian; |
| ... | ... | @@ -66,44 +67,43 @@ public class CustomAuthorizerTest { |
| 66 | 67 | deployment.addClass(CustomAuthorizer.class); |
| 67 | 68 | return deployment; |
| 68 | 69 | } |
| 69 | - | |
| 70 | + | |
| 70 | 71 | @Before |
| 71 | - public void loginToTest(){ | |
| 72 | + public void loginToTest() { | |
| 72 | 73 | context.login(); |
| 73 | 74 | } |
| 74 | 75 | |
| 75 | 76 | @Test |
| 76 | - public void hasPermission(){ | |
| 77 | - Assert.assertTrue(context.hasPermission("resource", "operation")); | |
| 77 | + public void hasPermission() { | |
| 78 | + assertTrue(context.hasPermission("resource", "operation")); | |
| 78 | 79 | } |
| 79 | - | |
| 80 | + | |
| 80 | 81 | @Test |
| 81 | - public void hasRole(){ | |
| 82 | - Assert.assertTrue(context.hasRole("role")); | |
| 82 | + public void hasRole() { | |
| 83 | + assertTrue(context.hasRole("role")); | |
| 83 | 84 | } |
| 84 | - | |
| 85 | + | |
| 85 | 86 | /** |
| 86 | 87 | * Verify if when already exist an authorizer, the things keeps working fine. |
| 87 | 88 | */ |
| 88 | 89 | @Test |
| 89 | - public void hasPermitionAndHasRole(){ | |
| 90 | - Assert.assertTrue(context.hasPermission("resource", "operation")); | |
| 91 | - Assert.assertTrue(context.hasRole("role")); | |
| 90 | + public void hasPermitionAndHasRole() { | |
| 91 | + assertTrue(context.hasPermission("resource", "operation")); | |
| 92 | + assertTrue(context.hasRole("role")); | |
| 92 | 93 | } |
| 93 | - | |
| 94 | + | |
| 94 | 95 | @Test |
| 95 | - public void denyPermission(){ | |
| 96 | - Assert.assertFalse(context.hasPermission("falseresource", "falseoperation")); | |
| 96 | + public void denyPermission() { | |
| 97 | + assertFalse(context.hasPermission("falseresource", "falseoperation")); | |
| 97 | 98 | } |
| 98 | - | |
| 99 | + | |
| 99 | 100 | @Test |
| 100 | - public void denyRole(){ | |
| 101 | - Assert.assertFalse(context.hasRole("falserole")); | |
| 101 | + public void denyRole() { | |
| 102 | + assertFalse(context.hasRole("falserole")); | |
| 102 | 103 | } |
| 103 | - | |
| 104 | + | |
| 104 | 105 | @After |
| 105 | - public void logoutAfterTest(){ | |
| 106 | + public void logoutAfterTest() { | |
| 106 | 107 | context.logout(); |
| 107 | 108 | } |
| 108 | - | |
| 109 | 109 | } | ... | ... |
impl/core/src/test/java/security/authorization/disable/DisabledAuthorizationTest.java
| ... | ... | @@ -36,14 +36,13 @@ |
| 36 | 36 | */ |
| 37 | 37 | package security.authorization.disable; |
| 38 | 38 | |
| 39 | +import static junit.framework.Assert.assertTrue; | |
| 39 | 40 | import static org.junit.Assert.assertNull; |
| 40 | 41 | |
| 41 | 42 | import javax.enterprise.context.RequestScoped; |
| 42 | 43 | import javax.enterprise.event.Observes; |
| 43 | 44 | import javax.inject.Inject; |
| 44 | 45 | |
| 45 | -import junit.framework.Assert; | |
| 46 | - | |
| 47 | 46 | import org.jboss.arquillian.container.test.api.Deployment; |
| 48 | 47 | import org.jboss.arquillian.junit.Arquillian; |
| 49 | 48 | import org.jboss.shrinkwrap.api.spec.JavaArchive; |
| ... | ... | @@ -69,10 +68,8 @@ public class DisabledAuthorizationTest { |
| 69 | 68 | |
| 70 | 69 | @Deployment |
| 71 | 70 | public static JavaArchive createDeployment() { |
| 72 | - JavaArchive deployment = Tests.createDeployment(ConfigurationResourceTest.class); | |
| 73 | - deployment.addClass(CustomAuthorizer.class); | |
| 74 | - deployment.addAsResource(Tests.createFileAsset(PATH + "/demoiselle.properties"), "demoiselle.properties"); | |
| 75 | - return deployment; | |
| 71 | + return Tests.createDeployment(ConfigurationResourceTest.class).addClasses(CustomAuthorizer.class) | |
| 72 | + .addAsResource(Tests.createFileAsset(PATH + "/demoiselle.properties"), "demoiselle.properties"); | |
| 76 | 73 | } |
| 77 | 74 | |
| 78 | 75 | public void observer(@Observes AfterLoginSuccessful event) { |
| ... | ... | @@ -81,15 +78,15 @@ public class DisabledAuthorizationTest { |
| 81 | 78 | |
| 82 | 79 | @Test |
| 83 | 80 | public void hasPermissionProcess() { |
| 84 | - Assert.assertTrue(context.hasPermission("resource", "operation")); | |
| 85 | - Assert.assertTrue(context.hasPermission("falseresource", "falseoperation")); | |
| 81 | + assertTrue(context.hasPermission("resource", "operation")); | |
| 82 | + assertTrue(context.hasPermission("falseresource", "falseoperation")); | |
| 86 | 83 | assertNull(event); |
| 87 | 84 | } |
| 88 | 85 | |
| 89 | 86 | @Test |
| 90 | - public void hasRoleProcess(){ | |
| 91 | - Assert.assertTrue(context.hasRole("role")); | |
| 92 | - Assert.assertTrue(context.hasRole("falserole")); | |
| 87 | + public void hasRoleProcess() { | |
| 88 | + assertTrue(context.hasRole("role")); | |
| 89 | + assertTrue(context.hasRole("falserole")); | |
| 93 | 90 | assertNull(event); |
| 94 | 91 | } |
| 95 | 92 | } | ... | ... |