use of com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType in project midpoint by Evolveum.
the class TestSanityLegacy method test023ChangeUserPasswordJAXB.
/**
* Similar to previous test just the request is constructed a bit differently.
*/
@Test
public void test023ChangeUserPasswordJAXB() throws Exception {
final String TEST_NAME = "test023ChangeUserPasswordJAXB";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
final String NEW_PASSWORD = "abandonSHIP";
Document doc = ModelClientUtil.getDocumnent();
ObjectDeltaType userDelta = new ObjectDeltaType();
userDelta.setOid(USER_JACK_OID);
userDelta.setChangeType(ChangeTypeType.MODIFY);
userDelta.setObjectType(UserType.COMPLEX_TYPE);
ItemDeltaType passwordDelta = new ItemDeltaType();
passwordDelta.setModificationType(ModificationTypeType.REPLACE);
passwordDelta.setPath(ModelClientUtil.createItemPathType("credentials/password/value"));
ProtectedStringType pass = new ProtectedStringType();
pass.setClearValue(NEW_PASSWORD);
XNode passValue = ((PrismContextImpl) prismContext).getBeanMarshaller().marshall(pass);
System.out.println("PASSWORD VALUE: " + passValue.debugDump());
RawType passwordValue = new RawType(passValue, prismContext);
passwordDelta.getValue().add(passwordValue);
userDelta.getItemDelta().add(passwordDelta);
// WHEN ObjectTypes.USER.getTypeQName(),
OperationResultType result = modifyObjectViaModelWS(userDelta);
// THEN
assertUserPasswordChange(NEW_PASSWORD, result);
}
use of com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType in project midpoint by Evolveum.
the class TestSanity method checkOpenResourceConfiguration.
private void checkOpenResourceConfiguration(PrismObject<ResourceType> resource, String connectorNamespace, String credentialsPropertyName, int numConfigProps, String source) {
PrismContainer<Containerable> configurationContainer = resource.findContainer(ResourceType.F_CONNECTOR_CONFIGURATION);
assertNotNull("No configuration container in " + resource + " from " + source, configurationContainer);
PrismContainer<Containerable> configPropsContainer = configurationContainer.findContainer(SchemaTestConstants.ICFC_CONFIGURATION_PROPERTIES);
assertNotNull("No configuration properties container in " + resource + " from " + source, configPropsContainer);
List<? extends Item<?, ?>> configProps = configPropsContainer.getValue().getItems();
assertEquals("Wrong number of config properties in " + resource + " from " + source, numConfigProps, configProps.size());
PrismProperty<Object> credentialsProp = configPropsContainer.findProperty(new QName(connectorNamespace, credentialsPropertyName));
if (credentialsProp == null) {
// The is the heisenbug we are looking for. Just dump the entire damn thing.
display("Configuration with the heisenbug", configurationContainer.debugDump());
}
assertNotNull("No " + credentialsPropertyName + " property in " + resource + " from " + source, credentialsProp);
assertEquals("Wrong number of " + credentialsPropertyName + " property value in " + resource + " from " + source, 1, credentialsProp.getValues().size());
PrismPropertyValue<Object> credentialsPropertyValue = credentialsProp.getValues().iterator().next();
assertNotNull("No " + credentialsPropertyName + " property value in " + resource + " from " + source, credentialsPropertyValue);
if (credentialsPropertyValue.isRaw()) {
Object rawElement = credentialsPropertyValue.getRawElement();
assertTrue("Wrong element class " + rawElement.getClass() + " in " + resource + " from " + source, rawElement instanceof MapXNode);
// Element rawDomElement = (Element)rawElement;
MapXNode xmap = (MapXNode) rawElement;
try {
ProtectedStringType protectedType = new ProtectedStringType();
XNodeProcessorUtil.parseProtectedType(protectedType, xmap, prismContext);
// display("LDAP credentials raw element", DOMUtil.serializeDOMToString(rawDomElement));
// assertEquals("Wrong credentials element namespace in "+resource+" from "+source, connectorNamespace, rawDomElement.getNamespaceURI());
// assertEquals("Wrong credentials element local name in "+resource+" from "+source, credentialsPropertyName, rawDomElement.getLocalName());
// Element encryptedDataElement = DOMUtil.getChildElement(rawDomElement, new QName(DOMUtil.NS_XML_ENC, "EncryptedData"));
EncryptedDataType encryptedDataType = protectedType.getEncryptedDataType();
assertNotNull("No EncryptedData element", encryptedDataType);
} catch (SchemaException ex) {
throw new IllegalArgumentException(ex);
}
// assertEquals("Wrong EncryptedData element namespace in "+resource+" from "+source, DOMUtil.NS_XML_ENC, encryptedDataType.getNamespaceURI());
// assertEquals("Wrong EncryptedData element local name in "+resource+" from "+source, "EncryptedData", encryptedDataType.getLocalName());
} else {
Object credentials = credentialsPropertyValue.getValue();
assertTrue("Wrong type of credentials configuration property in " + resource + " from " + source + ": " + credentials.getClass(), credentials instanceof ProtectedStringType);
ProtectedStringType credentialsPs = (ProtectedStringType) credentials;
EncryptedDataType encryptedData = credentialsPs.getEncryptedDataType();
assertNotNull("No EncryptedData element", encryptedData);
}
}
use of com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType 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.prism.xml.ns._public.types_3.ProtectedStringType 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.prism.xml.ns._public.types_3.ProtectedStringType 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);
}
Aggregations