• source navigation  • diff markup  • identifier search  • freetext search  • 

Sources/firewall4/tests/06_includes/06_invalid_include

  1 Testing that include sections with invalid options are skipped.
  2 
  3 -- Testcase --
  4 {%
  5         include("./root/usr/share/firewall4/main.uc", {
  6                 getenv: function(varname) {
  7                         switch (varname) {
  8                         case 'ACTION':
  9                                 return 'print';
 10                         }
 11                 }
 12         })
 13 %}
 14 -- End --
 15 
 16 -- File uci/helpers.json --
 17 {}
 18 -- End --
 19 
 20 -- File fs/open~_sys_class_net_eth0_flags.txt --
 21 0x1103
 22 -- End --
 23 
 24 -- File fs/open~_etc_testinclude1_nft.txt --
 25 # dummy
 26 -- End --
 27 
 28 -- File fs/open~_etc_testinclude2_nft.txt --
 29 # dummy
 30 -- End --
 31 
 32 -- File uci/firewall.json --
 33 {
 34         "zone": [
 35                 {
 36                         "name": "test",
 37                         "device": [ "eth0" ],
 38                         "auto_helper": 0
 39                 }
 40         ],
 41         "include": [
 42                 {
 43                         ".description": "By default, this include should be processed due to implicit enabled 1",
 44                         "path": "/etc/testinclude1.nft",
 45                         "type": "nftables"
 46                 },
 47 
 48                 {
 49                         ".description": "This include should be processed due to explicit enabled 1",
 50                         "path": "/etc/testinclude2.nft",
 51                         "type": "nftables",
 52                         "enabled": "1"
 53                 },
 54 
 55                 {
 56                         ".description": "This include should be skipped due to the missing path",
 57                         "type": "nftables"
 58                 }
 59         ]
 60 }
 61 -- End --
 62 
 63 -- Expect stderr --
 64 [!] Section @include[2] option 'path' is mandatory but not set
 65 [!] Section @include[2] skipped due to invalid options
 66 -- End --
 67 
 68 -- Expect stdout --
 69 table inet fw4
 70 flush table inet fw4
 71 
 72 table inet fw4 {
 73         #
 74         # Defines
 75         #
 76 
 77         define test_devices = { "eth0" }
 78         define test_subnets = {  }
 79 
 80 
 81         #
 82         # User includes
 83         #
 84 
 85         include "/etc/nftables.d/*.nft"
 86 
 87 
 88         #
 89         # Filter rules
 90         #
 91 
 92         chain input {
 93                 type filter hook input priority filter; policy drop;
 94 
 95                 iif "lo" accept comment "!fw4: Accept traffic from loopback"
 96 
 97                 ct state vmap { established : accept, related : accept } comment "!fw4: Handle inbound flows"
 98                 iifname "eth0" jump input_test comment "!fw4: Handle test IPv4/IPv6 input traffic"
 99         }
100 
101         chain forward {
102                 type filter hook forward priority filter; policy drop;
103 
104                 ct state vmap { established : accept, related : accept } comment "!fw4: Handle forwarded flows"
105                 iifname "eth0" jump forward_test comment "!fw4: Handle test IPv4/IPv6 forward traffic"
106         }
107 
108         chain output {
109                 type filter hook output priority filter; policy drop;
110 
111                 oif "lo" accept comment "!fw4: Accept traffic towards loopback"
112 
113                 ct state vmap { established : accept, related : accept } comment "!fw4: Handle outbound flows"
114                 oifname "eth0" jump output_test comment "!fw4: Handle test IPv4/IPv6 output traffic"
115         }
116 
117         chain prerouting {
118                 type filter hook prerouting priority filter; policy accept;
119         }
120 
121         chain handle_reject {
122                 meta l4proto tcp reject with tcp reset comment "!fw4: Reject TCP traffic"
123                 reject with icmpx type port-unreachable comment "!fw4: Reject any other traffic"
124         }
125 
126         chain input_test {
127                 jump drop_from_test
128         }
129 
130         chain output_test {
131                 jump drop_to_test
132         }
133 
134         chain forward_test {
135                 jump drop_to_test
136         }
137 
138         chain drop_from_test {
139                 iifname "eth0" counter drop comment "!fw4: drop test IPv4/IPv6 traffic"
140         }
141 
142         chain drop_to_test {
143                 oifname "eth0" counter drop comment "!fw4: drop test IPv4/IPv6 traffic"
144         }
145 
146 
147         #
148         # NAT rules
149         #
150 
151         chain dstnat {
152                 type nat hook prerouting priority dstnat; policy accept;
153         }
154 
155         chain srcnat {
156                 type nat hook postrouting priority srcnat; policy accept;
157         }
158 
159 
160         #
161         # Raw rules (notrack)
162         #
163 
164         chain raw_prerouting {
165                 type filter hook prerouting priority raw; policy accept;
166         }
167 
168         chain raw_output {
169                 type filter hook output priority raw; policy accept;
170         }
171 
172 
173         #
174         # Mangle rules
175         #
176 
177         chain mangle_prerouting {
178                 type filter hook prerouting priority mangle; policy accept;
179         }
180 
181         chain mangle_postrouting {
182                 type filter hook postrouting priority mangle; policy accept;
183         }
184 
185         chain mangle_input {
186                 type filter hook input priority mangle; policy accept;
187         }
188 
189         chain mangle_output {
190                 type route hook output priority mangle; policy accept;
191         }
192 
193         chain mangle_forward {
194                 type filter hook forward priority mangle; policy accept;
195         }
196 
197         include "/etc/testinclude1.nft"
198         include "/etc/testinclude2.nft"
199 }
200 -- End --

This page was automatically generated by LXR 0.3.1.  •  OpenWrt