|
|
86baa9 |
From f643289f42a0d537da2e8ab6be4727d0bc679690 Mon Sep 17 00:00:00 2001
|
|
|
86baa9 |
From: =?UTF-8?q?Fran=C3=A7ois=20Cami?= <fcami@redhat.com>
|
|
|
86baa9 |
Date: Fri, 22 Mar 2019 19:29:01 +0100
|
|
|
86baa9 |
Subject: [PATCH] ipatests: Exercise hidden replica feature
|
|
|
86baa9 |
|
|
|
86baa9 |
A hidden replica is a replica that does not advertise its services via
|
|
|
86baa9 |
DNS SRV records, ipa-ca DNS entry, or LDAP. Clients do not auto-select a
|
|
|
86baa9 |
hidden replica, but are still free to explicitly connect to it.
|
|
|
86baa9 |
|
|
|
86baa9 |
Fixes: https://pagure.io/freeipa/issue/7892
|
|
|
86baa9 |
Co-authored-by: Francois Cami <fcami@redhat.com>
|
|
|
86baa9 |
Signed-off-by: Francois Cami <fcami@redhat.com>
|
|
|
86baa9 |
Reviewed-By: Thomas Woerner <twoerner@redhat.com>
|
|
|
86baa9 |
Reviewed-By: Francois Cami <fcami@redhat.com>
|
|
|
86baa9 |
---
|
|
|
86baa9 |
.../test_replica_promotion.py | 114 ++++++++++++++++++
|
|
|
86baa9 |
1 file changed, 114 insertions(+)
|
|
|
86baa9 |
|
|
|
86baa9 |
diff --git a/ipatests/test_integration/test_replica_promotion.py b/ipatests/test_integration/test_replica_promotion.py
|
|
|
86baa9 |
index 6608b23f7fb37948d54c21c88d572527356e7335..80890bf05cb242fe09af77aa27b411ac6194e2d6 100644
|
|
|
86baa9 |
--- a/ipatests/test_integration/test_replica_promotion.py
|
|
|
86baa9 |
+++ b/ipatests/test_integration/test_replica_promotion.py
|
|
|
86baa9 |
@@ -17,6 +17,10 @@ from ipatests.pytest_ipa.integration.env_config import get_global_config
|
|
|
86baa9 |
from ipalib.constants import (
|
|
|
86baa9 |
DOMAIN_LEVEL_0, DOMAIN_LEVEL_1, DOMAIN_SUFFIX_NAME, IPA_CA_NICKNAME)
|
|
|
86baa9 |
from ipaplatform.paths import paths
|
|
|
86baa9 |
+from ipatests.test_integration.test_backup_and_restore import backup
|
|
|
86baa9 |
+from ipatests.test_integration.test_dns_locations import (
|
|
|
86baa9 |
+ resolve_records_from_server
|
|
|
86baa9 |
+)
|
|
|
86baa9 |
|
|
|
86baa9 |
config = get_global_config()
|
|
|
86baa9 |
|
|
|
86baa9 |
@@ -795,3 +799,113 @@ class TestReplicaInForwardZone(IntegrationTest):
|
|
|
86baa9 |
# Restore /etc/hosts on master and replica
|
|
|
86baa9 |
restore_etc_hosts(master)
|
|
|
86baa9 |
restore_etc_hosts(replica)
|
|
|
86baa9 |
+
|
|
|
86baa9 |
+
|
|
|
86baa9 |
+class TestHiddenReplicaPromotion(IntegrationTest):
|
|
|
86baa9 |
+ """
|
|
|
86baa9 |
+ Test hidden replica features
|
|
|
86baa9 |
+ """
|
|
|
86baa9 |
+
|
|
|
86baa9 |
+ topology = 'star'
|
|
|
86baa9 |
+ num_replicas = 1
|
|
|
86baa9 |
+
|
|
|
86baa9 |
+ @classmethod
|
|
|
86baa9 |
+ def install(cls, mh):
|
|
|
86baa9 |
+ tasks.install_master(cls.master, setup_dns=True, setup_kra=True)
|
|
|
86baa9 |
+
|
|
|
86baa9 |
+ @replicas_cleanup
|
|
|
86baa9 |
+ def test_hidden_replica_install(self):
|
|
|
86baa9 |
+ self.replicas[0].run_command([
|
|
|
86baa9 |
+ 'ipa-client-install',
|
|
|
86baa9 |
+ '-p', 'admin',
|
|
|
86baa9 |
+ '-w', self.master.config.admin_password,
|
|
|
86baa9 |
+ '--domain', self.master.domain.name,
|
|
|
86baa9 |
+ '--realm', self.master.domain.realm,
|
|
|
86baa9 |
+ '--server', self.master.hostname,
|
|
|
86baa9 |
+ '-U'
|
|
|
86baa9 |
+ ])
|
|
|
86baa9 |
+ self.replicas[0].run_command([
|
|
|
86baa9 |
+ 'ipa-replica-install', '-w',
|
|
|
86baa9 |
+ self.master.config.admin_password,
|
|
|
86baa9 |
+ '-n', self.master.domain.name,
|
|
|
86baa9 |
+ '-r', self.master.domain.realm,
|
|
|
86baa9 |
+ '--server', self.master.hostname,
|
|
|
86baa9 |
+ '--setup-ca',
|
|
|
86baa9 |
+ '--setup-dns', '--no-forwarders',
|
|
|
86baa9 |
+ '--hidden-replica',
|
|
|
86baa9 |
+ '--setup-kra',
|
|
|
86baa9 |
+ '-U'
|
|
|
86baa9 |
+ ])
|
|
|
86baa9 |
+ expected_txt = 'hidden'
|
|
|
86baa9 |
+ result = self.replicas[0].run_command([
|
|
|
86baa9 |
+ 'ipa', 'ipa server-role-find',
|
|
|
86baa9 |
+ '--server', self.replicas[0].hostname
|
|
|
86baa9 |
+ ])
|
|
|
86baa9 |
+ assert expected_txt in result.stdout
|
|
|
86baa9 |
+ dnsrecords = {
|
|
|
86baa9 |
+ '.'.join(('_kerberos._udp', self.master.domain.name)): 'SRV',
|
|
|
86baa9 |
+ '.'.join(('_kerberos._tcp', self.master.domain.name)): 'SRV',
|
|
|
86baa9 |
+ '.'.join(('_ldap._tcp', self.master.domain.name)): 'SRV',
|
|
|
86baa9 |
+ self.master.domain.name: 'NS'
|
|
|
86baa9 |
+ }
|
|
|
86baa9 |
+ nameserver = self.master.ip
|
|
|
86baa9 |
+ results = []
|
|
|
86baa9 |
+ for record in dnsrecords:
|
|
|
86baa9 |
+ srvr = resolve_records_from_server(
|
|
|
86baa9 |
+ record, dnsrecords[record], nameserver
|
|
|
86baa9 |
+ )
|
|
|
86baa9 |
+ results.extend(re.findall(
|
|
|
86baa9 |
+ '|'.join((self.master.hostname, self.replicas[0].hostname)),
|
|
|
86baa9 |
+ srvr)
|
|
|
86baa9 |
+ )
|
|
|
86baa9 |
+ assert self.master.hostname in results
|
|
|
86baa9 |
+ assert self.replicas[0].hostname not in results
|
|
|
86baa9 |
+
|
|
|
86baa9 |
+ def test_hidden_replica_promote(self):
|
|
|
86baa9 |
+ self.replicas[0].run_command([
|
|
|
86baa9 |
+ 'ipa', 'server-mod', '--state=enabled'
|
|
|
86baa9 |
+ ])
|
|
|
86baa9 |
+ unexpected_txt = 'hidden'
|
|
|
86baa9 |
+ result = self.replicas[0].run_command([
|
|
|
86baa9 |
+ 'ipa', 'ipa server-role-find',
|
|
|
86baa9 |
+ '--server', self.replicas[0].hostname
|
|
|
86baa9 |
+ ])
|
|
|
86baa9 |
+ assert unexpected_txt not in result.stdout
|
|
|
86baa9 |
+
|
|
|
86baa9 |
+ def test_hidden_replica_demote(self):
|
|
|
86baa9 |
+ self.replicas[0].run_command([
|
|
|
86baa9 |
+ 'ipa', 'server-mod', '--state=hidden'
|
|
|
86baa9 |
+ ])
|
|
|
86baa9 |
+ expected_txt = 'hidden'
|
|
|
86baa9 |
+ result = self.replicas[0].run_command([
|
|
|
86baa9 |
+ 'ipa', 'ipa server-role-find',
|
|
|
86baa9 |
+ '--server', self.replicas[0].hostname
|
|
|
86baa9 |
+ ])
|
|
|
86baa9 |
+ assert expected_txt in result.stdout
|
|
|
86baa9 |
+
|
|
|
86baa9 |
+ def test_hidden_replica_backup_and_restore(self):
|
|
|
86baa9 |
+ """
|
|
|
86baa9 |
+ Exercises backup+restore and hidden replica uninstall
|
|
|
86baa9 |
+ """
|
|
|
86baa9 |
+ # set expectations
|
|
|
86baa9 |
+ expected_txt = 'hidden'
|
|
|
86baa9 |
+ result = self.replicas[0].run_command([
|
|
|
86baa9 |
+ 'ipa', 'ipa server-role-find',
|
|
|
86baa9 |
+ '--server', self.replicas[0].hostname
|
|
|
86baa9 |
+ ])
|
|
|
86baa9 |
+ assert expected_txt in result.stdout
|
|
|
86baa9 |
+ # backup
|
|
|
86baa9 |
+ backup_path = backup(self.replicas[0])
|
|
|
86baa9 |
+ # uninstall
|
|
|
86baa9 |
+ result = self.replicas[0].run_command([
|
|
|
86baa9 |
+ 'ipa-server-uninstall', '-U', 'hidden-replica'
|
|
|
86baa9 |
+ ])
|
|
|
86baa9 |
+ # restore
|
|
|
86baa9 |
+ dirman_password = self.master.config.dirman_password
|
|
|
86baa9 |
+ self.replicas[0].run_command(
|
|
|
86baa9 |
+ ['ipa-restore', backup_path], stdin_text=dirman_password + '\nyes'
|
|
|
86baa9 |
+ )
|
|
|
86baa9 |
+ # check that the resulting server can be promoted to enabled
|
|
|
86baa9 |
+ self.replicas[0].run_command([
|
|
|
86baa9 |
+ 'ipa', 'server-mod', '--state=enabled'
|
|
|
86baa9 |
+ ])
|
|
|
86baa9 |
--
|
|
|
86baa9 |
2.20.1
|
|
|
86baa9 |
|