|
6 | 6 |
|
7 | 7 | from __future__ import annotations |
8 | 8 |
|
| 9 | +import re |
| 10 | + |
9 | 11 | import pytest |
10 | 12 | from sssd_test_framework.roles.client import Client |
11 | 13 | from sssd_test_framework.roles.generic import GenericProvider |
12 | | -from sssd_test_framework.topology import KnownTopologyGroup |
| 14 | +from sssd_test_framework.roles.kdc import KDC |
| 15 | +from sssd_test_framework.roles.ldap import LDAP |
| 16 | +from sssd_test_framework.topology import KnownTopology, KnownTopologyGroup |
13 | 17 |
|
14 | 18 |
|
15 | 19 | @pytest.mark.topology(KnownTopologyGroup.AnyProvider) |
@@ -226,3 +230,80 @@ def test_authentication__user_login_when_the_provider_is_offline( |
226 | 230 |
|
227 | 231 | assert client.auth.parametrize(method).password(user, correct), "User failed login!" |
228 | 232 | assert not client.auth.parametrize(method).password(user, wrong), "User logged in with an incorrect password!" |
| 233 | + |
| 234 | + |
| 235 | +@pytest.mark.importance("critical") |
| 236 | +@pytest.mark.topology(KnownTopology.IPA) |
| 237 | +@pytest.mark.topology(KnownTopology.Samba) |
| 238 | +@pytest.mark.topology(KnownTopology.AD) |
| 239 | +def test_disable_an2ln(client: Client, provider: GenericProvider): |
| 240 | + """ |
| 241 | + :title: Check localauth plugin config file (IPA/AD version) |
| 242 | + :setup: |
| 243 | + 1. Create user |
| 244 | + :steps: |
| 245 | + 1. Login as user |
| 246 | + 2. Run klist |
| 247 | + 3. Read localauth plugin config file |
| 248 | + :expectedresults: |
| 249 | + 1. User can log in |
| 250 | + 2. Kerberos TGT is available |
| 251 | + 3. localauth plugin config file is present and has expected content |
| 252 | + :customerscenario: False |
| 253 | + """ |
| 254 | + provider.user("tuser").add() |
| 255 | + |
| 256 | + pattern = ( |
| 257 | + r"\[plugins\]\n localauth = {\n disable = an2ln\n" |
| 258 | + " module = sssd:/.*/sssd/modules/sssd_krb5_localauth_plugin.so\n }" |
| 259 | + ) |
| 260 | + |
| 261 | + client.fs.rm("/var/lib/sss/pubconf/krb5.include.d/localauth_plugin") |
| 262 | + client.sssd.start() |
| 263 | + |
| 264 | + with client.ssh("tuser", "Secret123") as ssh: |
| 265 | + with client.auth.kerberos(ssh) as krb: |
| 266 | + result = krb.klist() |
| 267 | + assert f"krbtgt/{provider.realm}@{provider.realm}" in result.stdout |
| 268 | + |
| 269 | + try: |
| 270 | + out = client.fs.read("/var/lib/sss/pubconf/krb5.include.d/localauth_plugin") |
| 271 | + except Exception as e: |
| 272 | + assert False, f"Reading plugin config file caused exception: {e}" |
| 273 | + |
| 274 | + assert re.match(pattern, out), "Content of plugin config file does not match" |
| 275 | + |
| 276 | + |
| 277 | +@pytest.mark.importance("high") |
| 278 | +@pytest.mark.topology(KnownTopology.LDAP) |
| 279 | +def test_ensure_localauth_plugin_is_not_configured(client: Client, provider: GenericProvider, kdc: KDC): |
| 280 | + """ |
| 281 | + :title: Check localauth plugin config file (LDAP with Kerberos version) |
| 282 | + :setup: |
| 283 | + 1. Create user in LDAP and KDC |
| 284 | + 2. Setup SSSD to use Kerberos authentication |
| 285 | + :steps: |
| 286 | + 1. Login as user |
| 287 | + 2. Run klist |
| 288 | + 3. Read localauth plugin config file |
| 289 | + :expectedresults: |
| 290 | + 1. User can log in |
| 291 | + 2. Kerberos TGT is available |
| 292 | + 3. localauth plugin config file is not present |
| 293 | + :customerscenario: False |
| 294 | + """ |
| 295 | + provider.user("tuser").add() |
| 296 | + kdc.principal("tuser").add() |
| 297 | + |
| 298 | + client.sssd.common.krb5_auth(kdc) |
| 299 | + |
| 300 | + client.fs.rm("/var/lib/sss/pubconf/krb5.include.d/localauth_plugin") |
| 301 | + client.sssd.start() |
| 302 | + |
| 303 | + with client.ssh("tuser", "Secret123") as ssh: |
| 304 | + with client.auth.kerberos(ssh) as krb: |
| 305 | + result = krb.klist() |
| 306 | + assert f"krbtgt/{kdc.realm}@{kdc.realm}" in result.stdout |
| 307 | + |
| 308 | + with pytest.raises(Exception): |
| 309 | + client.fs.read("/var/lib/sss/pubconf/krb5.include.d/localauth_plugin") |
0 commit comments