redhat-qe-security / SCAutolib

Library for automation of smart card testing
GNU General Public License v3.0
3 stars 10 forks source link

V2 sssd fixes #110

Closed x00Pavel closed 1 year ago

x00Pavel commented 1 year ago

This PR brings another fix #107 along with functionality for using SSSD file in context manager. This feature is useful for tests when we need to make some changes in SSSD and then restore the state. Test example:

@pytest.mark.parametrize("user", [user_factory("local-user")], scope="session")
def test_su_login_p11_uri_slot_description(user, sssd, user_shell):
    """Test login with PIN to the system with p11_uri specified on specific
    slot in sssd.conf."""
    with sssd(section="pam", key="p11_uri",
              value="pkcs11:pkcs11:slot-description=Virtual%20PCD%2000%2000"):
        with Authselect(required=False), user.card(insert=True):
            cmd = f"su {user.username} -c whoami"
            user_shell.sendline(cmd)
            user_shell.expect(f"PIN for {user.username}")
            user_shell.sendline(user.pin)
            user_shell.expect(user.username)