/** * Change part of connector configuration. The cached resource should be refreshed, the schema re-parsed. * The connector also needs to re-initialized. */ @Test public void test030ModifyConnectorConfigAndGetResource() throws Exception { final String TEST_NAME = "test030ModifyConnectorConfigAndGetResource"; displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummyResourceAndSchemaCaching.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); // Change part of connector configuration. We change quite a useless part. But midPoint does not know that // it is useless and need to re-initialize the connector Collection<? extends ItemDelta> modifications = new ArrayList<>(1); PropertyDelta<String> uselessStringDelta = createUselessStringDelta("patlama chamalalija paprtala"); ((Collection)modifications).add(uselessStringDelta); // WHEN provisioningService.modifyObject(ResourceType.class, RESOURCE_DUMMY_OID, modifications, null, null, task, result); // THEN assertSuccess(result); assertConnectorConfigChanged(); }
@Test public void test704ConfiguredCapabilityNoUpdate() throws Exception{ final String TEST_NAME = "test704ConfiguredCapabilityNoUpdate"; Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); addResourceFromFile(new File(TEST_DIR, "/resource-opendj-no-update.xml"), IntegrationTestTools.CONNECTOR_LDAP_TYPE, true, result); try { PropertyDelta delta = prismContext.deltaFactory().property().createModificationReplaceProperty(ItemPath.create(ShadowType.F_ATTRIBUTES, new QName(resourceType.getNamespace(), "sn")), prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(ShadowType.class), "doesnotmatter"); Collection modifications = MiscUtil.createCollection(delta); provisioningService.modifyObject(ShadowType.class, ACCOUNT_WILL_OID, modifications, null, null, task, result); AssertJUnit .fail("Expected unsupported operation exception, but haven't got one."); } catch (UnsupportedOperationException ex) { // this is expected.. } }
@Test public void test150ModifyObject() throws Exception { final String TEST_NAME = "test150ModifyObject"; displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestOpenDjNegative.class.getName() + "." + TEST_NAME); ObjectModificationType objectChange = PrismTestUtil.parseAtomicValue(ACCOUNT_JACK_CHANGE_FILE, ObjectModificationType.COMPLEX_TYPE); ObjectDelta<ShadowType> delta = DeltaConvertor.createObjectDelta(objectChange, ShadowType.class, PrismTestUtil.getPrismContext()); display("Object change",delta); try { provisioningService.modifyObject(ShadowType.class, objectChange.getOid(), delta.getModifications(), null, null, taskManager.createTaskInstance(), result); AssertJUnit.fail("addObject succeeded unexpectedly"); } catch (ConfigurationException e) { // This is expected display("Expected exception", e); } result.computeStatus(); TestUtil.assertFailure(result); }
@Test public void test210ModifyAccountQuote() throws Exception { final String TEST_NAME = "test210ModifyAccountQuote"; TestUtil.displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); syncServiceMock.reset(); ObjectDelta<ShadowType> delta = prismContext.deltaFactory().object().createModificationReplaceProperty(ShadowType.class, ACCOUNT_WILL_OID, dummyResourceCtl.getAttributePath(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_QUOTE_NAME), "eh?"); display("ObjectDelta", delta); delta.checkConsistence(); try { // WHEN provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); AssertJUnit.fail("Unexpected success"); } catch (SecurityViolationException e) { // This is expected display("Expected exception", e); } }
/** * Modification of non-attribute property should go OK. */ @Test public void test503ModifyProtectedAccountShadowProperty() throws Exception { final String TEST_NAME = "test503ModifyProtectedAccountShadowProperty"; displayTestTitle(TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); syncServiceMock.reset(); ObjectDelta<ShadowType> shadowDelta = prismContext.deltaFactory().object() .createModificationReplaceProperty(ShadowType.class, ACCOUNT_DAEMON_OID, ShadowType.F_SYNCHRONIZATION_SITUATION, SynchronizationSituationType.DISPUTED); // WHEN provisioningService.modifyObject(ShadowType.class, ACCOUNT_DAEMON_OID, shadowDelta.getModifications(), null, null, task, result); // THEN result.computeStatus(); display("modifyObject result", result); TestUtil.assertSuccess(result); syncServiceMock.assertNotifySuccessOnly(); PrismObject<ShadowType> shadowAfter = provisioningService.getObject(ShadowType.class, ACCOUNT_DAEMON_OID, null, task, result); assertEquals("Wrong situation", SynchronizationSituationType.DISPUTED, shadowAfter.asObjectable().getSynchronizationSituation()); assertSteadyResource(); }
@Test public void test200ModifyAccountDrink() throws Exception { final String TEST_NAME = "test200ModifyAccountDrink"; TestUtil.displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); syncServiceMock.reset(); ObjectDelta<ShadowType> delta = prismContext.deltaFactory().object().createModificationReplaceProperty(ShadowType.class, ACCOUNT_WILL_OID, dummyResourceCtl.getAttributePath(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_DRINK_NAME), "RUM"); 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(); assertDummyAccountAttributeValues(ACCOUNT_WILL_USERNAME, willIcfUid, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_DRINK_NAME, "RUM"); syncServiceMock.assertNotifySuccessOnly(); }
@Test public void test201ModifyAccountGossip() throws Exception { final String TEST_NAME = "test201ModifyAccountGossip"; TestUtil.displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); syncServiceMock.reset(); ObjectDelta<ShadowType> delta = prismContext.deltaFactory().object().createModificationReplaceProperty(ShadowType.class, ACCOUNT_WILL_OID, dummyResourceCtl.getAttributePath(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_GOSSIP_NAME), "pirate"); 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(); assertDummyAccountAttributeValues(ACCOUNT_WILL_USERNAME, willIcfUid, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_GOSSIP_NAME, "pirate"); syncServiceMock.assertNotifySuccessOnly(); }
@Test public void test416AssociateUserToCorsairs() throws Exception { final String TEST_NAME = "test416AssociateUserToCorsairs"; displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); ObjectDelta<ShadowType> delta = IntegrationTestTools.createEntitleDelta(ACCOUNT_MORGAN_OID, ASSOCIATION_GROUP_NAME, GROUP_CORSAIRS_OID, prismContext); display("ObjectDelta", delta); delta.checkConsistence(); // WHEN displayWhen(TEST_NAME); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN displayThen(TEST_NAME); Entry groupEntry = openDJController.fetchEntry(GROUP_CORSAIRS_DN); display("LDAP group", groupEntry); assertNotNull("No LDAP group entry"); openDJController.assertUniqueMember(groupEntry, ACCOUNT_MORGAN_DN); assertShadows(22); }
@Test public void test282DetitleAccountWillPirates() throws Exception { final String TEST_NAME = "test282DetitleAccountWillPirates"; TestUtil.displayTestTitle(TEST_NAME); Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); syncServiceMock.reset(); ObjectDelta<ShadowType> delta = IntegrationTestTools.createDetitleDelta(ACCOUNT_WILL_OID, dummyResourceCtl.getAttributeQName(DummyResourceContoller.DUMMY_ENTITLEMENT_GROUP_NAME), GROUP_PIRATES_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(ACCOUNT_WILL_USERNAME, willIcfUid); assertNotNull("Account will is gone!", dummyAccount); syncServiceMock.assertNotifySuccessOnly(); assertSteadyResource(); }
@Test public void test130ModifyMorganFullNameAgainCommunicationFailure() throws Exception { final String TEST_NAME = "test130ModifyMorganFullNameAgainCommunicationFailure"; displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); syncServiceMock.reset(); dummyResource.setBreakMode(BreakMode.NETWORK); lastRequestStartTs = lastAttemptStartTs = clock.currentTimeXMLGregorianCalendar(); ObjectDelta<ShadowType> delta = prismContext.deltaFactory().object().createModificationReplaceProperty(ShadowType.class, shadowMorganOid, dummyResourceCtl.getAttributeFullnamePath(), ACCOUNT_MORGAN_FULLNAME_CHM); display("ObjectDelta", delta); // WHEN displayWhen(TEST_NAME); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), null, null, task, result); // THEN displayThen(TEST_NAME); assertInProgress(result); lastRequestEndTs = lastAttemptEndTs = clock.currentTimeXMLGregorianCalendar(); syncServiceMock.assertNotifyInProgressOnly(); assertUnmodifiedMorgan(1, 3, ACCOUNT_MORGAN_FULLNAME_CHM); assertSteadyResources(); }
@Test public void test123ModifyObjectDeletePirate() throws Exception { final String TEST_NAME = "test123ModifyObjectDeletePirate"; displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); syncServiceMock.reset(); ObjectDelta<ShadowType> delta = prismContext.deltaFactory().object().createModificationDeleteProperty(ShadowType.class, ACCOUNT_WILL_OID, dummyResourceCtl.getAttributePath(DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME), "Pirate"); display("ObjectDelta", delta); delta.checkConsistence(); // WHEN displayWhen(TEST_NAME); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN displayThen(TEST_NAME); assertSuccess(result); delta.checkConsistence(); // check if attribute was changed assertDummyAccountAttributeValues(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid, DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, "Captain"); syncServiceMock.assertNotifySuccessOnly(); assertSteadyResource(); }
@Test public void test120ModifyWillReplaceFullname() throws Exception { final String TEST_NAME = "test120ModifyWillReplaceFullname"; displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); syncServiceMock.reset(); ObjectDelta<ShadowType> delta = prismContext.deltaFactory().object().createModificationReplaceProperty(ShadowType.class, ACCOUNT_WILL_OID, dummyResourceCtl.getAttributeFullnamePath(), "Pirate Will Turner"); display("ObjectDelta", delta); delta.checkConsistence(); // WHEN displayWhen(TEST_NAME); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN displayThen(TEST_NAME); assertSuccess(result); delta.checkConsistence(); assertDummyAccount(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid) .assertAttribute(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Pirate Will Turner"); syncServiceMock.assertNotifySuccessOnly(); assertSteadyResource(); }
@Test public void test120ModifyMorganFullNameCommunicationFailure() throws Exception { final String TEST_NAME = "test120ModifyMorganFullNameCommunicationFailure"; displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); syncServiceMock.reset(); dummyResource.setBreakMode(BreakMode.NETWORK); lastRequestStartTs = lastAttemptStartTs = clock.currentTimeXMLGregorianCalendar(); ObjectDelta<ShadowType> delta = prismContext.deltaFactory().object().createModificationReplaceProperty(ShadowType.class, shadowMorganOid, dummyResourceCtl.getAttributeFullnamePath(), ACCOUNT_MORGAN_FULLNAME_HM); display("ObjectDelta", delta); // WHEN displayWhen(TEST_NAME); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), null, null, task, result); // THEN displayThen(TEST_NAME); assertInProgress(result); lastRequestEndTs = lastAttemptEndTs = clock.currentTimeXMLGregorianCalendar(); syncServiceMock.assertNotifyInProgressOnly(); assertUnmodifiedMorgan(1, 2, ACCOUNT_MORGAN_FULLNAME_HM); // Resource -> down assertResourceStatusChangeCounterIncrements(); assertSteadyResources(); }
@Test public void test122ModifyObjectAddCaptain() throws Exception { final String TEST_NAME = "test122ModifyObjectAddCaptain"; displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); syncServiceMock.reset(); ObjectDelta<ShadowType> delta = prismContext.deltaFactory().object().createModificationAddProperty(ShadowType.class, ACCOUNT_WILL_OID, dummyResourceCtl.getAttributePath(DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME), "Captain"); display("ObjectDelta", delta); delta.checkConsistence(); // WHEN displayWhen(TEST_NAME); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN displayThen(TEST_NAME); assertSuccess(result); delta.checkConsistence(); // check if attribute was changed assertDummyAccountAttributeValues(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid, DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, "Pirate", "Captain"); syncServiceMock.assertNotifySuccessOnly(); assertSteadyResource(); }
@Test public void test121ModifyObjectAddPirate() throws Exception { final String TEST_NAME = "test121ModifyObjectAddPirate"; displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); syncServiceMock.reset(); ObjectDelta<ShadowType> delta = prismContext.deltaFactory().object().createModificationAddProperty(ShadowType.class, ACCOUNT_WILL_OID, dummyResourceCtl.getAttributePath(DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME), "Pirate"); display("ObjectDelta", delta); delta.checkConsistence(); // WHEN displayWhen(TEST_NAME); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN displayThen(TEST_NAME); assertSuccess(result); delta.checkConsistence(); // check if attribute was changed assertDummyAccountAttributeValues(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid, DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, "Pirate"); syncServiceMock.assertNotifySuccessOnly(); assertSteadyResource(); }
@Test public void test184UnlockAccount() throws Exception{ final String TEST_NAME = "test184UnlockAccount"; displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); ObjectDelta<ShadowType> delta = prismContext.deltaFactory().object().createModificationReplaceProperty(ShadowType.class, ACCOUNT_WILL_OID, SchemaConstants.PATH_ACTIVATION_LOCKOUT_STATUS, LockoutStatusType.NORMAL); // WHEN provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), null, null, task, result); // THEN result.computeStatus(); assertSuccess(result); PrismObject<ShadowType> shadow = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, taskManager.createTaskInstance(), result); display("Object after change",shadow); String uid = ShadowUtil.getSingleStringAttributeValue(shadow.asObjectable(), getPrimaryIdentifierQName()); assertNotNull(uid); // Check if object was modified in LDAP Entry response = openDJController.searchAndAssertByEntryUuid(uid); display("LDAP account", response); String pager = openDJController.getAttributeValue(response, "pager"); assertNull("Pager attribute found in account "+uid+": "+pager, pager); PrismAsserts.assertPropertyValue(shadow, SchemaConstants.PATH_ACTIVATION_LOCKOUT_STATUS, LockoutStatusType.NORMAL); }
/** * Try to add the same value that the account attribute already has. Resources that do not tolerate this will fail * unless the mechanism to compensate for this works properly. */ @Test public void test124ModifyAccountWillAddCaptainAgain() throws Exception { final String TEST_NAME = "test124ModifyAccountWillAddCaptainAgain"; displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); syncServiceMock.reset(); ObjectDelta<ShadowType> delta = prismContext.deltaFactory().object().createModificationAddProperty(ShadowType.class, ACCOUNT_WILL_OID, dummyResourceCtl.getAttributePath(DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME), "Captain"); display("ObjectDelta", delta); delta.checkConsistence(); // WHEN displayWhen(TEST_NAME); provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result); // THEN displayThen(TEST_NAME); assertSuccess(result); delta.checkConsistence(); // check if attribute was changed assertDummyAccountAttributeValues(transformNameFromResource(ACCOUNT_WILL_USERNAME), willIcfUid, DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, "Captain"); syncServiceMock.assertNotifySuccessOnly(); assertSteadyResource(); }
provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result);
provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result);
provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result);