use of com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType in project midpoint by Evolveum.
the class TestAssignmentErrors method test210UserSharptoothAssignAccountBrokenGeneric.
// PARTIAL_ERROR: Unable to get object from the resource. Probably it has not been created yet because of previous unavailability of the resource.
// TODO: timeout or explicit retry
// @Test
// public void test205UserLemonheadRecovery() throws Exception {
// final String TEST_NAME = "test205UserLemonheadRecovery";
// TestUtil.displayTestTile(this, TEST_NAME);
//
// // GIVEN
// Task task = taskManager.createTaskInstance(TestAssignmentErrors.class.getName() + "." + TEST_NAME);
// OperationResult result = task.getResult();
// assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL);
//
// dummyResource.setBreakMode(BreakMode.NONE);
// dummyAuditService.clear();
//
// // WHEN
// //not expected that it fails, instead the error in the result is expected
// modelService.recompute(UserType.class, userLemonheadOid, task, result);
//
// result.computeStatus();
//
// display(result);
// // This has to be a partial error as some changes were executed (user) and others were not (account)
// TestUtil.assertSuccess(result);
//
// // Check audit
// display("Audit", dummyAuditService);
// dummyAuditService.assertSimpleRecordSanity();
// dummyAuditService.assertRecords(2);
// dummyAuditService.assertAnyRequestDeltas();
// dummyAuditService.assertTarget(userLemonheadOid);
// dummyAuditService.assertExecutionOutcome(OperationResultStatus.HANDLED_ERROR);
// dummyAuditService.assertExecutionMessage();
//
// }
@Test
public void test210UserSharptoothAssignAccountBrokenGeneric() throws Exception {
final String TEST_NAME = "test210UserSharptoothAssignAccountBrokenGeneric";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestAssignmentErrors.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL);
PrismObject<UserType> user = createUser(USER_SHARPTOOTH_NAME, USER_SHARPTOOTH_FULLNAME);
CredentialsType credentialsType = new CredentialsType();
PasswordType passwordType = new PasswordType();
ProtectedStringType passwordPs = new ProtectedStringType();
passwordPs.setClearValue(USER_SHARPTOOTH_PASSWORD_1_CLEAR);
passwordType.setValue(passwordPs);
credentialsType.setPassword(passwordType);
user.asObjectable().setCredentials(credentialsType);
addObject(user);
userSharptoothOid = user.getOid();
Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<ObjectDelta<? extends ObjectType>>();
ObjectDelta<UserType> accountAssignmentUserDelta = createAccountAssignmentUserDelta(user.getOid(), RESOURCE_DUMMY_OID, null, true);
deltas.add(accountAssignmentUserDelta);
getDummyResource().setBreakMode(BreakMode.GENERIC);
dummyAuditService.clear();
// WHEN
TestUtil.displayWhen(TEST_NAME);
//not expected that it fails, instead the error in the result is expected
modelService.executeChanges(deltas, null, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
display(result);
// This has to be a partial error as some changes were executed (user) and others were not (account)
TestUtil.assertPartialError(result);
// Check audit
display("Audit", dummyAuditService);
dummyAuditService.assertSimpleRecordSanity();
dummyAuditService.assertRecords(2);
dummyAuditService.assertAnyRequestDeltas();
dummyAuditService.assertExecutionDeltas(2);
dummyAuditService.assertHasDelta(ChangeType.MODIFY, UserType.class);
dummyAuditService.assertHasDelta(ChangeType.ADD, ShadowType.class, OperationResultStatus.FATAL_ERROR);
dummyAuditService.assertTarget(user.getOid());
dummyAuditService.assertExecutionOutcome(OperationResultStatus.PARTIAL_ERROR);
dummyAuditService.assertExecutionMessage();
LensContext<UserType> lastLensContext = lensDebugListener.getLastLensContext();
Collection<ObjectDeltaOperation<? extends ObjectType>> executedDeltas = lastLensContext.getExecutedDeltas();
display("Executed deltas", executedDeltas);
assertEquals("Unexpected number of execution deltas in context", 2, executedDeltas.size());
Iterator<ObjectDeltaOperation<? extends ObjectType>> i = executedDeltas.iterator();
ObjectDeltaOperation<? extends ObjectType> deltaop1 = i.next();
assertEquals("Unexpected result of first executed deltas", OperationResultStatus.SUCCESS, deltaop1.getExecutionResult().getStatus());
ObjectDeltaOperation<? extends ObjectType> deltaop2 = i.next();
assertEquals("Unexpected result of second executed deltas", OperationResultStatus.FATAL_ERROR, deltaop2.getExecutionResult().getStatus());
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType in project midpoint by Evolveum.
the class AbstractModelIntegrationTest method assertUserLdapPassword.
protected void assertUserLdapPassword(PrismObject<UserType> user, String expectedPassword) throws EncryptionException {
CredentialsType credentialsType = user.asObjectable().getCredentials();
assertNotNull("No credentials in " + user, credentialsType);
PasswordType passwordType = credentialsType.getPassword();
assertNotNull("No password in " + user, passwordType);
ProtectedStringType protectedStringType = passwordType.getValue();
assertLdapPassword(protectedStringType, expectedPassword, user);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType in project midpoint by Evolveum.
the class AbstractModelIntegrationTest method assertPassword.
protected void assertPassword(PrismObject<UserType> user, String expectedPassword) throws EncryptionException {
CredentialsType credentialsType = user.asObjectable().getCredentials();
assertNotNull("No credentials in " + user, credentialsType);
PasswordType passwordType = credentialsType.getPassword();
assertNotNull("No password in " + user, passwordType);
ProtectedStringType protectedStringType = passwordType.getValue();
assertNotNull("No password value in " + user, protectedStringType);
String decryptedUserPassword = protector.decryptString(protectedStringType);
assertEquals("Wrong password in " + user, expectedPassword, decryptedUserPassword);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType in project midpoint by Evolveum.
the class TestEditSchema method test210UserDefinition.
@Test
public void test210UserDefinition() throws Exception {
final String TEST_NAME = "test210UserDefinition";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestEditSchema.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
// WHEN
TestUtil.displayWhen(TEST_NAME);
PrismObject<UserType> user = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);
assertPropertyValues(user, UserType.F_ADDITIONAL_NAME, new Validator<PrismPropertyDefinition<PolyString>>() {
@Override
public void validate(PrismPropertyDefinition<PolyString> propDef, String name) throws Exception {
assertNotNull("No definition for additionalName in user", propDef);
assertEquals("Wrong additionalName displayName", "Middle Name", propDef.getDisplayName());
assertTrue("additionalName not readable", propDef.canRead());
}
}, PrismTestUtil.createPolyString("Jackie"));
assertPropertyValues(user, UserType.F_COST_CENTER, new Validator<PrismPropertyDefinition<String>>() {
@Override
public void validate(PrismPropertyDefinition<String> propDef, String name) throws Exception {
assertNotNull("No definition for costCenter in user", propDef);
assertEquals("Wrong costCenter displayOrder", (Integer) 123, propDef.getDisplayOrder());
assertTrue("costCenter not readable", propDef.canRead());
}
});
assertPropertyValues(user, UserType.F_PREFERRED_LANGUAGE, new Validator<PrismPropertyDefinition<String>>() {
@Override
public void validate(PrismPropertyDefinition<String> propDef, String name) throws Exception {
assertNotNull("No definition for preferredLanguage in user", propDef);
assertEquals("Wrong preferredLanguage displayName", "Language", propDef.getDisplayName());
assertTrue("preferredLanguage not readable", propDef.canRead());
PrismReferenceValue valueEnumerationRef = propDef.getValueEnumerationRef();
assertNotNull("No valueEnumerationRef for preferredLanguage", valueEnumerationRef);
assertEquals("Wrong valueEnumerationRef OID for preferredLanguage", LOOKUP_LANGUAGES_OID, valueEnumerationRef.getOid());
}
});
assertContainer(user, UserType.F_CREDENTIALS, new Validator<PrismContainerDefinition<CredentialsType>>() {
@Override
public void validate(PrismContainerDefinition<CredentialsType> credentialsDef, String name) throws Exception {
assertNotNull("No definition for credentials in user", credentialsDef);
assertTrue("Credentials not readable", credentialsDef.canRead());
}
}, true);
assertProperty(user, new ItemPath(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_VALUE), new Validator<PrismPropertyDefinition<String>>() {
@Override
public void validate(PrismPropertyDefinition<String> propDef, String name) throws Exception {
assertTrue("Password not readable", propDef.canRead());
}
});
assertSteadyResources();
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.CredentialsType in project midpoint by Evolveum.
the class TestEditSchema method assertUntouchedUserDefinition.
private void assertUntouchedUserDefinition() {
// WHEN
PrismObjectDefinition<UserType> userDefinition = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(UserType.class);
// THEN
PrismPropertyDefinition<PolyString> descriptionDef = userDefinition.findPropertyDefinition(UserType.F_DESCRIPTION);
assertNotNull("No definition for description in user", descriptionDef);
assertEquals("Wrong description displayName", "ObjectType.description", descriptionDef.getDisplayName());
assertTrue("description not readable", descriptionDef.canRead());
assertTrue("description not creatable", descriptionDef.canAdd());
assertTrue("description not modifiable", descriptionDef.canModify());
PrismPropertyDefinition<PolyString> additionalNameDef = userDefinition.findPropertyDefinition(UserType.F_ADDITIONAL_NAME);
assertNotNull("No definition for additionalName in user", additionalNameDef);
assertEquals("Wrong additionalName displayName", "UserType.additionalName", additionalNameDef.getDisplayName());
assertTrue("additionalName not readable", additionalNameDef.canRead());
assertTrue("additionalName not creatable", additionalNameDef.canAdd());
assertTrue("additionalName not modifiable", additionalNameDef.canModify());
PrismPropertyDefinition<String> costCenterDef = userDefinition.findPropertyDefinition(UserType.F_COST_CENTER);
assertNotNull("No definition for costCenter in user", costCenterDef);
assertEquals("Wrong costCenter displayOrder", (Integer) 420, costCenterDef.getDisplayOrder());
assertTrue("costCenter not readable", costCenterDef.canRead());
assertTrue("costCenter not creatable", costCenterDef.canAdd());
assertTrue("costCenter not modifiable", costCenterDef.canModify());
PrismReferenceValue valueEnumerationRef = costCenterDef.getValueEnumerationRef();
assertNull("valueEnumerationRef for costCente sneaked in", valueEnumerationRef);
PrismPropertyDefinition<String> preferredLanguageDef = userDefinition.findPropertyDefinition(UserType.F_PREFERRED_LANGUAGE);
assertNotNull("No definition for preferredLanguage in user", preferredLanguageDef);
assertEquals("Wrong preferredLanguage displayName", "UserType.preferredLanguage", preferredLanguageDef.getDisplayName());
assertTrue("preferredLanguage not readable", preferredLanguageDef.canRead());
assertTrue("preferredLanguage not creatable", preferredLanguageDef.canAdd());
assertTrue("preferredLanguage not modifiable", preferredLanguageDef.canModify());
valueEnumerationRef = preferredLanguageDef.getValueEnumerationRef();
assertNotNull("valueEnumerationRef for preferredLanguage missing", valueEnumerationRef);
assertEquals("wrong OID in valueEnumerationRef for preferredLanguage missing", SystemObjectsType.LOOKUP_LANGUAGES.value(), valueEnumerationRef.getOid());
PrismContainerDefinition<CredentialsType> credentialsDef = userDefinition.findContainerDefinition(UserType.F_CREDENTIALS);
assertNotNull("No definition for credentials in user", credentialsDef);
assertTrue("Credentials not readable", credentialsDef.canRead());
assertTrue("Credentials not creatable", credentialsDef.canAdd());
assertTrue("Credentials not modifiable", credentialsDef.canModify());
ItemPath passwdValPath = new ItemPath(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD, PasswordType.F_VALUE);
PrismPropertyDefinition<ProtectedStringType> passwdValDef = userDefinition.findPropertyDefinition(passwdValPath);
assertNotNull("No definition for " + passwdValPath + " in user", passwdValDef);
assertTrue("Password not readable", passwdValDef.canRead());
assertTrue("Password not creatable", passwdValDef.canAdd());
assertTrue("Password not modifiable", passwdValDef.canModify());
}
Aggregations