Skip to content

Commit

Permalink
tests: avoid skipif in the system tests for feature detection
Browse files Browse the repository at this point in the history
@pytest.mark.skipif condition parameter only takes expressions that
evaluates to boolean or string that is eval'd by pytest. This happens
way before the role objects are instantiated and it does not work.

These lambda functions are not executed at all (and can not be
executed because pytest does not support that). The reference to a
function is just evaluated to True therefore the test is always skipped.

This was broken by
4e95d6f

Reviewed-by: Jakub Vávra <[email protected]>
Reviewed-by: Justin Stephenson <[email protected]>
  • Loading branch information
pbrezina authored and jakub-vavra-cz committed Aug 26, 2024
1 parent 72232cc commit c006b88
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions src/tests/system/tests/test_ldap.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,11 @@
@pytest.mark.parametrize("use_ppolicy", ["true", "false"])
@pytest.mark.parametrize("sssd_service_user", ("root", "sssd"))
@pytest.mark.topology(KnownTopology.LDAP)
@pytest.mark.skipif(
bool(lambda client, sssd_service_user: ((sssd_service_user != "root") and not client.features["non-privileged"])),
reason="SSSD was built without support for running under non-root",
)
@pytest.mark.skipif(
bool(lambda client: not client.features["ldap_use_ppolicy"]),
reason="SSSD is missing support for ldap_use_ppolicy.",
@pytest.mark.require(
lambda client, sssd_service_user: ((sssd_service_user == "root") or client.features["non-privileged"]),
"SSSD was built without support for running under non-root",
)
@pytest.mark.builtwith("ldap_use_ppolicy")
def test_ldap__password_change_using_ppolicy(
client: Client, ldap: LDAP, modify_mode: str, use_ppolicy: str, sssd_service_user: str
):
Expand Down Expand Up @@ -81,10 +78,7 @@ def test_ldap__password_change_using_ppolicy(
@pytest.mark.parametrize("modify_mode", ["exop", "ldap_modify"])
@pytest.mark.parametrize("use_ppolicy", ["true", "false"])
@pytest.mark.topology(KnownTopology.LDAP)
@pytest.mark.skipif(
bool(lambda client: not client.features["ldap_use_ppolicy"]),
reason="SSSD is missing support for ldap_use_ppolicy.",
)
@pytest.mark.builtwith("ldap_use_ppolicy")
def test_ldap__password_change_new_passwords_do_not_match_using_ppolicy(
client: Client, ldap: LDAP, modify_mode: str, use_ppolicy: str
):
Expand Down Expand Up @@ -118,10 +112,7 @@ def test_ldap__password_change_new_passwords_do_not_match_using_ppolicy(
@pytest.mark.parametrize("modify_mode", ["exop", "ldap_modify"])
@pytest.mark.parametrize("use_ppolicy", ["true", "false"])
@pytest.mark.topology(KnownTopology.LDAP)
@pytest.mark.skipif(
bool(lambda client: not client.features["ldap_use_ppolicy"]),
reason="SSSD is missing support for ldap_use_ppolicy.",
)
@pytest.mark.builtwith("ldap_use_ppolicy")
def test_ldap__password_change_new_password_does_not_meet_complexity_requirements_using_ppolicy(
client: Client, ldap: LDAP, modify_mode: str, use_ppolicy: str
):
Expand Down Expand Up @@ -164,10 +155,7 @@ def test_ldap__password_change_new_password_does_not_meet_complexity_requirement
@pytest.mark.parametrize("modify_mode", ["exop", "ldap_modify"])
@pytest.mark.parametrize("use_ppolicy", ["true", "false"])
@pytest.mark.topology(KnownTopology.LDAP)
@pytest.mark.skipif(
bool(lambda client: not client.features["ldap_use_ppolicy"]),
reason="SSSD is missing support for ldap_use_ppolicy.",
)
@pytest.mark.builtwith("ldap_use_ppolicy")
def test_ldap__password_change_with_invalid_current_password_using_ppolicy(
client: Client, ldap: LDAP, modify_mode: str, use_ppolicy: str
):
Expand Down

0 comments on commit c006b88

Please sign in to comment.