1+ *** Settings ***
2+ Library SSHLibrary
3+
4+ *** Test Cases ***
5+ Ensure role mapping exists for traefik1
6+ ${rc } = Execute Command redis-cli HSET roles/module/traefik1 node/1 fwadm return_rc=True return_stdout=False
7+ Should Be Equal As Integers ${rc } 0
8+
9+ Add rich rules via Python script
10+ ${output } = Execute Command cat > /usr/local/bin/add_rich_rules <<'PY'
11+ ... #!/usr/local/bin/runagent python3
12+ ... import agent
13+ ... rules = [
14+ ... 'rule family=ipv4 forward-port port=5060 protocol=udp to-port=5060 source address=192.168.1.1',
15+ ... 'rule family=ipv4 source address=2.4.5.6 accept'
16+ ... ]
17+ ... result = agent.add_rich_rules(rules)
18+ ... print('SUCCESS' if result else 'FAILED')
19+ ... PY
20+ Execute Command chmod +x /usr/local/bin/add_rich_rules
21+ ${output } = Execute Command runagent -m traefik1 add_rich_rules
22+ Should Contain ${output } SUCCESS
23+ Execute Command rm -f /usr/local/bin/add_rich_rules
24+
25+ Verify rich rules are present in firewall
26+ ${output } = Execute Command firewall-cmd --list-rich-rules
27+ Should Contain ${output } rule family=ipv4 forward-port port=5060 protocol=udp to-port=5060 source address=192.168.1.1
28+ Should Contain ${output } rule family=ipv4 source address=2.4.5.6 accept
29+
30+ Query individual rich rules
31+ ${rc1 } = Execute Command firewall-cmd --query-rich-rule='rule family=ipv4 forward-port port=5060 protocol=udp to-port=5060 source address=192.168.1.1' return_rc=True return_stdout=False
32+ Should Be Equal As Integers ${rc1 } 0
33+ ${rc2 } = Execute Command firewall-cmd --query-rich-rule='rule family=ipv4 source address=2.4.5.6 accept' return_rc=True return_stdout=False
34+ Should Be Equal As Integers ${rc2 } 0
35+
36+ Remove rich rules via Python script
37+ ${output } = Execute Command cat > /usr/local/bin/remove_rich_rules <<'PY'
38+ ... import sys
39+ ... import agent
40+ ... rules = [
41+ ... 'rule family=ipv4 forward-port port=5060 protocol=udp to-port=5060 source address=192.168.1.1',
42+ ... 'rule family=ipv4 source address=2.4.5.6 accept'
43+ ... ]
44+ ... result = agent.remove_rich_rules(rules)
45+ ... print('SUCCESS' if result else 'FAILED')
46+ ... PY
47+ Execute Command chmod +x /usr/local/bin/remove_rich_rules
48+ ${output } = Execute Command runagent -m traefik1 remove_rich_rules
49+ Should Contain ${output } SUCCESS
50+ Execute Command rm -f /usr/local/bin/remove_rich_rules
51+
52+ Verify rich rules have been removed
53+ ${output } = Execute Command firewall-cmd --list-rich-rules
54+ Should Not Contain ${output } rule family=ipv4 forward-port port=5060 protocol=udp to-port=5060 source address=192.168.1.1
55+ Should Not Contain ${output } rule family=ipv4 source address=2.4.5.6 accept
56+
57+ Query removed rich rules return failure
58+ ${rc1 } = Execute Command firewall-cmd --query-rich-rule='rule family=ipv4 forward-port port=5060 protocol=udp to-port=5060 source address=192.168.1.1' return_rc=True return_stdout=False
59+ Should Not Be Equal As Integers ${rc1 } 0
60+ ${rc2 } = Execute Command firewall-cmd --query-rich-rule='rule family=ipv4 source address=2.4.5.6 accept' return_rc=True return_stdout=False
61+ Should Not Be Equal As Integers ${rc2 } 0
62+
63+ Remove role mapping for traefik1
64+ ${rc } = Execute Command redis-cli HDEL roles/module/traefik1 node/1 return_rc=True return_stdout=False
65+ Should Be Equal As Integers ${rc } 0
0 commit comments