Skip to content

Commit d5bc03d

Browse files
sumit-bosealexey-tikhonov
authored andcommitted
test: check is an2ln plugin is disabled or not
The Kerberos 'an2ln' localauth plugin should be disabled in AD and IPA environments where SSSD's localauth plugin can handle the mapping. In a plain Kerberos environment libkrb5 defaults should be used. Reviewed-by: Alexey Tikhonov <[email protected]> Reviewed-by: Alejandro López <[email protected]> (cherry picked from commit e95d3fe) (cherry picked from commit 91d564b)
1 parent aabf8e7 commit d5bc03d

File tree

1 file changed

+81
-1
lines changed

1 file changed

+81
-1
lines changed

src/tests/system/tests/test_authentication.py

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
66

77
from __future__ import annotations
88

9+
import re
10+
911
import pytest
1012
from sssd_test_framework.roles.client import Client
1113
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.topology import KnownTopology, KnownTopologyGroup
1316

1417

1518
@pytest.mark.topology(KnownTopologyGroup.AnyProvider)
@@ -226,3 +229,80 @@ def test_authentication__user_login_when_the_provider_is_offline(
226229

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

0 commit comments

Comments
 (0)