Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feature/simulations
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Nov 4, 2022
2 parents 3ad52cc + 60bafdc commit e4a5203
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 1 deletion.
Expand Up @@ -34,6 +34,7 @@
import java.util.Collections;
import java.util.Map;
import java.util.Set;
import java.util.HashSet;
import java.util.concurrent.ConcurrentHashMap;

import static com.evolveum.midpoint.util.MiscUtil.schemaCheck;
Expand Down Expand Up @@ -224,7 +225,7 @@ public synchronized void invalidate(Class<?> type, String oid, CacheInvalidation

/** Invalidates single (concrete) resource and all its descendants. */
synchronized void invalidateSingle(@NotNull String oid) {
Set<String> descendants = dependencyMap.get(oid);
Set<String> descendants = new HashSet<>(dependencyMap.get(oid));
LOGGER.trace("Invalidating {} and all its descendants: {}", oid, descendants);

invalidateSingleShallow(oid);
Expand Down
Expand Up @@ -38,6 +38,7 @@ public interface AdTestMixin extends InfraTestMixin {
String ATTRIBUTE_UNICODE_PWD_NAME = "unicodePwd";
String ATTRIBUTE_MS_EXCH_HIDE_FROM_ADDRESS_LISTS_NAME = "msExchHideFromAddressLists";
String ATTRIBUTE_TITLE_NAME = "title";
String ATTRIBUTE_TELEPHONE_NUMBER = "telephoneNumber";
String ATTRIBUTE_PROXY_ADDRESSES_NAME = "proxyAddresses";
String ATTRIBUTE_USER_PARAMETERS_NAME = "userParameters";
String ATTRIBUTE_MEMBER_NAME = "member";
Expand Down
Expand Up @@ -1016,6 +1016,82 @@ public void test216ModifyAccountBarbossaUserParameters() throws Exception {
// assertLdapConnectorInstances(2);
}

@Test
public void test218ModifyAccountBarbossaTelephoneNumberGood() throws Exception {
// GIVEN
Task task = getTestTask();
OperationResult result = task.getResult();

ObjectDelta<ShadowType> delta = prismContext.deltaFactory().object()
.createEmptyModifyDelta(ShadowType.class, accountBarbossaOid);
QName attrQName = new QName(MidPointConstants.NS_RI, ATTRIBUTE_TELEPHONE_NUMBER);
ResourceAttributeDefinition<?> attrDef = accountDefinition.findAttributeDefinition(attrQName);
PropertyDelta<String> attrDelta = prismContext.deltaFactory().property().createModificationReplaceProperty(
ItemPath.create(ShadowType.F_ATTRIBUTES, attrQName), attrDef, "+421901123456");
delta.addModification(attrDelta);

// WHEN
when();
executeChanges(delta, null, task, result);

// THEN
then();
assertSuccess(result);

Entry entry = assertLdapAccount(USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME);
assertAttribute(entry, ATTRIBUTE_TELEPHONE_NUMBER, "+421901123456");
assertAttribute(entry, ATTRIBUTE_USER_ACCOUNT_CONTROL_NAME, "512");
assertAttribute(entry, ATTRIBUTE_OBJECT_CATEGORY_NAME, getObjectCategoryPerson());
assertLdapPassword(USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, USER_BARBOSSA_PASSWORD);

PrismObject<UserType> user = getUser(USER_BARBOSSA_OID);
String shadowOid = getSingleLinkOid(user);
assertEquals("Shadows have moved", accountBarbossaOid, shadowOid);

// assertLdapConnectorReasonableInstances();
}

/**
* We are trying to set a telephone number that is too long (more than 64 chars).
* AD will not accept that.
* Make sure the operation fails in a graceful way (e.g. no endless retry loops).
*/
@Test
public void test219ModifyAccountBarbossaTelephoneNumberLong() throws Exception {
// GIVEN
Task task = getTestTask();
OperationResult result = task.getResult();

ObjectDelta<ShadowType> delta = prismContext.deltaFactory().object()
.createEmptyModifyDelta(ShadowType.class, accountBarbossaOid);
QName attrQName = new QName(MidPointConstants.NS_RI, ATTRIBUTE_TELEPHONE_NUMBER);
ResourceAttributeDefinition<?> attrDef = accountDefinition.findAttributeDefinition(attrQName);
PropertyDelta<String> attrDelta = prismContext.deltaFactory().property().createModificationReplaceProperty(
ItemPath.create(ShadowType.F_ATTRIBUTES, attrQName), attrDef, "+4219011234567890123456789012345678901234567890123456789012345678901234567890");
delta.addModification(attrDelta);

// WHEN
when();
executeChanges(delta, null, task, result);

// THEN
then();
assertPartialError(result);

Entry entry = assertLdapAccount(USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME);
// We expect unchanged telephone number here
assertAttribute(entry, ATTRIBUTE_TELEPHONE_NUMBER, "+421901123456");
assertAttribute(entry, ATTRIBUTE_USER_ACCOUNT_CONTROL_NAME, "512");
assertAttribute(entry, ATTRIBUTE_OBJECT_CATEGORY_NAME, getObjectCategoryPerson());
assertLdapPassword(USER_BARBOSSA_USERNAME, USER_BARBOSSA_FULL_NAME, USER_BARBOSSA_PASSWORD);

PrismObject<UserType> user = getUser(USER_BARBOSSA_OID);
String shadowOid = getSingleLinkOid(user);
assertEquals("Shadows have moved", accountBarbossaOid, shadowOid);

// assertLdapConnectorReasonableInstances();
}

@Test
public void test220ModifyUserBarbossaPasswordSelfServicePassword1() throws Exception {
testModifyUserBarbossaPasswordSelfServiceSuccess(
Expand Down
Expand Up @@ -197,6 +197,15 @@
</outbound>
</attribute>

<attribute>
<ref>ri:telephoneNumber</ref>
<outbound>
<source>
<path>telephoneNumber</path>
</source>
</outbound>
</attribute>

<attribute>
<ref>ri:userPrincipalName</ref>
<outbound>
Expand Down

0 comments on commit e4a5203

Please sign in to comment.