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
| @@ -51,7 +51,4 @@ public class CustomAuthorizer implements Authorizer { | @@ -51,7 +51,4 @@ public class CustomAuthorizer implements Authorizer { | ||
| 51 | public boolean hasPermission(String resource, String operation) { | 51 | public boolean hasPermission(String resource, String operation) { |
| 52 | return "resource".equals(resource) && "operation".equals(operation); | 52 | return "resource".equals(resource) && "operation".equals(operation); |
| 53 | } | 53 | } |
| 54 | - | ||
| 55 | - | ||
| 56 | - | ||
| 57 | } | 54 | } |
impl/core/src/test/java/security/authorization/custom/CustomAuthorizerTest.java
| @@ -36,9 +36,10 @@ | @@ -36,9 +36,10 @@ | ||
| 36 | */ | 36 | */ |
| 37 | package security.authorization.custom; | 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 | import org.jboss.arquillian.container.test.api.Deployment; | 44 | import org.jboss.arquillian.container.test.api.Deployment; |
| 44 | import org.jboss.arquillian.junit.Arquillian; | 45 | import org.jboss.arquillian.junit.Arquillian; |
| @@ -66,44 +67,43 @@ public class CustomAuthorizerTest { | @@ -66,44 +67,43 @@ public class CustomAuthorizerTest { | ||
| 66 | deployment.addClass(CustomAuthorizer.class); | 67 | deployment.addClass(CustomAuthorizer.class); |
| 67 | return deployment; | 68 | return deployment; |
| 68 | } | 69 | } |
| 69 | - | 70 | + |
| 70 | @Before | 71 | @Before |
| 71 | - public void loginToTest(){ | 72 | + public void loginToTest() { |
| 72 | context.login(); | 73 | context.login(); |
| 73 | } | 74 | } |
| 74 | 75 | ||
| 75 | @Test | 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 | @Test | 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 | * Verify if when already exist an authorizer, the things keeps working fine. | 87 | * Verify if when already exist an authorizer, the things keeps working fine. |
| 87 | */ | 88 | */ |
| 88 | @Test | 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 | @Test | 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 | @Test | 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 | @After | 105 | @After |
| 105 | - public void logoutAfterTest(){ | 106 | + public void logoutAfterTest() { |
| 106 | context.logout(); | 107 | context.logout(); |
| 107 | } | 108 | } |
| 108 | - | ||
| 109 | } | 109 | } |
impl/core/src/test/java/security/authorization/disable/DisabledAuthorizationTest.java
| @@ -36,14 +36,13 @@ | @@ -36,14 +36,13 @@ | ||
| 36 | */ | 36 | */ |
| 37 | package security.authorization.disable; | 37 | package security.authorization.disable; |
| 38 | 38 | ||
| 39 | +import static junit.framework.Assert.assertTrue; | ||
| 39 | import static org.junit.Assert.assertNull; | 40 | import static org.junit.Assert.assertNull; |
| 40 | 41 | ||
| 41 | import javax.enterprise.context.RequestScoped; | 42 | import javax.enterprise.context.RequestScoped; |
| 42 | import javax.enterprise.event.Observes; | 43 | import javax.enterprise.event.Observes; |
| 43 | import javax.inject.Inject; | 44 | import javax.inject.Inject; |
| 44 | 45 | ||
| 45 | -import junit.framework.Assert; | ||
| 46 | - | ||
| 47 | import org.jboss.arquillian.container.test.api.Deployment; | 46 | import org.jboss.arquillian.container.test.api.Deployment; |
| 48 | import org.jboss.arquillian.junit.Arquillian; | 47 | import org.jboss.arquillian.junit.Arquillian; |
| 49 | import org.jboss.shrinkwrap.api.spec.JavaArchive; | 48 | import org.jboss.shrinkwrap.api.spec.JavaArchive; |
| @@ -69,10 +68,8 @@ public class DisabledAuthorizationTest { | @@ -69,10 +68,8 @@ public class DisabledAuthorizationTest { | ||
| 69 | 68 | ||
| 70 | @Deployment | 69 | @Deployment |
| 71 | public static JavaArchive createDeployment() { | 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 | public void observer(@Observes AfterLoginSuccessful event) { | 75 | public void observer(@Observes AfterLoginSuccessful event) { |
| @@ -81,15 +78,15 @@ public class DisabledAuthorizationTest { | @@ -81,15 +78,15 @@ public class DisabledAuthorizationTest { | ||
| 81 | 78 | ||
| 82 | @Test | 79 | @Test |
| 83 | public void hasPermissionProcess() { | 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 | assertNull(event); | 83 | assertNull(event); |
| 87 | } | 84 | } |
| 88 | 85 | ||
| 89 | @Test | 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 | assertNull(event); | 90 | assertNull(event); |
| 94 | } | 91 | } |
| 95 | } | 92 | } |