use of javax.batch.operations.JobSecurityException in project wildfly by wildfly.
the class BatchSubsystemSecurityTestCase method testStart_NotAllowed.
/**
* Try running a job as a user who doesn't have the permission to run jobs. It should not succeed.
*/
@Test
public void testStart_NotAllowed() throws Exception {
final SecurityIdentity user2 = getSecurityIdentity("user2", "password2");
try {
user2.runAs((Callable<Long>) () -> operator.start("assert-identity", new Properties()));
Assert.fail("user2 shouldn't be allowed to start batch jobs");
} catch (JobSecurityException e) {
// OK
}
}
use of javax.batch.operations.JobSecurityException in project wildfly by wildfly.
the class BatchSubsystemSecurityTestCase method testRestart_NotAllowed.
/**
* Test restarting failed jobs by a user who doesn't have the permission to do it.
*/
@Test
public void testRestart_NotAllowed() throws Exception {
final SecurityIdentity user1 = getSecurityIdentity("user1", "password1");
final SecurityIdentity user2 = getSecurityIdentity("user2", "password2");
Properties params = new Properties();
params.put("should.fail", "true");
final Long executionId = user1.runAs((Callable<Long>) () -> operator.start("failing-batchlet", params));
waitForJobEnd(executionId, 10);
Assert.assertEquals(BatchStatus.FAILED, operator.getJobExecution(executionId).getBatchStatus());
try {
user2.runAs((Callable<Long>) () -> operator.restart(executionId, params));
Assert.fail("user2 shouldn't be allowed to restart batch jobs");
} catch (JobSecurityException e) {
// OK
}
}
use of javax.batch.operations.JobSecurityException in project wildfly by wildfly.
the class BatchSubsystemSecurityTestCase method testStop_NotAllowed.
/**
* Stopping an execution by a user who doesn't have the permission to do it.
*/
@Test
public void testStop_NotAllowed() throws Exception {
final SecurityIdentity user1 = getSecurityIdentity("user1", "password1");
final SecurityIdentity user3 = getSecurityIdentity("user3", "password3");
final Long id = user1.runAs((Callable<Long>) () -> operator.start("long-running-batchlet", null));
TimeUnit.SECONDS.sleep(1);
try {
user3.runAs(() -> operator.stop(id));
Assert.fail("user2 should not be allowed to stop job executions");
} catch (JobSecurityException e) {
// OK
}
Assert.assertNotEquals(BatchStatus.STOPPED, operator.getJobExecution(id).getBatchStatus());
}
use of javax.batch.operations.JobSecurityException in project wildfly by wildfly.
the class BatchSubsystemSecurityTestCase method testRead_NotAllowed.
/**
* Test reading execution metadata by a user who doesn't have the permission to do it.
* User1 runs a job and then user2 tries to read its metadata.
*/
@Test
public void testRead_NotAllowed() throws Exception {
final SecurityIdentity user1 = getSecurityIdentity("user1", "password1");
final SecurityIdentity user2 = getSecurityIdentity("user2", "password2");
final Long executionId = user1.runAs((Callable<Long>) () -> operator.start("assert-identity", new Properties()));
try {
user2.runAs((Callable<Properties>) () -> operator.getJobExecution(executionId).getJobParameters());
Assert.fail("user2 shouldn't be allowed to read batch job metadata");
} catch (JobSecurityException e) {
// OK
}
}
use of javax.batch.operations.JobSecurityException in project eap-additional-testsuite by jboss-set.
the class BatchSubsystemSecurityTestCase method testAbandon_NotAllowed.
/**
* Abandoning an execution by a user who doesn't have the permission to do it.
*/
@Test
public void testAbandon_NotAllowed() throws Exception {
final SecurityIdentity user1 = getSecurityIdentity("user1", "password1");
final SecurityIdentity user2 = getSecurityIdentity("user2", "password2");
final Long id = user1.runAs((Callable<Long>) () -> operator.start("assert-identity", new Properties()));
waitForJobEnd(id, 10);
try {
user2.runAs(() -> operator.abandon(id));
Assert.fail("user2 should not be allowed to abandon job executions");
} catch (JobSecurityException e) {
// OK
}
Assert.assertEquals(operator.getJobExecution(id).getBatchStatus(), BatchStatus.COMPLETED);
}
Aggregations