redhat-qe-security / SCAutolib

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

Add user factory function for using in tests #109

Closed x00Pavel closed 1 year ago

x00Pavel commented 1 year ago

Add user factory function that would be used in tests. This factory would generate (load from JSON) the user with requires a username and returns a new instance of the BaseUser object.

Code usage example:

@pytest.mark.parametrize("user", [user_factory("local-user"), user_factory("ipa-user")], scope="session")  # <-------------------------
def test_su_login_with_sc(user, user_shell):
    with Authselect(required=False):
        with 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)
x00Pavel commented 1 year ago

Will add unit test.