Example #1
0
def test_add_user(user_setup) -> None:
    binary_manager = BinaryManager()
    user_helper = UserHelper(binary_manager.binary(Binaries.USERADD),
                             binary_manager.binary(Binaries.USERMOD))
    user_helper.useradd(
        "addeduser",
        comment="freshly added user",
        uid=1200,
        gid=33,
        home="/var/lib/addeduser",
        shell="/usr/bin/nologin",
        root_directory=user_setup,
    )

    result = UserHelper.user_data("addeduser", root_directory=user_setup)
    assert result
    assert result._asdict() == {
        "name": "addeduser",
        "password": "******",
        "uid": 1200,
        "gid": 33,
        "comment": "freshly added user",
        "home": "/var/lib/addeduser",
        "shell": "/usr/bin/nologin",
    }
Example #2
0
def test_add_user(user_setup) -> None:
    binary_manager = BinaryManager()
    user_helper = UserHelper(binary_manager.binary(Binaries.USERADD),
                             binary_manager.binary(Binaries.USERMOD))
    user_helper.useradd('addeduser', comment='freshly added user',
                        uid=1200, gid=33, home='/var/lib/addeduser',
                        shell='/usr/bin/nologin', root_directory=user_setup)

    result = UserHelper.user_data('addeduser', root_directory=user_setup)
    assert result
    assert result._asdict() == {'name': 'addeduser', 'password': '******',
                                'uid': 1200, 'gid': 33, 'comment': 'freshly added user',
                                'home': '/var/lib/addeduser', 'shell': '/usr/bin/nologin'}