Standardize API response envelopes: use items for collection responses and update tests
This commit is contained in:
@@ -381,7 +381,7 @@ class TestListInactiveJails:
|
||||
):
|
||||
result = await list_inactive_jails(str(tmp_path), "/fake.sock")
|
||||
|
||||
names = [j.name for j in result.jails]
|
||||
names = [j.name for j in result.items]
|
||||
assert "sshd" not in names
|
||||
assert "apache-auth" in names
|
||||
|
||||
@@ -393,7 +393,7 @@ class TestListInactiveJails:
|
||||
):
|
||||
result = await list_inactive_jails(str(tmp_path), "/fake.sock")
|
||||
|
||||
assert result.total == len(result.jails)
|
||||
assert result.total == len(result.items)
|
||||
|
||||
async def test_empty_config_dir(self, tmp_path: Path) -> None:
|
||||
with patch(
|
||||
@@ -402,7 +402,7 @@ class TestListInactiveJails:
|
||||
):
|
||||
result = await list_inactive_jails(str(tmp_path), "/fake.sock")
|
||||
|
||||
assert result.jails == []
|
||||
assert result.items == []
|
||||
assert result.total == 0
|
||||
|
||||
async def test_all_active_returns_empty(self, tmp_path: Path) -> None:
|
||||
@@ -413,7 +413,7 @@ class TestListInactiveJails:
|
||||
):
|
||||
result = await list_inactive_jails(str(tmp_path), "/fake.sock")
|
||||
|
||||
assert result.jails == []
|
||||
assert result.items == []
|
||||
|
||||
async def test_fail2ban_unreachable_shows_all(self, tmp_path: Path) -> None:
|
||||
# When fail2ban is unreachable, _get_active_jail_names returns empty set,
|
||||
@@ -425,7 +425,7 @@ class TestListInactiveJails:
|
||||
):
|
||||
result = await list_inactive_jails(str(tmp_path), "/fake.sock")
|
||||
|
||||
names = {j.name for j in result.jails}
|
||||
names = {j.name for j in result.items}
|
||||
assert "sshd" in names
|
||||
assert "apache-auth" in names
|
||||
|
||||
@@ -440,7 +440,7 @@ class TestListInactiveJails:
|
||||
new=AsyncMock(return_value=set()),
|
||||
):
|
||||
result = await list_inactive_jails(str(tmp_path), "/fake.sock")
|
||||
jail = next(j for j in result.jails if j.name == "apache-auth")
|
||||
jail = next(j for j in result.items if j.name == "apache-auth")
|
||||
assert jail.has_local_override is True
|
||||
|
||||
async def test_has_local_override_false_when_no_local_file(self, tmp_path: Path) -> None:
|
||||
@@ -451,7 +451,7 @@ class TestListInactiveJails:
|
||||
new=AsyncMock(return_value=set()),
|
||||
):
|
||||
result = await list_inactive_jails(str(tmp_path), "/fake.sock")
|
||||
jail = next(j for j in result.jails if j.name == "apache-auth")
|
||||
jail = next(j for j in result.items if j.name == "apache-auth")
|
||||
assert jail.has_local_override is False
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user