From fe0389586f590e98104e1eec03193f6fdd251b11 Mon Sep 17 00:00:00 2001 From: Radovan Semancik Date: Thu, 8 Jan 2015 13:26:28 +0100 Subject: [PATCH 1/5] Test cleanup --- .../model/intest/TestModelCrudService.java | 7 +- .../midpoint/testing/sanity/TestSanity.java | 145 ++++++++++-------- 2 files changed, 81 insertions(+), 71 deletions(-) diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelCrudService.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelCrudService.java index 064bbb05153..8a81f4c7876 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelCrudService.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestModelCrudService.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -113,10 +113,11 @@ public void test050AddResource() throws Exception { @Test public void test100ModifyUserAddAccount() throws Exception { - TestUtil.displayTestTile(this, "test100ModifyUserAddAccount"); + final String TEST_NAME = "test100ModifyUserAddAccount"; + TestUtil.displayTestTile(this, TEST_NAME); // GIVEN - Task task = taskManager.createTaskInstance(TestModelCrudService.class.getName() + ".test100ModifyUserAddAccount"); + Task task = taskManager.createTaskInstance(TestModelCrudService.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.NONE); diff --git a/testing/sanity/src/test/java/com/evolveum/midpoint/testing/sanity/TestSanity.java b/testing/sanity/src/test/java/com/evolveum/midpoint/testing/sanity/TestSanity.java index d48df95a85b..d37556549e3 100644 --- a/testing/sanity/src/test/java/com/evolveum/midpoint/testing/sanity/TestSanity.java +++ b/testing/sanity/src/test/java/com/evolveum/midpoint/testing/sanity/TestSanity.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2015 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -1445,8 +1445,8 @@ private SearchResultEntry assertOpenDJAccountJack(SearchResultEntry entry, Strin * should be also applied to the account (by schemaHandling). */ @Test - public void test022ChangePassword() throws Exception { - final String TEST_NAME = "test022ChangePassword"; + public void test022ChangeUserPassword() throws Exception { + final String TEST_NAME = "test022ChangeUserPassword"; TestUtil.displayTestTile(TEST_NAME); // GIVEN @@ -1467,8 +1467,8 @@ public void test022ChangePassword() throws Exception { * Similar to previous test just the request is constructed a bit differently. */ @Test - public void test023ChangePasswordJAXB() throws Exception { - final String TEST_NAME = "test023ChangePasswordJAXB"; + public void test023ChangeUserPasswordJAXB() throws Exception { + final String TEST_NAME = "test023ChangeUserPasswordJAXB"; TestUtil.displayTestTile(TEST_NAME); // GIVEN @@ -1553,9 +1553,9 @@ private void assertUserPasswordChange(String expectedUserPassword, OperationResu * Try to disable user. As the user has an account, the account should be disabled as well. */ @Test - public void test030Disable() throws IOException, JAXBException, FaultMessage, - ObjectNotFoundException, SchemaException, DirectoryException { - TestUtil.displayTestTile("test030Disable"); + public void test030DisableUser() throws Exception { + final String TEST_NAME = "test030DisableUser"; + TestUtil.displayTestTile(TEST_NAME); // GIVEN ObjectDeltaType objectChange = unmarshallValueFromFile( @@ -1661,9 +1661,9 @@ public void test030Disable() throws IOException, JAXBException, FaultMessage, * Try to enable user after it has been disabled. As the user has an account, the account should be enabled as well. */ @Test - public void test031Enable() throws IOException, JAXBException, FaultMessage, - ObjectNotFoundException, SchemaException, DirectoryException { - TestUtil.displayTestTile("test031Enable"); + public void test031EnableUser() throws Exception { + final String TEST_NAME = "test031EnableUser"; + TestUtil.displayTestTile(TEST_NAME); // GIVEN ObjectDeltaType objectChange = unmarshallValueFromFile( @@ -2036,10 +2036,9 @@ public void test049DeleteUser() throws SchemaException, FaultMessage, DirectoryE } @Test - public void test050AssignRolePirate() throws IOException, JAXBException, FaultMessage, - ObjectNotFoundException, SchemaException, EncryptionException, DirectoryException, - ObjectAlreadyExistsException { - TestUtil.displayTestTile("test050AssignRolePirate"); + public void test100AssignRolePirate() throws Exception { + final String TEST_NAME = "test100AssignRolePirate"; + TestUtil.displayTestTile(TEST_NAME); // GIVEN @@ -2133,8 +2132,9 @@ public void test050AssignRolePirate() throws IOException, JAXBException, FaultMe } @Test - public void test051AccountOwnerAfterRole() throws FaultMessage { - TestUtil.displayTestTile("test051AccountOwnerAfterRole"); + public void test101AccountOwnerAfterRole() throws Exception { + final String TEST_NAME = "test101AccountOwnerAfterRole"; + TestUtil.displayTestTile(TEST_NAME); // GIVEN @@ -2159,9 +2159,9 @@ public void test051AccountOwnerAfterRole() throws FaultMessage { @Test - public void test052AssignRoleCaptain() throws IOException, JAXBException, FaultMessage, - ObjectNotFoundException, SchemaException, EncryptionException, DirectoryException { - TestUtil.displayTestTile("test052AssignRoleCaptain"); + public void test102AssignRoleCaptain() throws Exception { + final String TEST_NAME = "test102AssignRoleCaptain"; + TestUtil.displayTestTile(TEST_NAME); // GIVEN @@ -2241,9 +2241,9 @@ public void test052AssignRoleCaptain() throws IOException, JAXBException, FaultM * Assign the same "captain" role again, this time with a slightly different assignment parameters. */ @Test - public void test053AssignRoleCaptainAgain() throws IOException, JAXBException, FaultMessage, - ObjectNotFoundException, SchemaException, EncryptionException, DirectoryException { - TestUtil.displayTestTile("test053AssignRoleCaptain"); + public void test103AssignRoleCaptainAgain() throws Exception { + final String TEST_NAME = "test103AssignRoleCaptainAgain"; + TestUtil.displayTestTile(TEST_NAME); // GIVEN @@ -2320,8 +2320,9 @@ public void test053AssignRoleCaptainAgain() throws IOException, JAXBException, F @Test - public void test055ModifyAccount() throws Exception { - TestUtil.displayTestTile("test055ModifyAccount"); + public void test105ModifyAccount() throws Exception { + final String TEST_NAME = "test105ModifyAccount"; + TestUtil.displayTestTile(TEST_NAME); // GIVEN @@ -2333,7 +2334,7 @@ public void test055ModifyAccount() throws Exception { OperationResultType result = modifyObjectViaModelWS(objectChange); Task task = taskManager.createTaskInstance(); - OperationResult parentResult = new OperationResult("test55ModifyAccount-get after first modify"); + OperationResult parentResult = new OperationResult(TEST_NAME + "-get after first modify"); PrismObject shadow= modelService.getObject(ShadowType.class, accountShadowOidGuybrushOpendj, null, task, parentResult); assertNotNull("shadow must not be null", shadow); @@ -2404,9 +2405,9 @@ public void test055ModifyAccount() throws Exception { * Judge role excludes pirate role. This assignment should fail. */ @Test - public void test054AssignRoleJudge() throws IOException, JAXBException, FaultMessage, - ObjectNotFoundException, SchemaException, EncryptionException, DirectoryException { - TestUtil.displayTestTile("test054AssignRoleJudge"); + public void test104AssignRoleJudge() throws Exception { + final String TEST_NAME = "test104AssignRoleJudge"; + TestUtil.displayTestTile(TEST_NAME); // GIVEN @@ -2449,9 +2450,9 @@ public void test054AssignRoleJudge() throws IOException, JAXBException, FaultMes @Test - public void test057UnassignRolePirate() throws IOException, JAXBException, FaultMessage, - ObjectNotFoundException, SchemaException, EncryptionException, DirectoryException { - TestUtil.displayTestTile("test057UnassignRolePirate"); + public void test107UnassignRolePirate() throws Exception { + final String TEST_NAME = "test107UnassignRolePirate"; + TestUtil.displayTestTile(TEST_NAME); // GIVEN @@ -2532,9 +2533,9 @@ public void test057UnassignRolePirate() throws IOException, JAXBException, Fault } @Test - public void test058UnassignRoleCaptain() throws IOException, JAXBException, FaultMessage, - ObjectNotFoundException, SchemaException, EncryptionException, DirectoryException { - TestUtil.displayTestTile("test058UnassignRoleCaptain"); + public void test108UnassignRoleCaptain() throws Exception { + final String TEST_NAME = "test108UnassignRoleCaptain"; + TestUtil.displayTestTile(TEST_NAME); // GIVEN @@ -2620,9 +2621,9 @@ public void test058UnassignRoleCaptain() throws IOException, JAXBException, Faul * Captain role was assigned twice. It has to also be unassigned twice. */ @Test - public void test059UnassignRoleCaptainAgain() throws IOException, JAXBException, FaultMessage, - ObjectNotFoundException, SchemaException, EncryptionException, DirectoryException { - TestUtil.displayTestTile("test059UnassignRoleCaptain"); + public void test109UnassignRoleCaptainAgain() throws Exception { + final String TEST_NAME = "test109UnassignRoleCaptainAgain"; + TestUtil.displayTestTile(TEST_NAME); // GIVEN @@ -2687,8 +2688,9 @@ public void test059UnassignRoleCaptainAgain() throws IOException, JAXBException, * check if the cycle executes No changes are synchronized yet. */ @Test - public void test100LiveSyncInit() throws Exception { - TestUtil.displayTestTile("test100LiveSyncInit"); + public void test300LiveSyncInit() throws Exception { + final String TEST_NAME = "test300LiveSyncInit"; + TestUtil.displayTestTile(TEST_NAME); // Now it is the right time to add task definition to the repository // We don't want it there any sooner, as it may interfere with the // previous tests @@ -2701,7 +2703,7 @@ public void test100LiveSyncInit() throws Exception { assertSyncSettingsAssignmentPolicyEnforcement(AssignmentPolicyEnforcementType.POSITIVE); final OperationResult result = new OperationResult(TestSanity.class.getName() - + ".test100Synchronization"); + + "." + TEST_NAME); repoAddObjectFromFile(TASK_OPENDJ_SYNC_FILENAME, TaskType.class, result); @@ -2790,13 +2792,14 @@ public void timeout() { * should be created in repo. */ @Test - public void test101LiveSyncCreate() throws Exception { - TestUtil.displayTestTile("test101LiveSyncCreate"); + public void test301LiveSyncCreate() throws Exception { + final String TEST_NAME = "test301LiveSyncCreate"; + TestUtil.displayTestTile(TEST_NAME); // Sync task should be running (tested in previous test), so just create // new LDAP object. final OperationResult result = new OperationResult(TestSanity.class.getName() - + ".test101LiveSyncCreate"); + + "." + TEST_NAME); final Task syncCycle = taskManager.getTask(TASK_OPENDJ_SYNC_OID, result); AssertJUnit.assertNotNull(syncCycle); @@ -2828,11 +2831,12 @@ public void test101LiveSyncCreate() throws Exception { } @Test - public void test102LiveSyncModify() throws Exception { - TestUtil.displayTestTile("test102LiveSyncModify"); + public void test302LiveSyncModify() throws Exception { + final String TEST_NAME = "test302LiveSyncModify"; + TestUtil.displayTestTile(TEST_NAME); final OperationResult result = new OperationResult(TestSanity.class.getName() - + ".test102LiveSyncModify"); + + "." + TEST_NAME); final Task syncCycle = taskManager.getTask(TASK_OPENDJ_SYNC_OID, result); AssertJUnit.assertNotNull(syncCycle); @@ -2860,8 +2864,9 @@ public void test102LiveSyncModify() throws Exception { } @Test - public void test103LiveSyncLink() throws Exception { - TestUtil.displayTestTile("test103LiveSyncLink"); + public void test303LiveSyncLink() throws Exception { + final String TEST_NAME = "test303LiveSyncLink"; + TestUtil.displayTestTile(TEST_NAME); // GIVEN assertNoRepoCache(); @@ -2885,7 +2890,7 @@ public void test103LiveSyncLink() throws Exception { //WHEN //create account for e which should be correlated final OperationResult result = new OperationResult(TestSanity.class.getName() - + ".test103LiveSyncLink"); + + "." + TEST_NAME); final Task syncCycle = taskManager.getTask(TASK_OPENDJ_SYNC_OID, result); AssertJUnit.assertNotNull(syncCycle); @@ -2921,13 +2926,14 @@ public void test103LiveSyncLink() throws Exception { * Also location (ldap l) should be updated through outbound */ @Test - public void test104LiveSyncCreateNoLocation() throws Exception { - TestUtil.displayTestTile("test104LiveSyncCreateNoLocation"); + public void test304LiveSyncCreateNoLocation() throws Exception { + final String TEST_NAME = "test304LiveSyncCreateNoLocation"; + TestUtil.displayTestTile(TEST_NAME); // Sync task should be running (tested in previous test), so just create // new LDAP object. final OperationResult result = new OperationResult(TestSanity.class.getName() - + ".test104LiveSyncCreateNoLocation"); + + "." + TEST_NAME); final Task syncCycle = taskManager.getTask(TASK_OPENDJ_SYNC_OID, result); AssertJUnit.assertNotNull(syncCycle); @@ -2994,10 +3000,11 @@ private Object findSyncTokenObject(Task syncCycle) { * Not really a test. Just cleans up after live sync. */ @Test - public void test199LiveSyncCleanup() throws Exception { - TestUtil.displayTestTile("test199LiveSyncCleanup"); + public void test399LiveSyncCleanup() throws Exception { + final String TEST_NAME = "test399LiveSyncCleanup"; + TestUtil.displayTestTile(TEST_NAME); final OperationResult result = new OperationResult(TestSanity.class.getName() - + ".test199LiveSyncCleanup"); + + "." + TEST_NAME); taskManager.deleteTask(TASK_OPENDJ_SYNC_OID, result); @@ -3005,8 +3012,8 @@ public void test199LiveSyncCleanup() throws Exception { } @Test - public void test200ImportFromResource() throws Exception { - final String TEST_NAME = "test200ImportFromResource"; + public void test400ImportFromResource() throws Exception { + final String TEST_NAME = "test400ImportFromResource"; TestUtil.displayTestTile(TEST_NAME); // GIVEN checkAllShadows(); @@ -3212,12 +3219,13 @@ private String getUserLocality(UserType user){ } @Test - public void test300RecomputeUsers() throws Exception { - TestUtil.displayTestTile("test300RecomputeUsers"); + public void test420RecomputeUsers() throws Exception { + final String TEST_NAME = "test420RecomputeUsers"; + TestUtil.displayTestTile(TEST_NAME); // GIVEN final OperationResult result = new OperationResult(TestSanity.class.getName() - + ".test300RecomputeUsers"); + + "." + TEST_NAME); // Assign role to a user, but we do this using a repository instead of model. // The role assignment will not be executed and this created an inconsistent state. @@ -3354,12 +3362,13 @@ public void timeout() { } @Test - public void test310ReconcileResourceOpenDj() throws Exception { - TestUtil.displayTestTile("test310ReconcileResourceOpenDj"); + public void test440ReconcileResourceOpenDj() throws Exception { + final String TEST_NAME = "test440ReconcileResourceOpenDj"; + TestUtil.displayTestTile(TEST_NAME); // GIVEN final OperationResult result = new OperationResult(TestSanity.class.getName() - + ".test310ReconcileResourceOpenDj"); + + "." + TEST_NAME); // Create LDAP account without an owner. The liveSync is off, so it will not be picked up @@ -3572,8 +3581,8 @@ public void timeout() { } @Test - public void test400ListResources() throws Exception { - final String TEST_NAME = "test400ListResources"; + public void test480ListResources() throws Exception { + final String TEST_NAME = "test480ListResources"; TestUtil.displayTestTile(TEST_NAME); // GIVEN OperationResultType result = new OperationResultType(); @@ -3599,8 +3608,8 @@ public void test400ListResources() throws Exception { } @Test - public void test410ListResourcesWithBrokenResource() throws Exception { - TestUtil.displayTestTile("test410ListResourcesWithBrokenResource"); + public void test485ListResourcesWithBrokenResource() throws Exception { + TestUtil.displayTestTile("test485ListResourcesWithBrokenResource"); // GIVEN Task task = taskManager.createTaskInstance(TestSanity.class.getName() + ".test410ListResourcesWithBrokenResource"); From 6bf790c46af9329e8ab505708159d03dfca9ca31 Mon Sep 17 00:00:00 2001 From: Radovan Semancik Date: Thu, 8 Jan 2015 14:10:45 +0100 Subject: [PATCH 2/5] Tests for MID-2137 --- .../midpoint/test/ldap/OpenDJController.java | 7 +- .../midpoint/testing/sanity/TestSanity.java | 91 ++++++++++++++++++- .../request/account-modify-bad-path.xml | 31 +++++++ .../request/account-modify-roomnumber.xml | 31 +++++++ 4 files changed, 156 insertions(+), 4 deletions(-) create mode 100644 testing/sanity/src/test/resources/request/account-modify-bad-path.xml create mode 100644 testing/sanity/src/test/resources/request/account-modify-roomnumber.xml diff --git a/infra/test-util/src/main/java/com/evolveum/midpoint/test/ldap/OpenDJController.java b/infra/test-util/src/main/java/com/evolveum/midpoint/test/ldap/OpenDJController.java index 34fb25d5c11..7d3b1e4f473 100755 --- a/infra/test-util/src/main/java/com/evolveum/midpoint/test/ldap/OpenDJController.java +++ b/infra/test-util/src/main/java/com/evolveum/midpoint/test/ldap/OpenDJController.java @@ -620,14 +620,17 @@ public static void assertAttribute(SearchResultEntry response, String name, Stri for (String value: values) { boolean found = false; Iterator iterator = attribute.iterator(); + List attrVals = new ArrayList(); while (iterator.hasNext()) { AttributeValue attributeValue = iterator.next(); - if (attributeValue.toString().equals(value)) { + String attrVal = attributeValue.toString(); + attrVals.add(attrVal); + if (attrVal.equals(value)) { found = true; } } if (!found) { - AssertJUnit.fail("Attribute "+name+" does not contain value "+value); + AssertJUnit.fail("Attribute "+name+" does not contain value "+value+", it has values: "+attrVals); } } } diff --git a/testing/sanity/src/test/java/com/evolveum/midpoint/testing/sanity/TestSanity.java b/testing/sanity/src/test/java/com/evolveum/midpoint/testing/sanity/TestSanity.java index d37556549e3..fcfe4ad24a0 100644 --- a/testing/sanity/src/test/java/com/evolveum/midpoint/testing/sanity/TestSanity.java +++ b/testing/sanity/src/test/java/com/evolveum/midpoint/testing/sanity/TestSanity.java @@ -170,6 +170,7 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; import com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage; +import com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultType; import com.evolveum.midpoint.xml.ns._public.common.fault_3.ObjectAlreadyExistsFaultType; import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType; import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CredentialsCapabilityType; @@ -207,6 +208,7 @@ public class TestSanity extends AbstractModelIntegrationTest { private static final String REPO_DIR_NAME = "src/test/resources/repo/"; private static final String REQUEST_DIR_NAME = "src/test/resources/request/"; + private static final File REQUEST_DIR = new File(REQUEST_DIR_NAME); private static final String SYSTEM_CONFIGURATION_FILENAME = REPO_DIR_NAME + "system-configuration.xml"; private static final String SYSTEM_CONFIGURATION_OID = "00000000-0000-0000-0000-000000000001"; @@ -302,7 +304,9 @@ public class TestSanity extends AbstractModelIntegrationTest { private static final String REQUEST_USER_MODIFY_DELETE_ROLE_CAPTAIN_1_FILENAME = REQUEST_DIR_NAME + "user-modify-delete-role-captain-1.xml"; private static final String REQUEST_USER_MODIFY_DELETE_ROLE_CAPTAIN_2_FILENAME = REQUEST_DIR_NAME + "user-modify-delete-role-captain-2.xml"; - private static final String REQUEST_ACCOUNT_MODIFY_ATTRS_FILENAME = REQUEST_DIR_NAME + "account-modify-attrs.xml"; + private static final File REQUEST_ACCOUNT_MODIFY_ATTRS_FILE = new File(REQUEST_DIR, "account-modify-attrs.xml"); + private static final File REQUEST_ACCOUNT_MODIFY_ROOM_NUMBER_FILE = new File(REQUEST_DIR, "account-modify-roomnumber.xml"); + private static final File REQUEST_ACCOUNT_MODIFY_BAD_PATH_FILE = new File(REQUEST_DIR, "account-modify-bad-path.xml"); private static final String LDIF_WILL_FILENAME = REQUEST_DIR_NAME + "will.ldif"; private static final File LDIF_WILL_MODIFY_FILE = new File (REQUEST_DIR_NAME, "will-modify.ldif"); @@ -1548,6 +1552,89 @@ private void assertUserPasswordChange(String expectedUserPassword, OperationResu } lastJacksLdapPassword = ldapPasswordAfter; } + + @Test + public void test028ModifyAccountDj() throws Exception { + final String TEST_NAME = "test028ModifyAccountDj"; + TestUtil.displayTestTile(TEST_NAME); + // GIVEN + assertNoRepoCache(); + + ObjectDeltaType objectChange = unmarshallValueFromFile( + REQUEST_ACCOUNT_MODIFY_ROOM_NUMBER_FILE, ObjectDeltaType.class); + objectChange.setOid(accountShadowOidOpendj); + + // WHEN + OperationResultType result = modifyObjectViaModelWS(objectChange); + + // THEN + assertNoRepoCache(); + displayJaxb("modifyObject result:", result, SchemaConstants.C_RESULT); + TestUtil.assertSuccess("modifyObject has failed", result); + + OperationResult repoResult = new OperationResult("getObject"); + PrismObject repoShadow = repositoryService.getObject(ShadowType.class, accountShadowOidOpendj, null, repoResult); + repoResult.computeStatus(); + TestUtil.assertSuccess("getObject(repo) has failed", repoResult); + display("repository shadow", repoShadow); + AssertJUnit.assertNotNull(repoShadow); + ShadowType repoShadowType = repoShadow.asObjectable(); + AssertJUnit.assertEquals(RESOURCE_OPENDJ_OID, repoShadowType.getResourceRef().getOid()); + + // check attributes in the shadow: should be only identifiers (ICF UID) + + String uid = checkRepoShadow(repoShadow); + + // Check if LDAP account was updated + SearchResultEntry jackLdapEntry = assertOpenDJAccountJack(uid, "jack"); + OpenDJController.assertAttribute(jackLdapEntry, "roomNumber", "quarterdeck"); + } + + @Test + public void test029ModifyAccountDjBadPath() throws Exception { + final String TEST_NAME = "test029ModifyAccountDjBadPath"; + TestUtil.displayTestTile(TEST_NAME); + // GIVEN + assertNoRepoCache(); + + ObjectDeltaType objectChange = unmarshallValueFromFile( + REQUEST_ACCOUNT_MODIFY_BAD_PATH_FILE, ObjectDeltaType.class); + objectChange.setOid(accountShadowOidOpendj); + + OperationResultType result; + try { + // WHEN + result = modifyObjectViaModelWS(objectChange); + + AssertJUnit.fail("Unexpected success"); + } catch (FaultMessage f) { + // this is expected + FaultType faultInfo = f.getFaultInfo(); + result = faultInfo.getOperationResult(); + } + + // THEN + assertNoRepoCache(); + displayJaxb("modifyObject result:", result, SchemaConstants.C_RESULT); + TestUtil.assertFailure(result); + + OperationResult repoResult = new OperationResult("getObject"); + PrismObject repoShadow = repositoryService.getObject(ShadowType.class, accountShadowOidOpendj, null, repoResult); + repoResult.computeStatus(); + TestUtil.assertSuccess("getObject(repo) has failed", repoResult); + display("repository shadow", repoShadow); + AssertJUnit.assertNotNull(repoShadow); + ShadowType repoShadowType = repoShadow.asObjectable(); + AssertJUnit.assertEquals(RESOURCE_OPENDJ_OID, repoShadowType.getResourceRef().getOid()); + + // check attributes in the shadow: should be only identifiers (ICF UID) + + String uid = checkRepoShadow(repoShadow); + + // Check if LDAP account was updated + SearchResultEntry jackLdapEntry = assertOpenDJAccountJack(uid, "jack"); + OpenDJController.assertAttribute(jackLdapEntry, "roomNumber", "quarterdeck"); + } /** * Try to disable user. As the user has an account, the account should be disabled as well. @@ -2327,7 +2414,7 @@ public void test105ModifyAccount() throws Exception { // GIVEN ObjectDeltaType objectChange = unmarshallValueFromFile( - REQUEST_ACCOUNT_MODIFY_ATTRS_FILENAME, ObjectDeltaType.class); + REQUEST_ACCOUNT_MODIFY_ATTRS_FILE, ObjectDeltaType.class); objectChange.setOid(accountShadowOidGuybrushOpendj); // WHEN ObjectTypes.SHADOW.getTypeQName(), diff --git a/testing/sanity/src/test/resources/request/account-modify-bad-path.xml b/testing/sanity/src/test/resources/request/account-modify-bad-path.xml new file mode 100644 index 00000000000..b213068afa3 --- /dev/null +++ b/testing/sanity/src/test/resources/request/account-modify-bad-path.xml @@ -0,0 +1,31 @@ + + + + + modify + c:ShadowType + will be replaced by the test code + + replace + attributes/thisAttributeDoesNotExist + whatever + + diff --git a/testing/sanity/src/test/resources/request/account-modify-roomnumber.xml b/testing/sanity/src/test/resources/request/account-modify-roomnumber.xml new file mode 100644 index 00000000000..b4a2c7d5b0f --- /dev/null +++ b/testing/sanity/src/test/resources/request/account-modify-roomnumber.xml @@ -0,0 +1,31 @@ + + + + + modify + c:ShadowType + will be replaced by the test code + + replace + attributes/roomNumber + quarterdeck + + From f04c4005795620ee14f48ab7f4450fe6a70e2092 Mon Sep 17 00:00:00 2001 From: Radovan Semancik Date: Thu, 8 Jan 2015 16:09:42 +0100 Subject: [PATCH 3/5] Tests and fix for explicit type in delta in web service invocations (MID-2137) --- .../processor/ResourceAttributeContainer.java | 28 ++ ...bstractConfiguredModelIntegrationTest.java | 1 + .../negative/TestModelWebServiceNegative.java | 239 ++++++++++++++++++ model/model-intest/testng.xml | 5 +- .../provisioning/impl/ShadowCache.java | 15 +- .../midpoint/testing/sanity/TestSanity.java | 29 ++- ...ccount-modify-roomnumber-explicit-type.xml | 33 +++ 7 files changed, 332 insertions(+), 18 deletions(-) create mode 100644 model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestModelWebServiceNegative.java create mode 100644 testing/sanity/src/test/resources/request/account-modify-roomnumber-explicit-type.xml diff --git a/infra/schema/src/main/java/com/evolveum/midpoint/schema/processor/ResourceAttributeContainer.java b/infra/schema/src/main/java/com/evolveum/midpoint/schema/processor/ResourceAttributeContainer.java index efc73c71bdf..e07a0ff97a6 100644 --- a/infra/schema/src/main/java/com/evolveum/midpoint/schema/processor/ResourceAttributeContainer.java +++ b/infra/schema/src/main/java/com/evolveum/midpoint/schema/processor/ResourceAttributeContainer.java @@ -18,6 +18,7 @@ import java.util.ArrayList; import java.util.Collection; +import java.util.List; import java.util.Set; import javax.xml.namespace.QName; @@ -397,6 +398,33 @@ protected void copyValues(ResourceAttributeContainer clone) { // Nothing to copy } + + @Override + public void checkConsistenceInternal(Itemable rootItem, boolean requireDefinitions, boolean prohibitRaw, + ConsistencyCheckScope scope) { + super.checkConsistenceInternal(rootItem, requireDefinitions, prohibitRaw, scope); + List values = getValues(); + if (values == null) { + throw new IllegalStateException("Null values in ResourceAttributeContainer"); + } + if (values.isEmpty()) { + throw new IllegalStateException("Empty values in ResourceAttributeContainer"); + } + if (values.size() > 1) { + throw new IllegalStateException(values.size()+" values in ResourceAttributeContainer, expected just one"); + } + PrismContainerValue value = values.get(0); + List> items = value.getItems(); + if (items == null) { + throw new IllegalStateException("Null items in ResourceAttributeContainer"); + } + for (Item item: items) { + if (!(item instanceof ResourceAttribute)) { + throw new IllegalStateException("Found illegal item in ResourceAttributeContainer: "+item+" ("+item.getClass()+")"); + } + } + } + /** * Return a human readable name of this class suitable for logs. */ diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/AbstractConfiguredModelIntegrationTest.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/AbstractConfiguredModelIntegrationTest.java index 73e64901ce0..2b29e24c76d 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/AbstractConfiguredModelIntegrationTest.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/AbstractConfiguredModelIntegrationTest.java @@ -246,6 +246,7 @@ public class AbstractConfiguredModelIntegrationTest extends AbstractModelIntegra public static final String ACCOUNT_SHADOW_GUYBRUSH_DUMMY_FILENAME = COMMON_DIR + "/account-shadow-guybrush-dummy.xml"; public static final String ACCOUNT_SHADOW_GUYBRUSH_OID = "22226666-2200-6666-6666-444400004444"; public static final String ACCOUNT_GUYBRUSH_DUMMY_USERNAME = "guybrush"; + public static final String ACCOUNT_GUYBRUSH_DUMMY_FULLNAME = "Guybrush Threepwood"; public static final File ACCOUNT_GUYBRUSH_DUMMY_FILE = new File (COMMON_DIR, "account-guybrush-dummy.xml"); public static final String ACCOUNT_GUYBRUSH_DUMMY_RED_FILENAME = COMMON_DIR + "/account-guybrush-dummy-red.xml"; diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestModelWebServiceNegative.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestModelWebServiceNegative.java new file mode 100644 index 00000000000..a1023d87d7c --- /dev/null +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/negative/TestModelWebServiceNegative.java @@ -0,0 +1,239 @@ +/* + * Copyright (c) 2010-2015 Evolveum + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.evolveum.midpoint.model.intest.negative; + +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertFalse; +import static org.testng.AssertJUnit.assertNull; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; + +import javax.xml.bind.JAXBException; +import javax.xml.namespace.QName; + +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.annotation.DirtiesContext.ClassMode; +import org.springframework.test.context.ContextConfiguration; +import org.testng.AssertJUnit; +import org.testng.annotations.Test; + +import com.evolveum.midpoint.model.api.PolicyViolationException; +import com.evolveum.midpoint.model.impl.ModelCrudService; +import com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest; +import com.evolveum.midpoint.prism.PrismObject; +import com.evolveum.midpoint.prism.PrismReferenceValue; +import com.evolveum.midpoint.prism.delta.ItemDelta; +import com.evolveum.midpoint.prism.delta.ReferenceDelta; +import com.evolveum.midpoint.prism.util.PrismTestUtil; +import com.evolveum.midpoint.prism.xnode.PrimitiveXNode; +import com.evolveum.midpoint.prism.xnode.ValueParser; +import com.evolveum.midpoint.prism.xnode.XNode; +import com.evolveum.midpoint.schema.constants.ObjectTypes; +import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.task.api.Task; +import com.evolveum.midpoint.test.DummyResourceContoller; +import com.evolveum.midpoint.test.util.TestUtil; +import com.evolveum.midpoint.util.DOMUtil; +import com.evolveum.midpoint.util.exception.CommunicationException; +import com.evolveum.midpoint.util.exception.ConfigurationException; +import com.evolveum.midpoint.util.exception.ConsistencyViolationException; +import com.evolveum.midpoint.util.exception.ExpressionEvaluationException; +import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; +import com.evolveum.midpoint.util.exception.ObjectNotFoundException; +import com.evolveum.midpoint.util.exception.SchemaException; +import com.evolveum.midpoint.util.exception.SecurityViolationException; +import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType; +import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaOperationListType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPolicyEnforcementType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.ModelExecuteOptionsType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; +import com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage; +import com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultType; +import com.evolveum.midpoint.xml.ns._public.common.fault_3.IllegalArgumentFaultType; +import com.evolveum.midpoint.xml.ns._public.common.fault_3.SystemFaultType; +import com.evolveum.prism.xml.ns._public.types_3.ChangeTypeType; +import com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType; +import com.evolveum.prism.xml.ns._public.types_3.ItemPathType; +import com.evolveum.prism.xml.ns._public.types_3.ModificationTypeType; +import com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType; +import com.evolveum.prism.xml.ns._public.types_3.RawType; + +/** + * @author semancik + * + */ +@ContextConfiguration(locations = {"classpath:ctx-model-intest-test-main.xml"}) +@DirtiesContext(classMode = ClassMode.AFTER_CLASS) +public class TestModelWebServiceNegative extends AbstractInitializedModelIntegrationTest { + + public static final File TEST_DIR = new File("src/test/resources/crud"); + public static final File TEST_CONTRACT_DIR = new File("src/test/resources/contract"); + + public static final File RESOURCE_MAROON_FILE = new File(TEST_DIR, "resource-dummy-maroon.xml"); + public static final String RESOURCE_MAROON_OID = "10000000-0000-0000-0000-00000000e104"; + + private static final String USER_MORGAN_OID = "c0c010c0-d34d-b33f-f00d-171171117777"; + private static final String USER_BLACKBEARD_OID = "c0c010c0-d34d-b33f-f00d-161161116666"; + + private static String accountOid; + + /** + * First tests are positive, to make sure that this method works. + */ + @Test + public void test100ModifyAccountExplicitType() throws Exception { + final String TEST_NAME = "test100ModifyUserAddAccount"; + TestUtil.displayTestTile(this, TEST_NAME); + + // GIVEN + Task task = taskManager.createTaskInstance(TestModelWebServiceNegative.class.getName() + "." + TEST_NAME); + + ObjectDeltaType objectChange = createShadowReplaceChange(ACCOUNT_SHADOW_GUYBRUSH_OID, + "attributes/"+DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_GOSSIP_NAME, + "foo", DOMUtil.XSD_STRING); + ObjectDeltaListType deltaList = new ObjectDeltaListType(); + deltaList.getDelta().add(objectChange); + + // WHEN + modelWeb.executeChanges(deltaList, null); + + // THEN + + // Check account in dummy resource + assertDummyAccount(ACCOUNT_GUYBRUSH_DUMMY_USERNAME, ACCOUNT_GUYBRUSH_DUMMY_FULLNAME, true); + assertDummyAccountAttribute(null, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, + DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_GOSSIP_NAME, "foo"); + } + + /** + * First tests are positive, to make sure that this method works. + */ + @Test + public void test110ModifyAccountImplicitType() throws Exception { + final String TEST_NAME = "test110ModifyAccountImplicitType"; + TestUtil.displayTestTile(this, TEST_NAME); + + // GIVEN + Task task = taskManager.createTaskInstance(TestModelWebServiceNegative.class.getName() + "." + TEST_NAME); + + ObjectDeltaType objectChange = createShadowReplaceChange(ACCOUNT_SHADOW_GUYBRUSH_OID, + "attributes/"+DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_GOSSIP_NAME, + "bar", null); + ObjectDeltaListType deltaList = new ObjectDeltaListType(); + deltaList.getDelta().add(objectChange); + + // WHEN + modelWeb.executeChanges(deltaList, null); + + // THEN + + // Check account in dummy resource + assertDummyAccount(ACCOUNT_GUYBRUSH_DUMMY_USERNAME, ACCOUNT_GUYBRUSH_DUMMY_FULLNAME, true); + assertDummyAccountAttribute(null, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, + DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_GOSSIP_NAME, "bar"); + } + + @Test + public void test200ModifyAccountWrongExplicitType() throws Exception { + final String TEST_NAME = "test200ModifyAccountWrongExplicitType"; + TestUtil.displayTestTile(this, TEST_NAME); + + // GIVEN + Task task = taskManager.createTaskInstance(TestModelWebServiceNegative.class.getName() + "." + TEST_NAME); + + ObjectDeltaType objectChange = createShadowReplaceChange(ACCOUNT_SHADOW_GUYBRUSH_OID, + "attributes/"+DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_GOSSIP_NAME, + "42", DOMUtil.XSD_INT); + ObjectDeltaListType deltaList = new ObjectDeltaListType(); + deltaList.getDelta().add(objectChange); + + // WHEN, THEN + assertExecuteChangesFailure(deltaList, null, SystemFaultType.class, "The value of type", "cannot be applied to attribute"); + } + + + private void assertExecuteChangesFailure(ObjectDeltaListType deltaList, ModelExecuteOptionsType options, + Class expectedFaultTypeClass, String... messagePatterns) throws Exception { + + try { + modelWeb.executeChanges(deltaList, options); + + AssertJUnit.fail("Unexpected success"); + } catch (FaultMessage f) { + FaultType faultInfo = f.getFaultInfo(); + if (expectedFaultTypeClass.isAssignableFrom(faultInfo.getClass())) { + // This is expected + String message = f.getMessage(); + for (String pattern: messagePatterns) { + if (!message.contains(pattern)) { + AssertJUnit.fail("Exception message does not contain pattern '"+pattern+"': "+message); + } + } + } else { + AssertJUnit.fail("Expected fault type of "+expectedFaultTypeClass+" but got "+faultInfo.getClass()); + } + } + } + + // TODO: more negative tests + + private ObjectDeltaType createShadowReplaceChange(String oid, String path, final String value, QName type) { + ObjectDeltaType objectChange = new ObjectDeltaType(); + objectChange.setOid(oid); + objectChange.setChangeType(ChangeTypeType.MODIFY); + objectChange.setObjectType(ObjectTypes.SHADOW.getTypeQName()); + ItemDeltaType itemDeltaType = new ItemDeltaType(); + itemDeltaType.setModificationType(ModificationTypeType.REPLACE); + ItemPathType itemPath = new ItemPathType(path); + itemDeltaType.setPath(itemPath); + PrimitiveXNode xnode = new PrimitiveXNode<>(); + ValueParser valueParser = new ValueParser() { + @Override + public String parse(QName typeName) throws SchemaException { + return value; + } + + @Override + public boolean isEmpty() { + return false; + } + + @Override + public String getStringValue() { + return value; + } + }; + xnode.setValueParser(valueParser); + if (type != null) { + xnode.setExplicitTypeDeclaration(true); + xnode.setTypeQName(type); + } + RawType rawValue = new RawType(xnode, prismContext); + itemDeltaType.getValue().add(rawValue); + objectChange.getItemDelta().add(itemDeltaType); + return objectChange; + } +} diff --git a/model/model-intest/testng.xml b/model/model-intest/testng.xml index 78acff914b9..61259ffda30 100644 --- a/model/model-intest/testng.xml +++ b/model/model-intest/testng.xml @@ -1,6 +1,6 @@ + + + modify + c:ShadowType + will be replaced by the test code + + replace + attributes/roomNumber + upperdeck + + From 8eeacc975dc68af6eb405dce1b26fb2304d1c95c Mon Sep 17 00:00:00 2001 From: Erik Suta Date: Thu, 8 Jan 2015 16:57:25 +0100 Subject: [PATCH 4/5] fix for bug with password handling of mail server from issue MID-2094 --- .../PageSystemConfiguration.java | 3 ++- .../component/SystemConfigPanel.java | 23 +++++++++++-------- .../dto/MailServerConfigurationTypeDto.java | 16 +++++++++++-- 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/configuration/PageSystemConfiguration.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/configuration/PageSystemConfiguration.java index 0fcc7e3894d..eb67f4af0a3 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/configuration/PageSystemConfiguration.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/configuration/PageSystemConfiguration.java @@ -409,7 +409,6 @@ private SystemConfigurationType saveNotificationConfiguration(SystemConfiguratio NotificationConfigurationDto dto; NotificationConfigurationType notificationConfig; MailConfigurationType mailConfig; - MailServerConfigurationType mailServerConfig; if(systemConfigPanel != null && systemConfigPanel.getModel().getObject().getNotificationConfig() != null){ dto = systemConfigPanel.getModel().getObject().getNotificationConfig(); @@ -442,6 +441,8 @@ private SystemConfigurationType saveNotificationConfiguration(SystemConfiguratio ProtectedStringType pass = new ProtectedStringType(); pass.setClearValue(serverDto.getPassword()); newConfig.setPassword(pass); + } else { + newConfig.setPassword(serverDto.getOldConfig().getPassword()); } mailConfig.getServer().add(newConfig); diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/configuration/component/SystemConfigPanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/configuration/component/SystemConfigPanel.java index ce96990f9cc..1354e967237 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/configuration/component/SystemConfigPanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/configuration/component/SystemConfigPanel.java @@ -25,6 +25,7 @@ import com.evolveum.midpoint.web.util.InfoTooltipBehavior; import com.evolveum.midpoint.web.util.WebMiscUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.MailTransportSecurityType; +import org.apache.wicket.AttributeModifier; import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.ajax.form.OnChangeAjaxBehavior; import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink; @@ -144,6 +145,18 @@ public String getIdValue(MailServerConfigurationTypeDto object, int index) { @Override protected void onUpdate(AjaxRequestTarget target) { + PasswordTextField passwordField = (PasswordTextField)get(ID_MAIN_FORM + ":" + ID_MAIL_SERVER_CONFIG_CONTAINER + ":" + ID_PASSWORD); + + if(getModelObject() != null){ + if(getModelObject().getNotificationConfig().getSelectedServer() != null && + getModelObject().getNotificationConfig().getSelectedServer().getPassword() != null){ + + passwordField.add(new AttributeModifier("placeholder", createStringResource("SystemConfigPanel.mail.password.placeholder.set"))); + } else { + passwordField.add(new AttributeModifier("placeholder", createStringResource("SystemConfigPanel.mail.password.placeholder.empty"))); + } + } + target.add(SystemConfigPanel.this); } }); @@ -175,16 +188,6 @@ public boolean isVisible() { PasswordTextField passwordField = new PasswordTextField(ID_PASSWORD, new PropertyModel(getModel(), "notificationConfig.selectedServer.password")); passwordField.setRequired(false); - if(getModelObject() != null){ - if(getModelObject().getNotificationConfig().getSelectedServer() != null && - getModelObject().getNotificationConfig().getSelectedServer().getPassword() != null){ - - passwordField.add(new AttributeAppender("placeholder", createStringResource("SystemConfigPanel.mail.password.placeholder.set"))); - } else { - passwordField.add(new AttributeAppender("placeholder", createStringResource("SystemConfigPanel.mail.password.placeholder.empty"))); - } - } - TextField redirectToFileField = new TextField<>(ID_REDIRECT_TO_FILE, new PropertyModel(getModel(), "notificationConfig.redirectToFile")); DropDownFormGroup transportSecurity = new DropDownFormGroup<>(ID_TRANSPORT_SECURITY, new PropertyModel(getModel(), diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/configuration/dto/MailServerConfigurationTypeDto.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/configuration/dto/MailServerConfigurationTypeDto.java index cfec4a54e5d..6f6a193d4a7 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/configuration/dto/MailServerConfigurationTypeDto.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/page/admin/configuration/dto/MailServerConfigurationTypeDto.java @@ -32,6 +32,7 @@ public class MailServerConfigurationTypeDto implements Serializable { public static final String F_PASSWORD = "password"; public static final String F_MAIL_TRANSPORT_SECURITY_TYPE = "mailTransportSecurityType"; + private MailServerConfigurationType oldConfig; private String host; private Integer port; private String username; @@ -42,6 +43,7 @@ public MailServerConfigurationTypeDto(){} public MailServerConfigurationTypeDto(MailServerConfigurationType config){ + oldConfig = config; host = config.getHost(); port = config.getPort(); username = config.getUsername(); @@ -95,15 +97,24 @@ public void setMailTransportSecurityType(MailTransportSecurityType mailTransport this.mailTransportSecurityType = mailTransportSecurityType; } + public MailServerConfigurationType getOldConfig() { + return oldConfig; + } + + public void setOldConfig(MailServerConfigurationType oldConfig) { + this.oldConfig = oldConfig; + } + @Override public boolean equals(Object o) { if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (!(o instanceof MailServerConfigurationTypeDto)) return false; MailServerConfigurationTypeDto that = (MailServerConfigurationTypeDto) o; if (host != null ? !host.equals(that.host) : that.host != null) return false; if (mailTransportSecurityType != that.mailTransportSecurityType) return false; + if (oldConfig != null ? !oldConfig.equals(that.oldConfig) : that.oldConfig != null) return false; if (password != null ? !password.equals(that.password) : that.password != null) return false; if (port != null ? !port.equals(that.port) : that.port != null) return false; if (username != null ? !username.equals(that.username) : that.username != null) return false; @@ -113,7 +124,8 @@ public boolean equals(Object o) { @Override public int hashCode() { - int result = host != null ? host.hashCode() : 0; + int result = oldConfig != null ? oldConfig.hashCode() : 0; + result = 31 * result + (host != null ? host.hashCode() : 0); result = 31 * result + (port != null ? port.hashCode() : 0); result = 31 * result + (username != null ? username.hashCode() : 0); result = 31 * result + (password != null ? password.hashCode() : 0); From 819b9a4858a303d520be354df673d0daafc298fe Mon Sep 17 00:00:00 2001 From: Radovan Semancik Date: Thu, 8 Jan 2015 19:30:18 +0100 Subject: [PATCH 5/5] Fixing consistency check --- .../midpoint/schema/processor/ResourceAttributeContainer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infra/schema/src/main/java/com/evolveum/midpoint/schema/processor/ResourceAttributeContainer.java b/infra/schema/src/main/java/com/evolveum/midpoint/schema/processor/ResourceAttributeContainer.java index e07a0ff97a6..f9f6c3d02e3 100644 --- a/infra/schema/src/main/java/com/evolveum/midpoint/schema/processor/ResourceAttributeContainer.java +++ b/infra/schema/src/main/java/com/evolveum/midpoint/schema/processor/ResourceAttributeContainer.java @@ -408,7 +408,7 @@ public void checkConsistenceInternal(Itemable rootItem, boolean requireDefinitio throw new IllegalStateException("Null values in ResourceAttributeContainer"); } if (values.isEmpty()) { - throw new IllegalStateException("Empty values in ResourceAttributeContainer"); + return; } if (values.size() > 1) { throw new IllegalStateException(values.size()+" values in ResourceAttributeContainer, expected just one");