Skip to content

Commit 273b4ee

Browse files
Add IPA IPA Trust Topology Controller
Add "IPATrustIPA" KnownTopology For topology groups some changes are: - Remove "IPATrust" - Add "IPATrustAD" -- includes IPATrustAD and IPATrustSamba - Add "AnyIPATrust" -- includes IPATrustAD, IPATrustSamba, IPATrustIPA
1 parent 9672c6a commit 273b4ee

File tree

5 files changed

+116
-2
lines changed

5 files changed

+116
-2
lines changed

sssd_test_framework/roles/ad.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,13 @@ def fqn(self, name: str) -> str:
161161
"""
162162
return f"{name}@{self.domain}"
163163

164+
@property
165+
def admin_fqn(self) -> str:
166+
"""
167+
Return fully qualified administrator name in form name@domain.
168+
"""
169+
return f"administrator@{self.domain}"
170+
164171
def user(self, name: str, basedn: ADObject | str | None = "cn=users") -> ADUser:
165172
"""
166173
Get user object.

sssd_test_framework/roles/ipa.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,19 @@ def setup(self) -> None:
161161
super().setup()
162162
self.host.kinit()
163163

164+
def fqn(self, name: str) -> str:
165+
"""
166+
Return fully qualified name in form name@domain.
167+
"""
168+
return f"{name}@{self.domain}"
169+
170+
@property
171+
def admin_fqn(self) -> str:
172+
"""
173+
Return fully qualified admin name in form name@domain.
174+
"""
175+
return f"admin@{self.domain}"
176+
164177
def user(self, name: str) -> IPAUser:
165178
"""
166179
Get user object.

sssd_test_framework/roles/samba.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,13 @@ def fqn(self, name: str) -> str:
159159
"""
160160
return f"{name}@{self.domain}"
161161

162+
@property
163+
def admin_fqn(self) -> str:
164+
"""
165+
Return fully qualified administrator name in form name@domain.
166+
"""
167+
return f"administrator@{self.domain}"
168+
162169
def user(self, name: str) -> SambaUser:
163170
"""
164171
Get user object.

sssd_test_framework/topology.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
ClientTopologyController,
1414
IPATopologyController,
1515
IPATrustADTopologyController,
16+
IPATrustIPATopologyController,
1617
IPATrustSambaTopologyController,
1718
KeycloakTopologyController,
1819
LDAPTopologyController,
@@ -133,6 +134,17 @@ def test_ldap(client: Client, ldap: LDAP):
133134
.. topology-mark:: KnownTopology.Keycloak
134135
"""
135136

137+
IPATrustIPA = SSSDTopologyMark(
138+
name="ipa-trust-ipa",
139+
topology=Topology(TopologyDomain("sssd", client=1, ipa=1), TopologyDomain("ipa2", ipa=1)),
140+
controller=IPATrustIPATopologyController(),
141+
domains=dict(test="sssd.ipa[0]"),
142+
fixtures=dict(client="sssd.client[0]", ipa="sssd.ipa[0]", trusted="ipa2.ipa[0]"),
143+
)
144+
"""
145+
.. topology-mark:: KnownTopology.IPATrustIPA
146+
"""
147+
136148

137149
class KnownTopologyGroup(KnownTopologyGroupBase):
138150
"""
@@ -165,7 +177,12 @@ def test_ldap(client: Client, provider: GenericProvider):
165177
..topology-mark:: KnownTopologyGroup.AnyDC
166178
"""
167179

168-
IPATrust = [KnownTopology.IPATrustAD, KnownTopology.IPATrustSamba]
180+
IPATrustAD = [KnownTopology.IPATrustAD, KnownTopology.IPATrustSamba]
181+
"""
182+
.. topology-mark:: KnownTopologyGroup.IPATrustAD
183+
"""
184+
185+
AnyIPATrust = [KnownTopology.IPATrustAD, KnownTopology.IPATrustSamba, KnownTopology.IPATrustIPA]
169186
"""
170-
.. topology-mark:: KnownTopologyGroup.IPATrust
187+
.. topology-mark:: KnownTopologyGroup.AnyIPATrust
171188
"""

