Skip to content

Commit 8730c92

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 3f7908b commit 8730c92

File tree

5 files changed

+117
-2
lines changed

5 files changed

+117
-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: 71 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

@@ -182,6 +183,7 @@ class KeycloakTopologyController(ProvisionedBackupTopologyController):
182183
Keycloak Topology Controller.
183184
"""
184185

186+
185187
@BackupTopologyController.restore_vanilla_on_error
186188
def topology_setup(self, client: ClientHost, keycloak: KeycloakHost) -> None:
187189
if self.provisioned:
@@ -217,3 +219,72 @@ def topology_setup(self, client: ClientHost, keycloak: KeycloakHost) -> None:
217219

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

0 commit comments

Comments
 (0)