Esempio n. 1
0
def test_with_known_ipv6():
    xml = region_srv.get_response_xml('2000::1', None, region_map,
                                      ipv4_ranges_map, ipv6_ranges_map)

    assert type(xml) is str

    smt_info_elems = etree.fromstring(xml).findall('.//smtInfo')
    xml_helper.assert_xml_validity(smt_info_elems, region_data)
Esempio n. 2
0
def test_with_region_hint():
    xml = region_srv.get_response_xml('0.0.0.0', 'antarctica-central',
                                      region_map, ipv4_ranges_map,
                                      ipv6_ranges_map)

    assert type(xml) is str

    smt_info_elems = etree.fromstring(xml).findall('.//smtInfo')
    xml_helper.assert_xml_validity(smt_info_elems, region_data)
def test_with_ip_fallback():
    xml = region_srv.get_response_xml('123.123.1.1', 'unknown-region',
                                      region_map, ipv4_ranges_map,
                                      ipv6_ranges_map)

    assert type(xml) is str

    smt_info_elems = etree.fromstring(xml).findall('.//smtInfo')
    xml_helper.assert_xml_validity(smt_info_elems, region_data)
Esempio n. 4
0
def index():
    requester_ip = request.remote_addr
    region_hint = request.args.get('regionHint')

    logging.info('Data request from: %s' % requester_ip)

    if region_hint:
        region_hint = region_hint.lower()
        logging.info('\tRegion hint: %s' % region_hint)

    response_xml = region_srv.get_response_xml(requester_ip, region_hint,
                                               region_name_to_smt_data_map,
                                               ipv4_ranges_map,
                                               ipv6_ranges_map)

    if response_xml:
        logging.info('Provided: %s' % response_xml)
        return response_xml, 200
    else:
        logging.info('\tDenied')
        return 'Not found', 404
Esempio n. 5
0
def test_with_unknown_ipv6():
    xml = region_srv.get_response_xml('1000::1', None, region_map,
                                      ipv4_ranges_map, ipv6_ranges_map)

    assert xml is None