def test_attribute_sync_from_udm_to_s4(attribute, sync_mode): (ucs_attribute, con_attribute, con_other_attribute) = attribute udm_user = NormalUser(selection=("username", "lastname", ucs_attribute)) primary_value = udm_user.basic.get(ucs_attribute) all_values = (primary_value, random_number(), random_number()) secondary_values = all_values[1:] with connector_setup(sync_mode) as s4, UCSTestUDM() as udm: # A single `phone` number must be synced to `telephoneNumber` in AD. (udm_user_dn, s4_user_dn) = create_udm_user(udm, s4, udm_user, s4connector.wait_for_sync) # Additional `phone` values must be synced to `otherTelephone`, # `telephoneNumber` must keep its value. print("\nModifying UDM user: {}={}\n".format(ucs_attribute, all_values)) udm.modify_object('users/user', dn=udm_user_dn, set={ucs_attribute: all_values}) s4connector.wait_for_sync() s4.verify_object(s4_user_dn, {con_attribute: primary_value, con_other_attribute: secondary_values}) tcommon.verify_udm_object("users/user", udm_user_dn, {ucs_attribute: all_values}) # If we delete the first `phone` value via UDM, we want to duplicate # the first value of `otherTelephone` into `telephoneNumber`. (new_primary, next_primary) = secondary_values print("\nModifying UDM user: {}={}\n".format(ucs_attribute, secondary_values)) udm.modify_object('users/user', dn=udm_user_dn, set={ucs_attribute: secondary_values}) s4connector.wait_for_sync() s4.verify_object(s4_user_dn, {con_attribute: new_primary, con_other_attribute: secondary_values}) tcommon.verify_udm_object("users/user", udm_user_dn, {ucs_attribute: secondary_values}) # If we delete a `phone` value via UDM that is duplicated in AD, we want # it to be deleted from `telephoneNumber` and `otherTelephone`. print("\nModifying UDM user: {}={}\n".format(ucs_attribute, next_primary)) udm.modify_object('users/user', dn=udm_user_dn, set={ucs_attribute: next_primary}) s4connector.wait_for_sync() s4.verify_object(s4_user_dn, {con_attribute: next_primary, con_other_attribute: next_primary}) tcommon.verify_udm_object("users/user", udm_user_dn, {ucs_attribute: next_primary}) # Setting a completely new `phone` value via UDM, this must be synced # to `telephoneNumber` and `otherTelephone` must be empty. new_phone_who_dis = random_number() print("\nModifying UDM user: {}={}\n".format(ucs_attribute, new_phone_who_dis)) udm.modify_object('users/user', dn=udm_user_dn, set={ucs_attribute: new_phone_who_dis}) s4connector.wait_for_sync() s4.verify_object(s4_user_dn, {con_attribute: new_phone_who_dis, con_other_attribute: []}) tcommon.verify_udm_object("users/user", udm_user_dn, {ucs_attribute: new_phone_who_dis}) # No `phone` value via UDM, must result in an empty `telephoneNumber` # and `otherTelephone`. print("\nModifying UDM user: {}={}\n".format(ucs_attribute, [])) udm.modify_object('users/user', dn=udm_user_dn, set={ucs_attribute: ''}) s4connector.wait_for_sync() s4.verify_object(s4_user_dn, {con_attribute: [], con_other_attribute: []}) tcommon.verify_udm_object("users/user", udm_user_dn, {ucs_attribute: []}) delete_udm_user(udm, s4, udm_user_dn, s4_user_dn, s4connector.wait_for_sync)
def test_attribute_sync_from_ad_to_udm(attribute, sync_mode): (ucs_attribute, con_attribute, con_other_attribute) = attribute udm_user = NormalUser(selection=("username", "lastname", ucs_attribute)) primary_value = udm_user.basic.get(ucs_attribute) all_values = (primary_value, random_number(), random_number()) secondary_values = all_values[1:] with connector_setup(sync_mode): # A single `telephoneNumber` must be synced to `phone` in UDM. (basic_ad_user, ad_user_dn, udm_user_dn) = create_con_user(AD, udm_user, adconnector.wait_for_sync) # Additional values in `otherTelephone` must be appended to `phone`. print("\nModifying AD user: {}={}, {}={}\n".format( con_attribute, primary_value, con_other_attribute, secondary_values)) AD.set_attributes( ad_user_dn, **{ con_attribute: primary_value, con_other_attribute: secondary_values }) adconnector.wait_for_sync() tcommon.verify_udm_object("users/user", udm_user_dn, {ucs_attribute: all_values}) AD.verify_object(ad_user_dn, { con_attribute: primary_value, con_other_attribute: secondary_values }) if sync_mode == "sync": # otherwise the connector can't write into AD # If we delete the value of `telephoneNumber` from AD, we expect to get # the first value of `otherTelephone` duplicated into # `telephoneNumber`. (new_primary, _) = secondary_values print("\nModifying AD user: {}={}\n".format(con_attribute, [])) AD.set_attributes(ad_user_dn, **{con_attribute: []}) adconnector.wait_for_sync() tcommon.verify_udm_object("users/user", udm_user_dn, {ucs_attribute: secondary_values}) AD.verify_object(ad_user_dn, { con_attribute: new_primary, con_other_attribute: secondary_values }) # Deleting the duplicate from `otherTelephone` must retain the value of # `telephoneNumber` and `phone` in UDM. print("\nModifying AD user: {}={}\n".format( con_other_attribute, [])) AD.set_attributes(ad_user_dn, **{con_other_attribute: []}) adconnector.wait_for_sync() tcommon.verify_udm_object("users/user", udm_user_dn, {ucs_attribute: new_primary}) AD.verify_object(ad_user_dn, { con_attribute: new_primary, con_other_attribute: [] }) # Setting a new `telephoneNumber` and no `otherTelephone` in AD must # result in a single new value in `phone`. new_phone_who_dis = random_number() print("\nModifying AD user: {}={}\n".format(con_attribute, new_phone_who_dis)) AD.set_attributes( ad_user_dn, **{ con_attribute: new_phone_who_dis, con_other_attribute: [] }) adconnector.wait_for_sync() tcommon.verify_udm_object("users/user", udm_user_dn, {ucs_attribute: new_phone_who_dis}) AD.verify_object(ad_user_dn, { con_attribute: new_phone_who_dis, con_other_attribute: [] }) # Setting no `telephoneNumber` and no `otherTelephone` in AD must # result in no value in `phone`. print("\nModifying AD user: {}={}\n".format(con_attribute, [])) AD.set_attributes(ad_user_dn, **{ con_attribute: [], con_other_attribute: [] }) adconnector.wait_for_sync() tcommon.verify_udm_object("users/user", udm_user_dn, {ucs_attribute: []}) AD.verify_object(ad_user_dn, { con_attribute: [], con_other_attribute: [] }) delete_con_user(AD, ad_user_dn, udm_user_dn, adconnector.wait_for_sync)