Fix issues reported by flake8, pycodestyle, isort, black and mypy.
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
from __future__ import annotations
import pytest
-
from pytest_mh.conn import ProcessError
+
from framework.misc import days_since_epoch
from framework.roles.shadow import Shadow
from framework.topology import KnownTopology
"""
shadow.groupadd("tgroup")
- result = shadow.tools.getent.group("tgroup")
- assert result is not None, "Group should be found"
- assert result.name == "tgroup", "Incorrect groupname"
- assert result.gid == 1000, "Incorrect GID"
+ group_entry = shadow.tools.getent.group("tgroup")
+ assert group_entry is not None, "Group should be found"
+ assert group_entry.name == "tgroup", "Incorrect groupname"
+ assert group_entry.gid == 1000, "Incorrect GID"
if shadow.host.features["gshadow"]:
- result = shadow.tools.getent.gshadow("tgroup")
- assert result is not None, "Group should be found"
- assert result.name == "tgroup", "Incorrect groupname"
- assert result.password == "!", "Incorrect password"
+ gshadow_entry = shadow.tools.getent.gshadow("tgroup")
+ assert gshadow_entry is not None, "Group should be found"
+ assert gshadow_entry.name == "tgroup", "Incorrect groupname"
+ assert gshadow_entry.password == "!", "Incorrect password"
shadow.groupadd("tgroup")
shadow.groupdel("tgroup")
- result = shadow.tools.getent.group("tgroup")
- assert result is None, "Group should not be found"
+ group_entry = shadow.tools.getent.group("tgroup")
+ assert group_entry is None, "Group should not be found"
- result = shadow.tools.getent.gshadow("tgroup")
- assert result is None, "Group should not be found"
+ gshadow_entry = shadow.tools.getent.gshadow("tgroup")
+ assert gshadow_entry is None, "Group should not be found"
shadow.groupadd("tgroup")
shadow.groupmod("-g 1001 tgroup")
- result = shadow.tools.getent.group("tgroup")
- assert result is not None, "Group should be found"
- assert result.name == "tgroup", "Incorrect groupname"
- assert result.gid == 1001, "Incorrect GID"
+ group_entry = shadow.tools.getent.group("tgroup")
+ assert group_entry is not None, "Group should be found"
+ assert group_entry.name == "tgroup", "Incorrect groupname"
+ assert group_entry.gid == 1001, "Incorrect GID"
if shadow.host.features["gshadow"]:
- result = shadow.tools.getent.gshadow("tgroup")
- assert result is not None, "Group should be found"
- assert result.name == "tgroup", "Incorrect groupname"
- assert result.password == "!", "Incorrect password"
+ gshadow_entry = shadow.tools.getent.gshadow("tgroup")
+ assert gshadow_entry is not None, "Group should be found"
+ assert gshadow_entry.name == "tgroup", "Incorrect groupname"
+ assert gshadow_entry.password == "!", "Incorrect password"
from __future__ import annotations
import pytest
+from pytest_mh.conn import ProcessError
from framework.misc import days_since_epoch
-from pytest_mh.conn import ProcessError
from framework.roles.shadow import Shadow
from framework.topology import KnownTopology
"""
shadow.useradd("tuser")
- result = shadow.tools.getent.passwd("tuser")
- assert result is not None, "User should be found"
- assert result.name == "tuser", "Incorrect username"
- assert result.password == "x", "Incorrect password"
- assert result.uid == 1000, "Incorrect UID"
- assert result.gid == 1000, "Incorrect GID"
- assert result.home == "/home/tuser", "Incorrect home"
+ passwd_entry = shadow.tools.getent.passwd("tuser")
+ assert passwd_entry is not None, "User should be found"
+ assert passwd_entry.name == "tuser", "Incorrect username"
+ assert passwd_entry.password == "x", "Incorrect password"
+ assert passwd_entry.uid == 1000, "Incorrect UID"
+ assert passwd_entry.gid == 1000, "Incorrect GID"
+ assert passwd_entry.home == "/home/tuser", "Incorrect home"
if "Debian" in shadow.host.distro_name:
- assert result.shell == "/bin/sh", "Incorrect shell"
+ assert passwd_entry.shell == "/bin/sh", "Incorrect shell"
else:
- assert result.shell == "/bin/bash", "Incorrect shell"
-
- result = shadow.tools.getent.shadow("tuser")
- assert result is not None, "User should be found"
- assert result.name == "tuser", "Incorrect username"
- assert result.password == "!", "Incorrect password"
- assert result.last_changed == days_since_epoch(), "Incorrect last changed"
- assert result.min_days == 0, "Incorrect min days"
- assert result.max_days == 99999, "Incorrect max days"
- assert result.warn_days == 7, "Incorrect warn days"
-
- result = shadow.tools.getent.group("tuser")
- assert result is not None, "Group should be found"
- assert result.name == "tuser", "Incorrect groupname"
- assert result.gid == 1000, "Incorrect GID"
+ assert passwd_entry.shell == "/bin/bash", "Incorrect shell"
+
+ shadow_entry = shadow.tools.getent.shadow("tuser")
+ assert shadow_entry is not None, "User should be found"
+ assert shadow_entry.name == "tuser", "Incorrect username"
+ assert shadow_entry.password == "!", "Incorrect password"
+ assert shadow_entry.last_changed == days_since_epoch(), "Incorrect last changed"
+ assert shadow_entry.min_days == 0, "Incorrect min days"
+ assert shadow_entry.max_days == 99999, "Incorrect max days"
+ assert shadow_entry.warn_days == 7, "Incorrect warn days"
+
+ group_entry = shadow.tools.getent.group("tuser")
+ assert group_entry is not None, "Group should be found"
+ assert group_entry.name == "tuser", "Incorrect groupname"
+ assert group_entry.gid == 1000, "Incorrect GID"
if shadow.host.features["gshadow"]:
- result = shadow.tools.getent.gshadow("tuser")
- assert result is not None, "User should be found"
- assert result.name == "tuser", "Incorrect username"
- assert result.password == "!", "Incorrect password"
+ gshadow_entry = shadow.tools.getent.gshadow("tuser")
+ assert gshadow_entry is not None, "User should be found"
+ assert gshadow_entry.name == "tuser", "Incorrect username"
+ assert gshadow_entry.password == "!", "Incorrect password"
assert shadow.fs.exists("/home/tuser"), "Home folder should be found"
shadow.userdel("tuser")
shadow.useradd("tuser")
- result = shadow.tools.id("tuser")
- assert result is not None, "User should be found"
- assert result.user.name == "tuser", "Incorrect username"
- assert result.user.id == 1000, "Incorrect UID"
+ id_entry = shadow.tools.id("tuser")
+ assert id_entry is not None, "User should be found"
+ assert id_entry.user.name == "tuser", "Incorrect username"
+ assert id_entry.user.id == 1000, "Incorrect UID"
- result = shadow.tools.getent.group("tuser")
- assert result is not None, "Group should be found"
- assert result.name == "tuser", "Incorrect groupname"
- assert result.gid == 1000, "Incorrect GID"
+ group_entry = shadow.tools.getent.group("tuser")
+ assert group_entry is not None, "Group should be found"
+ assert group_entry.name == "tuser", "Incorrect groupname"
+ assert group_entry.gid == 1000, "Incorrect GID"
assert shadow.fs.exists("/home/tuser"), "Home folder should be found"
shadow.useradd("tuser")
shadow.userdel("-r tuser")
- result = shadow.tools.getent.passwd("tuser")
- assert result is None, "User should not be found"
+ passwd_entry = shadow.tools.getent.passwd("tuser")
+ assert passwd_entry is None, "User should not be found"
- result = shadow.tools.getent.shadow("tuser")
- assert result is None, "User should not be found"
+ shadow_entry = shadow.tools.getent.shadow("tuser")
+ assert shadow_entry is None, "User should not be found"
- result = shadow.tools.getent.group("tuser")
- assert result is None, "Group should not be found"
+ group_entry = shadow.tools.getent.group("tuser")
+ assert group_entry is None, "Group should not be found"
- result = shadow.tools.getent.gshadow("tuser1")
- assert result is None, "User should not be found"
+ gshadow_entry = shadow.tools.getent.gshadow("tuser1")
+ assert gshadow_entry is None, "User should not be found"
assert not shadow.fs.exists("/home/tuser"), "Home folder should not exist"
from __future__ import annotations
import pytest
-
from pytest_mh.conn import ProcessError
+
from framework.roles.shadow import Shadow
from framework.topology import KnownTopology
shadow.useradd("tuser1")
shadow.usermod("-l tuser2 tuser1")
- result = shadow.tools.getent.passwd("tuser2")
- assert result is not None, "User should be found"
- assert result.name == "tuser2", "Incorrect username"
- assert result.uid == 1000, "Incorrect UID"
+ passwd_entry = shadow.tools.getent.passwd("tuser2")
+ assert passwd_entry is not None, "User should be found"
+ assert passwd_entry.name == "tuser2", "Incorrect username"
+ assert passwd_entry.uid == 1000, "Incorrect UID"
- result = shadow.tools.getent.shadow("tuser2")
- assert result is not None, "User should be found"
- assert result.name == "tuser2", "Incorrect username"
+ shadow_entry = shadow.tools.getent.shadow("tuser2")
+ assert shadow_entry is not None, "User should be found"
+ assert shadow_entry.name == "tuser2", "Incorrect username"
- result = shadow.tools.getent.group("tuser1")
- assert result is not None, "Group should be found"
- assert result.name == "tuser1", "Incorrect groupname"
- assert result.gid == 1000, "Incorrect GID"
+ group_entry = shadow.tools.getent.group("tuser1")
+ assert group_entry is not None, "Group should be found"
+ assert group_entry.name == "tuser1", "Incorrect groupname"
+ assert group_entry.gid == 1000, "Incorrect GID"
if shadow.host.features["gshadow"]:
- result = shadow.tools.getent.gshadow("tuser1")
- assert result is not None, "User should be found"
- assert result.name == "tuser1", "Incorrect username"
+ gshadow_entry = shadow.tools.getent.gshadow("tuser1")
+ assert gshadow_entry is not None, "User should be found"
+ assert gshadow_entry.name == "tuser1", "Incorrect username"
assert shadow.fs.exists("/home/tuser1"), "Home folder should be found"