Skip to content

Commit

Permalink
fixes for rule-tests (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
ansibleguy committed Aug 24, 2024
1 parent 1f8d0f5 commit 87eb425
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 13 deletions.
13 changes: 12 additions & 1 deletion tests/rule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
not opn18.changed
when: not ansible_check_mode

- name: Triggering server-side validation error
- name: Triggering server-side validation error for interfaces
ansibleguy.opnsense.rule:
source_net: '192.168.0.0/24'
destination_net: '192.168.2.0/24'
Expand All @@ -107,6 +107,17 @@
failed_when: not opn19.failed
when: not ansible_check_mode

- name: Triggering server-side validation error for ports
ansibleguy.opnsense.rule:
source_net: '192.168.0.0/24'
destination_net: '192.168.2.0/24'
destination_port: 'XYZ'
protocol: 'TCP'
description: 'ANSIBLE_TEST_1_11'
register: opn20
failed_when: not opn20.failed
when: not ansible_check_mode

- name: Creating block rule
ansibleguy.opnsense.rule:
source_net: '192.168.1.0/24'
Expand Down
36 changes: 24 additions & 12 deletions tests/rule_multi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
opn9.failed or
opn9.changed
- name: Fail on client-side validation
- name: Fail on server-side validation
ansibleguy.opnsense.rule_multi:
rules:
ANSIBLE_TEST_2_1:
Expand All @@ -136,18 +136,30 @@
ANSIBLE_TEST_2_3:
register: opn6
failed_when: not opn6.failed
when: not ansible_check_mode

- name: Don't fail on client-side validation
ansibleguy.opnsense.rule_multi:
rules:
ANSIBLE_TEST_2_1:
ANSIBLE_TEST_2_2:
destination_port: 'XXX'
ANSIBLE_TEST_2_3:
fail_verification: false
register: opn7
failed_when: opn7.failed
when: ansible_check_mode # else the server-side will reject it
# noting to validate..
# - name: Fail on client-side validation
# ansibleguy.opnsense.rule_multi:
# rules:
# ANSIBLE_TEST_2_1:
# ANSIBLE_TEST_2_2:
# destination_port: 'XXX'
# ANSIBLE_TEST_2_3:
# register: opn6
# failed_when: not opn6.failed
#
# - name: Don't fail on client-side validation
# ansibleguy.opnsense.rule_multi:
# rules:
# ANSIBLE_TEST_2_1:
# ANSIBLE_TEST_2_2:
# destination_port: 'XXX'
# ANSIBLE_TEST_2_3:
# fail_verification: false
# register: opn7
# failed_when: opn7.failed
# when: ansible_check_mode # else the server-side will reject it

- name: Listing rules
ansibleguy.opnsense.list:
Expand Down

0 comments on commit 87eb425

Please sign in to comment.