Ejemplo n.º 1
0
 @Test
 public void testRunAsPrincipal() throws Exception {
   WhoAmI bean = lookupCallerRunAsPrincipal();
   try {
     String actual = bean.getCallerPrincipal();
     Assert.fail("Expected EJBAccessException and it was get identity: " + actual);
   } catch (EJBAccessException e) {
     // good
   }
 }
Ejemplo n.º 2
0
 @Test
 public void testAnonymous() throws Exception {
   SecurityClient client = SecurityClientFactory.getSecurityClient();
   client.setSimple("user1", "password1");
   client.login();
   try {
     WhoAmI bean = lookupCaller();
     String actual = bean.getCallerPrincipal();
     Assert.assertEquals("anonymous", actual);
   } finally {
     client.logout();
   }
 }
Ejemplo n.º 3
0
 @Test
 public void testSingletonPostconstructSecurity() throws Exception {
   SecurityClient client = SecurityClientFactory.getSecurityClient();
   client.setSimple("user1", "password1");
   client.login();
   try {
     WhoAmI bean = lookupSingleCallerWithIdentity();
     String actual = bean.getCallerPrincipal();
     Assert.assertEquals("Helloween", actual);
   } finally {
     client.logout();
   }
 }
Ejemplo n.º 4
0
 @Test
 public void testJackInABox() throws Exception {
   SecurityClient client = SecurityClientFactory.getSecurityClient();
   client.setSimple("user1", "password1");
   client.login();
   try {
     WhoAmI bean = lookupCallerWithIdentity();
     String actual = bean.getCallerPrincipal();
     Assert.assertEquals("jackinabox", actual);
   } finally {
     client.logout();
   }
 }
Ejemplo n.º 5
0
 @Test
 public void testSingletonPostconstructSecurityNotPropagating() throws Exception {
   SecurityClient client = SecurityClientFactory.getSecurityClient();
   client.setSimple("user1", "password1");
   client.login();
   try {
     WhoAmI bean = lookupSingletonUseBeanWithIdentity(); // To load the singleton
     bean.getCallerPrincipal();
     Assert.fail("Deployment should fail");
   } catch (Exception dex) {
     Throwable t = checkEjbException(dex);
     log.trace(
         "Expected deployment error because the Singleton has nosecurity context per itself",
         dex.getCause());
     Assert.assertThat(t.getMessage(), t.getMessage(), CoreMatchers.containsString("WFLYEJB0364"));
   } finally {
     client.logout();
   }
 }