diff --git a/install/ui/src/freeipa/host.js b/install/ui/src/freeipa/host.js index 81b6a3fc5..c4c1e0491 100644 --- a/install/ui/src/freeipa/host.js +++ b/install/ui/src/freeipa/host.js @@ -840,7 +840,22 @@ IPA.host_dnsrecord_entity_link_widget = function(spec) { var first_dot = pkey.search(/\./); var pkeys = []; pkeys[1] = pkey.substring(0,first_dot); - pkeys[0] = pkey.substring(first_dot+1); + var dnszone = pkey.substring(first_dot+1); + pkeys[0] = dnszone; + + // Check whether DNS record associated with the host belongs to a + // fully qualified DNS zone (has trailing '.'). If so, modify the + // pkey to be correct in the link. + if (that.check_data && dnszone[dnszone.length-1] !== '.') { + var avas = that.check_data.dn.split(','); + for (var i=0, j=avas.length; i 0) { + pkeys[0] = dnszone + '.'; + } + } + } + return pkeys; }; diff --git a/install/ui/src/freeipa/widget.js b/install/ui/src/freeipa/widget.js index ec2d10503..025743a8d 100644 --- a/install/ui/src/freeipa/widget.js +++ b/install/ui/src/freeipa/widget.js @@ -5223,6 +5223,9 @@ IPA.link_widget = function(spec) { retry: false, on_success: function(data) { that.is_link = data.result && data.result.result; + if (that.is_link) { + that.check_data = data.result.result; + } that.update_link(); }, on_error: function() { diff --git a/ipatests/test_webui/test_dns.py b/ipatests/test_webui/test_dns.py index 864b8494b..7d129db00 100644 --- a/ipatests/test_webui/test_dns.py +++ b/ipatests/test_webui/test_dns.py @@ -24,7 +24,7 @@ DNS tests from ipatests.test_webui.ui_driver import UI_driver from ipatests.test_webui.ui_driver import screenshot from ipatests.test_webui.data_dns import ( - ZONE_ENTITY, FORWARD_ZONE_ENTITY, CONFIG_ENTITY, + ZONE_ENTITY, FORWARD_ZONE_ENTITY, CONFIG_ENTITY, RECORD_ENTITY, ZONE_DEFAULT_FACET, ZONE_PKEY, ZONE_DATA, FORWARD_ZONE_PKEY, FORWARD_ZONE_DATA, RECORD_PKEY, A_IP, RECORD_ADD_DATA, RECORD_MOD_DATA, CONFIG_MOD_DATA @@ -113,3 +113,69 @@ class test_dns(UI_driver): self.init_app() self.navigate_by_menu('network_services/dns/dnsconfig') self.mod_record(CONFIG_ENTITY, CONFIG_MOD_DATA) + + def test_ptr_from_host_creation(self): + """ + Test scenario for RHBZ 2009114 - a PTR record is created correctly + with trailing dot when navigated to DNS Records page from host details + page. + """ + self.init_app() + + zone = "ptrzone.test." + reverse_zone = "12.168.192.in-addr.arpa." + hostname = "server" + fqdn = "server.ptrzone.test" + dns_fqdn = fqdn + "." + ip = "192.168.12.20" + zone_add_data = { + "add": [ + ("textbox", "idnsname", zone), + ], + } + reverse_zone_add_data = { + "add": [ + ("radio", "dnszone_name_type", "name_from_ip"), + ("textbox", "name_from_ip", ip + "/24"), + ], + } + record_add_data = { + "add": [ + ("textbox", "idnsname", "server"), + ("textbox", "a_part_ip_address", ip), + ] + } + host_add_data = { + "add": [ + ("textbox", "hostname", hostname), + ("combobox", "dnszone", zone), + ], + } + + # Create needed DNS zones and record + self.add_record(ZONE_ENTITY, zone_add_data, navigate=True) + self.add_record(ZONE_ENTITY, reverse_zone_add_data, navigate=False) + self.navigate_to_record(zone) + self.add_record(ZONE_ENTITY, record_add_data, + facet=ZONE_DEFAULT_FACET) + + # Create host record + self.navigate_by_menu("identity/host") + self.add_record("host", host_add_data, navigate=False) + self.navigate_to_record(fqdn) + self.click_on_link(fqdn) + self.wait_for_request(n=2, d=0.5) + self.assert_facet(RECORD_ENTITY, "details") + self.click_on_link(ip) + self.wait_for_request(n=2, d=0.5) + self.assert_dialog() + self.click_on_link("Create dns record") + self.wait_for_request(n=3, d=0.5) + self.assert_facet(RECORD_ENTITY, "details") + self.assert_record(dns_fqdn, table_name="ptrrecord") + + # Cleanup + self.navigate_to_entity(ZONE_ENTITY) + self.delete_record([zone, reverse_zone]) + self.navigate_to_entity("host") + self.delete_record([fqdn])