use of org.jboss.security.client.SecurityClient in project wildfly by wildfly.
the class DefaultContextServiceTestCase method testTaskSubmit.
@Test
public void testTaskSubmit() throws Exception {
SecurityClient client = SecurityClientFactory.getSecurityClient();
client.setSimple("guest", "guest");
client.login();
try {
final DefaultContextServiceTestEJB testEJB = (DefaultContextServiceTestEJB) new InitialContext().lookup("java:module/" + DefaultContextServiceTestEJB.class.getSimpleName());
testEJB.submit(new TestEJBRunnable()).get();
} finally {
client.logout();
}
}
use of org.jboss.security.client.SecurityClient in project wildfly by wildfly.
the class DefaultManagedThreadFactoryTestCase method testTaskSubmit.
@Test
public void testTaskSubmit() throws Exception {
SecurityClient client = SecurityClientFactory.getSecurityClient();
client.setSimple("guest", "guest");
client.login();
try {
final DefaultManagedThreadFactoryTestEJB testEJB = (DefaultManagedThreadFactoryTestEJB) new InitialContext().lookup("java:module/" + DefaultManagedThreadFactoryTestEJB.class.getSimpleName());
testEJB.run(new TestEJBRunnable());
} finally {
client.logout();
}
}
use of org.jboss.security.client.SecurityClient in project wildfly by wildfly.
the class EjbXACMLAuthorizationModuleTestCase method testAuthz.
/**
* Test secured EJB call for authenticated and authorized user.
*
* @throws Exception
*/
@Test
public void testAuthz() throws Exception {
SecurityClient securityClient = SecurityClientFactory.getSecurityClient();
securityClient.setSimple("jduke", "theduke");
try {
securityClient.login();
assertEquals(HelloBean.HELLO_WORLD, hello.sayHelloWorld());
} finally {
securityClient.logout();
}
}
use of org.jboss.security.client.SecurityClient in project wildfly by wildfly.
the class RunAsPrincipalTestCase method testSingletonPostconstructSecurityNotPropagating.
@Test
public void testSingletonPostconstructSecurityNotPropagating() throws Exception {
SecurityClient client = SecurityClientFactory.getSecurityClient();
client.setSimple("user1", "password1");
client.login();
try {
//To load the singleton
WhoAmI bean = lookupSingletonUseBeanWithIdentity();
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();
}
}
use of org.jboss.security.client.SecurityClient in project wildfly by wildfly.
the class GetCallerPrincipalTestCase method testMDBLifecycle.
/**
* Run this one in the container so it can lookup the queue
* @throws Exception
*/
@OperateOnDeployment("test")
@Test
public void testMDBLifecycle() throws Exception {
deployer.deploy("mdb");
SecurityClient client = this.login();
ITestResultsSingleton results = this.getResultsSingleton();
MessageProducer producer = null;
MessageConsumer consumer = null;
QueueConnection conn = null;
Session session = null;
try {
QueueConnectionFactory qcf = (QueueConnectionFactory) new InitialContext().lookup("java:/ConnectionFactory");
Queue queue = (Queue) new InitialContext().lookup("java:jboss/" + QUEUE_NAME);
conn = qcf.createQueueConnection("guest", "guest");
conn.start();
session = conn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
TemporaryQueue replyQueue = session.createTemporaryQueue();
TextMessage msg = session.createTextMessage("Hello world");
msg.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT);
msg.setJMSReplyTo(replyQueue);
producer = session.createProducer(queue);
producer.send(msg);
consumer = session.createConsumer(replyQueue);
Message replyMsg = consumer.receive(5000);
Object obj = ((ObjectMessage) replyMsg).getObject();
log.trace("MDB message get: " + obj);
Assert.assertEquals(OK + "start", results.getMdb("postconstruct"));
deployer.undeploy("mdb");
Assert.assertEquals(OK + "stop", results.getMdb("predestroy"));
} finally {
if (consumer != null) {
consumer.close();
}
if (producer != null) {
producer.close();
}
if (session != null) {
session.close();
}
if (conn != null) {
conn.close();
}
client.logout();
}
}
Aggregations