def test_update_route_table_no_route_table_for_update(virtual_network_client):
    error_message = 'No Route Table'
    module = get_module(dict(rt_id='ocid1.routetable..xvdf'))
    try:
        oci_route_table.update_route_table(virtual_network_client, None,
                                           module)
    except Exception as ex:
        assert error_message in str(ex.args)
def test_update_route_table_freeform_tags_changed(virtual_network_client,
                                                  update_and_wait_patch):
    route_table = get_route_table()
    module = get_module(dict(freeform_tags=dict(route_type='intranet')))
    update_and_wait_patch.return_value = dict(changed=True,
                                              route_table=route_table)
    result = oci_route_table.update_route_table(virtual_network_client,
                                                route_table, module)
    assert result['changed'] is True
def test_update_route_table_name_changed(virtual_network_client,
                                         update_and_wait_patch):
    route_table = get_route_table()
    module = get_module(dict(display_name='updated_ansible_route_table'))
    update_and_wait_patch.return_value = dict(changed=True,
                                              route_table=route_table)
    result = oci_route_table.update_route_table(virtual_network_client,
                                                route_table, module)
    assert result['changed'] is True
def test_update_route_table_empty_input_route_rules(virtual_network_client,
                                                    update_and_wait_patch):
    route_table = get_route_table()
    route_rules = []
    module = get_module(dict(route_rules=route_rules))
    update_and_wait_patch.return_value = dict(changed=True,
                                              route_table=to_dict(route_table))
    result = oci_route_table.update_route_table(virtual_network_client,
                                                route_table, module)
    assert result['changed'] is True
def test_update_route_table_defined_tags_changed(virtual_network_client,
                                                 update_and_wait_patch):
    route_table = get_route_table()
    module = get_module(
        dict(defined_tags=dict(admin_type=dict(admin_role='limited_user'))))
    update_and_wait_patch.return_value = dict(changed=True,
                                              route_table=route_table)
    result = oci_route_table.update_route_table(virtual_network_client,
                                                route_table, module)
    assert result['changed'] is True
Exemple #6
0
def test_update_route_table_service_cidr_input_route_rules_different(
        virtual_network_client, update_and_wait_patch):
    route_table = get_route_table()
    route_table.route_rules = [get_service_cidr_route_rule()]
    route_rules = [{
        "destination": "oci-ashburn-objectstorage",
        "destination_type": RouteRule.DESTINATION_TYPE_SERVICE_CIDR_BLOCK,
        "network_entity_id": "oci1.internetgateway.abcd",
    }]
    module = get_module(dict(route_rules=route_rules))
    update_and_wait_patch.return_value = dict(changed=True,
                                              route_table=to_dict(route_table))
    result = oci_route_table.update_route_table(virtual_network_client,
                                                route_table, module)
    assert result["changed"] is True
Exemple #7
0
def test_update_route_table_input_no_route_rules_different(
        virtual_network_client, update_and_wait_patch):
    route_table = get_route_table()
    route_rules = [{
        'cidr_block': '10.0.0.0/12',
        'network_entity_id': 'oci1.internetgateway.ijkl'
    }, {
        'cidr_block': '10.0.0.0/16',
        'network_entity_id': 'oci1.internetgateway.efgh'
    }]
    module = get_module(dict(route_rules=route_rules))
    update_and_wait_patch.return_value = dict(changed=False,
                                              route_table=to_dict(route_table))
    result = oci_route_table.update_route_table(virtual_network_client,
                                                route_table, module)
    assert result['changed'] is False
def test_update_route_table_input_route_rules_different(
        virtual_network_client, get_route_rules_difference_patch,
        update_and_wait_patch):
    route_table = get_route_table()
    route_rules = [{
        'cidr_block': '0.0.0.0/0',
        'network_entity_id': 'oci1.internetgateway.abcd'
    }, {
        'cidr_block': '10.0.0.4/16',
        'network_entity_id': 'oci1.internetgateway.efgh'
    }]
    module = get_module(dict(route_rules=route_rules))
    get_route_rules_difference_patch.return_value = get_route_rules(), True
    update_and_wait_patch.return_value = dict(changed=True,
                                              route_table=to_dict(route_table))
    result = oci_route_table.update_route_table(virtual_network_client,
                                                route_table, module)
    assert result['changed'] is True
Exemple #9
0
def test_update_route_table_input_no_route_rules_different(
        virtual_network_client, update_and_wait_patch):
    route_table = get_route_table()
    route_rules = [
        {
            "cidr_block": "10.0.0.0/12",
            "network_entity_id": "oci1.internetgateway.ijkl"
        },
        {
            "cidr_block": "10.0.0.0/16",
            "network_entity_id": "oci1.internetgateway.efgh"
        },
    ]
    module = get_module(dict(route_rules=route_rules))
    update_and_wait_patch.return_value = dict(changed=False,
                                              route_table=to_dict(route_table))
    result = oci_route_table.update_route_table(virtual_network_client,
                                                route_table, module)
    assert result["changed"] is False