def test_create_user_with_group_failure_no_group_exists( identity_client, get_ids_from_group_names, add_user_to_groups, create_and_wait_patch, delete_user_patch, ): error_message = "No group named error_group exists" user = get_user() create_and_wait_patch.return_value = dict({ "user": to_dict(user), "changed": True }) delete_user_patch.return_value = None get_ids_from_group_names.side_effect = ClientError(error_message) add_user_to_groups.return_value = None try: oci_user.create_user( identity_client, get_module( dict({ "create_or_reset_ui_password": False, "user_groups": ["admin", "network"], "compartment_id": "test_compartment", })), ) except Exception as ex: assert error_message in ex.args[0]
def test_create_user_with_password_failure(identity_client, create_or_reset_password, create_and_wait_patch, delete_user_patch): error_message = 'Error during password generation' user = get_user() create_and_wait_patch = dict({'user': to_dict(user), 'changed': True}) create_or_reset_password.side_effect = ServiceError( 499, 'InternalServerError', dict(), error_message) try: oci_user.create_user( identity_client, get_module( dict({ 'create_or_reset_ui_password': True, 'user_groups': None, 'compartment_id': 'test_compartment' }))) except Exception as ex: assert error_message in ex.args[0]
def test_create_user_with_password_failure(identity_client, create_or_reset_password, create_and_wait_patch, delete_user_patch): error_message = "Error during password generation" user = get_user() create_and_wait_patch = dict({"user": to_dict(user), "changed": True}) create_or_reset_password.side_effect = ServiceError( 499, "InternalServerError", dict(), error_message) try: oci_user.create_user( identity_client, get_module( dict({ "create_or_reset_ui_password": True, "user_groups": None, "compartment_id": "test_compartment", })), ) except Exception as ex: assert error_message in ex.args[0]
def test_create_user_with_group_failure_no_group_exists( identity_client, get_ids_from_group_names, add_user_to_groups, create_and_wait_patch, delete_user_patch): error_message = 'No group named error_group exists' user = get_user() create_and_wait_patch.return_value = dict({ 'user': to_dict(user), 'changed': True }) delete_user_patch.return_value = None get_ids_from_group_names.side_effect = ClientError(error_message) add_user_to_groups.return_value = None try: oci_user.create_user( identity_client, get_module( dict({ 'create_or_reset_ui_password': False, 'user_groups': ['admin', 'network'], 'compartment_id': 'test_compartment' }))) except Exception as ex: assert error_message in ex.args[0]
def test_create_user_success(identity_client, create_and_wait_patch): user = get_user() create_and_wait_patch.return_value = dict({ 'user': to_dict(user), 'changed': True }) result = oci_user.create_user( identity_client, get_module( dict({ 'create_or_reset_ui_password': False, 'user_groups': None, 'compartment_id': 'test_compartment' }))) assert result['user']['name'] is user.name
def test_create_user_success(identity_client, create_and_wait_patch): user = get_user() create_and_wait_patch.return_value = dict({ "user": to_dict(user), "changed": True }) result = oci_user.create_user( identity_client, get_module( dict({ "create_or_reset_ui_password": False, "user_groups": None, "compartment_id": "test_compartment", })), ) assert result["user"]["name"] is user.name
def test_create_user_with_group_success(identity_client, get_ids_from_group_names, add_user_to_groups, create_and_wait_patch): user = get_user() create_and_wait_patch.return_value = dict({ 'user': to_dict(user), 'changed': True }) get_ids_from_group_names.return_value = [ 'ocid1.group.oc1.asx', 'ocid1.group.oc1.vfc' ] add_user_to_groups.return_value = None result = oci_user.create_user( identity_client, get_module( dict({ 'create_or_reset_ui_password': False, 'user_groups': ['admin', 'network'], 'compartment_id': 'test_compartment' }))) assert result['user']['name'] is user.name
def test_create_user_with_group_success(identity_client, get_ids_from_group_names, add_user_to_groups, create_and_wait_patch): user = get_user() create_and_wait_patch.return_value = dict({ "user": to_dict(user), "changed": True }) get_ids_from_group_names.return_value = [ "ocid1.group.oc1.asx", "ocid1.group.oc1.vfc", ] add_user_to_groups.return_value = None result = oci_user.create_user( identity_client, get_module( dict({ "create_or_reset_ui_password": False, "user_groups": ["admin", "network"], "compartment_id": "test_compartment", })), ) assert result["user"]["name"] is user.name