use of com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType in project midpoint by Evolveum.
the class TestPasswordPolicy method testPasswordGeneratorComplexNegative.
@Test
public void testPasswordGeneratorComplexNegative() throws Exception {
final String TEST_NAME = "testPasswordGeneratorComplexNegative";
TestUtil.displayTestTile(TEST_NAME);
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
File file = new File(TEST_DIR, "password-policy-complex.xml");
ValuePolicyType pp = (ValuePolicyType) PrismTestUtil.parseObject(file).asObjectable();
// Make switch some cosistency
pp.getStringPolicy().getLimitations().setMinLength(2);
pp.getStringPolicy().getLimitations().setMinUniqueChars(5);
// WHEN
TestUtil.displayWhen(TEST_NAME);
String psswd = valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp.getStringPolicy(), 10, null, TEST_NAME, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
display("Generated password", psswd);
result.computeStatus();
AssertJUnit.assertTrue(result.isAcceptable());
assertNotNull(psswd);
// Switch to all must be first :-) to test if there is error
for (StringLimitType l : pp.getStringPolicy().getLimitations().getLimit()) {
l.setMustBeFirst(true);
}
LOGGER.info("Negative testing: passwordGeneratorComplexTest");
try {
valuePolicyProcessor.generate(SchemaConstants.PATH_PASSWORD_VALUE, pp.getStringPolicy(), 10, null, TEST_NAME, task, result);
assertNotReached();
} catch (ExpressionEvaluationException e) {
result.computeStatus();
TestUtil.assertFailure(result);
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType in project midpoint by Evolveum.
the class TestImportRecon method test330ReconcileDummyAzureAddAccountRapp.
/**
* Create account that will correlate to existing user.
* See that it is linked and modified.
*/
@Test
public void test330ReconcileDummyAzureAddAccountRapp() throws Exception {
final String TEST_NAME = "test330ReconcileDummyAzureAddAccountRapp";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = createTask(TestImportRecon.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE);
getDummyResource().setBreakMode(BreakMode.NONE);
dummyResourceAzure.setBreakMode(BreakMode.NONE);
dummyResourceCtlAzure.addAccount(USER_RAPP_USERNAME, USER_RAPP_FULLNAME);
display("Rapp azure account before", dummyResourceAzure.getAccountByUsername(USER_RAPP_USERNAME));
PrismObject<UserType> userRappBefore = getUser(USER_RAPP_OID);
display("User rapp before", userRappBefore);
PrismAsserts.assertPropertyValue(userRappBefore, UserType.F_ORGANIZATIONAL_UNIT, PrismTestUtil.createPolyString("The crew of The Elaine"));
dummyResourceAzure.purgeScriptHistory();
dummyAuditService.clear();
reconciliationTaskResultListener.clear();
// WHEN
TestUtil.displayWhen(TEST_NAME);
restartTask(TASK_RECONCILE_DUMMY_AZURE_OID);
// THEN
TestUtil.displayThen(TEST_NAME);
waitForTaskFinish(TASK_RECONCILE_DUMMY_AZURE_OID, false);
TestUtil.displayThen(TEST_NAME);
List<PrismObject<UserType>> users = modelService.searchObjects(UserType.class, null, null, task, result);
display("Users after reconcile", users);
reconciliationTaskResultListener.assertResult(RESOURCE_DUMMY_AZURE_OID, 0, 1, 0, 0);
assertImportedUserByOid(USER_ADMINISTRATOR_OID);
assertImportedUserByOid(USER_JACK_OID);
assertImportedUserByOid(USER_BARBOSSA_OID);
assertImportedUserByUsername(ACCOUNT_HERMAN_DUMMY_USERNAME);
assertImportedUserByUsername(ACCOUNT_HTM_NAME, RESOURCE_DUMMY_OID);
// Rapp
display("Rapp azure account after", dummyResourceAzure.getAccountByUsername(USER_RAPP_USERNAME));
assertImportedUserByOid(USER_RAPP_OID, RESOURCE_DUMMY_OID, RESOURCE_DUMMY_LIME_OID, RESOURCE_DUMMY_AZURE_OID);
assertDummyAccount(RESOURCE_DUMMY_AZURE_NAME, USER_RAPP_USERNAME, USER_RAPP_FULLNAME, true);
assertDummyAccountAttribute(RESOURCE_DUMMY_AZURE_NAME, USER_RAPP_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, "The crew of The Elaine");
//Checking password policy
PrismObject<UserType> userRapp = findUserByUsername(USER_RAPP_USERNAME);
assertNotNull("No user Rapp", userRapp);
UserType userTypeRapp = userRapp.asObjectable();
assertNotNull("User Rapp has no credentials", userTypeRapp.getCredentials());
PasswordType password = userTypeRapp.getCredentials().getPassword();
assertNotNull("User Rapp has no password", password);
ProtectedStringType passwordType = password.getValue();
String stringPassword = null;
if (passwordType.getClearValue() == null) {
stringPassword = protector.decryptString(passwordType);
}
assertNotNull("No clear text password", stringPassword);
PrismObject<ValuePolicyType> passwordPolicy = getObjectViaRepo(ValuePolicyType.class, PASSWORD_POLICY_LOWER_CASE_ALPHA_AZURE_OID);
boolean isPasswordValid = valuePolicyProcessor.validateValue(stringPassword, passwordPolicy.asObjectable(), userRapp, TEST_NAME, task, result);
assertTrue("Password doesn't satisfy password policy, generated password: " + stringPassword, isPasswordValid);
// These are protected accounts, they should not be imported
assertNoImporterUserByUsername(ACCOUNT_DAVIEJONES_DUMMY_USERNAME);
assertNoImporterUserByUsername(ACCOUNT_CALYPSO_DUMMY_USERNAME);
// Calypso is protected account. Reconciliation should not touch it
assertDummyAccountAttribute(null, ACCOUNT_CALYPSO_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Calypso");
assertEquals("Unexpected number of users", 11, users.size());
display("Dummy resource (azure)", dummyResourceAzure.debugDump());
assertReconAuditModifications(1, TASK_RECONCILE_DUMMY_AZURE_OID);
}
Aggregations