use of com.evolveum.midpoint.xml.ns._public.common.common_3.OperationProvisioningScriptsType in project midpoint by Evolveum.
the class TestDummy method test132ModifyScript.
// MID-1113
@Test
public void test132ModifyScript() throws Exception {
final String TEST_NAME = "test132ModifyScript";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
syncServiceMock.reset();
dummyResource.purgeScriptHistory();
OperationProvisioningScriptsType scriptsType = unmarshallValueFromFile(SCRIPTS_FILE, OperationProvisioningScriptsType.class);
display("Provisioning scripts", PrismTestUtil.serializeAnyDataWrapped(scriptsType));
ObjectDelta<ShadowType> delta = ObjectDelta.createModificationReplaceProperty(ShadowType.class, ACCOUNT_NEW_SCRIPT_OID, dummyResourceCtl.getAttributeFullnamePath(), prismContext, "Will Turner");
display("ObjectDelta", delta);
delta.checkConsistence();
// WHEN
provisioningService.modifyObject(ShadowType.class, ACCOUNT_NEW_SCRIPT_OID, delta.getModifications(), scriptsType, null, task, result);
// THEN
result.computeStatus();
display("modifyObject result", result);
TestUtil.assertSuccess("modifyObject has failed (result)", result);
syncServiceMock.assertNotifySuccessOnly();
// Check if the account was modified in the dummy resource
DummyAccount dummyAccount = getDummyAccountAssert("william", williamIcfUid);
assertNotNull("No dummy account", dummyAccount);
assertEquals("Fullname is wrong", "Will Turner", dummyAccount.getAttributeValue("fullname"));
assertTrue("The account is not enabled", dummyAccount.isEnabled());
assertEquals("Wrong password", "3lizab3th123", dummyAccount.getPassword());
ProvisioningScriptSpec beforeScript = new ProvisioningScriptSpec("Where am I?");
ProvisioningScriptSpec afterScript = new ProvisioningScriptSpec("Still here");
afterScript.addArgMulti("status", "dead", "alive");
IntegrationTestTools.assertScripts(dummyResource.getScriptHistory(), beforeScript, afterScript);
assertSteadyResource();
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.OperationProvisioningScriptsType in project midpoint by Evolveum.
the class TestDummy method test222EntitleAccountWillPillage.
@Test
public void test222EntitleAccountWillPillage() throws Exception {
final String TEST_NAME = "test222EntitleAccountWillPillage";
TestUtil.displayTestTile(TEST_NAME);
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
rememberDummyResourceGroupMembersReadCount(null);
syncServiceMock.reset();
ObjectDelta<ShadowType> delta = IntegrationTestTools.createEntitleDelta(ACCOUNT_WILL_OID, ASSOCIATION_PRIV_NAME, PRIVILEGE_PILLAGE_OID, prismContext);
display("ObjectDelta", delta);
delta.checkConsistence();
// WHEN
provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result);
// THEN
result.computeStatus();
display("modifyObject result", result);
TestUtil.assertSuccess(result);
assertDummyResourceGroupMembersReadCountIncrement(null, 0);
DummyAccount dummyAccount = getDummyAccountAssert(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid);
assertNotNull("Account will is gone!", dummyAccount);
Set<String> accountProvileges = dummyAccount.getAttributeValues(DummyAccount.ATTR_PRIVILEGES_NAME, String.class);
PrismAsserts.assertSets("account privileges", accountProvileges, PRIVILEGE_PILLAGE_NAME);
assertDummyResourceGroupMembersReadCountIncrement(null, 0);
// Make sure that privilege object is still there
DummyPrivilege priv = getDummyPrivilegeAssert(PRIVILEGE_PILLAGE_NAME, pillageIcfUid);
assertNotNull("Privilege object is gone!", priv);
delta.checkConsistence();
assertDummyResourceGroupMembersReadCountIncrement(null, 0);
// Make sure that the groups is still there and will is a member
DummyGroup group = getDummyGroupAssert(GROUP_PIRATES_NAME, piratesIcfUid);
assertMember(group, transformNameToResource(ACCOUNT_WILL_USERNAME));
syncServiceMock.assertNotifySuccessOnly();
assertDummyResourceGroupMembersReadCountIncrement(null, 0);
PrismObject<ShadowType> shadow = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, task, result);
display("Shadow after", shadow);
assertEntitlementGroup(shadow, GROUP_PIRATES_OID);
assertEntitlementPriv(shadow, PRIVILEGE_PILLAGE_OID);
assertSteadyResource();
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.OperationProvisioningScriptsType in project midpoint by Evolveum.
the class ProvisioningServiceImpl method deleteObject.
@Override
public <T extends ObjectType> void deleteObject(Class<T> type, String oid, ProvisioningOperationOptions options, OperationProvisioningScriptsType scripts, Task task, OperationResult parentResult) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
Validate.notNull(oid, "Oid of object to delete must not be null.");
Validate.notNull(parentResult, "Operation result must not be null.");
LOGGER.trace("**PROVISIONING: Start to delete object with oid {}", oid);
OperationResult result = parentResult.createSubresult(ProvisioningService.class.getName() + ".deleteObject");
result.addParam("oid", oid);
result.addParam("scripts", scripts);
result.addContext(OperationResult.CONTEXT_IMPLEMENTATION_CLASS, ProvisioningServiceImpl.class);
//TODO: is critical when shadow does not exits anymore?? do we need to log it?? if not, change null to allowNotFound options
PrismObject<T> object = getRepoObject(type, oid, null, result);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("**PROVISIONING: Object from repository to delete:\n{}", object.debugDump());
}
if (object.canRepresent(ShadowType.class) && !ProvisioningOperationOptions.isRaw(options)) {
try {
getShadowCache(Mode.STANDARD).deleteShadow((PrismObject<ShadowType>) object, options, scripts, task, result);
} catch (CommunicationException e) {
ProvisioningUtil.recordFatalError(LOGGER, result, "Couldn't delete object: communication problem: " + e.getMessage(), e);
throw new CommunicationException(e.getMessage(), e);
} catch (GenericFrameworkException e) {
ProvisioningUtil.recordFatalError(LOGGER, result, "Couldn't delete object: generic error in the connector: " + e.getMessage(), e);
throw new CommunicationException(e.getMessage(), e);
} catch (SchemaException e) {
ProvisioningUtil.recordFatalError(LOGGER, result, "Couldn't delete object: schema problem: " + e.getMessage(), e);
throw new SchemaException(e.getMessage(), e);
} catch (ConfigurationException e) {
ProvisioningUtil.recordFatalError(LOGGER, result, "Couldn't delete object: configuration problem: " + e.getMessage(), e);
throw e;
} catch (SecurityViolationException e) {
ProvisioningUtil.recordFatalError(LOGGER, result, "Couldn't delete object: security violation: " + e.getMessage(), e);
throw e;
} catch (ExpressionEvaluationException e) {
ProvisioningUtil.recordFatalError(LOGGER, result, "Couldn't delete object: expression errror: " + e.getMessage(), e);
throw e;
} catch (RuntimeException e) {
ProvisioningUtil.recordFatalError(LOGGER, result, "Couldn't delete object: " + e.getMessage(), e);
throw new SystemException(e);
}
} else if (object.canRepresent(ResourceType.class)) {
resourceManager.deleteResource(oid, options, task, result);
} else {
try {
getCacheRepositoryService().deleteObject(type, oid, result);
} catch (ObjectNotFoundException ex) {
result.recordFatalError(ex);
result.cleanupResult(ex);
throw ex;
}
}
LOGGER.trace("**PROVISIONING: Finished deleting object.");
result.computeStatus();
result.cleanupResult();
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.OperationProvisioningScriptsType in project midpoint by Evolveum.
the class TestDummySecurity method test210ModifyAccountQuote.
@Test
public void test210ModifyAccountQuote() throws Exception {
final String TEST_NAME = "test210ModifyAccountQuote";
TestUtil.displayTestTile(TEST_NAME);
Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
syncServiceMock.reset();
ObjectDelta<ShadowType> delta = ObjectDelta.createModificationReplaceProperty(ShadowType.class, ACCOUNT_WILL_OID, dummyResourceCtl.getAttributePath(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_QUOTE_NAME), prismContext, "eh?");
display("ObjectDelta", delta);
delta.checkConsistence();
try {
// WHEN
provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result);
AssertJUnit.fail("Unexpected success");
} catch (SecurityViolationException e) {
// This is expected
display("Expected exception", e);
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.OperationProvisioningScriptsType in project midpoint by Evolveum.
the class TestOpenDj method test416AssociateUserToCorsairs.
@Test
public void test416AssociateUserToCorsairs() throws Exception {
final String TEST_NAME = "test416AssociateUserToCorsairs";
TestUtil.displayTestTile(TEST_NAME);
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
ObjectDelta<ShadowType> delta = IntegrationTestTools.createEntitleDelta(ACCOUNT_MORGAN_OID, ASSOCIATION_GROUP_NAME, GROUP_CORSAIRS_OID, prismContext);
display("ObjectDelta", delta);
delta.checkConsistence();
// WHEN
TestUtil.displayWhen(TEST_NAME);
provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
Entry groupEntry = openDJController.fetchEntry(GROUP_CORSAIRS_DN);
display("LDAP group", groupEntry);
assertNotNull("No LDAP group entry");
openDJController.assertUniqueMember(groupEntry, ACCOUNT_MORGAN_DN);
assertShadows(22);
}
Aggregations