Skip to content

Commit c3e817d

Browse files
Fix the issue with firewall subcommand
1 parent 7b6be69 commit c3e817d

2 files changed

Lines changed: 23 additions & 3 deletions

File tree

cidre/cli.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,14 +215,14 @@ def main():
215215
else:
216216
print_title(cidr_parser)
217217
elif args.command == "firewall":
218-
if args.command in ["allow", "deny", "reject"]:
218+
if args.firewall_subcommand in ["allow", "deny", "reject"]:
219219
joined_countries = ", ".join(args.countries)
220220
print(
221-
f"💡 Applying '{args.command}' action to '{args.firewall.value}' firewall for {joined_countries} countries...",
221+
f"💡 Applying '{args.firewall_subcommand}' action to '{args.firewall.value}' firewall for {joined_countries} countries...",
222222
end="\n\n",
223223
)
224224
success = apply(
225-
args.firewall, args.command, args.countries, args.cidr_store
225+
args.firewall, args.firewall_subcommand, args.countries, args.cidr_store
226226
)
227227
print("")
228228

tests/test_cidr.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,23 @@ def test_cidr_count():
4747
assert result.returncode == 0
4848
assert "US: " in result.stdout
4949
assert "RU: " in result.stdout
50+
51+
52+
def test_firewall_reject():
53+
result = subprocess.run(
54+
["cidre", "cidr", "pull", "--merge"],
55+
capture_output=True,
56+
text=True,
57+
)
58+
assert result.returncode == 0
59+
60+
result = subprocess.run(
61+
["cidre", "firewall", "reject", "ru"],
62+
capture_output=True,
63+
text=True,
64+
)
65+
assert result.returncode == 0
66+
assert (
67+
"💡 Applying 'reject' action to 'ufw' firewall for RU countries"
68+
in result.stdout
69+
)

0 commit comments

Comments
 (0)