From b445cff4530b815cd0a3445809bb6efdbd69f383 Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Fri, 11 Feb 2022 13:07:41 -0500 Subject: [PATCH] Strip off trailing period of a user-provided FQDN in installer The example text included a trailing dot which isn't actually allowed in a system hostname (just DNS). Remove the suggestion to include it and strip off any trailing dot so that the install can proceed. Related: https://pagure.io/freeipa/issue/9111 Signed-off-by: Rob Crittenden Reviewed-By: Florence Blanc-Renaud --- ipaserver/install/server/install.py | 5 ++- ipatests/prci_definitions/nightly_latest.yaml | 12 +++++ .../nightly_latest_selinux.yaml | 13 ++++++ .../nightly_latest_testing.yaml | 13 ++++++ .../nightly_latest_testing_selinux.yaml | 14 ++++++ .../prci_definitions/nightly_previous.yaml | 12 +++++ .../prci_definitions/nightly_rawhide.yaml | 13 ++++++ .../test_integration/test_installation.py | 45 ++++++++++++++++--- 8 files changed, 120 insertions(+), 7 deletions(-) diff --git a/ipaserver/install/server/install.py b/ipaserver/install/server/install.py index b57b31065..3f07b8ce3 100644 --- a/ipaserver/install/server/install.py +++ b/ipaserver/install/server/install.py @@ -186,7 +186,7 @@ def read_host_name(host_default): print("Enter the fully qualified domain name of the computer") print("on which you're setting up server software. Using the form") print(".") - print("Example: master.example.com.") + print("Example: master.example.com") print("") print("") if host_default == "": @@ -194,6 +194,9 @@ def read_host_name(host_default): host_name = user_input("Server host name", host_default, allow_empty=False) print("") + if host_name.endswith('.'): + host_name = host_name[:-1] + return host_name diff --git a/ipatests/prci_definitions/nightly_latest.yaml b/ipatests/prci_definitions/nightly_latest.yaml index 3623dc79e..5250d08ed 100644 --- a/ipatests/prci_definitions/nightly_latest.yaml +++ b/ipatests/prci_definitions/nightly_latest.yaml @@ -1522,6 +1522,18 @@ jobs: timeout: 3600 topology: *master_1repl + fedora-latest/hostname_validator: + requires: [fedora-latest/build] + priority: 50 + job: + class: RunPytest + args: + build_url: '{fedora-latest/build_url}' + test_suite: test_integration/test_installation.py::TestHostnameValidator + template: *ci-master-latest + timeout: 3600 + topology: *master_1repl + fedora-latest/automember: requires: [fedora-latest/build] priority: 50 diff --git a/ipatests/prci_definitions/nightly_latest_selinux.yaml b/ipatests/prci_definitions/nightly_latest_selinux.yaml index d62030cd0..24bb12f43 100644 --- a/ipatests/prci_definitions/nightly_latest_selinux.yaml +++ b/ipatests/prci_definitions/nightly_latest_selinux.yaml @@ -1629,6 +1629,19 @@ jobs: timeout: 3600 topology: *master_1repl + fedora-latest/hostname_validator: + requires: [fedora-latest/build] + priority: 50 + job: + class: RunPytest + args: + build_url: '{fedora-latest/build_url}' + selinux_enforcing: True + test_suite: test_integration/test_installation.py::TestHostnameValidator + template: *ci-master-latest + timeout: 3600 + topology: *master_1repl + fedora-latest/automember: requires: [fedora-latest/build] priority: 50 diff --git a/ipatests/prci_definitions/nightly_latest_testing.yaml b/ipatests/prci_definitions/nightly_latest_testing.yaml index 9100f0a44..95516ff17 100644 --- a/ipatests/prci_definitions/nightly_latest_testing.yaml +++ b/ipatests/prci_definitions/nightly_latest_testing.yaml @@ -1629,6 +1629,19 @@ jobs: timeout: 3600 topology: *master_1repl + testing-fedora/hostname_validator: + requires: [testing-fedora/build] + priority: 50 + job: + class: RunPytest + args: + build_url: '{testing-fedora/build_url}' + update_packages: True + test_suite: test_integration/test_installation.py::TestHostnameValidator + template: *testing-master-latest + timeout: 3600 + topology: *master_1repl + testing-fedora/automember: requires: [testing-fedora/build] priority: 50 diff --git a/ipatests/prci_definitions/nightly_latest_testing_selinux.yaml b/ipatests/prci_definitions/nightly_latest_testing_selinux.yaml index 7580b59e8..3a74ebdd2 100644 --- a/ipatests/prci_definitions/nightly_latest_testing_selinux.yaml +++ b/ipatests/prci_definitions/nightly_latest_testing_selinux.yaml @@ -1748,6 +1748,20 @@ jobs: timeout: 3600 topology: *master_1repl + testing-fedora/hostname_validator: + requires: [testing-fedora/build] + priority: 50 + job: + class: RunPytest + args: + build_url: '{testing-fedora/build_url}' + update_packages: True + selinux_enforcing: True + test_suite: test_integration/test_installation.py::TestHostnameValidator + template: *testing-master-latest + timeout: 3600 + topology: *master_1repl + testing-fedora/automember: requires: [testing-fedora/build] priority: 50 diff --git a/ipatests/prci_definitions/nightly_previous.yaml b/ipatests/prci_definitions/nightly_previous.yaml index b89488dc6..71f5154d2 100644 --- a/ipatests/prci_definitions/nightly_previous.yaml +++ b/ipatests/prci_definitions/nightly_previous.yaml @@ -1522,6 +1522,18 @@ jobs: timeout: 3600 topology: *master_1repl + fedora-previous/hostname_validator: + requires: [fedora-previous/build] + priority: 50 + job: + class: RunPytest + args: + build_url: '{fedora-previous/build_url}' + test_suite: test_integration/test_installation.py::TestHostnameValidator + template: *ci-master-previous + timeout: 3600 + topology: *master_1repl + fedora-previous/automember: requires: [fedora-previous/build] priority: 50 diff --git a/ipatests/prci_definitions/nightly_rawhide.yaml b/ipatests/prci_definitions/nightly_rawhide.yaml index 0f377cfce..b17a48619 100644 --- a/ipatests/prci_definitions/nightly_rawhide.yaml +++ b/ipatests/prci_definitions/nightly_rawhide.yaml @@ -1616,6 +1616,19 @@ jobs: timeout: 3600 topology: *master_1repl + fedora-rawhide/hostname_validator: + requires: [fedora-rawhide/build] + priority: 50 + job: + class: RunPytest + args: + build_url: '{fedora-rawhide/build_url}' + update_packages: True + test_suite: test_integration/test_installation.py::TestHostnameValidator + template: *ci-master-frawhide + timeout: 3600 + topology: *master_1repl + # fedora-rawhide/nfs: # requires: [fedora-rawhide/build] # priority: 50 diff --git a/ipatests/test_integration/test_installation.py b/ipatests/test_integration/test_installation.py index 26da3a520..b6e3501cb 100644 --- a/ipatests/test_integration/test_installation.py +++ b/ipatests/test_integration/test_installation.py @@ -1997,19 +1997,52 @@ class TestInstallwithSHA384withRSA(IntegrationTest): class TestHostnameValidator(IntegrationTest): - """Test installer options/validation""" + """Test installer hostname validator.""" num_replicas = 0 - def test_validate_hostname(self): + def get_args(self, host): + return [ + 'ipa-server-install', + '-n', host.domain.name, + '-r', host.domain.realm, + '-p', host.config.dirman_password, + '-a', host.config.admin_password, + '--setup-dns', + '--forwarder', host.config.dns_forwarder, + '--auto-reverse', + '--netbios-name', 'EXAMPLE', + ] + + def test_user_input_hostname(self): # https://pagure.io/freeipa/issue/9111 # Validate the user-provided hostname self.master.run_command(['hostname', 'fedora']) - result = tasks.install_master( - self.master, unattended=False, + result = self.master.run_command( + self.get_args(self.master), raiseonerr=False, stdin_text=self.master.hostname + '\nn\nn\nn\n', - extra_args=('--netbios-name', 'EXAMPLE',), - raiseonerr=False + ) + + # Scrape the output for the summary which is only displayed + # if the hostname is validated. + hostname = None + for line in result.stdout_text.split('\n'): + print(line) + m = re.match( + r"Hostname:\s+({})".format(self.master.hostname), line + ) + if m: + hostname = m.group(1) + break + assert hostname == self.master.hostname + + def test_hostname_with_dot(self): + # https://pagure.io/freeipa/issue/9111 + # Validate the user-provided hostname + self.master.run_command(['hostname', 'fedora']) + result = self.master.run_command( + self.get_args(self.master), raiseonerr=False, + stdin_text=self.master.hostname + '.\nn\nn\nn\n', ) # Scrape the output for the summary which is only displayed