Exemple #1
0
def test_delete_user_with_memberships_force_no_failure(
        identity_client, get_existing_resource_patch, delete_memberships):
    error_message = 'User has group association'
    user = get_user()
    get_existing_resource_patch.return_value = user
    identity_client.delete_user.side_effect = ServiceError(
        400, 'UserHasAssociation', dict(), error_message)
    module = get_module(
        dict({
            'force': False,
            'compartment_id': 'ocid1.compartment..abuw',
            'user_id': 'ocid1.user..abuw'
        }))
    try:
        oci_user.delete_user(identity_client, module)
    except Exception as ex:
        assert error_message is ex.args[0]
Exemple #2
0
def test_delete_user_no_memberships(identity_client,
                                    get_existing_resource_patch,
                                    delete_and_wait_patch):
    user = get_user()
    get_existing_resource_patch.return_value = user
    delete_and_wait_patch.return_value = {
        'user': to_dict(user),
        'changed': True
    }
    module = get_module(
        dict({
            'force': False,
            'compartment_id': 'ocid1.compartment..abuw',
            'user_id': 'ocid1.user..abuw'
        }))
    result = oci_user.delete_user(identity_client, module)
    assert result['changed'] is True
Exemple #3
0
def test_delete_user_no_memberships(identity_client,
                                    get_existing_resource_patch,
                                    delete_and_wait_patch):
    user = get_user()
    get_existing_resource_patch.return_value = user
    delete_and_wait_patch.return_value = {
        "user": to_dict(user),
        "changed": True
    }
    module = get_module(
        dict({
            "force": False,
            "compartment_id": "ocid1.compartment..abuw",
            "user_id": "ocid1.user..abuw",
        }))
    result = oci_user.delete_user(identity_client, module)
    assert result["changed"] is True