Debian Codegraph @

neutron_fwaas/tests/unit/services/firewall/service_drivers/agents/test_agents.py

raw symbols SCIP
1 # Copyright 2016
2 # All Rights Reserved.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License"); you may
5 # not use this file except in compliance with the License. You may obtain
6 # a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 # License for the specific language governing permissions and limitations
14 # under the License.
15
16 from unittest import mock
17
18 from neutron.conf import common as common_conf
19 from neutron import extensions as neutron_extensions
20 from neutron.tests.unit.extensions import test_l3
21 from neutron_lib import constants as nl_constants
22 from neutron_lib import context
23 from neutron_lib.db import api as db_api
24 from neutron_lib.exceptions import firewall_v2 as f_exc
25 from neutron_lib.plugins import directory
26 from oslo_config import cfg
27
28 from neutron_fwaas.db.firewall.v2.firewall_db_v2 import FirewallGroup
29 from neutron_fwaas.services.firewall.service_drivers.agents import agents
30 from neutron_fwaas.tests import base
31 from neutron_fwaas.tests.unit.services.firewall import test_fwaas_plugin_v2
32
33
34 FIREWALL_AGENT_PLUGIN = ('neutron_fwaas.services.firewall.service_drivers.'
35 'agents.agents')
36 FIREWALL_AGENT_PLUGIN_KLASS = FIREWALL_AGENT_PLUGIN + '.FirewallAgentDriver'
37 DELETEFW_PATH = (FIREWALL_AGENT_PLUGIN + '.FirewallAgentApi.'
38 'delete_firewall_group')
39
40
41 class FakeAgentApi(agents.FirewallAgentCallbacks):
42 """This class used to mock the AgentAPI delete method
43
44 It inherits from FirewallCallbacks because it needs access to
45 the firewall_deleted method.
46 The delete_firewall method belongs to the FirewallAgentApi, which has
47 no access to the firewall_deleted method normally because it's not
48 responsible for deleting the firewall from the DB. However, it needs
49 to in the unit tests since there is no agent to call back.
50 """
51 def __init__(self):
52 return
53
54 def delete_firewall_group(self, context, firewall_group, **kwargs):
55 self.plugin = directory.get_plugin('FIREWALL_V2')
56 self.firewall_db = self.plugin.driver.firewall_db
57 self.firewall_group_deleted(context, firewall_group['id'], **kwargs)
58
59
60 class TestFirewallAgentApi(base.BaseTestCase):
61 def setUp(self):
62 super().setUp()
63
64 self.api = agents.FirewallAgentApi('topic', 'host')
65
66 def test_init(self):
67 self.assertEqual('topic', self.api.client.target.topic)
68 self.assertEqual('host', self.api.host)
69
70 def _call_test_helper(self, method_name):
71 with mock.patch.object(self.api.client, 'cast') as rpc_mock, \
72 mock.patch.object(self.api.client, 'prepare') as prepare_mock:
73 prepare_mock.return_value = self.api.client
74 getattr(self.api, method_name)(mock.sentinel.context, 'test')
75
76 prepare_args = {'fanout': True}
77 prepare_mock.assert_called_once_with(**prepare_args)
78
79 rpc_mock.assert_called_once_with(mock.sentinel.context, method_name,
80 firewall_group='test', host='host')
81
82 def test_create_firewall_group(self):
83 self._call_test_helper('create_firewall_group')
84
85 def test_update_firewall_group(self):
86 self._call_test_helper('update_firewall_group')
87
88 def test_delete_firewall_group(self):
89 self._call_test_helper('delete_firewall_group')
90
91
92 class TestAgentDriver(test_fwaas_plugin_v2.FirewallPluginV2TestCase,
93 test_l3.L3NatTestCaseMixin):
94
95 def setUp(self):
96 self._mock_agentapi_del_fw_p = mock.patch(
97 DELETEFW_PATH, create=True,
98 new=FakeAgentApi().delete_firewall_group,
99 )
100 self.agentapi_del_fw_p = self._mock_agentapi_del_fw_p.start()
101 self.addCleanup(self._mock_agentapi_del_fw_p.stop)
102 self._mock_get_client = mock.patch.object(agents.n_rpc, 'get_client')
103 self._mock_get_client.start()
104 self.addCleanup(self._mock_get_client.stop)
105 mock.patch.object(agents.n_rpc, 'Connection').start()
106
107 l3_plugin_str = ('neutron.tests.unit.extensions.test_l3.'
108 'TestL3NatServicePlugin')
109 l3_plugin = {'l3_plugin_name': l3_plugin_str}
110 common_conf.register_core_common_config_opts(cfg=cfg.CONF)
111 super().setUp(
112 service_provider=FIREWALL_AGENT_PLUGIN_KLASS,
113 extra_service_plugins=l3_plugin,
114 extra_extension_paths=neutron_extensions.__path__)
115
116 self.db = self.plugin.driver.firewall_db
117 self.callbacks = agents.FirewallAgentCallbacks(self.db)
118
119 @property
120 def _self_context(self):
121 return context.Context('', self._project_id)
122
123 def _get_test_firewall_group_attrs(self, name,
124 status=nl_constants.INACTIVE):
125 return super()._get_test_firewall_group_attrs(
126 name, status=status)
127
128 def test_set_firewall_group_status(self):
129 ctx = context.get_admin_context()
130 with self.firewall_policy(as_admin=True) as fwp:
131 fwp_id = fwp['firewall_policy']['id']
132 with self.firewall_group(
133 ingress_firewall_policy_id=fwp_id,
134 admin_state_up=self.ADMIN_STATE_UP
135 ) as fwg:
136 fwg_id = fwg['firewall_group']['id']
137 res = self.callbacks.set_firewall_group_status(
138 ctx, fwg_id, nl_constants.ACTIVE)
139 fwg_db = self.plugin.get_firewall_group(ctx, fwg_id)
140 self.assertEqual(nl_constants.ACTIVE, fwg_db['status'])
141 self.assertTrue(res)
142 res = self.callbacks.set_firewall_group_status(
143 ctx, fwg_id, nl_constants.ERROR)
144 fwg_db = self.plugin.get_firewall_group(ctx, fwg_id)
145 self.assertEqual(nl_constants.ERROR, fwg_db['status'])
146 self.assertFalse(res)
147
148 def test_firewall_group_deleted(self):
149 ctx = context.get_admin_context()
150 with self.firewall_policy(as_admin=True) as fwp:
151 fwp_id = fwp['firewall_policy']['id']
152 with self.firewall_group(
153 ingress_firewall_policy_id=fwp_id,
154 admin_state_up=self.ADMIN_STATE_UP,
155 do_delete=False
156 ) as fwg:
157 fwg_id = fwg['firewall_group']['id']
158 with db_api.CONTEXT_WRITER.using(ctx):
159 fwg_db = self.db._get_firewall_group(ctx, fwg_id)
160 fwg_db['status'] = nl_constants.PENDING_DELETE
161
162 observed = self.callbacks.firewall_group_deleted(ctx, fwg_id)
163 self.assertTrue(observed)
164
165 self.assertRaises(f_exc.FirewallGroupNotFound,
166 self.plugin.get_firewall_group,
167 ctx, fwg_id)
168
169 def test_firewall_group_deleted_concurrently(self):
170 ctx = context.get_admin_context()
171 alt_ctx = context.get_admin_context()
172
173 _get_firewall_group = self.db._get_firewall_group
174
175 def getdelete(context, fwg_id):
176 fwg_db = _get_firewall_group(context, fwg_id)
177 # NOTE(cby): Use a different session to simulate a concurrent del
178 with db_api.CONTEXT_READER.using(alt_ctx):
179 alt_ctx.session.query(FirewallGroup).filter_by(
180 id=fwg_id).delete()
181 return fwg_db
182
183 with self.firewall_policy(as_admin=True) as fwp:
184 fwp_id = fwp['firewall_policy']['id']
185 with self.firewall_group(
186 firewall_policy_id=fwp_id,
187 admin_state_up=self.ADMIN_STATE_UP,
188 do_delete=False,
189 as_admin=True,
190 ) as fwg:
191 fwg_id = fwg['firewall_group']['id']
192 with db_api.CONTEXT_WRITER.using(ctx):
193 fwg_db = self.db._get_firewall_group(ctx, fwg_id)
194 fwg_db['status'] = nl_constants.PENDING_DELETE
195 ctx.session.flush()
196
197 with mock.patch.object(
198 self.db, '_get_firewall_group', side_effect=getdelete
199 ):
200 observed = self.callbacks.firewall_group_deleted(
201 ctx, fwg_id)
202 self.assertTrue(observed)
203
204 self.assertRaises(f_exc.FirewallGroupNotFound,
205 self.plugin.get_firewall_group,
206 ctx, fwg_id)
207
208 def test_firewall_group_deleted_not_found(self):
209 ctx = context.get_admin_context()
210 observed = self.callbacks.firewall_group_deleted(
211 ctx, 'notfound')
212 self.assertTrue(observed)
213
214 def test_firewall_group_deleted_error(self):
215 ctx = context.get_admin_context()
216 with self.firewall_policy(as_admin=True) as fwp:
217 fwp_id = fwp['firewall_policy']['id']
218 with self.firewall_group(
219 firewall_policy_id=fwp_id,
220 admin_state_up=self.ADMIN_STATE_UP,
221 as_admin=True,
222 ) as fwg:
223 fwg_id = fwg['firewall_group']['id']
224 observed = self.callbacks.firewall_group_deleted(
225 ctx, fwg_id)
226 self.assertFalse(observed)
227 fwg_db = self.db._get_firewall_group(ctx, fwg_id)
228 self.assertEqual(nl_constants.ERROR, fwg_db['status'])
229
230 def test_create_firewall_group_ports_not_specified(self):
231 """neutron firewall-create test-policy """
232 with self.firewall_policy(as_admin=True) as fwp:
233 fwp_id = fwp['firewall_policy']['id']
234 with self.firewall_group(
235 name='test',
236 ingress_firewall_policy_id=fwp_id,
237 egress_firewall_policy_id=fwp_id,
238 admin_state_up=True) as fwg1:
239 self.assertEqual(nl_constants.INACTIVE,
240 fwg1['firewall_group']['status'])
241
242 def test_create_firewall_group_with_ports(self):
243 """neutron firewall_group create test-policy """
244 with self.router(name='router1', admin_state_up=True,
245 project_id=self._project_id) as r, \
246 self.subnet() as s1, \
247 self.subnet(cidr='20.0.0.0/24') as s2:
248
249 body = self._router_interface_action(
250 'add',
251 r['router']['id'],
252 s1['subnet']['id'],
253 None)
254 port_id1 = body['port_id']
255
256 body = self._router_interface_action(
257 'add',
258 r['router']['id'],
259 s2['subnet']['id'],
260 None)
261 port_id2 = body['port_id']
262 fwg_ports = [port_id1, port_id2]
263 with self.firewall_policy(as_admin=True) as fwp:
264 fwp_id = fwp['firewall_policy']['id']
265 with self.firewall_group(
266 name='test',
267 ingress_firewall_policy_id=fwp_id,
268 egress_firewall_policy_id=fwp_id, ports=fwg_ports,
269 admin_state_up=True) as fwg1:
270 self.assertEqual(nl_constants.PENDING_CREATE,
271 fwg1['firewall_group']['status'])
272
273 def test_create_firewall_group_with_ports_on_diff_routers(self):
274 """neutron firewall_group create test-policy """
275 with self.router(name='router1', admin_state_up=True,
276 project_id=self._project_id) as r, \
277 self.subnet() as s1, \
278 self.subnet(cidr='20.0.0.0/24') as s2:
279 body = self._router_interface_action(
280 'add',
281 r['router']['id'],
282 s1['subnet']['id'],
283 None)
284 port_id1 = body['port_id']
285 body = self._router_interface_action(
286 'add',
287 r['router']['id'],
288 s2['subnet']['id'],
289 None)
290 port_id2 = body['port_id']
291
292 with self.router(name='router1', admin_state_up=True,
293 project_id=self._project_id) as r2, \
294 self.subnet() as s3:
295
296 body = self._router_interface_action(
297 'add',
298 r2['router']['id'],
299 s3['subnet']['id'],
300 None)
301 port_id3 = body['port_id']
302
303 fwg_ports = [port_id1, port_id2, port_id3]
304 with self.firewall_policy(as_admin=True) as fwp:
305 fwp_id = fwp['firewall_policy']['id']
306 with self.firewall_group(
307 name='test',
308 ingress_firewall_policy_id=fwp_id,
309 egress_firewall_policy_id=fwp_id,
310 ports=fwg_ports,
311 admin_state_up=True) as fwg1:
312 self.assertEqual(nl_constants.PENDING_CREATE,
313 fwg1['firewall_group']['status'])
314
315 def test_create_firewall_group_with_ports_no_policy(self):
316 """neutron firewall_group create test-policy """
317 with self.router(name='router1', admin_state_up=True,
318 project_id=self._project_id) as r, \
319 self.subnet() as s1, \
320 self.subnet(cidr='20.0.0.0/24') as s2:
321
322 body = self._router_interface_action(
323 'add',
324 r['router']['id'],
325 s1['subnet']['id'],
326 None)
327 port_id1 = body['port_id']
328
329 body = self._router_interface_action(
330 'add',
331 r['router']['id'],
332 s2['subnet']['id'],
333 None)
334 port_id2 = body['port_id']
335 fwg_ports = [port_id1, port_id2]
336 with self.firewall_group(
337 name='test',
338 default_policy=False,
339 ports=fwg_ports,
340 admin_state_up=True) as fwg1:
341 self.assertEqual(nl_constants.INACTIVE,
342 fwg1['firewall_group']['status'])
343
344 def test_update_firewall_group_with_new_ports_no_policy(self):
345 """neutron firewall_group create test-policy """
346 with self.router(name='router1', admin_state_up=True,
347 project_id=self._project_id) as r, \
348 self.subnet() as s1, \
349 self.subnet(cidr='20.0.0.0/24') as s2, \
350 self.subnet(cidr='30.0.0.0/24') as s3:
351
352 body = self._router_interface_action(
353 'add',
354 r['router']['id'],
355 s1['subnet']['id'],
356 None)
357 port_id1 = body['port_id']
358
359 body = self._router_interface_action(
360 'add',
361 r['router']['id'],
362 s2['subnet']['id'],
363 None)
364 port_id2 = body['port_id']
365
366 body = self._router_interface_action(
367 'add',
368 r['router']['id'],
369 s3['subnet']['id'],
370 None)
371 port_id3 = body['port_id']
372
373 fwg_ports = [port_id1, port_id2]
374 with self.firewall_group(
375 name='test',
376 default_policy=False,
377 ports=fwg_ports,
378 admin_state_up=True) as fwg1:
379 self.assertEqual(nl_constants.INACTIVE,
380 fwg1['firewall_group']['status'])
381 data = {'firewall_group': {'ports': [port_id2, port_id3]}}
382 req = self.new_update_request('firewall_groups', data,
383 fwg1['firewall_group']['id'],
384 context=self._self_context)
385 res = self.deserialize(self.fmt,
386 req.get_response(self.ext_api))
387
388 self.assertEqual(sorted([port_id2, port_id3]),
389 sorted(res['firewall_group']['ports']))
390
391 self.assertEqual(nl_constants.INACTIVE,
392 res['firewall_group']['status'])
393
394 def test_update_firewall_group_with_new_ports_status_pending(self):
395 """neutron firewall_group create test-policy """
396 with self.router(name='router1', admin_state_up=True,
397 project_id=self._project_id) as r, \
398 self.subnet() as s1, \
399 self.subnet(cidr='20.0.0.0/24') as s2, \
400 self.subnet(cidr='30.0.0.0/24') as s3:
401
402 body = self._router_interface_action(
403 'add',
404 r['router']['id'],
405 s1['subnet']['id'],
406 None)
407 port_id1 = body['port_id']
408
409 body = self._router_interface_action(
410 'add',
411 r['router']['id'],
412 s2['subnet']['id'],
413 None)
414 port_id2 = body['port_id']
415 fwg_ports = [port_id1, port_id2]
416
417 body = self._router_interface_action(
418 'add',
419 r['router']['id'],
420 s3['subnet']['id'],
421 None)
422 port_id3 = body['port_id']
423
424 with self.firewall_policy(as_admin=True) as fwp:
425 fwp_id = fwp['firewall_policy']['id']
426 with self.firewall_group(
427 name='test',
428 ingress_firewall_policy_id=fwp_id,
429 egress_firewall_policy_id=fwp_id, ports=fwg_ports,
430 admin_state_up=True) as fwg1:
431 self.assertEqual(nl_constants.PENDING_CREATE,
432 fwg1['firewall_group']['status'])
433 data = {'firewall_group': {'ports': [port_id2, port_id3]}}
434 req = self.new_update_request('firewall_groups', data,
435 fwg1['firewall_group']['id'])
436 res = req.get_response(self.ext_api)
437 self.assertEqual(409, res.status_int)
438
439 def test_update_firewall_group_with_new_ports_status_active(self):
440 """neutron firewall_group create test-policy """
441 with self.router(name='router1', admin_state_up=True,
442 project_id=self._project_id) as r, \
443 self.subnet() as s1, \
444 self.subnet(cidr='20.0.0.0/24') as s2, \
445 self.subnet(cidr='30.0.0.0/24') as s3:
446
447 body = self._router_interface_action(
448 'add',
449 r['router']['id'],
450 s1['subnet']['id'],
451 None)
452 port_id1 = body['port_id']
453
454 body = self._router_interface_action(
455 'add',
456 r['router']['id'],
457 s2['subnet']['id'],
458 None)
459 port_id2 = body['port_id']
460 fwg_ports = [port_id1, port_id2]
461
462 body = self._router_interface_action(
463 'add',
464 r['router']['id'],
465 s3['subnet']['id'],
466 None)
467 port_id3 = body['port_id']
468
469 with self.firewall_policy(as_admin=True) as fwp:
470 fwp_id = fwp['firewall_policy']['id']
471 with self.firewall_group(
472 name='test',
473 ingress_firewall_policy_id=fwp_id,
474 egress_firewall_policy_id=fwp_id, ports=fwg_ports,
475 admin_state_up=True) as fwg1:
476 self.assertEqual(nl_constants.PENDING_CREATE,
477 fwg1['firewall_group']['status'])
478
479 ctx = context.get_admin_context()
480 self.callbacks.set_firewall_group_status(
481 ctx,
482 fwg1['firewall_group']['id'], nl_constants.ACTIVE)
483 data = {'firewall_group': {'ports': [port_id2, port_id3]}}
484 req = self.new_update_request('firewall_groups', data,
485 fwg1['firewall_group']['id'],
486 context=self._self_context)
487 res = self.deserialize(self.fmt,
488 req.get_response(self.ext_api))
489 self.assertEqual(sorted([port_id2, port_id3]),
490 sorted(res['firewall_group']['ports']))
491
492 def test_update_firewall_rule_on_active_fwg(self):
493 name = "new_firewall_rule1"
494 attrs = self._get_test_firewall_rule_attrs(name)
495 with self.router(name='router1', admin_state_up=True,
496 project_id=self._project_id) as r, \
497 self.subnet() as s1:
498
499 body = self._router_interface_action(
500 'add',
501 r['router']['id'],
502 s1['subnet']['id'],
503 None)
504 port_id1 = body['port_id']
505 with self.firewall_rule(as_admin=True) as fwr:
506 with self.firewall_policy(
507 firewall_rules=[fwr['firewall_rule']['id']],
508 as_admin=True) as fwp:
509 fwp_id = fwp['firewall_policy']['id']
510 with self.firewall_group(
511 name='test',
512 ingress_firewall_policy_id=fwp_id,
513 egress_firewall_policy_id=fwp_id, ports=[port_id1],
514 admin_state_up=True) as fwg1:
515 self.assertEqual(nl_constants.PENDING_CREATE,
516 fwg1['firewall_group']['status'])
517
518 ctx = context.get_admin_context()
519 self.callbacks.set_firewall_group_status(
520 ctx,
521 fwg1['firewall_group']['id'], nl_constants.ACTIVE)
522 data = {'firewall_rule': {'name': name}}
523 req = self.new_update_request(
524 'firewall_rules',
525 data, fwr['firewall_rule']['id'])
526 res = self.deserialize(self.fmt,
527 req.get_response(self.ext_api))
528 for k, v in attrs.items():
529 self.assertEqual(v, res['firewall_rule'][k])
530
531 def test_update_firewall_rule_on_pending_create_fwg(self):
532 """update should fail"""
533 name = "new_firewall_rule1"
534 with self.router(name='router1', admin_state_up=True,
535 project_id=self._project_id) as r, \
536 self.subnet() as s1:
537
538 body = self._router_interface_action(
539 'add',
540 r['router']['id'],
541 s1['subnet']['id'],
542 None)
543 port_id1 = body['port_id']
544 with self.firewall_rule(as_admin=True) as fwr:
545 with self.firewall_policy(
546 firewall_rules=[fwr['firewall_rule']['id']],
547 as_admin=True) as fwp:
548 fwp_id = fwp['firewall_policy']['id']
549 with self.firewall_group(
550 name='test',
551 ingress_firewall_policy_id=fwp_id,
552 egress_firewall_policy_id=fwp_id, ports=[port_id1],
553 admin_state_up=True) as fwg1:
554 self.assertEqual(nl_constants.PENDING_CREATE,
555 fwg1['firewall_group']['status'])
556
557 data = {'firewall_rule': {'name': name}}
558 req = self.new_update_request(
559 'firewall_rules',
560 data, fwr['firewall_rule']['id'])
561 res = req.get_response(self.ext_api)
562 self.assertEqual(409, res.status_int)
563
564 def test_update_firewall_group_with_non_exist_ports(self):
565 """neutron firewall_group create test-policy """
566 with self.router(name='router1', admin_state_up=True,
567 project_id=self._project_id) as r, \
568 self.subnet(cidr='30.0.0.0/24') as s:
569 body = self._router_interface_action(
570 'add',
571 r['router']['id'],
572 s['subnet']['id'],
573 None)
574 port_id1 = body['port_id']
575 foo_port_id = 'caef152d-b118-4b9b-bc77-800661bf082d'
576 fwg_ports = [port_id1]
577 with self.firewall_group(
578 name='test',
579 default_policy=False,
580 ports=fwg_ports,
581 admin_state_up=True) as fwg1:
582 self.assertEqual(nl_constants.INACTIVE,
583 fwg1['firewall_group']['status'])
584 data = {'firewall_group': {'ports': [foo_port_id]}}
585 req = self.new_update_request('firewall_groups', data,
586 fwg1['firewall_group']['id'])
587 res = self.deserialize(self.fmt,
588 req.get_response(self.ext_api))
589 self.assertEqual('PortNotFound',
590 res['NeutronError']['type'])
591
592 def test_update_firewall_group_with_ports_and_policy(self):
593 """neutron firewall_group create test-policy """
594 with self.router(name='router1', admin_state_up=True,
595 project_id=self._project_id) as r, \
596 self.subnet() as s1, \
597 self.subnet(cidr='20.0.0.0/24') as s2:
598
599 body = self._router_interface_action(
600 'add',
601 r['router']['id'],
602 s1['subnet']['id'],
603 None)
604 port_id1 = body['port_id']
605
606 body = self._router_interface_action(
607 'add',
608 r['router']['id'],
609 s2['subnet']['id'],
610 None)
611 port_id2 = body['port_id']
612
613 fwg_ports = [port_id1, port_id2]
614 with self.firewall_rule(as_admin=True) as fwr:
615 with self.firewall_policy(
616 firewall_rules=[fwr['firewall_rule']['id']],
617 as_admin=True) as fwp:
618 with self.firewall_group(
619 name='test',
620 default_policy=False,
621 ports=fwg_ports,
622 admin_state_up=True) as fwg1:
623 self.assertEqual(nl_constants.INACTIVE,
624 fwg1['firewall_group']['status'])
625 fwp_id = fwp["firewall_policy"]["id"]
626
627 data = {'firewall_group': {'ports': fwg_ports}}
628 req = (self.
629 new_update_request('firewall_groups', data,
630 fwg1['firewall_group']['id'],
631 context=self._self_context))
632 res = self.deserialize(self.fmt,
633 req.get_response(self.ext_api))
634 self.assertEqual(nl_constants.INACTIVE,
635 res['firewall_group']['status'])
636
637 data = {'firewall_group': {
638 'ingress_firewall_policy_id': fwp_id}}
639 req = (self.
640 new_update_request('firewall_groups', data,
641 fwg1['firewall_group']['id'],
642 context=self._self_context))
643 res = self.deserialize(self.fmt,
644 req.get_response(self.ext_api))
645 self.assertEqual(nl_constants.PENDING_UPDATE,
646 res['firewall_group']['status'])
647
648 def test_create_firewall_group_with_dvr(self):
649 cfg.CONF.set_override('router_distributed', True)
650 attrs = self._get_test_firewall_group_attrs("firewall1")
651 self._test_create_firewall_group(attrs)
652
653 def test_create_firewall_group(self):
654 attrs = self._get_test_firewall_group_attrs("firewall1")
655 self._test_create_firewall_group(attrs)
656
657 def test_create_firewall_group_with_empty_ports(self):
658 attrs = self._get_test_firewall_group_attrs("fwg1")
659 attrs['ports'] = []
660 self._test_create_firewall_group(attrs)