diff --git a/Sanity/test_smart_card_detection.py b/Sanity/test_smart_card_detection.py index cf5fca8..4798bdc 100644 --- a/Sanity/test_smart_card_detection.py +++ b/Sanity/test_smart_card_detection.py @@ -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 @@ -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 " \ diff --git a/Sanity/test_sssd_conf.py b/Sanity/test_sssd_conf.py index 4d57270..ba4c61b 100644 --- a/Sanity/test_sssd_conf.py +++ b/Sanity/test_sssd_conf.py @@ -136,12 +136,13 @@ def test_matchrule_defined_for_other_user(local_user, sssd, user_shell): value=".*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):