Include icmp_type and icmp_code in the payload even they are 0
Since 0 is a valid number for icmp_type, icmp_code, and protocol_number, they need to be included in the payload. Change-Id: I638e4757cb1f09e0a0677ad2c36d16db900da284
This commit is contained in:
@@ -941,6 +941,14 @@ class TestPolicyIcmpService(NsxPolicyLibTestCase):
|
|||||||
self.assert_called_with_defs(
|
self.assert_called_with_defs(
|
||||||
update_call, [service_def, entry_def])
|
update_call, [service_def, entry_def])
|
||||||
|
|
||||||
|
def test_icmp_type_and_code_in_obj_dict(self):
|
||||||
|
icmp_type, icmp_code = 0, 0
|
||||||
|
entry_def = core_defs.IcmpServiceEntryDef(
|
||||||
|
icmp_type=icmp_type, icmp_code=icmp_code)
|
||||||
|
body = entry_def.get_obj_dict()
|
||||||
|
self.assertEqual(icmp_type, body["icmp_type"])
|
||||||
|
self.assertEqual(icmp_code, body["icmp_code"])
|
||||||
|
|
||||||
|
|
||||||
class TestPolicyIPProtocolService(NsxPolicyLibTestCase):
|
class TestPolicyIPProtocolService(NsxPolicyLibTestCase):
|
||||||
|
|
||||||
@@ -1062,6 +1070,13 @@ class TestPolicyIPProtocolService(NsxPolicyLibTestCase):
|
|||||||
self.assert_called_with_defs(service_update_call,
|
self.assert_called_with_defs(service_update_call,
|
||||||
[service_def, entry_def])
|
[service_def, entry_def])
|
||||||
|
|
||||||
|
def test_protocol_number_in_obj_dict(self):
|
||||||
|
protocol_number = 0
|
||||||
|
entry_def = core_defs.IPProtocolServiceEntryDef(
|
||||||
|
protocol_number=protocol_number)
|
||||||
|
body = entry_def.get_obj_dict()
|
||||||
|
self.assertEqual(protocol_number, body["protocol_number"])
|
||||||
|
|
||||||
|
|
||||||
class TestPolicyMixedService(NsxPolicyLibTestCase):
|
class TestPolicyMixedService(NsxPolicyLibTestCase):
|
||||||
|
|
||||||
|
|||||||
@@ -1167,7 +1167,8 @@ class IcmpServiceEntryDef(ServiceEntryDef):
|
|||||||
body['protocol'] = 'ICMPv' + str(self.get_attr('version'))
|
body['protocol'] = 'ICMPv' + str(self.get_attr('version'))
|
||||||
|
|
||||||
for attr in ('icmp_type', 'icmp_code'):
|
for attr in ('icmp_type', 'icmp_code'):
|
||||||
if self.get_attr(attr):
|
# Note that icmp_type and icmp_code could be 0.
|
||||||
|
if self.get_attr(attr) is not None:
|
||||||
body[attr] = self.get_attr(attr)
|
body[attr] = self.get_attr(attr)
|
||||||
return body
|
return body
|
||||||
|
|
||||||
@@ -1180,7 +1181,8 @@ class IPProtocolServiceEntryDef(ServiceEntryDef):
|
|||||||
|
|
||||||
def get_obj_dict(self):
|
def get_obj_dict(self):
|
||||||
body = super(IPProtocolServiceEntryDef, self).get_obj_dict()
|
body = super(IPProtocolServiceEntryDef, self).get_obj_dict()
|
||||||
if self.get_attr('protocol_number'):
|
if self.get_attr('protocol_number') is not None:
|
||||||
|
# Note that protocol_number could be 0.
|
||||||
body['protocol_number'] = self.get_attr('protocol_number')
|
body['protocol_number'] = self.get_attr('protocol_number')
|
||||||
return body
|
return body
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user