Skip to content

Commit 132cd8b

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 5668acf commit 132cd8b

File tree

5 files changed

+111
-2
lines changed

5 files changed

+111
-2
lines changed

sssd_test_framework/roles/ad.py

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

131+
@property
132+
def admin_fqn(self) -> str:
133+
"""
134+
Return fully qualified administrator name in form name@domain.
135+
"""
136+
return f"administrator@{self.domain}"
137+
131138
def user(self, name: str, basedn: ADObject | str | None = "cn=users") -> ADUser:
132139
"""
133140
Get user object.

sssd_test_framework/roles/ipa.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,19 @@ def setup(self) -> None:
137137
super().setup()
138138
self.host.kinit()
139139

140+
def fqn(self, name: str) -> str:
141+
"""
142+
Return fully qualified name in form name@domain.
143+
"""
144+
return f"{name}@{self.domain}"
145+
146+
@property
147+
def admin_fqn(self) -> str:
148+
"""
149+
Return fully qualified admin name in form name@domain.
150+
"""
151+
return f"admin@{self.domain}"
152+
140153
def user(self, name: str) -> IPAUser:
141154
"""
142155
Get user object.

sssd_test_framework/roles/samba.py

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

125+
@property
126+
def admin_fqn(self) -> str:
127+
"""
128+
Return fully qualified administrator name in form name@domain.
129+
"""
130+
return f"administrator@{self.domain}"
131+
125132
def user(self, name: str) -> SambaUser:
126133
"""
127134
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
LDAPTopologyController,
1819
SambaTopologyController,
@@ -118,6 +119,17 @@ def test_ldap(client: Client, ldap: LDAP):
118119
.. topology-mark:: KnownTopology.IPATrustSamba
119120
"""
120121

122+
IPATrustIPA = SSSDTopologyMark(
123+
name="ipa-trust-ipa",
124+
topology=Topology(TopologyDomain("sssd", client=1, ipa=1), TopologyDomain("ipa2", ipa=1)),
125+
controller=IPATrustIPATopologyController(),
126+
domains=dict(test="sssd.ipa[0]"),
127+
fixtures=dict(client="sssd.client[0]", ipa="sssd.ipa[0]", trusted="ipa2.ipa[0]"),
128+
)
129+
"""
130+
.. topology-mark:: KnownTopology.IPATrustIPA
131+
"""
132+
121133

122134
class KnownTopologyGroup(KnownTopologyGroupBase):
123135
"""
@@ -145,7 +157,12 @@ def test_ldap(client: Client, provider: GenericProvider):
145157
.. topology-mark:: KnownTopologyGroup.AnyAD
146158
"""
147159

148-
IPATrust = [KnownTopology.IPATrustAD, KnownTopology.IPATrustSamba]
160+
IPATrustAD = [KnownTopology.IPATrustAD, KnownTopology.IPATrustSamba]
161+
"""
162+
.. topology-mark:: KnownTopologyGroup.IPATrustAD
163+
"""
164+
165+
AnyIPATrust = [KnownTopology.IPATrustAD, KnownTopology.IPATrustSamba, KnownTopology.IPATrustIPA]
149166
"""
150-
.. topology-mark:: KnownTopologyGroup.IPATrust
167+
.. topology-mark:: KnownTopologyGroup.AnyIPATrust
151168
"""

sssd_test_framework/topology_controllers.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"SambaTopologyController",
2323
"IPATrustADTopologyController",
2424
"IPATrustSambaTopologyController",
25+
"IPATrustIPATopologyController",
2526
]
2627

2728

@@ -250,3 +251,67 @@ class IPATrustSambaTopologyController(IPATrustADTopologyController):
250251
"""
251252

252253
pass
254+
255+
256+
class IPATrustIPATopologyController(BackupTopologyController):
257+
"""
258+
IPA trust IPA Topology Controller.
259+
"""
260+
261+
@restore_vanilla_on_error
262+
def topology_setup(self, client: ClientHost, ipa: IPAHost, trusted: IPAHost) -> None:
263+
if self.provisioned:
264+
self.logger.info(f"Topology '{self.name}' is already provisioned")
265+
return
266+
267+
# Add ipa-ipa trust COPR and update packages
268+
self.logger.info("Adding COPR and updating packages")
269+
ipa.conn.exec(["dnf", "copr", "enable", "abbra/wip-ipa-trust", "-y"])
270+
client.conn.exec(["dnf", "copr", "enable", "abbra/wip-ipa-trust", "-y"])
271+
trusted.conn.exec(["dnf", "copr", "enable", "abbra/wip-ipa-trust", "-y"])
272+
273+
ipa.conn.exec(["dnf", "update", "freeipa-server", "sssd-client", "-y"])
274+
trusted.conn.exec(["dnf", "update", "freeipa-server", "sssd-client", "-y"])
275+
client.conn.exec(["dnf", "update", "sssd-client", "-y"])
276+
277+
# F40 sssd-kcm fails to start with 'Invalid option --genconf-section=kcm:'
278+
ipa.conn.exec(["systemctl", "restart", "sssd-kcm"])
279+
trusted.conn.exec(["systemctl", "restart", "sssd-kcm"])
280+
281+
# Create trust
282+
self.logger.info(f"Establishing trust between {ipa.domain} and {trusted.domain}")
283+
284+
ipa.kinit()
285+
ipa.conn.exec(
286+
[
287+
"ipa",
288+
"trust-add",
289+
trusted.domain,
290+
"--admin",
291+
"admin",
292+
"--password",
293+
"--range-type=ipa-ad-trust-posix",
294+
"--two-way=true",
295+
],
296+
input=trusted.adminpw,
297+
)
298+
299+
# Do not enroll client into IPA domain if it is already joined
300+
if "ipa" not in self.multihost.provisioned_topologies:
301+
self.logger.info(f"Enrolling {client.hostname} into {ipa.domain}")
302+
303+
# Remove any existing Kerberos configuration and keytab
304+
client.fs.rm("/etc/krb5.conf")
305+
client.fs.rm("/etc/krb5.keytab")
306+
307+
# Backup ipa-client-install files
308+
client.fs.backup("/etc/ipa")
309+
client.fs.backup("/var/lib/ipa-client")
310+
311+
# Join IPA domain)
312+
client.conn.exec(["realm", "join", ipa.domain], input=ipa.adminpw)
313+
314+
# Backup so we can restore to this state after each test
315+
self.backup_data[ipa] = ipa.backup()
316+
self.backup_data[trusted] = trusted.backup()
317+
self.backup_data[client] = client.backup()

0 commit comments

Comments
 (0)