Skip to content

Commit

Permalink
Fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
twangboy committed Feb 11, 2025
1 parent 755584f commit a17ccd4
Showing 1 changed file with 26 additions and 7 deletions.
33 changes: 26 additions & 7 deletions tests/pytests/unit/utils/win_lgpo/test_netsh.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,29 @@ def test_set_firewall_settings(store, setting, value):
assert ret is True


@pytest.mark.destructive_test
@pytest.mark.parametrize("store", ["local", "lgpo"])
@pytest.mark.parametrize("state", ["on", "off", "notconfigured"])
def test_set_firewall_state(store, state):
current_state = win_lgpo_netsh.get_settings(
profile="domain", section="state", store=store
)["State"]
try:
ret = win_lgpo_netsh.set_state(profile="domain", state=state, store=store)
assert ret is True
new = win_lgpo_netsh.get_settings(
profile="domain", section="state", store=store
)["State"]
assert new.lower() == state.lower()
finally:
win_lgpo_netsh.set_state(profile="domain", state=current_state, store=store)


@pytest.mark.destructive_test
@pytest.mark.parametrize("store", ["local", "lgpo"])
@pytest.mark.parametrize("allow_inbound", ["enable", "disable"])
@pytest.mark.parametrize("state", ["on", "off", "notconfigured"])
def test_set_firewall_state(store, allow_inbound, state):
def test_set_firewall_state_allow_inbound(store, allow_inbound, state):
current_state = win_lgpo_netsh.get_settings(
profile="domain", section="state", store=store
)["State"]
Expand All @@ -316,10 +334,11 @@ def test_set_firewall_state(store, allow_inbound, state):
)["State"]
assert new.lower() == state.lower()
finally:
win_lgpo_netsh.set_settings(
profile="domain",
setting="localfirewallrules",
value=current_local_fw_rules,
store=store,
)
if current_local_fw_rules.lower() != "notconfigured":
win_lgpo_netsh.set_settings(
profile="domain",
setting="localfirewallrules",
value=current_local_fw_rules,
store=store,
)
win_lgpo_netsh.set_state(profile="domain", state=current_state, store=store)

0 comments on commit a17ccd4

Please sign in to comment.