Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fw support floating 'all' interface rule #90

Merged
merged 2 commits into from
Jan 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion plugins/module_utils/rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,10 @@ def _parse_floating_interfaces(self, interfaces):
""" validate param interface field when floating is true """
res = []
for interface in interfaces.split(','):
res.append(self.pfsense.parse_interface(interface))
if interface == 'any':
res.append(interface)
else:
res.append(self.pfsense.parse_interface(interface))
self._floating_interfaces = interfaces
return ','.join(res)

Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/pfsense_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
default: false
type: bool
interface:
description: The interface for the rule
description: The interface for the rule. Use 'any' to apply to all interface (for floating rules only).
required: true
type: str
floating:
Expand Down
11 changes: 11 additions & 0 deletions tests/unit/plugins/modules/test_pfsense_rule_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,17 @@ def test_rule_create_floating(self):
command = "create rule 'one_rule' on 'floating(lan)', source='any', destination='any', direction='any'"
self.do_module_test(obj, command=command)

def test_rule_create_floating_any(self):
""" test creation of a new floating rule with any interface """
obj = dict(name='one_rule', source='any', destination='any', interface='any', floating='yes', direction='any')
command = "create rule 'one_rule' on 'floating(any)', source='any', destination='any', direction='any'"

def test_rule_create_non_floating_any(self):
""" test creation of a new rule with any interface """
obj = dict(name='one_rule', source='any', destination='any', interface='any', floating='no', direction='any')
msg = "any is not a valid interface"
self.do_module_test(obj, failed=True, msg=msg)

def test_rule_create_floating_quick(self):
""" test creation of a new floating rule with quick match """
obj = dict(name='one_rule', source='any', destination='any', interface='lan', floating='yes', direction='any', quick='yes')
Expand Down