Skip to content

Commit

Permalink
Fix ipv6 Infoblox test
Browse files Browse the repository at this point in the history
Signed-off-by: Shubham Ganar <sganar@redhat.com>
  • Loading branch information
shubhamsg199 committed Feb 24, 2025
1 parent 4bd56d0 commit 7e303a6
Showing 1 changed file with 27 additions and 16 deletions.
43 changes: 27 additions & 16 deletions tests/foreman/destructive/test_infoblox.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@
infoblox_dns_package = 'rubygem-smart_proxy_dns_infoblox'

params = [
(
'enable-foreman-proxy-plugin-dhcp-remote-isc',
{'foreman-proxy-dhcp': 'true'},
f'rpm -q {dhcp_isc_package}',
),
(
'enable-foreman-proxy-plugin-dhcp-infoblox',
{
Expand Down Expand Up @@ -89,7 +84,7 @@
@pytest.mark.parametrize(
('command_args', 'command_opts', 'rpm_command'),
params,
ids=['isc_dhcp', 'infoblox_dhcp', 'infoblox_dns'],
ids=['infoblox_dhcp', 'infoblox_dns'],
)
def test_plugin_installation(target_sat, command_args, command_opts, rpm_command):
"""Check that external DNS and DHCP plugins install correctly
Expand Down Expand Up @@ -192,13 +187,20 @@ def test_infoblox_end_to_end(
subnet = module_target_sat.api.Subnet(
location=[module_location],
organization=[module_sca_manifest_org],
network=settings.infoblox.network,
cidr=settings.infoblox.network_prefix,
mask=settings.infoblox.netmask,
from_=settings.infoblox.start_range,
to=settings.infoblox.end_range,
network=settings.infoblox.network_ipv6
if settings.server.is_ipv6
else settings.infoblox.network_ipv6,
network_type='IPv6' if settings.server.is_ipv6 else 'IPv4',
cidr=settings.infoblox.network_prefix_ipv6
if settings.server.is_ipv6
else settings.infoblox.network_prefix_ipv4,
mask=settings.infoblox.netmask_ipv6
if settings.server.is_ipv6
else settings.infoblox.netmask_ipv4,
from_=None if settings.server.is_ipv6 else settings.infoblox.start_range,
to=None if settings.server.is_ipv6 else settings.infoblox.end_range,
boot_mode='DHCP',
ipam='DHCP',
ipam='EUI-64' if settings.server.is_ipv6 else 'DHCP',
dhcp=module_provisioning_capsule.id,
tftp=module_provisioning_capsule.id,
dns=module_provisioning_capsule.id,
Expand All @@ -214,7 +216,8 @@ def test_infoblox_end_to_end(
operatingsystem=module_sync_kickstart_content.os,
architecture=default_architecture,
domain=domain,
subnet=subnet,
subnet=subnet if not settings.server.is_ipv6 else None,
subnet6=subnet if settings.server.is_ipv6 else None,
root_pass=settings.provisioning.host_root_password,
ptable=default_partitiontable,
content_facet_attributes={
Expand All @@ -224,18 +227,26 @@ def test_infoblox_end_to_end(
},
).create()
# check if A Record is created for the host IP on Infoblox
url = f'https://{settings.infoblox.hostname}/wapi/v2.0/ipv4address?ip_address={host.ip}'
url = (
f'https://{settings.infoblox.hostname}/wapi/v2.0/ipv6address?ip_address={host.ip6}'
if settings.server.is_ipv6
else f'https://{settings.infoblox.hostname}/wapi/v2.0/ipv4address?ip_address={host.ip}'
)
auth = (settings.infoblox.username, settings.infoblox.password)
result = requests.get(url, auth=auth, verify=False)
assert result.status_code == 200
# check hostname and ip is present in A record
assert host.name in result.text
assert host.ip in result.text
if settings.server.is_ipv6:
assert host.ip6 in result.text
else:
assert host.ip in result.text
# delete host
module_target_sat.api.Subnet(id=subnet.id, domain=[]).update()
module_target_sat.api.Host(id=host.id).delete()
module_target_sat.api.Subnet(id=subnet.id).delete()
module_target_sat.api.Domain(id=domain.id).delete()
if not settings.server.is_ipv6:
module_target_sat.api.Domain(id=domain.id).delete()
with pytest.raises(HTTPError):
host.read()
# disable dhcp and dns plugin
Expand Down

0 comments on commit 7e303a6

Please sign in to comment.