use of com.evolveum.icf.dummy.resource.DummyAccount in project midpoint by Evolveum.
the class TestDummy method test110SeachIterative.
@Test
public void test110SeachIterative() throws Exception {
final String TEST_NAME = "test110SeachIterative";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
OperationResult result = new OperationResult(TestDummy.class.getName() + "." + TEST_NAME);
// Make sure there is an account on resource that the provisioning has
// never seen before, so there is no shadow
// for it yet.
DummyAccount newAccount = new DummyAccount("meathook");
newAccount.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Meathook");
newAccount.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, "Sea Monkey");
newAccount.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME, "hook");
newAccount.addAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOOT_NAME, 666L);
newAccount.setEnabled(true);
newAccount.setPassword("parrotMonster");
dummyResource.addAccount(newAccount);
ObjectQuery query = ObjectQueryUtil.createResourceAndObjectClassQuery(RESOURCE_DUMMY_OID, new QName(ResourceTypeUtil.getResourceNamespace(resourceType), SchemaConstants.ACCOUNT_OBJECT_CLASS_LOCAL_NAME), prismContext);
final XMLGregorianCalendar startTs = clock.currentTimeXMLGregorianCalendar();
final Holder<Boolean> seenMeathookHolder = new Holder<Boolean>(false);
final List<PrismObject<ShadowType>> foundObjects = new ArrayList<PrismObject<ShadowType>>();
ResultHandler<ShadowType> handler = new ResultHandler<ShadowType>() {
@Override
public boolean handle(PrismObject<ShadowType> object, OperationResult parentResult) {
foundObjects.add(object);
display("Found", object);
XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar();
assertTrue(object.canRepresent(ShadowType.class));
try {
checkAccountShadow(object, parentResult, true, startTs, endTs);
} catch (SchemaException e) {
throw new SystemException(e.getMessage(), e);
}
assertCachingMetadata(object, false, startTs, endTs);
if (object.asObjectable().getName().getOrig().equals("meathook")) {
meathookAccountOid = object.getOid();
seenMeathookHolder.setValue(true);
try {
Long loot = ShadowUtil.getAttributeValue(object, dummyResourceCtl.getAttributeQName(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOOT_NAME));
assertEquals("Wrong meathook's loot", (Long) 666L, loot);
} catch (SchemaException e) {
throw new SystemException(e.getMessage(), e);
}
}
return true;
}
};
rememberShadowFetchOperationCount();
// WHEN
provisioningService.searchObjectsIterative(ShadowType.class, query, null, handler, null, result);
// THEN
XMLGregorianCalendar endTs = clock.currentTimeXMLGregorianCalendar();
result.computeStatus();
display("searchObjectsIterative result", result);
TestUtil.assertSuccess(result);
assertShadowFetchOperationCountIncrement(1);
assertEquals(4, foundObjects.size());
checkConsistency(foundObjects);
assertProtected(foundObjects, 1);
PrismObject<ShadowType> shadowWillRepo = repositoryService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, result);
assertRepoShadowCachedAttributeValue(shadowWillRepo, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME, "Flying Dutchman");
checkRepoAccountShadowWill(shadowWillRepo, startTs, endTs);
PrismObject<ShadowType> shadowMeathook = repositoryService.getObject(ShadowType.class, meathookAccountOid, null, result);
display("Meathook shadow", shadowMeathook);
assertRepoShadowCachedAttributeValue(shadowMeathook, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME, "hook");
assertRepoCachingMetadata(shadowMeathook, startTs, endTs);
// And again ...
foundObjects.clear();
rememberShadowFetchOperationCount();
XMLGregorianCalendar startTs2 = clock.currentTimeXMLGregorianCalendar();
// WHEN
provisioningService.searchObjectsIterative(ShadowType.class, query, null, handler, null, result);
// THEN
XMLGregorianCalendar endTs2 = clock.currentTimeXMLGregorianCalendar();
assertShadowFetchOperationCountIncrement(1);
display("Found shadows", foundObjects);
assertEquals(4, foundObjects.size());
checkConsistency(foundObjects);
assertProtected(foundObjects, 1);
shadowWillRepo = repositoryService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, result);
checkRepoAccountShadowWill(shadowWillRepo, startTs2, endTs2);
shadowMeathook = repositoryService.getObject(ShadowType.class, meathookAccountOid, null, result);
assertRepoShadowCachedAttributeValue(shadowMeathook, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME, "hook");
assertRepoCachingMetadata(shadowMeathook, startTs2, endTs2);
assertSteadyResource();
}
use of com.evolveum.icf.dummy.resource.DummyAccount in project midpoint by Evolveum.
the class TestDummy method test234DetitleAccountWillBargain.
@Test
public void test234DetitleAccountWillBargain() throws Exception {
final String TEST_NAME = "test234DetitleAccountWillBargain";
TestUtil.displayTestTile(TEST_NAME);
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
syncServiceMock.reset();
ObjectDelta<ShadowType> delta = IntegrationTestTools.createDetitleDelta(ACCOUNT_WILL_OID, ASSOCIATION_PRIV_NAME, PRIVILEGE_BARGAIN_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);
delta.checkConsistence();
DummyGroup group = getDummyGroupAssert(GROUP_PIRATES_NAME, piratesIcfUid);
assertNoMember(group, getWillRepoIcfName());
// Make sure that account is still there and it has the privilege
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("Wrong account privileges", accountProvileges, PRIVILEGE_NONSENSE_NAME);
// Make sure that privilege object is still there
DummyPrivilege priv = getDummyPrivilegeAssert(PRIVILEGE_PILLAGE_NAME, pillageIcfUid);
assertNotNull("Privilege object is gone!", priv);
DummyPrivilege priv2 = getDummyPrivilegeAssert(PRIVILEGE_BARGAIN_NAME, bargainIcfUid);
assertNotNull("Privilege object (bargain) is gone!", priv);
syncServiceMock.assertNotifySuccessOnly();
assertSteadyResource();
}
use of com.evolveum.icf.dummy.resource.DummyAccount in project midpoint by Evolveum.
the class TestActivation method assertDummyActivationEnabledState.
private void assertDummyActivationEnabledState(String instance, String userId, Boolean expectedEnabled) throws SchemaViolationException, ConflictException {
DummyAccount account = getDummyAccount(instance, userId);
assertNotNull("No dummy account " + userId, account);
assertEquals("Wrong enabled flag in dummy '" + instance + "' account " + userId, expectedEnabled, account.isEnabled());
}
use of com.evolveum.icf.dummy.resource.DummyAccount in project midpoint by Evolveum.
the class AbstractModelIntegrationTest method assertNoDummyAccountAttribute.
protected void assertNoDummyAccountAttribute(String dummyInstanceName, String username, String attributeName) throws SchemaViolationException, ConflictException {
DummyAccount account = getDummyAccount(dummyInstanceName, username);
assertNotNull("No dummy account for username " + username, account);
Set<Object> values = account.getAttributeValues(attributeName, Object.class);
if (values == null || values.isEmpty()) {
return;
}
AssertJUnit.fail("Expected no value in attribute " + attributeName + " of dummy account " + username + ". Values found: " + values);
}
use of com.evolveum.icf.dummy.resource.DummyAccount in project midpoint by Evolveum.
the class TestDummyNoActivation method test157SetValidTo.
@Test
@Override
public void test157SetValidTo() throws Exception {
final String TEST_NAME = "test157SetValidTo";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
syncServiceMock.reset();
long millis = VALID_TO_MILLIS;
ObjectDelta<ShadowType> delta = ObjectDelta.createModificationReplaceProperty(ShadowType.class, ACCOUNT_WILL_OID, SchemaConstants.PATH_ACTIVATION_VALID_TO, prismContext, XmlTypeConverter.createXMLGregorianCalendar(VALID_TO_MILLIS));
delta.checkConsistence();
try {
// WHEN
provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result);
AssertJUnit.fail("Unexpected success");
} catch (SchemaException e) {
// This is expected
}
// THEN
result.computeStatus();
display("modifyObject result", result);
TestUtil.assertFailure(result);
delta.checkConsistence();
// check if activation was changed
DummyAccount dummyAccount = dummyResource.getAccountByUsername(ACCOUNT_WILL_USERNAME);
assertTrue("Dummy account " + ACCOUNT_WILL_USERNAME + " is disabled, expected enabled", dummyAccount.isEnabled());
assertNull("Unexpected account validFrom in account " + ACCOUNT_WILL_USERNAME + ": " + dummyAccount.getValidFrom(), dummyAccount.getValidFrom());
assertNull("Unexpected account validTo in account " + ACCOUNT_WILL_USERNAME + ": " + dummyAccount.getValidTo(), dummyAccount.getValidTo());
syncServiceMock.assertNotifyFailureOnly();
assertSteadyResource();
}
Aggregations