fix(webui): create correct PTR record when navigated from host page

In scenario:
1. make sure that reverse zone doesn't have the desired PTR record
2. open host page of the host with matchnig the A record, e.g.: https://server.pvoborni.test/ipa/ui/#/e/host/details/test2.pvoborni.test
3. click on the "Host name" link, it will bring us to it's DNS record page. E.g., https://server.pvoborni.test/ipa/ui/#/e/dnsrecord/details/pvoborni.test&test2
! notice the missing '.' in the URL after zone name (pvoborni.test)
4. click on the A record , dialog will show up, saying "record not found"
5. click on the "create DNS record"

PTR record created by Web UI doesn't have trailing '.' (is not fully
qualified record) even if the DNS zone is.

This patch is fixing the link to the DNS Record page so that the
page then correctly gets the DNS Zone name and thus creates a correct
fully qualified PTR record.

https://bugzilla.redhat.com/show_bug.cgi?id=2009114
https://pagure.io/freeipa/issue/9036

Signed-off-by: Petr Vobornik <pvoborni@redhat.com>
Reviewed-By: Florence Blanc-Renaud <flo@redhat.com>
This commit is contained in:
Petr Vobornik
2021-10-04 20:53:27 +02:00
committed by Florence Blanc-Renaud
parent 76afa643f4
commit 4f5ed837b4
3 changed files with 86 additions and 2 deletions

View File

@@ -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<j; i++) {
var ava = avas[i];
if (ava.indexOf('idnsname') === 0 && ava.indexOf(dnszone + '.') > 0) {
pkeys[0] = dnszone + '.';
}
}
}
return pkeys;
};

View File

@@ -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() {

View File

@@ -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])