sssd_test_framework/topology_controllers.py

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"SambaTopologyController",
1919
"IPATrustADTopologyController",
2020
"IPATrustSambaTopologyController",
21+
"IPATrustIPATopologyController",
2122
"KeycloakTopologyController",
2223
]
2324

@@ -217,3 +218,72 @@ def topology_setup(self, client: ClientHost, keycloak: KeycloakHost) -> None:
217218

218219
# Backup so we can restore to this state after each test
219220
super().topology_setup()
221+
222+
223+
class IPATrustIPATopologyController(ProvisionedBackupTopologyController):
224+
"""
225+
IPA trust IPA Topology Controller.
226+
"""
227+
228+
@BackupTopologyController.restore_vanilla_on_error
229+
def topology_setup(self, client: ClientHost, ipa: IPAHost, trusted: IPAHost) -> None:
230+
if self.provisioned:
231+
self.logger.info(f"Topology '{self.name}' is already provisioned")
232+
return
233+
234+
# Add ipa-ipa trust COPR and update packages
235+
self.logger.info("Adding COPR and updating packages")
236+
ipa.conn.exec(["dnf", "copr", "enable", "abbra/wip-ipa-trust", "-y"])
237+
client.conn.exec(["dnf", "copr", "enable", "abbra/wip-ipa-trust", "-y"])
238+
trusted.conn.exec(["dnf", "copr", "enable", "abbra/wip-ipa-trust", "-y"])
239+
240+
ipa.conn.exec(["dnf", "update", "freeipa-server", "sssd-client", "-y"])
241+
trusted.conn.exec(["dnf", "update", "freeipa-server", "sssd-client", "-y"])
242+
client.conn.exec(["dnf", "update", "sssd-client", "-y"])
243+
244+
# F40 sssd-kcm fails to start with 'Invalid option --genconf-section=kcm:'
245+
ipa.conn.exec(["systemctl", "restart", "sssd-kcm"])
246+
trusted.conn.exec(["systemctl", "restart", "sssd-kcm"])
247+
248+
# IPA server and the remote domain cannot share the same NetBIOS name: MASTER
249+
trusted.kinit()
250+
trusted.conn.exec(["ipa-adtrust-install", "--netbios-name", "MASTER2", "-U"])
251+
252+
# Create trust
253+
self.logger.info(f"Establishing trust between {ipa.domain} and {trusted.domain}")
254+
255+
ipa.kinit()
256+
ipa.conn.exec(
257+
[
258+
"ipa",
259+
"trust-add",
260+
trusted.domain,
261+
"--admin",
262+
"admin",
263+
"--password",
264+
"--range-type=ipa-ad-trust-posix",
265+
"--type=ipa",
266+
"--two-way=true",
267+
],
268+
input=trusted.adminpw,
269+
)
270+
271+
# Do not enroll client into IPA domain if it is already joined
272+
if "ipa" not in self.multihost.provisioned_topologies:
273+
self.logger.info(f"Enrolling {client.hostname} into {ipa.domain}")
274+
275+
# Remove any existing Kerberos configuration and keytab
276+
client.fs.rm("/etc/krb5.conf")
277+
client.fs.rm("/etc/krb5.keytab")
278+
279+
# Backup ipa-client-install files
280+
client.fs.backup("/etc/ipa")
281+
client.fs.backup("/var/lib/ipa-client")
282+
283+
# Join IPA domain)
284+
client.conn.exec(["realm", "join", ipa.domain], input=ipa.adminpw)
285+
286+
# Backup so we can restore to this state after each test
287+
self.backup_data[ipa] = ipa.backup()
288+
self.backup_data[trusted] = trusted.backup()
289+
self.backup_data[client] = client.backup()

0 commit comments

Comments
 (0)