use of com.evolveum.icf.dummy.resource.DummyAccount in project midpoint by Evolveum.
the class TestDummyCaching method test107BGetModifiedAccountFromCacheHighStaleness.
/**
* Make a native modification to an account and read it with high staleness option.
* This should return cached data.
* MID-3481
*/
@Test
@Override
public void test107BGetModifiedAccountFromCacheHighStaleness() throws Exception {
// GIVEN
Task task = getTestTask();
OperationResult result = createOperationResult();
rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT);
DummyAccount accountWill = getDummyAccountAssert(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid);
accountWill.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, "Very Nice Pirate");
accountWill.setEnabled(true);
Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createStaleness(1000000L));
XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar();
// WHEN
when();
PrismObject<ShadowType> shadow = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, options, task, result);
// THEN
then();
assertSuccess(result);
assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0);
display("Retrieved account shadow", shadow);
assertNotNull("No dummy account", shadow);
assertAttribute(shadow, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, "Pirate");
assertAttribute(shadow, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, "Black Pearl");
assertRepoShadowCachedAttributeValue(shadow, DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME, "sword", "love");
assertAttribute(shadow, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOOT_NAME, 42);
Collection<ResourceAttribute<?>> attributes = ShadowUtil.getAttributes(shadow);
assertEquals("Unexpected number of attributes", 7, attributes.size());
PrismObject<ShadowType> shadowRepo = getShadowRepo(ACCOUNT_WILL_OID);
checkRepoAccountShadowWillBasic(shadowRepo, null, startTs, null);
assertRepoShadowCachedAttributeValue(shadowRepo, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, "Pirate");
assertRepoShadowCachedAttributeValue(shadowRepo, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, "Black Pearl");
assertRepoShadowCachedAttributeValue(shadowRepo, DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME, "sword", "love");
assertRepoShadowCachedAttributeValue(shadowRepo, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOOT_NAME, 42);
assertRepoShadowCacheActivation(shadowRepo, ActivationStatusType.DISABLED);
checkUniqueness(shadow);
assertCachingMetadata(shadow, true, null, startTs);
assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0);
assertSteadyResource();
}
use of com.evolveum.icf.dummy.resource.DummyAccount in project midpoint by Evolveum.
the class AbstractBasicDummyTest method test100AddAccountWill.
@Test
public void test100AddAccountWill() throws Exception {
// GIVEN
Task task = getTestTask();
OperationResult result = task.getResult();
syncServiceMock.reset();
PrismObject<ShadowType> account = prismContext.parseObject(getAccountWillFile());
account.checkConsistence();
display("Adding shadow", account);
XMLGregorianCalendar start = clock.currentTimeXMLGregorianCalendar();
// WHEN
when();
String addedObjectOid = provisioningService.addObject(account, null, null, task, result);
// THEN
then();
assertSuccess(result);
XMLGregorianCalendar end = clock.currentTimeXMLGregorianCalendar();
assertEquals(ACCOUNT_WILL_OID, addedObjectOid);
account.checkConsistence();
PrismObject<ShadowType> accountRepo = getShadowRepo(ACCOUNT_WILL_OID);
// Added account is slightly different case. Even not-returned-by-default attributes are stored in the cache.
checkRepoAccountShadowWill(accountRepo, start, end);
willIcfUid = getIcfUid(accountRepo);
displayValue("Will ICF UID", willIcfUid);
assertNotNull("No will ICF UID", willIcfUid);
ActivationType activationRepo = accountRepo.asObjectable().getActivation();
if (supportsActivation()) {
assertNotNull("No activation in " + accountRepo + " (repo)", activationRepo);
assertEquals("Wrong activation enableTimestamp in " + accountRepo + " (repo)", ACCOUNT_WILL_ENABLE_TIMESTAMP, activationRepo.getEnableTimestamp());
} else {
assertNull("Activation sneaked in (repo)", activationRepo);
}
assertWillRepoShadowAfterCreate(accountRepo);
syncServiceMock.assertSingleNotifySuccessOnly();
PrismObject<ShadowType> accountProvisioning = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, task, result);
XMLGregorianCalendar tsAfterRead = clock.currentTimeXMLGregorianCalendar();
display("Account provisioning", accountProvisioning);
ShadowType accountTypeProvisioning = accountProvisioning.asObjectable();
display("account from provisioning", accountTypeProvisioning);
assertShadowName(accountProvisioning, ACCOUNT_WILL_USERNAME);
assertEquals("Wrong kind (provisioning)", ShadowKindType.ACCOUNT, accountTypeProvisioning.getKind());
assertAttribute(accountProvisioning, SchemaConstants.ICFS_NAME, transformNameFromResource(ACCOUNT_WILL_USERNAME));
assertAttribute(accountProvisioning, getUidMatchingRule(), SchemaConstants.ICFS_UID, willIcfUid);
ActivationType activationProvisioning = accountTypeProvisioning.getActivation();
if (supportsActivation()) {
assertNotNull("No activation in " + accountProvisioning + " (provisioning)", activationProvisioning);
assertEquals("Wrong activation administrativeStatus in " + accountProvisioning + " (provisioning)", ActivationStatusType.ENABLED, activationProvisioning.getAdministrativeStatus());
TestUtil.assertEqualsTimestamp("Wrong activation enableTimestamp in " + accountProvisioning + " (provisioning)", ACCOUNT_WILL_ENABLE_TIMESTAMP, activationProvisioning.getEnableTimestamp());
} else {
assertNull("Activation sneaked in (provisioning)", activationProvisioning);
}
assertNull("The _PASSSWORD_ attribute sneaked into shadow", ShadowUtil.getAttributeValues(accountTypeProvisioning, new QName(SchemaConstants.NS_ICF_SCHEMA, "password")));
// Check if the account was created in the dummy resource
DummyAccount dummyAccount = getDummyAccountAssert(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid);
assertNotNull("No dummy account", dummyAccount);
assertEquals("Username is wrong", transformNameFromResource(ACCOUNT_WILL_USERNAME), dummyAccount.getName());
assertEquals("Fullname is wrong", "Will Turner", dummyAccount.getAttributeValue("fullname"));
assertTrue("The account is not enabled", dummyAccount.isEnabled());
assertEquals("Wrong password", ACCOUNT_WILL_PASSWORD, dummyAccount.getPassword());
// Check if the shadow is still in the repo (e.g. that the consistency or sync haven't removed it)
PrismObject<ShadowType> shadowFromRepo = getShadowRepo(addedObjectOid);
assertNotNull("Shadow was not created in the repository", shadowFromRepo);
displayValue("Repository shadow", shadowFromRepo.debugDump());
checkRepoAccountShadow(shadowFromRepo);
checkRepoAccountShadowWill(shadowFromRepo, end, tsAfterRead);
// MID-3860
assertShadowPasswordMetadata(shadowFromRepo, true, start, end, null, null);
assertRepoShadowCredentials(shadowFromRepo, ACCOUNT_WILL_PASSWORD);
lastPasswordModifyStart = start;
lastPasswordModifyEnd = end;
checkUniqueness(accountProvisioning);
assertSteadyResource();
}
use of com.evolveum.icf.dummy.resource.DummyAccount in project midpoint by Evolveum.
the class TestVillage method test110AddSrcAccountLemonhead.
@Test
public void test110AddSrcAccountLemonhead() throws Exception {
DummyAccount newAccount = new DummyAccount(ACCOUNT_LEMONHEAD_USERNAME);
newAccount.addAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_SRC_FIRST_NAME, ACCOUNT_LEMONHEAD_FIST_NAME);
newAccount.addAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_SRC_LAST_NAME, ACCOUNT_LEMONHEAD_LAST_NAME);
newAccount.addAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_SRC_TYPE, ROLE_BASIC_NAME);
newAccount.addAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_SRC_LOC, ACCOUNT_LEMONHEAD_LOC);
newAccount.addAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_SRC_ORG, ACCOUNT_LEMONHEAD_ORG);
// WHEN
dummyResourceSrc.addAccount(newAccount);
waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_SOURCE_OID, true);
// THEN
PrismObject<UserType> userAfter = findUserByUsername(USER_LEMONHEAD_NAME);
assertUserLdap(userAfter, ACCOUNT_LEMONHEAD_FIST_NAME, ACCOUNT_LEMONHEAD_LAST_NAME, ACCOUNT_LEMONHEAD_ORG);
assertLocGov(userAfter, ACCOUNT_LEMONHEAD_LOC, ACCOUNT_LEMONHEAD_ORG);
assertLdapLocGov(userAfter, ACCOUNT_LEMONHEAD_LOC, ACCOUNT_LEMONHEAD_ORG);
}
use of com.evolveum.icf.dummy.resource.DummyAccount in project midpoint by Evolveum.
the class TestVillage method test150ModifySrcAccountHermanReplaceOrg.
/**
* Change of org should trigger rename
*/
@Test
public void test150ModifySrcAccountHermanReplaceOrg() throws Exception {
DummyAccount account = dummyResourceSrc.getAccountByUsername(ACCOUNT_HERMAN_USERNAME);
// WHEN
account.replaceAttributeValues(DUMMY_ACCOUNT_ATTRIBUTE_SRC_ORG, ORG_INFRA_NAME);
waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_SOURCE_OID, true);
// THEN
PrismObject<UserType> user = findUserByUsername(getUsername(ACCOUNT_HERMAN_FIST_NAME, ACCOUNT_HERMAN_LAST_NAME, ORG_INFRA_NAME));
assertUserNoRole(user, ACCOUNT_HERMAN_FIST_NAME, ACCOUNT_HERMAN_LAST_NAME, ORG_INFRA_NAME);
assertLocGov(user, null, ORG_INFRA_NAME);
PrismObject<UserType> userGone = findUserByUsername(USER_HERMAN_NAME);
assertNull("Original herman is not gone", userGone);
}
use of com.evolveum.icf.dummy.resource.DummyAccount in project midpoint by Evolveum.
the class TestVillage method test130AddSrcAccountMancomb.
/**
* Wally has no org. User without an org should be created.
*/
@Test
public void test130AddSrcAccountMancomb() throws Exception {
DummyAccount newAccount = new DummyAccount(ACCOUNT_MANCOMB_USERNAME);
newAccount.addAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_SRC_FIRST_NAME, ACCOUNT_MANCOMB_FIST_NAME);
newAccount.addAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_SRC_LAST_NAME, ACCOUNT_MANCOMB_LAST_NAME);
newAccount.addAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_SRC_LOC, ACCOUNT_MANCOMB_LOC);
newAccount.addAttributeValue(DUMMY_ACCOUNT_ATTRIBUTE_SRC_ORG, ACCOUNT_MANCOMB_ORG);
// WHEN
dummyResourceSrc.addAccount(newAccount);
waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_SOURCE_OID, true);
// THEN
PrismObject<UserType> userAfter = findUserByUsername(USER_MANCOMB_NAME);
assertUserNoRole(userAfter, ACCOUNT_MANCOMB_FIST_NAME, ACCOUNT_MANCOMB_LAST_NAME, null);
assertLocGov(userAfter, ACCOUNT_MANCOMB_LOC, ACCOUNT_MANCOMB_ORG);
}
Aggregations