protected void assertNoRepoShadow(String oid) throws SchemaException { OperationResult result = new OperationResult("assertNoRepoShadow"); try { PrismObject<ShadowType> shadow = repositoryService.getObject(ShadowType.class, oid, GetOperationOptions.createRawCollection(), result); fail("Expected that shadow "+oid+" will not be in the repo. But it was: "+shadow); } catch (ObjectNotFoundException e) { // Expected assertFailure(result); } }
public static void checkAllShadows(ResourceType resourceType, RepositoryService repositoryService, ObjectChecker<ShadowType> checker, PrismContext prismContext) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException { OperationResult result = new OperationResult(IntegrationTestTools.class.getName() + ".checkAllShadows"); ObjectQuery query = createAllShadowsQuery(resourceType, prismContext); List<PrismObject<ShadowType>> allShadows = repositoryService.searchObjects(ShadowType.class, query, GetOperationOptions.createRawCollection(), result); LOGGER.trace("Checking {} shadows, query:\n{}", allShadows.size(), query.debugDump()); for (PrismObject<ShadowType> shadow: allShadows) { checkShadow(shadow.asObjectable(), resourceType, repositoryService, checker, prismContext, result); } }
@Override public void stopProcessInstance(String instanceId, String username, Task task, OperationResult parentResult) throws SchemaException, ObjectNotFoundException, SecurityViolationException, ExpressionEvaluationException, CommunicationException, ConfigurationException { if (!securityEnforcer.isAuthorized(AuthorizationConstants.AUTZ_ALL_URL, null, AuthorizationParameters.EMPTY, null, task, parentResult)) { ObjectQuery query = prismContext.queryFor(TaskType.class) .item(TaskType.F_WORKFLOW_CONTEXT, WfContextType.F_PROCESS_INSTANCE_ID).eq(instanceId) .build(); List<PrismObject<TaskType>> tasks = cacheRepositoryService.searchObjects(TaskType.class, query, GetOperationOptions.createRawCollection(), parentResult); if (tasks.size() > 1) { throw new IllegalStateException("More than one task for process instance ID " + instanceId); } else if (tasks.size() == 0) { throw new ObjectNotFoundException("No task for process instance ID " + instanceId, instanceId); } securityEnforcer.authorize(ModelAuthorizationAction.STOP_APPROVAL_PROCESS_INSTANCE.getUrl(), null, AuthorizationParameters.Builder.buildObject(tasks.get(0)), null, task, parentResult); } getWorkflowManagerChecked().stopProcessInstance(instanceId, username, parentResult); }
protected PrismObject<ShadowType> getShadowRepo(String shadowOid) throws ObjectNotFoundException, SchemaException { OperationResult result = new OperationResult("getShadowRepo"); // We need to read the shadow as raw, so repo will look for some kind of rudimentary attribute // definitions here. Otherwise we will end up with raw values for non-indexed (cached) attributes LOGGER.info("Getting repo shadow {}", shadowOid); PrismObject<ShadowType> shadow = repositoryService.getObject(ShadowType.class, shadowOid, GetOperationOptions.createRawCollection(), result); LOGGER.info("Got repo shadow\n{}", shadow.debugDumpLazily(1)); assertSuccess(result); return shadow; }
GetOperationOptions.createRawCollection(), result); try { repo.getObject(ObjectTypes.ROLE.getClassDefinition(), oid, GetOperationOptions.createRawCollection(), result);
@Test public void test329DeleteAccountPosix() throws Exception { final String TEST_NAME = "test329DeleteAccountPosix"; displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); // WHEN displayWhen(TEST_NAME); provisioningService.deleteObject(ShadowType.class, ACCOUNT_POSIX_MCMUTTON_OID, null, null, task, result); // THEN displayThen(TEST_NAME); try { provisioningService.getObject(ShadowType.class, ACCOUNT_POSIX_MCMUTTON_OID, null, task, result); Assert.fail("Expected exception ObjectNotFoundException, but haven't got one."); } catch (ObjectNotFoundException ex) { display("Expected exception", ex); } try { repositoryService.getObject(ShadowType.class, ACCOUNT_POSIX_MCMUTTON_OID, GetOperationOptions.createRawCollection(), result); // objType = container.getObject(); Assert.fail("Expected exception, but haven't got one."); } catch (ObjectNotFoundException ex) { display("Expected exception", ex); assertTrue(ex.getMessage().contains(ACCOUNT_POSIX_MCMUTTON_OID)); } assertShadows(16); }
@Test public void test298DeletePrivPillage() throws Exception { final String TEST_NAME = "test298DeletePrivPillage"; displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); syncServiceMock.reset(); // WHEN provisioningService.deleteObject(ShadowType.class, PRIVILEGE_PILLAGE_OID, null, null, task, result); // THEN result.computeStatus(); display(result); TestUtil.assertSuccess(result); syncServiceMock.assertNotifySuccessOnly(); try { repositoryService.getObject(ShadowType.class, PRIVILEGE_PILLAGE_OID, GetOperationOptions.createRawCollection(), result); AssertJUnit.fail("Priv shadow is not gone (repo)"); } catch (ObjectNotFoundException e) { // This is expected } try { provisioningService.getObject(ShadowType.class, PRIVILEGE_PILLAGE_OID, null, task, result); AssertJUnit.fail("Priv shadow is not gone (provisioning)"); } catch (ObjectNotFoundException e) { // This is expected } DummyPrivilege priv = getDummyPrivilege(PRIVILEGE_PILLAGE_NAME, pillageIcfUid); assertNull("Privilege object NOT is gone", priv); assertSteadyResource(); }
@Test public void test299DeleteGroupPirates() throws Exception { final String TEST_NAME = "test299DeleteGroupPirates"; displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); syncServiceMock.reset(); // WHEN provisioningService.deleteObject(ShadowType.class, GROUP_PIRATES_OID, null, null, task, result); // THEN result.computeStatus(); display(result); TestUtil.assertSuccess(result); syncServiceMock.assertNotifySuccessOnly(); try { repositoryService.getObject(ShadowType.class, GROUP_PIRATES_OID, GetOperationOptions.createRawCollection(), result); AssertJUnit.fail("Group shadow is not gone (repo)"); } catch (ObjectNotFoundException e) { // This is expected } try { provisioningService.getObject(ShadowType.class, GROUP_PIRATES_OID, null, task, result); AssertJUnit.fail("Group shadow is not gone (provisioning)"); } catch (ObjectNotFoundException e) { // This is expected } DummyGroup dummyAccount = getDummyGroup(GROUP_PIRATES_NAME, piratesIcfUid); assertNull("Dummy group '"+GROUP_PIRATES_NAME+"' is not gone from dummy resource", dummyAccount); assertSteadyResource(); }
PrismObject<ShadowType> shadow = repositoryService.getObject(ShadowType.class, accountOid, createRawCollection(), result); String xml = prismContext.xmlSerializer().options(createSerializeForExport()).serialize(shadow); System.out.println("Serialized for export:\n" + xml);
repositoryService.getObject(ShadowType.class, ACCOUNT_LECHUCK_OID, GetOperationOptions.createRawCollection(), result);