protected DummyAccount getDummyAccount(String dummyInstanceName, String username) throws SchemaViolationException, ConflictException, InterruptedException { DummyResource dummyResource = DummyResource.getInstance(dummyInstanceName); try { return dummyResource.getAccountByUsername(username); } catch (ConnectException e) { throw new IllegalStateException(e.getMessage(),e); } catch (FileNotFoundException e) { throw new IllegalStateException(e.getMessage(),e); } }
public void assertNoAccountByUsername(String username) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException { DummyAccount account = dummyResource.getAccountByUsername(username); assertNull("Unexpected account "+username+" on dummy resource "+getName(), account); }
public DummyAccountAsserter<Void> assertAccountByUsername(String username) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException { DummyAccount account = dummyResource.getAccountByUsername(username); assertNotNull("Account "+username+" does not exist on dummy resource "+getName(), account); return assertAccount(account); }
protected DummyAccount getDummyAccount(String icfName, String icfUid) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException { if (isIcfNameUidSame()) { return dummyResource.getAccountByUsername(icfName); } else { return dummyResource.getAccountById(icfUid); } }
protected void assertNoDummyAccount(String icfName, String icfUid) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException { DummyAccount account; if (isIcfNameUidSame()) { account = dummyResource.getAccountByUsername(icfName); } else { account = dummyResource.getAccountById(icfUid); } assertNull("Unexpected dummy account with ICF UID "+icfUid+" (name "+icfName+")", account); }
protected void applyModifyMetadata(DummyObject object, OperationOptions options) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException { String runAsUser = options.getRunAsUser(); if (runAsUser != null) { if (!configuration.getSupportRunAs()) { throw new UnsupportedOperationException("runAsUser option is not supported"); } DummyAccount runAsAccount = resource.getAccountByUsername(runAsUser); if (runAsAccount == null) { new ConfigurationException("No runAsUser "+runAsUser); } GuardedString runWithPassword = options.getRunWithPassword(); if (runWithPassword != null) { runWithPassword.access((clearChars) -> { if (!runAsAccount.getPassword().equals(new String(clearChars))) { throw new InvalidPasswordException("Wrong runWithPassword"); } }); } else { throw new InvalidPasswordException("No runWithPassword"); } object.setLastModifier(runAsAccount.getName()); } else { object.setLastModifier(null); } }
protected DummyAccount getDummyAccountAssert(String icfName, String icfUid) throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, InterruptedException { if (isIcfNameUidSame()) { return dummyResource.getAccountByUsername(icfName); } else { DummyAccount account = dummyResource.getAccountById(icfUid); assertNotNull("No dummy account with ICF UID "+icfUid+" (expected name "+icfName+")", account); assertEquals("Unexpected name in "+account, icfName, account.getName()); return account; } }
@Test public void test720DarkVioletModifyShinetopLocation() throws Exception { final String TEST_NAME = "test720DarkVioletModifyShinetopLocation"; displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); dummyAuditService.clear(); DummyAccount account = getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).getAccountByUsername(ACCOUNT_SHINETOP_USERNAME); // WHEN displayWhen(TEST_NAME); account.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "Monkey Island"); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN displayThen(TEST_NAME); displayAllUsers(); assertUserNick(ACCOUNT_LECHUCK_USERNAME, LECHUCK_FULLNAME, LECHUCK_FULLNAME); assertNoUserNick(ACCOUNT_CHARLES_USERNAME, LECHUCK_FULLNAME, LECHUCK_FULLNAME+".1"); assertUserNick(ACCOUNT_SHINETOP_USERNAME, LECHUCK_FULLNAME, LECHUCK_FULLNAME+".2", "Monkey Island"); }
@Test public void test760DarkVioletModifyMillonarioLocation() throws Exception { final String TEST_NAME = "test760DarkVioletModifyMillonarioLocation"; displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); dummyAuditService.clear(); DummyAccount account = getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).getAccountByUsername(ACCOUNT_MILLONARIO_USERNAME); // WHEN displayWhen(TEST_NAME); account.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "Northern Peru"); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN displayThen(TEST_NAME); displayAllUsers(); assertUserNick(ACCOUNT_MATUSALEM_USERNAME, RUM_FULLNAME, RUM_FULLNAME); assertNoUserNick(ACCOUNT_DIPLOMATICO_USERNAME, RUM_FULLNAME, RUM_FULLNAME+iterationTokenDiplomatico); assertUserNick(ACCOUNT_MILLONARIO_USERNAME, RUM_FULLNAME, RUM_FULLNAME+iterationTokenMillonario, "Northern Peru"); }
/** * MID-2104 */ @Test public void test110ModifyAccountTitleCraticAndReconcile() throws Exception { final String TEST_NAME = "test110ModifyAccountTitleCraticAndReconcile"; displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); DummyAccount accountHerman = getDummyResource(RESOURCE_DUMMY_AUTOGREEN_NAME).getAccountByUsername(USER_HERMAN_USERNAME); accountHerman.replaceAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, "cratic"); // WHEN displayWhen(TEST_NAME); reconcileUser(userHermanOid, task, result); // THEN displayThen(TEST_NAME); assertSuccess(result); PrismObject<UserType> userAfter = getUser(userHermanOid); display("User after", userAfter); assertAssignedRole(userAfter, ROLE_AUTOCRATIC_OID); assertAssignments(userAfter, 1); }
@Test public void test722DarkVioletModifyShinetopFullName() throws Exception { final String TEST_NAME = "test722DarkVioletModifyShinetopFullName"; displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); dummyAuditService.clear(); DummyAccount account = getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).getAccountByUsername(ACCOUNT_SHINETOP_USERNAME); // WHEN displayWhen(TEST_NAME); account.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, CHUCKIE_FULLNAME); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN displayThen(TEST_NAME); displayAllUsers(); assertUserNick(ACCOUNT_LECHUCK_USERNAME, LECHUCK_FULLNAME, LECHUCK_FULLNAME); assertNoUserNick(ACCOUNT_CHARLES_USERNAME, LECHUCK_FULLNAME, LECHUCK_FULLNAME+".1"); assertUserNick(ACCOUNT_SHINETOP_USERNAME, CHUCKIE_FULLNAME, CHUCKIE_FULLNAME, "Monkey Island"); assertNoUserNick(ACCOUNT_SHINETOP_USERNAME, LECHUCK_FULLNAME, LECHUCK_FULLNAME+".2"); }
@Test public void test040AddAccount() throws Exception { final String TEST_NAME = "test040AddAccount"; TestUtil.displayTestTitle(this, TEST_NAME); OperationResult result = new OperationResult(this.getClass().getName() + "." + TEST_NAME); ObjectClassComplexTypeDefinition defaultAccountDefinition = resourceSchema.findDefaultObjectClassDefinition(ShadowKindType.ACCOUNT); ShadowType shadowType = new ShadowType(); PrismTestUtil.getPrismContext().adopt(shadowType); shadowType.setName(PrismTestUtil.createPolyStringType(ACCOUNT_JACK_USERNAME)); ObjectReferenceType resourceRef = new ObjectReferenceType(); resourceRef.setOid(resource.getOid()); shadowType.setResourceRef(resourceRef); shadowType.setObjectClass(defaultAccountDefinition.getTypeName()); PrismObject<ShadowType> shadow = shadowType.asPrismObject(); ResourceAttributeContainer attributesContainer = ShadowUtil.getOrCreateAttributesContainer(shadow, defaultAccountDefinition); ResourceAttribute<String> icfsNameProp = attributesContainer.findOrCreateAttribute(SchemaConstants.ICFS_NAME); icfsNameProp.setRealValue(ACCOUNT_JACK_USERNAME); // WHEN cc.addObject(shadow, null, null, result); // THEN DummyAccount dummyAccount = dummyResource.getAccountByUsername(ACCOUNT_JACK_USERNAME); assertNotNull("Account "+ACCOUNT_JACK_USERNAME+" was not created", dummyAccount); assertNotNull("Account "+ACCOUNT_JACK_USERNAME+" has no username", dummyAccount.getName()); }
@Test public void test100AddAccount() throws Exception { final String TEST_NAME = "test100AddAccount"; TestUtil.displayTestTitle(this, TEST_NAME); OperationResult result = new OperationResult(this.getClass().getName() + "." + TEST_NAME); ObjectClassComplexTypeDefinition defaultAccountDefinition = resourceSchema.findDefaultObjectClassDefinition(ShadowKindType.ACCOUNT); ShadowType shadowType = new ShadowType(); PrismTestUtil.getPrismContext().adopt(shadowType); shadowType.setName(PrismTestUtil.createPolyStringType(ACCOUNT_JACK_USERNAME)); ObjectReferenceType resourceRef = new ObjectReferenceType(); resourceRef.setOid(resource.getOid()); shadowType.setResourceRef(resourceRef); shadowType.setObjectClass(defaultAccountDefinition.getTypeName()); PrismObject<ShadowType> shadow = shadowType.asPrismObject(); ResourceAttributeContainer attributesContainer = ShadowUtil.getOrCreateAttributesContainer(shadow, defaultAccountDefinition); ResourceAttribute<String> icfsNameProp = attributesContainer.findOrCreateAttribute(SchemaConstants.ICFS_NAME); icfsNameProp.setRealValue(ACCOUNT_JACK_USERNAME); // WHEN cc.addObject(shadow, null, null, result); // THEN DummyAccount dummyAccount = dummyResource.getAccountByUsername(ACCOUNT_JACK_USERNAME); assertNotNull("Account "+ACCOUNT_JACK_USERNAME+" was not created", dummyAccount); assertNotNull("Account "+ACCOUNT_JACK_USERNAME+" has no username", dummyAccount.getName()); }
assertPartialError(result); DummyAccount jackDummyAccount = getDummyResource().getAccountByUsername(USER_JACK_USERNAME); assertNotNull("No jack dummy account", jackDummyAccount);
/** * Rename to an identifier that is free. Empty iterationToken is expected. */ @Test public void test762DarkVioletModifyMillonarioFullName() throws Exception { final String TEST_NAME = "test762DarkVioletModifyMillonarioFullName"; displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); dummyAuditService.clear(); DummyAccount account = getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).getAccountByUsername(ACCOUNT_MILLONARIO_USERNAME); // WHEN displayWhen(TEST_NAME); account.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, RON_FULLNAME); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN displayThen(TEST_NAME); displayAllUsers(); assertUserNick(ACCOUNT_MATUSALEM_USERNAME, RUM_FULLNAME, RUM_FULLNAME); assertNoUserNick(ACCOUNT_DIPLOMATICO_USERNAME, RUM_FULLNAME, RUM_FULLNAME+iterationTokenDiplomatico); assertUserNick(ACCOUNT_MILLONARIO_USERNAME, RON_FULLNAME, RON_FULLNAME, "Northern Peru"); assertNoUserNick(ACCOUNT_MILLONARIO_USERNAME, RUM_FULLNAME, RUM_FULLNAME+iterationTokenMillonario); }
/** * MID-2104 */ @Test public void test112ModifyAccountTitleDidacticGraphicAndReconcile() throws Exception { final String TEST_NAME = "test112ModifyAccountTitleDidacticGraphicAndReconcile"; displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); DummyAccount accountHerman = getDummyResource(RESOURCE_DUMMY_AUTOGREEN_NAME).getAccountByUsername(USER_HERMAN_USERNAME); accountHerman.replaceAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, "didactic", "graphic"); // WHEN displayWhen(TEST_NAME); reconcileUser(userHermanOid, task, result); // THEN displayThen(TEST_NAME); assertSuccess(result); PrismObject<UserType> userAfter = getUser(userHermanOid); display("User after", userAfter); assertAssignedRole(userAfter, ROLE_AUTODIDACTIC_OID); assertAssignedRole(userAfter, ROLE_AUTOGRAPHIC_OID); assertAssignments(userAfter, 2); }
@Test public void test610EnableUser1() throws Exception { final String TEST_NAME = "test610EnableUser1"; displayTestTitle(TEST_NAME); // GIVEN PrismObject<UserType> user1 = findUserByUsername("user1"); Task task = taskManager.createTaskInstance(TestActivation.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); Collection<ObjectDelta<? extends ObjectType>> deltas = cast(prismContext.deltaFor(UserType.class) .item(ACTIVATION_ADMINISTRATIVE_STATUS_PATH).replace(ActivationStatusType.ENABLED) .asObjectDeltas(user1.getOid())); // WHEN modelService.executeChanges(deltas, null, task, result); // THEN user1 = getUser(user1.getOid()); display("User after change execution", user1); DummyAccount dummyAccount = dummyResourceCoral.getAccountByUsername("user1"); display("Dummy account", dummyAccount); checkSuspendedAttribute(dummyAccount, Boolean.FALSE); String accountOid = getSingleLinkOid(user1); PrismObject<ShadowType> shadow = getShadowModel(accountOid); display("Shadow: ", shadow); // TODO check real state of the account and shadow }
/** * Rename to an identifier that is taken. New random iterationToken is expected. */ @Test public void test764DarkVioletModifyMatusalemFullName() throws Exception { final String TEST_NAME = "test764DarkVioletModifyMatusalemFullName"; displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); dummyAuditService.clear(); DummyAccount account = getDummyResource(RESOURCE_DUMMY_DARK_VIOLET_NAME).getAccountByUsername(ACCOUNT_MATUSALEM_USERNAME); // WHEN displayWhen(TEST_NAME); account.replaceAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, RON_FULLNAME); waitForTaskNextRunAssertSuccess(TASK_LIVE_SYNC_DUMMY_DARK_VIOLET_OID, true); // THEN displayThen(TEST_NAME); displayAllUsers(); assertNoUserNick(ACCOUNT_MATUSALEM_USERNAME, RUM_FULLNAME, RUM_FULLNAME); String iterationTokenMatusalem = lookupIterationTokenByAdditionalName(ACCOUNT_MATUSALEM_USERNAME); assertUserNick(ACCOUNT_MATUSALEM_USERNAME, RON_FULLNAME, RON_FULLNAME+iterationTokenMatusalem); assertNoUserNick(ACCOUNT_DIPLOMATICO_USERNAME, RUM_FULLNAME, RUM_FULLNAME+iterationTokenDiplomatico); assertUserNick(ACCOUNT_MILLONARIO_USERNAME, RON_FULLNAME, RON_FULLNAME, "Northern Peru"); assertNoUserNick(ACCOUNT_MILLONARIO_USERNAME, RUM_FULLNAME, RUM_FULLNAME+iterationTokenMillonario); }
private PrismObject<ShadowType> checkWallyAccount(PrismObject<ResourceType> resource, DummyResource dummy, String resourceDesc, String expectedFullName, String shipName, String quote) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ConnectException, FileNotFoundException, SchemaViolationException, ConflictException, ExpressionEvaluationException, InterruptedException { PrismObject<ShadowType> accountShadowWally = findAccountByUsername(ACCOUNT_WALLY_DUMMY_USERNAME, resource); display("Account shadow wally ("+resourceDesc+")", accountShadowWally); assertEquals("Wrong resourceRef in wally account ("+resourceDesc+")", resource.getOid(), accountShadowWally.asObjectable().getResourceRef().getOid()); if (expectedFullName != null) { IntegrationTestTools.assertAttribute(accountShadowWally.asObjectable(), resource.asObjectable(), DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, expectedFullName); } DummyAccount dummyAccount = dummy.getAccountByUsername(ACCOUNT_WALLY_DUMMY_USERNAME); display("Account wally ("+resourceDesc+")", dummyAccount); assertNotNull("No dummy account ("+resourceDesc+")", dummyAccount); if (expectedFullName != null) { assertEquals("Wrong dummy account fullname ("+resourceDesc+")", expectedFullName, dummyAccount.getAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME)); } if (shipName != null){ assertEquals("Wrong dummy account shipName ("+resourceDesc+")", shipName, dummyAccount.getAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME)); } if (quote != null){ assertEquals("Wrong dummy account quote ("+resourceDesc+")", quote, dummyAccount.getAttributeValue(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_QUOTE_NAME)); } return accountShadowWally; }
@Test public void test600AddUser1() throws Exception { final String TEST_NAME = "test600AddUser1"; displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); PrismObject<UserType> user1 = prismContext.createObject(UserType.class); prismContext.deltaFor(UserType.class) .item(UserType.F_NAME).replace(new PolyString("user1")) .item(UserType.F_ASSIGNMENT).add(ObjectTypeUtil.createAssignmentTo(resourceDummyCoral, prismContext).asPrismContainerValue()) .item(ACTIVATION_ADMINISTRATIVE_STATUS_PATH).replace(ActivationStatusType.DISABLED) .asObjectDelta(null) .applyTo((PrismObject) user1); ObjectDelta<UserType> addDelta = user1.createAddDelta(); // WHEN displayWhen(TEST_NAME); Collection<ObjectDeltaOperation<? extends ObjectType>> executedChanges = executeChanges(addDelta, null, task, result); // THEN displayThen(TEST_NAME); user1 = getUser(ObjectDeltaOperation.findFocusDeltaOidInCollection(executedChanges)); display("User after change execution", user1); DummyAccount dummyAccount = dummyResourceCoral.getAccountByUsername("user1"); display("Dummy account", dummyAccount); checkSuspendedAttribute(dummyAccount, Boolean.TRUE); String accountOid = getSingleLinkOid(user1); PrismObject<ShadowType> shadow = getShadowModel(accountOid); display("Shadow: ", shadow); // TODO check real state of the account and shadow }