def test_prepare_port_filter(self):
    port_dict = {'device': 'port-id', 'security_groups': [1], 'fixed_ips': ['10.0.0.1']}
    self._prepare_security_group()
    self.firewall.prepare_port_filter(port_dict)
    exp_egress_classifier = mock.call(actions='set_field:{:d}->reg5,set_field:{:d}->reg6,resubmit(,{:d})'.format(self.port_ofport, TESTING_VLAN_TAG, ovs_consts.BASE_EGRESS_TABLE), in_port=self.port_ofport, priority=100, table=ovs_consts.TRANSIENT_TABLE)
    exp_ingress_classifier = mock.call(actions='set_field:{:d}->reg5,set_field:{:d}->reg6,strip_vlan,resubmit(,{:d})'.format(self.port_ofport, TESTING_VLAN_TAG, ovs_consts.BASE_INGRESS_TABLE), dl_dst=self.port_mac, dl_vlan=('0x%x' % TESTING_VLAN_TAG), priority=90, table=ovs_consts.TRANSIENT_TABLE)
    filter_rule = mock.call(actions='ct(commit,zone=NXM_NX_REG6[0..15]),output:{:d},resubmit(,{:d})'.format(self.port_ofport, ovs_consts.ACCEPTED_INGRESS_TRAFFIC_TABLE), dl_type='0x{:04x}'.format(n_const.ETHERTYPE_IP), nw_proto=constants.PROTO_NUM_TCP, priority=77, reg5=self.port_ofport, ct_state=ovsfw_consts.OF_STATE_NEW_NOT_ESTABLISHED, table=ovs_consts.RULES_INGRESS_TABLE, tcp_dst='0x007b')
    calls = self.mock_bridge.br.add_flow.call_args_list
    for call in (exp_ingress_classifier, exp_egress_classifier, filter_rule):
        self.assertIn(call, calls)
def test_prepare_port_filter(self):
    port_dict = {'device': 'port-id', 'security_groups': [1], 'fixed_ips': ['10.0.0.1']}
    self._prepare_security_group()
    self.firewall.prepare_port_filter(port_dict)
    exp_egress_classifier = mock.call(actions='set_field:{:d}->reg5,set_field:{:d}->reg6,resubmit(,{:d})'.format(self.port_ofport, TESTING_VLAN_TAG, ovs_consts.BASE_EGRESS_TABLE), in_port=self.port_ofport, priority=100, table=ovs_consts.TRANSIENT_TABLE)
    exp_ingress_classifier = mock.call(actions='set_field:{:d}->reg5,set_field:{:d}->reg6,strip_vlan,resubmit(,{:d})'.format(self.port_ofport, TESTING_VLAN_TAG, ovs_consts.BASE_INGRESS_TABLE), dl_dst=self.port_mac, dl_vlan=('0x%x' % TESTING_VLAN_TAG), priority=90, table=ovs_consts.TRANSIENT_TABLE)
    filter_rule = mock.call(actions='ct(commit,zone=NXM_NX_REG6[0..15]),output:{:d},resubmit(,{:d})'.format(self.port_ofport, ovs_consts.ACCEPTED_INGRESS_TRAFFIC_TABLE), dl_type='0x{:04x}'.format(n_const.ETHERTYPE_IP), nw_proto=constants.PROTO_NUM_TCP, priority=77, reg5=self.port_ofport, ct_state=ovsfw_consts.OF_STATE_NEW_NOT_ESTABLISHED, table=ovs_consts.RULES_INGRESS_TABLE, tcp_dst='0x007b')
    calls = self.mock_bridge.br.add_flow.call_args_list
    for call in (exp_ingress_classifier, exp_egress_classifier, filter_rule):
        self.assertIn(call, calls)