Skip to content

Commit

Permalink
Fix small errors for the tests to be compatible with V3
Browse files Browse the repository at this point in the history
1) Sanity/test_smart_card_detection.py::test_pam_services_config: added
   new line at the end on /etc/pam.d/pam_cert_service
2) Sanity/test_sssd_conf.py::test_matchrule_defined_for_other_user: fix
   the way it replaces certmap/shadowutils section
  • Loading branch information
GeorgePantelakis committed Feb 5, 2024
1 parent 4e383a9 commit be03b08
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
5 changes: 3 additions & 2 deletions Sanity/test_smart_card_detection.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest

from time import sleep
import pexpect

def test_modutil_token_info(local_user, root_shell):
"""Check that p11-kit module shows smart card information with modutil
Expand All @@ -17,7 +18,7 @@ def test_pam_services_config(local_user, root_shell, sssd):
works as expected for smart card authentication.
GitHub issue: https://github.com/SSSD/sssd/issues/3967"""
with open("/etc/pam.d/pam_cert_service", "w") as f:
f.write("auth\trequired\tpam_sss.so require_cert_auth")
f.write("auth\trequired\tpam_sss.so require_cert_auth\n")
with sssd(section="pam", key="pam_p11_allowed_services", value="-su") as sssd_conf:
with local_user.card(insert=False) as sc:
cmd = "sssctl user-checks -a auth -s pam_cert_service " \
Expand Down
9 changes: 5 additions & 4 deletions Sanity/test_sssd_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,13 @@ def test_matchrule_defined_for_other_user(local_user, sssd, user_shell):
value="<SUBJECT>.*CN=testuser.*") as sssd_file:
# FIXME: this section should be replaced with library call for removing
# the section as soon as this functionality is implemented
with sssd_file.path.open("r+") as sources:
sourcesdata = sources.read()
sourcesdata = sourcesdata.replace(
with sssd_file.path.open("r") as fp:
new_context = fp.read()
new_context = new_context.replace(
f'[certmap/shadowutils/{local_user.username}]',
'[certmap/shadowutils/testuser]')
sources.write(sourcesdata)
with sssd_file.path.open("w") as fp:
fp.write(new_context)
run(["systemctl", "restart", "sssd"])

with Authselect(required=False), local_user.card(insert=True):
Expand Down

0 comments on commit be03b08

Please sign in to comment.