Add IPv6 SecurityGroup tests. 23/33823/1
authorSridhar Gaddam <sgaddam@redhat.com>
Wed, 27 Jan 2016 12:57:40 +0000 (18:27 +0530)
committerSam Hague <shague@redhat.com>
Sun, 31 Jan 2016 01:20:53 +0000 (01:20 +0000)
This patch also includes fix for Bug-5134: Address exceptions when SG
remote_group_id has both IPv4 and IPv6 addresses.

Change-Id: I25855fa0bd5fe1938efb68a459982d790f4bdb27
Signed-off-by: Sridhar Gaddam <sgaddam@redhat.com>
openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/services/EgressAclService.java
openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/services/IngressAclService.java
openstack/net-virt-providers/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/services/EgressAclServiceTest.java
openstack/net-virt-providers/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/services/IngressAclServiceTest.java

index 25405d7795c9e53cc4328e0ab9dd8d681593506f..32f00d8844dbdd28b36d23e588a33c4ccfbcf804 100644 (file)
@@ -74,6 +74,8 @@ public class EgressAclService extends AbstractServiceInstance implements EgressA
     private static final int DHCPV6_DESTINATION_PORT = 546;
     private static final String HOST_MASK = "/32";
     private static final String V6_HOST_MASK = "/128";
+    private static final String IP_VERSION_4 = "IPv4";
+    private static final String IP_VERSION_6 = "IPv6";
     private static final int PORT_RANGE_MIN = 1;
     private static final int PORT_RANGE_MAX = 65535;
 
@@ -149,15 +151,31 @@ public class EgressAclService extends AbstractServiceInstance implements EgressA
     public void programPortSecurityRule(Long dpid, String segmentationId, String attachedMac,
                                         long localPort, NeutronSecurityRule portSecurityRule,
                                         Neutron_IPs vmIp, boolean write) {
+        String securityRuleEtherType = portSecurityRule.getSecurityRuleEthertype();
+        boolean isIpv6 = securityRuleEtherType.equals(IP_VERSION_6);
+        if (!securityRuleEtherType.equals(IP_VERSION_6) && !securityRuleEtherType.equals(IP_VERSION_4)) {
+            LOG.debug("programPortSecurityRule: SecurityRuleEthertype {} does not match IPv4/v6.", securityRuleEtherType);
+            return;
+        }
+
         if (null == portSecurityRule.getSecurityRuleProtocol()) {
             /* TODO Rework on the priority values */
-            boolean isIpv6 = portSecurityRule.getSecurityRuleEthertype().equals("IPv6");
             egressAclIP(dpid, isIpv6, segmentationId, attachedMac,
                           write, Constants.PROTO_PORT_PREFIX_MATCH_PRIORITY);
         } else {
             String ipaddress = null;
             if (null != vmIp) {
                 ipaddress = vmIp.getIpAddress();
+                try {
+                    InetAddress address = InetAddress.getByName(ipaddress);
+                    if ((isIpv6 && (address instanceof Inet4Address)) || (!isIpv6 && address instanceof Inet6Address)) {
+                        LOG.debug("programPortSecurityRule: Remote vmIP {} does not match with SecurityRuleEthertype {}.", ipaddress, securityRuleEtherType);
+                        return;
+                    }
+                } catch (UnknownHostException e) {
+                    LOG.warn("Invalid IP address {}", ipaddress);
+                    return;
+                }
             }
 
             switch (portSecurityRule.getSecurityRuleProtocol()) {
@@ -430,7 +448,7 @@ public class EgressAclService extends AbstractServiceInstance implements EgressA
         boolean portRange = false;
         MatchBuilder matchBuilder = new MatchBuilder();
         String flowId = "Egress_TCP_" + segmentationId + "_" + srcMac + "_";
-        boolean isIpv6 = portSecurityRule.getSecurityRuleEthertype().equals("IPv6");
+        boolean isIpv6 = portSecurityRule.getSecurityRuleEthertype().equals(IP_VERSION_6);
         if (isIpv6) {
             matchBuilder = MatchUtils.createV6EtherMatchWithType(matchBuilder,srcMac,null);
         } else {
@@ -494,7 +512,7 @@ public class EgressAclService extends AbstractServiceInstance implements EgressA
             NeutronSecurityRule portSecurityRule, String dstAddress,
             boolean write, Integer protoPortMatchPriority) {
 
-        boolean isIpv6 = portSecurityRule.getSecurityRuleEthertype().equals("IPv6");
+        boolean isIpv6 = portSecurityRule.getSecurityRuleEthertype().equals(IP_VERSION_6);
         if (isIpv6) {
             egressAclIcmpV6(dpidLong, segmentationId, srcMac, portSecurityRule, dstAddress, write, protoPortMatchPriority);
         } else {
@@ -615,9 +633,9 @@ public class EgressAclService extends AbstractServiceInstance implements EgressA
         boolean portRange = false;
         MatchBuilder matchBuilder = new MatchBuilder();
         String flowId = "Egress_UDP_" + segmentationId + "_" + srcMac + "_";
-        boolean isIpv6 = portSecurityRule.getSecurityRuleEthertype().equals("IPv6");
+        boolean isIpv6 = portSecurityRule.getSecurityRuleEthertype().equals(IP_VERSION_6);
         if (isIpv6) {
-            matchBuilder = MatchUtils.createV6EtherMatchWithType(matchBuilder,srcMac,null);    
+            matchBuilder = MatchUtils.createV6EtherMatchWithType(matchBuilder,srcMac,null);
         } else {
             matchBuilder = MatchUtils.createV4EtherMatchWithType(matchBuilder,srcMac,null);
         }
index a185397cafbeda757ecf9860e39a555869328254..b59d9130f84cb9c3c10d8bedc08e3a184f363d5c 100644 (file)
@@ -56,6 +56,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.math.BigInteger;
+import java.net.Inet4Address;
 import java.net.Inet6Address;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
@@ -68,6 +69,8 @@ public class IngressAclService extends AbstractServiceInstance implements Ingres
     private volatile SecurityGroupCacheManger securityGroupCacheManger;
     private static final int PORT_RANGE_MIN = 1;
     private static final int PORT_RANGE_MAX = 65535;
+    private static final String IP_VERSION_4 = "IPv4";
+    private static final String IP_VERSION_6 = "IPv6";
 
     public IngressAclService() {
         super(Service.INGRESS_ACL);
@@ -141,15 +144,31 @@ public class IngressAclService extends AbstractServiceInstance implements Ingres
     public void programPortSecurityRule(Long dpid, String segmentationId, String attachedMac,
                                         long localPort, NeutronSecurityRule portSecurityRule,
                                         Neutron_IPs vmIp, boolean write) {
+        String securityRuleEtherType = portSecurityRule.getSecurityRuleEthertype();
+        boolean isIpv6 = securityRuleEtherType.equals(IP_VERSION_6);
+        if (!securityRuleEtherType.equals(IP_VERSION_6) && !securityRuleEtherType.equals(IP_VERSION_4)) {
+            LOG.debug("programPortSecurityRule: SecurityRuleEthertype {} does not match IPv4/v6.", securityRuleEtherType);
+            return;
+        }
+
         if (null == portSecurityRule.getSecurityRuleProtocol()) {
-            boolean isIpv6 = portSecurityRule.getSecurityRuleEthertype().equals("IPv6");
             ingressAclIP(dpid, isIpv6, segmentationId, attachedMac,
                          write, Constants.PROTO_PORT_PREFIX_MATCH_PRIORITY);
         } else {
             String ipaddress = null;
             if (null != vmIp) {
                 ipaddress = vmIp.getIpAddress();
-            } 
+                try {
+                    InetAddress address = InetAddress.getByName(vmIp.getIpAddress());
+                    if ((isIpv6 && (address instanceof Inet4Address)) || (!isIpv6 && address instanceof Inet6Address)) {
+                        LOG.debug("programPortSecurityRule: Remote vmIP {} does not match with SecurityRuleEthertype {}.", ipaddress, securityRuleEtherType);
+                        return;
+                    }
+                } catch(UnknownHostException e) {
+                    LOG.warn("Invalid IP address {}", ipaddress);
+                    return;
+                }
+            }
 
             switch (portSecurityRule.getSecurityRuleProtocol()) {
               case MatchUtils.TCP:
@@ -403,7 +422,7 @@ public class IngressAclService extends AbstractServiceInstance implements Ingres
         boolean portRange = false;
         MatchBuilder matchBuilder = new MatchBuilder();
         String flowId = "Ingress_TCP_" + segmentationId + "_" + dstMac + "_";
-        boolean isIpv6 = portSecurityRule.getSecurityRuleEthertype().equals("IPv6");
+        boolean isIpv6 = portSecurityRule.getSecurityRuleEthertype().equals(IP_VERSION_6);
         if (isIpv6) {
             matchBuilder = MatchUtils.createV6EtherMatchWithType(matchBuilder,null,dstMac);
         } else {
@@ -481,7 +500,7 @@ public class IngressAclService extends AbstractServiceInstance implements Ingres
                                NeutronSecurityRule portSecurityRule, String srcAddress,
                                boolean write, Integer protoPortMatchPriority ) {
         boolean portRange = false;
-        boolean isIpv6 = portSecurityRule.getSecurityRuleEthertype().equals("IPv6");
+        boolean isIpv6 = portSecurityRule.getSecurityRuleEthertype().equals(IP_VERSION_6);
         MatchBuilder matchBuilder = new MatchBuilder();
         String flowId = "Ingress_UDP_" + segmentationId + "_" + dstMac + "_";
         if (isIpv6)  {
@@ -549,7 +568,7 @@ public class IngressAclService extends AbstractServiceInstance implements Ingres
             NeutronSecurityRule portSecurityRule, String srcAddress,
             boolean write, Integer protoPortMatchPriority) {
 
-        boolean isIpv6 = portSecurityRule.getSecurityRuleEthertype().equals("IPv6");
+        boolean isIpv6 = portSecurityRule.getSecurityRuleEthertype().equals(IP_VERSION_6);
         if (isIpv6) {
             ingressAclIcmpV6(dpidLong, segmentationId, dstMac, portSecurityRule, srcAddress, write, protoPortMatchPriority);
         } else {
index 6a85018375e8f016eaccc18d36112b21dec24edf..73162c6efd3f8166768535b48b7dd91316fd913c 100644 (file)
@@ -46,6 +46,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6Match;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatch;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@@ -72,6 +73,8 @@ public class EgressAclServiceTest {
 
     @Mock private NeutronSecurityGroup securityGroup;
     @Mock private NeutronSecurityRule portSecurityRule;
+    @Mock private NeutronSecurityGroup securityGroupIpv6;
+    @Mock private NeutronSecurityRule portSecurityIpv6Rule;
 
     @Mock private SecurityServicesManager securityServices;
     @Mock private SecurityGroupCacheManger securityGroupCacheManger;
@@ -79,14 +82,20 @@ public class EgressAclServiceTest {
     private Neutron_IPs neutron_ip_src;
     private Neutron_IPs neutron_ip_dest_1;
     private Neutron_IPs neutron_ip_dest_2;
+    private Neutron_IPs neutron_ipv6_dest_1;
+    private Neutron_IPs neutron_ipv6_dest_2;
     private List<Neutron_IPs> neutronSrcIpList = new ArrayList<>();
     private List<Neutron_IPs> neutronDestIpList = new ArrayList<>();
     private static final String MAC_ADDRESS = "87:1D:5E:02:40:B7";
     private static final String SRC_IP = "192.168.0.1";
     private static final String DEST_IP_1 = "192.169.0.1";
     private static final String DEST_IP_2 = "192.169.0.2";
+    private static final String IPV6_DEST_IP_1 = "2001:db8:2::200";
+    private static final String IPV6_DEST_IP_2 = "2001:db8:2::201";
     private static final String SECURITY_GROUP_UUID = "85cc3048-abc3-43cc-89b3-377341426ac5";
     private static final String PORT_UUID = "95cc3048-abc3-43cc-89b3-377341426ac5";
+    private static final Long IPV6_ETHER_TYPE = (long) 0x86DD;
+    private static final Long IPV4_ETHER_TYPE = (long) 0x0800;
     private static final String SEGMENT_ID = "2";
     private static final Long DP_ID_LONG = (long) 1554;
     private static final Long LOCAL_PORT = (long) 124;
@@ -118,9 +127,12 @@ public class EgressAclServiceTest {
         when(orchestrator.getNextServiceInPipeline(any(Service.class))).thenReturn(Service.ARP_RESPONDER);
 
         portSecurityRule = mock(NeutronSecurityRule.class);
+        portSecurityIpv6Rule = mock(NeutronSecurityRule.class);
 
         when(portSecurityRule.getSecurityRuleEthertype()).thenReturn("IPv4");
         when(portSecurityRule.getSecurityRuleDirection()).thenReturn("egress");
+        when(portSecurityIpv6Rule.getSecurityRuleEthertype()).thenReturn("IPv6");
+        when(portSecurityIpv6Rule.getSecurityRuleDirection()).thenReturn("egress");
 
         List<NeutronSecurityRule> portSecurityList = new ArrayList<>();
         portSecurityList.add(portSecurityRule);
@@ -137,6 +149,18 @@ public class EgressAclServiceTest {
         neutron_ip_dest_2.setIpAddress(DEST_IP_2);
         neutronDestIpList.add(neutron_ip_dest_2);
 
+        List<NeutronSecurityRule> portSecurityIpv6List = new ArrayList<>();
+        portSecurityIpv6List.add(portSecurityIpv6Rule);
+        when(securityGroupIpv6.getSecurityRules()).thenReturn(portSecurityIpv6List);
+
+        neutron_ipv6_dest_1 = new Neutron_IPs();
+        neutron_ipv6_dest_1.setIpAddress(IPV6_DEST_IP_1);
+        neutronDestIpList.add(neutron_ipv6_dest_1);
+
+        neutron_ipv6_dest_2 = new Neutron_IPs();
+        neutron_ipv6_dest_2.setIpAddress(IPV6_DEST_IP_2);
+        neutronDestIpList.add(neutron_ipv6_dest_2);
+
         when(securityGroup.getSecurityRules()).thenReturn(portSecurityList);
         when(securityServices.getVmListForSecurityGroup(PORT_UUID, SECURITY_GROUP_UUID)).thenReturn(neutronDestIpList);
 
@@ -194,7 +218,24 @@ public class EgressAclServiceTest {
 
         egressAclServiceSpy.programPortSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 124, securityGroup,PORT_UUID,true);
 
-        verify(writeTransaction, times(2)).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(Node.class), eq(true));
+        verify(writeTransaction, times(1)).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(Node.class), eq(true));
+        verify(writeTransaction, times(1)).submit();
+        verify(commitFuture, times(1)).checkedGet();
+    }
+
+    /**
+     *  Test IPv6 add test case.
+     */
+    @Test
+    public void testProgramPortSecurityACLRuleAddIpv6() throws Exception {
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn(null);
+        when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(null);
+        when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(null);
+        when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn(null);
+
+        egressAclServiceSpy.programPortSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 124, securityGroupIpv6, PORT_UUID, true);
+
+        verify(writeTransaction, times(1)).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(Node.class), eq(true));
         verify(writeTransaction, times(1)).submit();
         verify(commitFuture, times(1)).checkedGet();
     }
@@ -216,7 +257,23 @@ public class EgressAclServiceTest {
     }
 
     /**
-     *  Test TCP add with port no and CIDR selected.
+     *  Test IPv6 remove test case.
+     */
+    @Test
+    public void testProgramPortSecurityACLRuleRemoveIpv6() throws Exception {
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn(null);
+        when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(null);
+        when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(null);
+        when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn(null);
+
+        egressAclServiceSpy.programPortSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 124, securityGroupIpv6, PORT_UUID, false);
+        verify(writeTransaction, times(1)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
+        verify(writeTransaction, times(1)).submit();
+        verify(commitFuture, times(1)).get();
+    }
+
+    /**
+     *  Test IPv4 TCP add with port no and CIDR selected.
      */
     @Test
     public void testProgramPortSecurityACLRuleAddTcp1() throws Exception {
@@ -232,6 +289,7 @@ public class EgressAclServiceTest {
         Match match = flowBuilder.getMatch();
         EthernetMatch ethMatch = match.getEthernetMatch();
         Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetSource().getAddress().getValue());
+        Assert.assertEquals((long) IPV4_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
 
         Assert.assertTrue(match.getLayer4Match() instanceof TcpMatch);
         TcpMatch layer4Match=(TcpMatch) match.getLayer4Match();
@@ -242,7 +300,34 @@ public class EgressAclServiceTest {
     }
 
     /**
-     *  Test TCP remove with port no and CIDR selected.
+     *  Test IPv6 TCP add with port no and CIDR selected.
+     */
+    @Test
+    public void testProgramPortSecurityACLRuleIpv6AddTcp1() throws Exception {
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("tcp");
+        when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(20);
+        when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(20);
+        when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
+        PowerMockito.doAnswer(answer()).when(egressAclServiceSpy, "writeFlow", any(FlowBuilder.class),
+                any(NodeBuilder.class));
+        egressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroupIpv6,
+                PORT_UUID, true);
+
+        Match match = flowBuilder.getMatch();
+        EthernetMatch ethMatch = match.getEthernetMatch();
+        Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetSource().getAddress().getValue());
+        Assert.assertEquals((long) IPV6_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
+
+        Assert.assertTrue(match.getLayer4Match() instanceof TcpMatch);
+        TcpMatch layer4Match=(TcpMatch) match.getLayer4Match();
+        Assert.assertEquals(20, layer4Match.getTcpDestinationPort().getValue().intValue());
+        int port=portSecurityIpv6Rule.getSecurityRulePortMin();
+        Assert.assertEquals("Egress_TCP_" + SEGMENT_ID + "_" + MAC_ADDRESS +
+                "_" + port + "_::/64_Permit", flowBuilder.getFlowName());
+    }
+
+    /**
+     *  Test IPv4 TCP remove with port no and CIDR selected.
      */
     @Test
     public void testProgramPortSecurityACLRuleRemoveTcp1() throws Exception {
@@ -259,6 +344,7 @@ public class EgressAclServiceTest {
         Match match = flowBuilder.getMatch();
         EthernetMatch ethMatch = match.getEthernetMatch();
         Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetSource().getAddress().getValue());
+        Assert.assertEquals((long) IPV4_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
 
         Assert.assertTrue(match.getLayer4Match() instanceof TcpMatch);
         TcpMatch layer4Match = (TcpMatch) match.getLayer4Match();
@@ -269,7 +355,35 @@ public class EgressAclServiceTest {
     }
 
     /**
-     *  Test TCP add with port no and remote SG selected.
+     *  Test IPv6 TCP remove with port no and CIDR selected.
+     */
+    @Test
+    public void testProgramPortSecurityACLRuleIpv6RemoveTcp1() throws Exception {
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("tcp");
+        when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(30);
+        when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(30);
+        when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
+        PowerMockito.doAnswer(answer()).when(egressAclServiceSpy, "removeFlow", any(FlowBuilder.class),
+                any(NodeBuilder.class));
+
+        egressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroupIpv6,
+                PORT_UUID, false);
+
+        Match match = flowBuilder.getMatch();
+        EthernetMatch ethMatch = match.getEthernetMatch();
+        Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetSource().getAddress().getValue());
+        Assert.assertEquals((long) IPV6_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
+
+        Assert.assertTrue(match.getLayer4Match() instanceof TcpMatch);
+        TcpMatch layer4Match = (TcpMatch) match.getLayer4Match();
+        Assert.assertEquals(30, layer4Match.getTcpDestinationPort().getValue().intValue());
+        int port=portSecurityIpv6Rule.getSecurityRulePortMin();
+        Assert.assertEquals("Egress_TCP_" + SEGMENT_ID + "_" + MAC_ADDRESS +
+                "_" + port + "_::/64_Permit", flowBuilder.getFlowName());
+    }
+
+    /**
+     *  Test IPv4 TCP add with port no and remote SG selected.
      */
     @Test
     public void testProgramPortSecurityACLRuleAddTcp2() throws Exception {
@@ -285,6 +399,7 @@ public class EgressAclServiceTest {
         Match match = flowBuilder.getMatch();
         EthernetMatch ethMatch = match.getEthernetMatch();
         Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetSource().getAddress().getValue());
+        Assert.assertEquals((long) IPV4_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
 
         Assert.assertTrue(match.getLayer4Match() instanceof TcpMatch);
         TcpMatch layer4Match=(TcpMatch) match.getLayer4Match();
@@ -302,7 +417,41 @@ public class EgressAclServiceTest {
     }
 
     /**
-     *  Test TCP remove with port no and remote SG selected.
+     *  Test IPv6 TCP add with port no and remote SG selected.
+     */
+    @Test
+    public void testProgramPortSecurityACLRuleIpv6AddTcp2() throws Exception {
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("tcp");
+        when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(40);
+        when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(40);
+        when(portSecurityIpv6Rule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
+        PowerMockito.doAnswer(answer()).when(egressAclServiceSpy, "writeFlow", any(FlowBuilder.class),
+                any(NodeBuilder.class));
+        egressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroupIpv6,
+                PORT_UUID, true);
+
+        Match match = flowBuilder.getMatch();
+        EthernetMatch ethMatch = match.getEthernetMatch();
+        Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetSource().getAddress().getValue());
+        Assert.assertEquals((long) IPV6_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
+
+        Assert.assertTrue(match.getLayer4Match() instanceof TcpMatch);
+        TcpMatch layer4Match=(TcpMatch) match.getLayer4Match();
+        int port=portSecurityIpv6Rule.getSecurityRulePortMin();
+        String expectedFlowId1 = "Egress_TCP_" + SEGMENT_ID + "_" + MAC_ADDRESS + "_" + port + "_" + IPV6_DEST_IP_1 +
+                "_Permit";
+        String expectedFlowId2 = "Egress_TCP_" + SEGMENT_ID + "_" + MAC_ADDRESS + "_" + port + "_" + IPV6_DEST_IP_2 +
+                "_Permit";
+        String actualFlowId = flowBuilder.getFlowName();
+        if(actualFlowId.equals(expectedFlowId1) || actualFlowId.equals(expectedFlowId2)) {
+            Assert.assertTrue(true);
+        } else {
+            Assert.assertTrue(false);
+        }
+    }
+
+    /**
+     *  Test IPv4 TCP remove with port no and remote SG selected.
      */
     @Test
     public void testProgramPortSecurityACLRuleRemoveTcp2() throws Exception {
@@ -319,6 +468,7 @@ public class EgressAclServiceTest {
         Match match = flowBuilder.getMatch();
         EthernetMatch ethMatch = match.getEthernetMatch();
         Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetSource().getAddress().getValue());
+        Assert.assertEquals((long) IPV4_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
 
         Assert.assertTrue(match.getLayer4Match() instanceof TcpMatch);
         TcpMatch layer4Match=(TcpMatch) match.getLayer4Match();
@@ -336,7 +486,42 @@ public class EgressAclServiceTest {
     }
 
     /**
-     *  Test TCP add with port range (All TCP) and CIDR selected.
+     *  Test IPv6 TCP remove with port no and remote SG selected.
+     */
+    @Test
+    public void testProgramPortSecurityACLRuleIpv6RemoveTcp2() throws Exception {
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("tcp");
+        when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(50);
+        when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(50);
+        when(portSecurityIpv6Rule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
+        PowerMockito.doAnswer(answer()).when(egressAclServiceSpy, "removeFlow", any(FlowBuilder.class),
+                any(NodeBuilder.class));
+
+        egressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroupIpv6,
+                PORT_UUID, false);
+
+        Match match = flowBuilder.getMatch();
+        EthernetMatch ethMatch = match.getEthernetMatch();
+        Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetSource().getAddress().getValue());
+        Assert.assertEquals((long) IPV6_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
+
+        Assert.assertTrue(match.getLayer4Match() instanceof TcpMatch);
+        TcpMatch layer4Match=(TcpMatch) match.getLayer4Match();
+        int port=portSecurityIpv6Rule.getSecurityRulePortMin();
+        String expectedFlowId1 = "Egress_TCP_" + SEGMENT_ID + "_" + MAC_ADDRESS +"_" + port + "_" + IPV6_DEST_IP_1 +
+                "_Permit";
+        String expectedFlowId2 = "Egress_TCP_" + SEGMENT_ID + "_" + MAC_ADDRESS +"_" + port + "_" + IPV6_DEST_IP_2 +
+                "_Permit";
+        String actualFlowId = flowBuilder.getFlowName();
+        if(actualFlowId.equals(expectedFlowId1) || actualFlowId.equals(expectedFlowId2)) {
+            Assert.assertTrue(true);
+        } else {
+            Assert.assertTrue(false);
+        }
+    }
+
+    /**
+     *  Test IPv4 TCP add with port range (All TCP) and CIDR selected.
      */
     @Test
     public void testProgramPortSecurityACLRuleAddTcpAll1() throws Exception {
@@ -354,10 +539,33 @@ public class EgressAclServiceTest {
         TcpMatch layer4Match=(TcpMatch) match.getLayer4Match();
         EthernetMatch ethMatch = match.getEthernetMatch();
         Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetSource().getAddress().getValue());
+        Assert.assertEquals((long) IPV4_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
+    }
+
+    /**
+     *  Test IPv6 TCP add with port range (All TCP) and CIDR selected.
+     */
+    @Test
+    public void testProgramPortSecurityACLRuleIpv6AddTcpAll1() throws Exception {
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("tcp");
+        when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(PORT_RANGE_MAX);
+        when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(PORT_RANGE_MIN);
+        when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
+        PowerMockito.doAnswer(answer()).when(egressAclServiceSpy, "writeFlow", any(FlowBuilder.class),
+                any(NodeBuilder.class));
+        egressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroupIpv6,
+                PORT_UUID, true);
+
+        Match match = flowBuilder.getMatch();
+        Assert.assertTrue(match.getLayer4Match() instanceof TcpMatch);
+        TcpMatch layer4Match=(TcpMatch) match.getLayer4Match();
+        EthernetMatch ethMatch = match.getEthernetMatch();
+        Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetSource().getAddress().getValue());
+        Assert.assertEquals((long) IPV6_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
     }
 
     /**
-     *  Test TCP remove with port range (All TCP) and CIDR selected.
+     *  Test IPv4 TCP remove with port range (All TCP) and CIDR selected.
      */
     @Test
     public void testProgramPortSecurityACLRuleRemoveTcpAll1() throws Exception {
@@ -374,14 +582,38 @@ public class EgressAclServiceTest {
         Match match = flowBuilder.getMatch();
         EthernetMatch ethMatch = match.getEthernetMatch();
         Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetSource().getAddress().getValue());
-
+        Assert.assertEquals((long) IPV4_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
         Assert.assertTrue(match.getLayer4Match() instanceof TcpMatch);
         Assert.assertEquals("Egress_TCP_" + SEGMENT_ID + "_" + MAC_ADDRESS + "_" + PORT_RANGE_MIN + "_" +
                             PORT_RANGE_MAX + "_0.0.0.0/24_Permit", flowBuilder.getFlowName());
     }
 
     /**
-     *  Test TCP add with port range (All TCP) and remote SG selected.
+     *  Test IPv6 TCP remove with port range (All TCP) and CIDR selected.
+     */
+    @Test
+    public void testProgramPortSecurityACLRuleIpv6RemoveTcpAll1() throws Exception {
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("tcp");
+        when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(PORT_RANGE_MAX);
+        when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(PORT_RANGE_MIN);
+        when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
+        PowerMockito.doAnswer(answer()).when(egressAclServiceSpy, "removeFlow", any(FlowBuilder.class),
+                any(NodeBuilder.class));
+
+        egressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroupIpv6,
+                PORT_UUID, false);
+
+        Match match = flowBuilder.getMatch();
+        EthernetMatch ethMatch = match.getEthernetMatch();
+        Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetSource().getAddress().getValue());
+        Assert.assertEquals((long) IPV6_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
+        Assert.assertTrue(match.getLayer4Match() instanceof TcpMatch);
+        Assert.assertEquals("Egress_TCP_" + SEGMENT_ID + "_" + MAC_ADDRESS + "_" + PORT_RANGE_MIN + "_" +
+                PORT_RANGE_MAX + "_::/64_Permit", flowBuilder.getFlowName());
+    }
+
+    /**
+     *  Test IPv4 TCP add with port range (All TCP) and remote SG selected.
      */
     @Test
     public void testProgramPortSecurityACLRuleAddTcpAll2() throws Exception {
@@ -397,6 +629,7 @@ public class EgressAclServiceTest {
         Match match = flowBuilder.getMatch();
         EthernetMatch ethMatch = match.getEthernetMatch();
         Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetSource().getAddress().getValue());
+        Assert.assertEquals((long) IPV4_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
 
         Assert.assertTrue(match.getLayer4Match() instanceof TcpMatch);
         String expectedFlowId1 = "Egress_TCP_" + SEGMENT_ID + "_" + MAC_ADDRESS + "_" + PORT_RANGE_MIN + "_" +
@@ -412,7 +645,39 @@ public class EgressAclServiceTest {
     }
 
     /**
-     *  Test TCP remove with port range (All TCP) and remote SG selected.
+     *  Test IPv6 TCP add with port range (All TCP) and remote SG selected.
+     */
+    @Test
+    public void testProgramPortSecurityACLRuleIpv6AddTcpAll2() throws Exception {
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("tcp");
+        when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(PORT_RANGE_MAX);
+        when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(PORT_RANGE_MIN);
+        when(portSecurityIpv6Rule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
+        PowerMockito.doAnswer(answer()).when(egressAclServiceSpy, "writeFlow", any(FlowBuilder.class),
+                any(NodeBuilder.class));
+        egressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroupIpv6,
+                PORT_UUID, true);
+
+        Match match = flowBuilder.getMatch();
+        EthernetMatch ethMatch = match.getEthernetMatch();
+        Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetSource().getAddress().getValue());
+        Assert.assertEquals((long) IPV6_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
+
+        Assert.assertTrue(match.getLayer4Match() instanceof TcpMatch);
+        String expectedFlowId1 = "Egress_TCP_" + SEGMENT_ID + "_" + MAC_ADDRESS + "_" + PORT_RANGE_MIN + "_" +
+                PORT_RANGE_MAX + "_" + IPV6_DEST_IP_1 + "_Permit";
+        String expectedFlowId2 = "Egress_TCP_" + SEGMENT_ID + "_" + MAC_ADDRESS + "_" + PORT_RANGE_MIN + "_" +
+                PORT_RANGE_MAX + "_" + IPV6_DEST_IP_2 + "_Permit";
+        String actualFlowId = flowBuilder.getFlowName();
+        if(actualFlowId.equals(expectedFlowId1) || actualFlowId.equals(expectedFlowId2)) {
+            Assert.assertTrue(true);
+        } else {
+            Assert.assertTrue(false);
+        }
+    }
+
+    /**
+     *  Test IPv4 TCP remove with port range (All TCP) and remote SG selected.
      */
     @Test
     public void testProgramPortSecurityACLRuleRemoveTcpAll2() throws Exception {
@@ -429,6 +694,7 @@ public class EgressAclServiceTest {
         Match match = flowBuilder.getMatch();
         EthernetMatch ethMatch = match.getEthernetMatch();
         Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetSource().getAddress().getValue());
+        Assert.assertEquals((long) IPV4_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
 
         Assert.assertTrue(match.getLayer4Match() instanceof TcpMatch);
         String expectedFlowId1 = "Egress_TCP_" + SEGMENT_ID + "_" + MAC_ADDRESS + "_" + PORT_RANGE_MIN + "_" +
@@ -444,7 +710,40 @@ public class EgressAclServiceTest {
     }
 
     /**
-     *  Test UDP add with port no and CIDR selected.
+     *  Test IPv6 TCP remove with port range (All TCP) and remote SG selected.
+     */
+    @Test
+    public void testProgramPortSecurityACLRuleIpv6RemoveTcpAll2() throws Exception {
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("tcp");
+        when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(PORT_RANGE_MAX);
+        when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(PORT_RANGE_MIN);
+        when(portSecurityIpv6Rule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
+        PowerMockito.doAnswer(answer()).when(egressAclServiceSpy, "removeFlow", any(FlowBuilder.class),
+                any(NodeBuilder.class));
+
+        egressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroupIpv6,
+                PORT_UUID, false);
+
+        Match match = flowBuilder.getMatch();
+        EthernetMatch ethMatch = match.getEthernetMatch();
+        Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetSource().getAddress().getValue());
+        Assert.assertEquals((long) IPV6_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
+
+        Assert.assertTrue(match.getLayer4Match() instanceof TcpMatch);
+        String expectedFlowId1 = "Egress_TCP_" + SEGMENT_ID + "_" + MAC_ADDRESS + "_" + PORT_RANGE_MIN + "_" +
+                PORT_RANGE_MAX + "_" + IPV6_DEST_IP_1 + "_Permit";
+        String expectedFlowId2 = "Egress_TCP_" + SEGMENT_ID + "_" + MAC_ADDRESS + "_" + PORT_RANGE_MIN + "_" +
+                PORT_RANGE_MAX + "_" + IPV6_DEST_IP_2 + "_Permit";
+        String actualFlowId = flowBuilder.getFlowName();
+        if(actualFlowId.equals(expectedFlowId1) || actualFlowId.equals(expectedFlowId2)) {
+            Assert.assertTrue(true);
+        } else {
+            Assert.assertTrue(false);
+        }
+    }
+
+    /**
+     *  Test IPv4 UDP add with port no and CIDR selected.
      */
     @Test
     public void testProgramPortSecurityACLRuleAddUdp1() throws Exception {
@@ -460,6 +759,7 @@ public class EgressAclServiceTest {
         Match match = flowBuilder.getMatch();
         EthernetMatch ethMatch = match.getEthernetMatch();
         Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetSource().getAddress().getValue());
+        Assert.assertEquals((long) IPV4_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
 
         Assert.assertTrue(match.getLayer4Match() instanceof UdpMatch);
         UdpMatch layer4Match = (UdpMatch) match.getLayer4Match();
@@ -470,7 +770,34 @@ public class EgressAclServiceTest {
     }
 
     /**
-     *  Test UDP remove with port no and CIDR selected.
+     *  Test IPv6 UDP add with port no and CIDR selected.
+     */
+    @Test
+    public void testProgramPortSecurityACLRuleIpv6AddUdp1() throws Exception {
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("udp");
+        when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(50);
+        when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(50);
+        when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
+        PowerMockito.doAnswer(answer()).when(egressAclServiceSpy, "writeFlow", any(FlowBuilder.class),
+                any(NodeBuilder.class));
+        egressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroupIpv6,
+                PORT_UUID, true);
+
+        Match match = flowBuilder.getMatch();
+        EthernetMatch ethMatch = match.getEthernetMatch();
+        Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetSource().getAddress().getValue());
+        Assert.assertEquals((long) IPV6_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
+
+        Assert.assertTrue(match.getLayer4Match() instanceof UdpMatch);
+        UdpMatch layer4Match = (UdpMatch) match.getLayer4Match();
+        Assert.assertEquals(50, layer4Match.getUdpDestinationPort().getValue().intValue());
+        int port = portSecurityIpv6Rule.getSecurityRulePortMin();
+        Assert.assertEquals("Egress_UDP_" + SEGMENT_ID + "_" + MAC_ADDRESS +
+                "_" + port + "_::/64_Permit", flowBuilder.getFlowName());
+    }
+
+    /**
+     *  Test IPv4 UDP remove with port no and CIDR selected.
      */
     @Test
     public void testProgramPortSecurityACLRuleRemoveUdp1() throws Exception {
@@ -486,6 +813,7 @@ public class EgressAclServiceTest {
         Match match = flowBuilder.getMatch();
         EthernetMatch ethMatch = match.getEthernetMatch();
         Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetSource().getAddress().getValue());
+        Assert.assertEquals((long) IPV4_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
 
         Assert.assertTrue(match.getLayer4Match() instanceof UdpMatch);
         UdpMatch layer4Match = (UdpMatch) match.getLayer4Match();
@@ -496,7 +824,34 @@ public class EgressAclServiceTest {
     }
 
     /**
-     *  Test UDP add with port no and remote SG selected.
+     *  Test IPv6 UDP remove with port no and CIDR selected.
+     */
+    @Test
+    public void testProgramPortSecurityACLRuleIpv6RemoveUdp1() throws Exception {
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("udp");
+        when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(50);
+        when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(50);
+        when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
+        PowerMockito.doAnswer(answer()).when(egressAclServiceSpy, "removeFlow", any(FlowBuilder.class),
+                any(NodeBuilder.class));
+        egressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroupIpv6,
+                PORT_UUID, false);
+
+        Match match = flowBuilder.getMatch();
+        EthernetMatch ethMatch = match.getEthernetMatch();
+        Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetSource().getAddress().getValue());
+        Assert.assertEquals((long) IPV6_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
+
+        Assert.assertTrue(match.getLayer4Match() instanceof UdpMatch);
+        UdpMatch layer4Match = (UdpMatch) match.getLayer4Match();
+        Assert.assertEquals(50, layer4Match.getUdpDestinationPort().getValue().intValue());
+        int port = portSecurityIpv6Rule.getSecurityRulePortMin();
+        Assert.assertEquals("Egress_UDP_" + SEGMENT_ID + "_" + MAC_ADDRESS +
+                "_" + port + "_::/64_Permit", flowBuilder.getFlowName());
+    }
+
+    /**
+     *  Test IPv4 UDP add with port no and remote SG selected.
      */
     @Test
     public void testProgramPortSecurityACLRuleAddUdp2() throws Exception {
@@ -513,6 +868,7 @@ public class EgressAclServiceTest {
         Match match = flowBuilder.getMatch();
         EthernetMatch ethMatch = match.getEthernetMatch();
         Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetSource().getAddress().getValue());
+        Assert.assertEquals((long) IPV4_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
 
         Assert.assertTrue(match.getLayer4Match() instanceof UdpMatch);
         UdpMatch layer4Match = (UdpMatch) match.getLayer4Match();
@@ -531,7 +887,43 @@ public class EgressAclServiceTest {
     }
 
     /**
-     *  Test UDP remove with port no and remote SG selected.
+     *  Test IPv6 UDP add with port no and remote SG selected.
+     */
+    @Test
+    public void testProgramPortSecurityACLRuleIpv6AddUdp2() throws Exception {
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("udp");
+        when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(50);
+        when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(50);
+        when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
+        when(portSecurityIpv6Rule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
+        PowerMockito.doAnswer(answer()).when(egressAclServiceSpy, "writeFlow", any(FlowBuilder.class),
+                any(NodeBuilder.class));
+        egressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroupIpv6,
+                PORT_UUID, true);
+
+        Match match = flowBuilder.getMatch();
+        EthernetMatch ethMatch = match.getEthernetMatch();
+        Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetSource().getAddress().getValue());
+        Assert.assertEquals((long) IPV6_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
+
+        Assert.assertTrue(match.getLayer4Match() instanceof UdpMatch);
+        UdpMatch layer4Match = (UdpMatch) match.getLayer4Match();
+        Assert.assertEquals(50, layer4Match.getUdpDestinationPort().getValue().intValue());
+        int port = portSecurityIpv6Rule.getSecurityRulePortMin();
+        String expectedFlowId1 = "Egress_UDP_" + SEGMENT_ID + "_" + MAC_ADDRESS + "_" + port + "_" + IPV6_DEST_IP_1 +
+                "_Permit";
+        String expectedFlowId2 = "Egress_UDP_" + SEGMENT_ID + "_" + MAC_ADDRESS + "_" + port + "_" + IPV6_DEST_IP_2 +
+                "_Permit";
+        String actualFlowId = flowBuilder.getFlowName();
+        if(actualFlowId.equals(expectedFlowId1) || actualFlowId.equals(expectedFlowId2)) {
+            Assert.assertTrue(true);
+        } else {
+            Assert.assertTrue(false);
+        }
+    }
+
+    /**
+     *  Test IPv4 UDP remove with port no and remote SG selected.
      */
     @Test
     public void testProgramPortSecurityACLRuleRemoveUdp2() throws Exception {
@@ -548,6 +940,7 @@ public class EgressAclServiceTest {
         Match match = flowBuilder.getMatch();
         EthernetMatch ethMatch = match.getEthernetMatch();
         Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetSource().getAddress().getValue());
+        Assert.assertEquals((long) IPV4_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
 
         Assert.assertTrue(match.getLayer4Match() instanceof UdpMatch);
         UdpMatch layer4Match = (UdpMatch) match.getLayer4Match();
@@ -566,7 +959,43 @@ public class EgressAclServiceTest {
     }
 
     /**
-     *  Test UDP add with port (All UDP) and CIDR selected.
+     *  Test IPv6 UDP remove with port no and remote SG selected.
+     */
+    @Test
+    public void testProgramPortSecurityACLRuleIpv6RemoveUdp2() throws Exception {
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("udp");
+        when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(50);
+        when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(50);
+        when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
+        when(portSecurityIpv6Rule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
+        PowerMockito.doAnswer(answer()).when(egressAclServiceSpy, "removeFlow", any(FlowBuilder.class),
+                any(NodeBuilder.class));
+        egressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroupIpv6,
+                PORT_UUID, false);
+
+        Match match = flowBuilder.getMatch();
+        EthernetMatch ethMatch = match.getEthernetMatch();
+        Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetSource().getAddress().getValue());
+        Assert.assertEquals((long) IPV6_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
+
+        Assert.assertTrue(match.getLayer4Match() instanceof UdpMatch);
+        UdpMatch layer4Match = (UdpMatch) match.getLayer4Match();
+        Assert.assertEquals(50, layer4Match.getUdpDestinationPort().getValue().intValue());
+        int port = portSecurityIpv6Rule.getSecurityRulePortMin();
+        String expectedFlowId1 = "Egress_UDP_" + SEGMENT_ID + "_" + MAC_ADDRESS + "_" + port + "_" + IPV6_DEST_IP_1 +
+                "_Permit";
+        String expectedFlowId2 = "Egress_UDP_" + SEGMENT_ID + "_" + MAC_ADDRESS + "_" + port + "_" + IPV6_DEST_IP_2 +
+                "_Permit";
+        String actualFlowId = flowBuilder.getFlowName();
+        if(actualFlowId.equals(expectedFlowId1) || actualFlowId.equals(expectedFlowId2)) {
+            Assert.assertTrue(true);
+        } else {
+            Assert.assertTrue(false);
+        }
+    }
+
+    /**
+     *  Test IPv4 UDP add with port (All UDP) and CIDR selected.
      */
     @Test
     public void testProgramPortSecurityACLRuleAddUdpAll1() throws Exception {
@@ -582,6 +1011,7 @@ public class EgressAclServiceTest {
         Match match = flowBuilder.getMatch();
         EthernetMatch ethMatch = match.getEthernetMatch();
         Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetSource().getAddress().getValue());
+        Assert.assertEquals((long) IPV4_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
 
         Assert.assertTrue(match.getLayer4Match() instanceof UdpMatch);
         Assert.assertEquals("Egress_UDP_" + SEGMENT_ID + "_" + MAC_ADDRESS + "_" + PORT_RANGE_MIN + "_" +
@@ -589,7 +1019,31 @@ public class EgressAclServiceTest {
     }
 
     /**
-     *  Test UDP remove with port (All UDP) and CIDR selected.
+     *  Test IPv6 UDP add with port (All UDP) and CIDR selected.
+     */
+    @Test
+    public void testProgramPortSecurityACLRuleIpv6AddUdpAll1() throws Exception {
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("udp");
+        when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(PORT_RANGE_MAX);
+        when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(PORT_RANGE_MIN);
+        when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
+        PowerMockito.doAnswer(answer()).when(egressAclServiceSpy, "writeFlow", any(FlowBuilder.class),
+                any(NodeBuilder.class));
+        egressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroupIpv6,
+                PORT_UUID, true);
+
+        Match match = flowBuilder.getMatch();
+        EthernetMatch ethMatch = match.getEthernetMatch();
+        Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetSource().getAddress().getValue());
+        Assert.assertEquals((long) IPV6_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
+
+        Assert.assertTrue(match.getLayer4Match() instanceof UdpMatch);
+        Assert.assertEquals("Egress_UDP_" + SEGMENT_ID + "_" + MAC_ADDRESS + "_" + PORT_RANGE_MIN + "_" +
+                PORT_RANGE_MAX + "_::/64_Permit", flowBuilder.getFlowName());
+    }
+
+    /**
+     *  Test IPv4 UDP remove with port (All UDP) and CIDR selected.
      */
     @Test
     public void testProgramPortSecurityACLRuleRemoveUdpAll1() throws Exception {
@@ -605,6 +1059,7 @@ public class EgressAclServiceTest {
         Match match = flowBuilder.getMatch();
         EthernetMatch ethMatch = match.getEthernetMatch();
         Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetSource().getAddress().getValue());
+        Assert.assertEquals((long) IPV4_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
 
         Assert.assertTrue(match.getLayer4Match() instanceof UdpMatch);
         Assert.assertEquals("Egress_UDP_" + SEGMENT_ID + "_" + MAC_ADDRESS + "_" + PORT_RANGE_MIN + "_" +
@@ -612,7 +1067,31 @@ public class EgressAclServiceTest {
     }
 
     /**
-     *  Test UDP add with port (All UDP) and remote SG selected.
+     *  Test IPv6 UDP remove with port (All UDP) and CIDR selected.
+     */
+    @Test
+    public void testProgramPortSecurityACLRuleIpv6RemoveUdpAll1() throws Exception {
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("udp");
+        when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(PORT_RANGE_MAX);
+        when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(PORT_RANGE_MIN);
+        when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
+        PowerMockito.doAnswer(answer()).when(egressAclServiceSpy, "removeFlow", any(FlowBuilder.class),
+                any(NodeBuilder.class));
+        egressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroupIpv6,
+                PORT_UUID, false);
+
+        Match match = flowBuilder.getMatch();
+        EthernetMatch ethMatch = match.getEthernetMatch();
+        Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetSource().getAddress().getValue());
+        Assert.assertEquals((long) IPV6_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
+
+        Assert.assertTrue(match.getLayer4Match() instanceof UdpMatch);
+        Assert.assertEquals("Egress_UDP_" + SEGMENT_ID + "_" + MAC_ADDRESS + "_" + PORT_RANGE_MIN + "_" +
+                PORT_RANGE_MAX + "_::/64_Permit", flowBuilder.getFlowName());
+    }
+
+    /**
+     *  Test IPv4 UDP add with port (All UDP) and remote SG selected.
      */
     @Test
     public void testProgramPortSecurityACLRuleAddUdpAll2() throws Exception {
@@ -628,6 +1107,7 @@ public class EgressAclServiceTest {
         Match match = flowBuilder.getMatch();
         EthernetMatch ethMatch = match.getEthernetMatch();
         Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetSource().getAddress().getValue());
+        Assert.assertEquals((long) IPV4_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
 
         Assert.assertTrue(match.getLayer4Match() instanceof UdpMatch);
         String expectedFlowId1 = "Egress_UDP_" + SEGMENT_ID + "_" + MAC_ADDRESS + "_" + PORT_RANGE_MIN + "_" +
@@ -643,7 +1123,39 @@ public class EgressAclServiceTest {
     }
 
     /**
-     *  Test UDP remove with port (All UDP) and remote SG selected.
+     *  Test IPv6 UDP add with port (All UDP) and remote SG selected.
+     */
+    @Test
+    public void testProgramPortSecurityACLRuleIpv6AddUdpAll2() throws Exception {
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("udp");
+        when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(PORT_RANGE_MAX);
+        when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(PORT_RANGE_MIN);
+        when(portSecurityIpv6Rule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
+        PowerMockito.doAnswer(answer()).when(egressAclServiceSpy, "writeFlow", any(FlowBuilder.class),
+                any(NodeBuilder.class));
+        egressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroupIpv6,
+                PORT_UUID, true);
+
+        Match match = flowBuilder.getMatch();
+        EthernetMatch ethMatch = match.getEthernetMatch();
+        Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetSource().getAddress().getValue());
+        Assert.assertEquals((long) IPV6_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
+
+        Assert.assertTrue(match.getLayer4Match() instanceof UdpMatch);
+        String expectedFlowId1 = "Egress_UDP_" + SEGMENT_ID + "_" + MAC_ADDRESS + "_" + PORT_RANGE_MIN + "_" +
+                PORT_RANGE_MAX + "_" + IPV6_DEST_IP_1 + "_Permit";
+        String expectedFlowId2 = "Egress_UDP_" + SEGMENT_ID + "_" + MAC_ADDRESS + "_" + PORT_RANGE_MIN + "_" +
+                PORT_RANGE_MAX + "_" + IPV6_DEST_IP_2 + "_Permit";
+        String actualFlowId = flowBuilder.getFlowName();
+        if(actualFlowId.equals(expectedFlowId1) || actualFlowId.equals(expectedFlowId2)) {
+            Assert.assertTrue(true);
+        } else {
+            Assert.assertTrue(false);
+        }
+    }
+
+    /**
+     *  Test IPv4 UDP remove with port (All UDP) and remote SG selected.
      */
     @Test
     public void testProgramPortSecurityACLRuleRemoveUdpAll2() throws Exception {
@@ -659,6 +1171,7 @@ public class EgressAclServiceTest {
         Match match = flowBuilder.getMatch();
         EthernetMatch ethMatch = match.getEthernetMatch();
         Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetSource().getAddress().getValue());
+        Assert.assertEquals((long) IPV4_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
 
         Assert.assertTrue(match.getLayer4Match() instanceof UdpMatch);
         String expectedFlowId1 = "Egress_UDP_" + SEGMENT_ID + "_" + MAC_ADDRESS + "_" + PORT_RANGE_MIN + "_" +
@@ -673,6 +1186,38 @@ public class EgressAclServiceTest {
         }
     }
 
+    /**
+     *  Test IPv6 UDP remove with port (All UDP) and remote SG selected.
+     */
+    @Test
+    public void testProgramPortSecurityACLRuleIpv6RemoveUdpAll2() throws Exception {
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("udp");
+        when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(PORT_RANGE_MAX);
+        when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(PORT_RANGE_MIN);
+        when(portSecurityIpv6Rule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
+        PowerMockito.doAnswer(answer()).when(egressAclServiceSpy, "removeFlow", any(FlowBuilder.class),
+                any(NodeBuilder.class));
+        egressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroupIpv6,
+                PORT_UUID, false);
+
+        Match match = flowBuilder.getMatch();
+        EthernetMatch ethMatch = match.getEthernetMatch();
+        Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetSource().getAddress().getValue());
+        Assert.assertEquals((long) IPV6_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
+
+        Assert.assertTrue(match.getLayer4Match() instanceof UdpMatch);
+        String expectedFlowId1 = "Egress_UDP_" + SEGMENT_ID + "_" + MAC_ADDRESS + "_" + PORT_RANGE_MIN + "_" +
+                PORT_RANGE_MAX + "_" + IPV6_DEST_IP_1 + "_Permit";
+        String expectedFlowId2 = "Egress_UDP_" + SEGMENT_ID + "_" + MAC_ADDRESS + "_" + PORT_RANGE_MIN + "_" +
+                PORT_RANGE_MAX + "_" + IPV6_DEST_IP_2 + "_Permit";
+        String actualFlowId = flowBuilder.getFlowName();
+        if(actualFlowId.equals(expectedFlowId1) || actualFlowId.equals(expectedFlowId2)) {
+            Assert.assertTrue(true);
+        } else {
+            Assert.assertTrue(false);
+        }
+    }
+
     /**
      *  Test ICMP add with code, type and CIDR selected.
      */
@@ -694,12 +1239,41 @@ public class EgressAclServiceTest {
         Assert.assertEquals(10, icmpv4Match.getIcmpv4Code().shortValue());
         EthernetMatch ethMatch = match.getEthernetMatch();
         Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetSource().getAddress().getValue());
+        Assert.assertEquals((long) IPV4_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
         Short type = portSecurityRule.getSecurityRulePortMin().shortValue();
         Short code = portSecurityRule.getSecurityRulePortMax().shortValue();
         Assert.assertEquals("Egress_ICMP_" + SEGMENT_ID + "_" + MAC_ADDRESS +
                             "_" + type + "_" + code + "_0.0.0.0/24_Permit", flowBuilder.getFlowName());
     }
 
+    /**
+     *  Test ICMPv6 add with code, type and CIDR selected.
+     */
+    @Test
+    public void testProgramPortSecurityACLRuleIpv6AddIcmp1() throws Exception {
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("icmpv6");
+        when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(10);
+        when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(10);
+        when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
+        PowerMockito.doAnswer(answer()).when(egressAclServiceSpy, "writeFlow", any(FlowBuilder.class),
+                any(NodeBuilder.class));
+
+        egressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroupIpv6,
+                PORT_UUID, true);
+
+        Match match = flowBuilder.getMatch();
+        Icmpv6Match icmpv6Match = match.getIcmpv6Match();
+        Assert.assertEquals(10, icmpv6Match.getIcmpv6Type().shortValue());
+        Assert.assertEquals(10, icmpv6Match.getIcmpv6Code().shortValue());
+        EthernetMatch ethMatch = match.getEthernetMatch();
+        Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetSource().getAddress().getValue());
+        Assert.assertEquals((long) IPV6_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
+        Short type = portSecurityIpv6Rule.getSecurityRulePortMin().shortValue();
+        Short code = portSecurityIpv6Rule.getSecurityRulePortMax().shortValue();
+        Assert.assertEquals("Egress_ICMP_" + SEGMENT_ID + "_" + MAC_ADDRESS +
+                "_" + type + "_" + code + "_::/64_Permit", flowBuilder.getFlowName());
+    }
+
     /**
      *  Test ICMP remove with code, type and CIDR selected.
      */
@@ -721,12 +1295,41 @@ public class EgressAclServiceTest {
         Assert.assertEquals(20, icmpv4Match.getIcmpv4Code().shortValue());
         EthernetMatch ethMatch = match.getEthernetMatch();
         Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetSource().getAddress().getValue());
+        Assert.assertEquals((long) IPV4_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
         Short type = portSecurityRule.getSecurityRulePortMin().shortValue();
         Short code = portSecurityRule.getSecurityRulePortMax().shortValue();
         Assert.assertEquals("Egress_ICMP_" + SEGMENT_ID + "_" + MAC_ADDRESS +
                             "_" + type + "_" + code + "_0.0.0.0/24_Permit", flowBuilder.getFlowName());
     }
 
+    /**
+     *  Test ICMPv6 remove with code, type and CIDR selected.
+     */
+    @Test
+    public void testProgramPortSecurityACLRuleIpv6RemoveIcmp1() throws Exception {
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("icmpv6");
+        when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(20);
+        when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(20);
+        when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
+        PowerMockito.doAnswer(answer()).when(egressAclServiceSpy, "removeFlow", any(FlowBuilder.class),
+                any(NodeBuilder.class));
+
+        egressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroupIpv6,
+                PORT_UUID, false);
+
+        Match match = flowBuilder.getMatch();
+        Icmpv6Match icmpv6Match = match.getIcmpv6Match();
+        Assert.assertEquals(20, icmpv6Match.getIcmpv6Type().shortValue());
+        Assert.assertEquals(20, icmpv6Match.getIcmpv6Code().shortValue());
+        EthernetMatch ethMatch = match.getEthernetMatch();
+        Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetSource().getAddress().getValue());
+        Assert.assertEquals((long) IPV6_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
+        Short type = portSecurityIpv6Rule.getSecurityRulePortMin().shortValue();
+        Short code = portSecurityIpv6Rule.getSecurityRulePortMax().shortValue();
+        Assert.assertEquals("Egress_ICMP_" + SEGMENT_ID + "_" + MAC_ADDRESS +
+                "_" + type + "_" + code + "_::/64_Permit", flowBuilder.getFlowName());
+    }
+
     /**
      *  Test ICMP add with code, type and remote SG selected.
      */
@@ -749,6 +1352,7 @@ public class EgressAclServiceTest {
         Assert.assertEquals(30, icmpv4Match.getIcmpv4Code().shortValue());
         EthernetMatch ethMatch = match.getEthernetMatch();
         Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetSource().getAddress().getValue());
+        Assert.assertEquals((long) IPV4_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
         Short type = portSecurityRule.getSecurityRulePortMin().shortValue();
         Short code = portSecurityRule.getSecurityRulePortMax().shortValue();
         String expectedFlowId1 = "Egress_ICMP_" + SEGMENT_ID + "_" + MAC_ADDRESS + "_" + type + "_" + code + "_"
@@ -763,6 +1367,43 @@ public class EgressAclServiceTest {
         }
     }
 
+    /**
+     *  Test ICMPv6 add with code, type and remote SG selected.
+     */
+    @Test
+    public void testProgramPortSecurityACLRuleIpv6AddIcmp2() throws Exception {
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("icmpv6");
+        when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(30);
+        when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(30);
+        when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
+        when(portSecurityIpv6Rule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
+        PowerMockito.doAnswer(answer()).when(egressAclServiceSpy, "writeFlow", any(FlowBuilder.class),
+                any(NodeBuilder.class));
+
+        egressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroupIpv6,
+                PORT_UUID, true);
+
+        Match match = flowBuilder.getMatch();
+        Icmpv6Match icmpv6Match = match.getIcmpv6Match();
+        Assert.assertEquals(30, icmpv6Match.getIcmpv6Type().shortValue());
+        Assert.assertEquals(30, icmpv6Match.getIcmpv6Code().shortValue());
+        EthernetMatch ethMatch = match.getEthernetMatch();
+        Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetSource().getAddress().getValue());
+        Assert.assertEquals((long) IPV6_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
+        Short type = portSecurityIpv6Rule.getSecurityRulePortMin().shortValue();
+        Short code = portSecurityIpv6Rule.getSecurityRulePortMax().shortValue();
+        String expectedFlowId1 = "Egress_ICMP_" + SEGMENT_ID + "_" + MAC_ADDRESS + "_" + type + "_" + code + "_"
+                + IPV6_DEST_IP_1 + "_Permit";
+        String expectedFlowId2 = "Egress_ICMP_" + SEGMENT_ID + "_" + MAC_ADDRESS + "_" + type + "_" + code + "_"
+                + IPV6_DEST_IP_2 + "_Permit";
+        String actualFlowId = flowBuilder.getFlowName();
+        if(actualFlowId.equals(expectedFlowId1) || actualFlowId.equals(expectedFlowId2)) {
+            Assert.assertTrue(true);
+        } else {
+            Assert.assertTrue(false);
+        }
+    }
+
     /**
      *  Test ICMP remove with code, type and remote SG selected.
      */
@@ -784,6 +1425,7 @@ public class EgressAclServiceTest {
         Assert.assertEquals(40, icmpv4Match.getIcmpv4Code().shortValue());
         EthernetMatch ethMatch = match.getEthernetMatch();
         Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetSource().getAddress().getValue());
+        Assert.assertEquals((long) IPV4_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
         Short type = portSecurityRule.getSecurityRulePortMin().shortValue();
         Short code = portSecurityRule.getSecurityRulePortMax().shortValue();
         String expectedFlowId1 = "Egress_ICMP_" + SEGMENT_ID + "_" + MAC_ADDRESS + "_" + type + "_" + code + "_"
@@ -798,12 +1440,48 @@ public class EgressAclServiceTest {
         }
     }
 
+    /**
+     *  Test ICMPv6 remove with code, type and remote SG selected.
+     */
+    @Test
+    public void testProgramPortSecurityACLRuleIpv6RemoveIcmp2() throws Exception {
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("icmpv6");
+        when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(40);
+        when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(40);
+        when(portSecurityIpv6Rule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
+        PowerMockito.doAnswer(answer()).when(egressAclServiceSpy, "removeFlow", any(FlowBuilder.class),
+                any(NodeBuilder.class));
+
+        egressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroupIpv6,
+                PORT_UUID, false);
+
+        Match match = flowBuilder.getMatch();
+        Icmpv6Match icmpv6Match = match.getIcmpv6Match();
+        Assert.assertEquals(40, icmpv6Match.getIcmpv6Type().shortValue());
+        Assert.assertEquals(40, icmpv6Match.getIcmpv6Code().shortValue());
+        EthernetMatch ethMatch = match.getEthernetMatch();
+        Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetSource().getAddress().getValue());
+        Assert.assertEquals((long) IPV6_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
+        Short type = portSecurityIpv6Rule.getSecurityRulePortMin().shortValue();
+        Short code = portSecurityIpv6Rule.getSecurityRulePortMax().shortValue();
+        String expectedFlowId1 = "Egress_ICMP_" + SEGMENT_ID + "_" + MAC_ADDRESS + "_" + type + "_" + code + "_"
+                + IPV6_DEST_IP_1 + "_Permit";
+        String expectedFlowId2 = "Egress_ICMP_" + SEGMENT_ID + "_" + MAC_ADDRESS + "_" + type + "_" + code + "_"
+                + IPV6_DEST_IP_2 + "_Permit";
+        String actualFlowId = flowBuilder.getFlowName();
+        if(actualFlowId.equals(expectedFlowId1) || actualFlowId.equals(expectedFlowId2)) {
+            Assert.assertTrue(true);
+        } else {
+            Assert.assertTrue(false);
+        }
+    }
+
     /**
      *  Test IPv4 invalid ether type test case.
      */
     @Test
     public void testProgramPortSecurityACLRuleInvalidEther() throws Exception {
-        when(portSecurityRule.getSecurityRuleEthertype()).thenReturn("IPV6");
+        when(portSecurityRule.getSecurityRuleEthertype()).thenReturn("IP");
 
         egressAclServiceSpy.programPortSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 124, securityGroup,PORT_UUID,false);
 
@@ -836,8 +1514,8 @@ public class EgressAclServiceTest {
         egressAclServiceSpy.programFixedSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 1, neutronDestIpList, false, false, true);
 
         verify(writeTransaction, times(2)).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(Node.class), eq(true));
-        verify(writeTransaction, times(1)).submit();
-        verify(commitFuture, times(1)).checkedGet();
+        verify(writeTransaction, times(2)).submit();
+        verify(commitFuture, times(2)).checkedGet();
     }
     /**
      *  Test With isConntrackEnabled false isComputeNode false
@@ -848,9 +1526,9 @@ public class EgressAclServiceTest {
 
         egressAclServiceSpy.programFixedSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 1, neutronDestIpList, false, false, false);
 
-        verify(writeTransaction, times(1)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
-        verify(writeTransaction, times(1)).submit();
-        verify(commitFuture, times(1)).get();
+        verify(writeTransaction, times(2)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
+        verify(writeTransaction, times(2)).submit();
+        verify(commitFuture, times(2)).get();
     }
 
     /**
@@ -862,9 +1540,9 @@ public class EgressAclServiceTest {
 
         egressAclServiceSpy.programFixedSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 1, neutronDestIpList, false, true, true);
 
-        verify(writeTransaction, times(10)).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(Node.class), eq(true));
-        verify(writeTransaction, times(5)).submit();
-        verify(commitFuture, times(5)).checkedGet();
+        verify(writeTransaction, times(9)).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(Node.class), eq(true));
+        verify(writeTransaction, times(9)).submit();
+        verify(commitFuture, times(9)).checkedGet();
     }
 
     /**
@@ -876,9 +1554,9 @@ public class EgressAclServiceTest {
 
         egressAclServiceSpy.programFixedSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 1, neutronDestIpList, false, true, false);
 
-        verify(writeTransaction, times(5)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
-        verify(writeTransaction, times(5)).submit();
-        verify(commitFuture, times(5)).get();
+        verify(writeTransaction, times(9)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
+        verify(writeTransaction, times(9)).submit();
+        verify(commitFuture, times(9)).get();
     }
 
     /**
@@ -891,8 +1569,8 @@ public class EgressAclServiceTest {
         egressAclServiceSpy.programFixedSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 1, neutronDestIpList, false, false, true);
 
         verify(writeTransaction, times(2)).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(Node.class), eq(true));
-        verify(writeTransaction, times(1)).submit();
-        verify(commitFuture, times(1)).checkedGet();
+        verify(writeTransaction, times(2)).submit();
+        verify(commitFuture, times(2)).checkedGet();
     }
 
     /**
@@ -904,9 +1582,9 @@ public class EgressAclServiceTest {
 
         egressAclServiceSpy.programFixedSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 1, neutronDestIpList, false, false, false);
 
-        verify(writeTransaction, times(1)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
-        verify(writeTransaction, times(1)).submit();
-        verify(commitFuture, times(1)).get();
+        verify(writeTransaction, times(2)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
+        verify(writeTransaction, times(2)).submit();
+        verify(commitFuture, times(2)).get();
     }
 
     /**
@@ -918,10 +1596,10 @@ public class EgressAclServiceTest {
 
         egressAclServiceSpy.programFixedSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 1, neutronDestIpList, false, true, true);
 
-        verify(writeTransaction, times(16)).put(any(LogicalDatastoreType.class),
+        verify(writeTransaction, times(12)).put(any(LogicalDatastoreType.class),
                                                any(InstanceIdentifier.class), any(Node.class), eq(true));
-        verify(writeTransaction, times(8)).submit();
-        verify(commitFuture, times(8)).checkedGet();
+        verify(writeTransaction, times(12)).submit();
+        verify(commitFuture, times(12)).checkedGet();
     }
 
     /**
@@ -933,9 +1611,9 @@ public class EgressAclServiceTest {
 
         egressAclServiceSpy.programFixedSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 1, neutronDestIpList, false, true, false);
 
-        verify(writeTransaction, times(8)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
-        verify(writeTransaction, times(8)).submit();
-        verify(commitFuture, times(8)).get();
+        verify(writeTransaction, times(12)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
+        verify(writeTransaction, times(12)).submit();
+        verify(commitFuture, times(12)).get();
     }
 
 }
index 91fc5914d8bbee1365720513a81b7343cc377e15..37f87492acecce4769a6191e841c79c17373e4e0 100644 (file)
@@ -45,6 +45,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.N
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6Match;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatch;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@@ -72,6 +73,8 @@ public class IngressAclServiceTest {
 
     @Mock private NeutronSecurityGroup securityGroup;
     @Mock private NeutronSecurityRule portSecurityRule;
+    @Mock private NeutronSecurityGroup securityGroupIpv6;
+    @Mock private NeutronSecurityRule portSecurityIpv6Rule;
     @Mock private SecurityServicesManager securityServices;
     @Mock private SecurityGroupCacheManger securityGroupCacheManger;
 
@@ -80,12 +83,18 @@ public class IngressAclServiceTest {
     private Neutron_IPs neutron_ip_src;
     private Neutron_IPs neutron_ip_dest_1;
     private Neutron_IPs neutron_ip_dest_2;
+    private Neutron_IPs neutron_ipv6_dest_1;
+    private Neutron_IPs neutron_ipv6_dest_2;
 
     private static final String MAC_ADDRESS = "87:1D:5E:02:40:B8";
     private static final String DHCP_MAC_ADDRESS = "87:1D:5E:02:40:B9";
     private static final String SRC_IP = "192.168.0.1";
     private static final String DEST_IP_1 = "192.169.0.1";
     private static final String DEST_IP_2 = "192.169.0.2";
+    private static final String IPV6_DEST_IP_1 = "2001:db8:2::200";
+    private static final String IPV6_DEST_IP_2 = "2001:db8:2::201";
+    private static final Long IPV6_ETHER_TYPE = (long) 0x86DD;
+    private static final Long IPV4_ETHER_TYPE = (long) 0x0800;
     private static final String SECURITY_GROUP_UUID = "85cc3048-abc3-43cc-89b3-377341426ac5";
     private static final String PORT_UUID = "95cc3048-abc3-43cc-89b3-377341426ac5";
     private static final String SEGMENT_ID = "2";
@@ -137,6 +146,21 @@ public class IngressAclServiceTest {
         neutron_ip_dest_2.setIpAddress(DEST_IP_2);
         neutronDestIpList.add(neutron_ip_dest_2);
 
+        portSecurityIpv6Rule = mock(NeutronSecurityRule.class);
+        when(portSecurityIpv6Rule.getSecurityRuleEthertype()).thenReturn("IPv6");
+        when(portSecurityIpv6Rule.getSecurityRuleDirection()).thenReturn("ingress");
+
+        List<NeutronSecurityRule> portSecurityIpv6List = new ArrayList<>();
+        portSecurityIpv6List.add(portSecurityIpv6Rule);
+        when(securityGroupIpv6.getSecurityRules()).thenReturn(portSecurityIpv6List);
+
+        neutron_ipv6_dest_1 = new Neutron_IPs();
+        neutron_ipv6_dest_1.setIpAddress(IPV6_DEST_IP_1);
+        neutronDestIpList.add(neutron_ipv6_dest_1);
+
+        neutron_ipv6_dest_2 = new Neutron_IPs();
+        neutron_ipv6_dest_2.setIpAddress(IPV6_DEST_IP_2);
+        neutronDestIpList.add(neutron_ipv6_dest_2);
 
         when(securityGroup.getSecurityRules()).thenReturn(portSecurityList);
         when(securityServices.getVmListForSecurityGroup
@@ -194,7 +218,24 @@ public class IngressAclServiceTest {
 
         ingressAclServiceSpy.programPortSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 124, securityGroup,PORT_UUID,true);
 
-        verify(writeTransaction, times(2)).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(Node.class), eq(true));
+        verify(writeTransaction, times(1)).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(Node.class), eq(true));
+        verify(writeTransaction, times(1)).submit();
+        verify(commitFuture, times(1)).checkedGet();
+    }
+
+    /**
+     *  Test IPv6 add test case.
+     */
+    @Test
+    public void testProgramPortSecurityACLRuleAddIpv6() throws Exception {
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn(null);
+        when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(null);
+        when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(null);
+        when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn(null);
+
+        ingressAclServiceSpy.programPortSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 124, securityGroupIpv6, PORT_UUID, true);
+
+        verify(writeTransaction, times(1)).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(Node.class), eq(true));
         verify(writeTransaction, times(1)).submit();
         verify(commitFuture, times(1)).checkedGet();
     }
@@ -217,7 +258,24 @@ public class IngressAclServiceTest {
     }
 
     /**
-     *  Test TCP add with port no and CIDR selected.
+     *  Test IPv6 remove test case.
+     */
+    @Test
+    public void testProgramPortSecurityACLRuleRemoveIpv6() throws Exception {
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn(null);
+        when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(null);
+        when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(null);
+        when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn(null);
+
+        ingressAclServiceSpy.programPortSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 124, securityGroupIpv6, PORT_UUID, false);
+
+        verify(writeTransaction, times(1)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
+        verify(writeTransaction, times(1)).submit();
+        verify(commitFuture, times(1)).get();
+    }
+
+    /**
+     *  Test IPv4 TCP add with port no and CIDR selected.
      */
     @Test
     public void testProgramPortSecurityACLRuleAddTcp1() throws Exception {
@@ -234,6 +292,7 @@ public class IngressAclServiceTest {
         Match match = flowBuilder.getMatch();
         EthernetMatch ethMatch = match.getEthernetMatch();
         Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetDestination().getAddress().getValue());
+        Assert.assertEquals((long) IPV4_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
 
         Assert.assertTrue(match.getLayer4Match() instanceof TcpMatch);
         TcpMatch layer4Match = (TcpMatch) match.getLayer4Match();
@@ -244,7 +303,35 @@ public class IngressAclServiceTest {
     }
 
     /**
-     *  Test TCP remove with port no and CIDR selected.
+     *  Test IPv6 TCP add with port no and CIDR selected.
+     */
+    @Test
+    public void testProgramPortSecurityACLRuleIpv6AddTcp1() throws Exception {
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("tcp");
+        when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(20);
+        when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(20);
+        when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
+        PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "writeFlow", any(FlowBuilder.class),
+                any(NodeBuilder.class));
+
+        ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroupIpv6,
+                PORT_UUID, true);
+
+        Match match = flowBuilder.getMatch();
+        EthernetMatch ethMatch = match.getEthernetMatch();
+        Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetDestination().getAddress().getValue());
+        Assert.assertEquals((long) IPV6_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
+
+        Assert.assertTrue(match.getLayer4Match() instanceof TcpMatch);
+        TcpMatch layer4Match = (TcpMatch) match.getLayer4Match();
+        Assert.assertEquals(20, layer4Match.getTcpDestinationPort().getValue().intValue());
+        int port = portSecurityIpv6Rule.getSecurityRulePortMin();
+        Assert.assertEquals("Ingress_TCP_" + SEGMENT_ID + "_" + MAC_ADDRESS +
+                "_" + port + "_::/64_Permit", flowBuilder.getFlowName());
+    }
+
+    /**
+     *  Test IPv4 TCP remove with port no and CIDR selected.
      */
     @Test
     public void testProgramPortSecurityACLRuleRemoveTcp1() throws Exception {
@@ -261,6 +348,7 @@ public class IngressAclServiceTest {
         Match match = flowBuilder.getMatch();
         EthernetMatch ethMatch = match.getEthernetMatch();
         Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetDestination().getAddress().getValue());
+        Assert.assertEquals((long) IPV4_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
 
         Assert.assertTrue(match.getLayer4Match() instanceof TcpMatch);
         TcpMatch layer4Match = (TcpMatch) match.getLayer4Match();
@@ -271,7 +359,35 @@ public class IngressAclServiceTest {
     }
 
     /**
-     *  Test TCP add with port no and remote SG selected.
+     *  Test IPv6 TCP remove with port no and CIDR selected.
+     */
+    @Test
+    public void testProgramPortSecurityACLRuleIpv6RemoveTcp1() throws Exception {
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("tcp");
+        when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(15);
+        when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(15);
+        when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
+        PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "removeFlow", any(FlowBuilder.class),
+                any(NodeBuilder.class));
+
+        ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroupIpv6,
+                PORT_UUID, false);
+
+        Match match = flowBuilder.getMatch();
+        EthernetMatch ethMatch = match.getEthernetMatch();
+        Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetDestination().getAddress().getValue());
+        Assert.assertEquals((long) IPV6_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
+
+        Assert.assertTrue(match.getLayer4Match() instanceof TcpMatch);
+        TcpMatch layer4Match = (TcpMatch) match.getLayer4Match();
+        Assert.assertEquals(15, layer4Match.getTcpDestinationPort().getValue().intValue());
+        int port = portSecurityIpv6Rule.getSecurityRulePortMin();
+        Assert.assertEquals("Ingress_TCP_" + SEGMENT_ID + "_" + MAC_ADDRESS +
+                "_" + port + "_::/64_Permit", flowBuilder.getFlowName());
+    }
+
+    /**
+     *  Test IPv4 TCP add with port no and remote SG selected.
      */
     @Test
     public void testProgramPortSecurityACLRuleAddTcp2() throws Exception {
@@ -288,6 +404,7 @@ public class IngressAclServiceTest {
         Match match = flowBuilder.getMatch();
         EthernetMatch ethMatch = match.getEthernetMatch();
         Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetDestination().getAddress().getValue());
+        Assert.assertEquals((long) IPV4_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
 
         Assert.assertTrue(match.getLayer4Match() instanceof TcpMatch);
         TcpMatch layer4Match = (TcpMatch) match.getLayer4Match();
@@ -306,7 +423,43 @@ public class IngressAclServiceTest {
     }
 
     /**
-     *  Test TCP remove with port no and remote SG selected.
+     *  Test IPv6 TCP add with port no and remote SG selected.
+     */
+    @Test
+    public void testProgramPortSecurityACLRuleIpv6AddTcp2() throws Exception {
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("tcp");
+        when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(50);
+        when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(50);
+        when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
+        when(portSecurityIpv6Rule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
+        PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "writeFlow", any(FlowBuilder.class),
+                any(NodeBuilder.class));
+        ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroupIpv6,
+                PORT_UUID, true);
+
+        Match match = flowBuilder.getMatch();
+        EthernetMatch ethMatch = match.getEthernetMatch();
+        Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetDestination().getAddress().getValue());
+        Assert.assertEquals((long) IPV6_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
+
+        Assert.assertTrue(match.getLayer4Match() instanceof TcpMatch);
+        TcpMatch layer4Match = (TcpMatch) match.getLayer4Match();
+        Assert.assertEquals(50, layer4Match.getTcpDestinationPort().getValue().intValue());
+        int port = portSecurityIpv6Rule.getSecurityRulePortMin();
+        String expectedFlowId1 = "Ingress_TCP_" + SEGMENT_ID + "_" + MAC_ADDRESS +"_" + port + "_" + IPV6_DEST_IP_1 +
+                "_Permit";
+        String expectedFlowId2 = "Ingress_TCP_" + SEGMENT_ID + "_" + MAC_ADDRESS +"_" + port + "_" + IPV6_DEST_IP_2 +
+                "_Permit";
+        String actualFlowId = flowBuilder.getFlowName();
+        if (actualFlowId.equals(expectedFlowId1) || actualFlowId.equals(expectedFlowId2)) {
+            Assert.assertTrue(true);
+        } else {
+            Assert.assertTrue(false);
+        }
+    }
+
+    /**
+     *  Test IPv4 TCP remove with port no and remote SG selected.
      */
     @Test
     public void testProgramPortSecurityACLRuleRemoveTcp2() throws Exception {
@@ -324,6 +477,7 @@ public class IngressAclServiceTest {
         Match match = flowBuilder.getMatch();
         EthernetMatch ethMatch = match.getEthernetMatch();
         Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetDestination().getAddress().getValue());
+        Assert.assertEquals((long) IPV4_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
 
         Assert.assertTrue(match.getLayer4Match() instanceof TcpMatch);
         TcpMatch layer4Match = (TcpMatch) match.getLayer4Match();
@@ -343,7 +497,44 @@ public class IngressAclServiceTest {
 
 
     /**
-     *  Test TCP add with port (All TCP) and CIDR selected.
+     *  Test IPv6 TCP remove with port no and remote SG selected.
+     */
+    @Test
+    public void testProgramPortSecurityACLRuleIpv6RemoveTcp2() throws Exception {
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("tcp");
+        when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(50);
+        when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(50);
+        when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
+        when(portSecurityIpv6Rule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
+        PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "removeFlow", any(FlowBuilder.class),
+                any(NodeBuilder.class));
+
+        ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroupIpv6,
+                PORT_UUID, false);
+
+        Match match = flowBuilder.getMatch();
+        EthernetMatch ethMatch = match.getEthernetMatch();
+        Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetDestination().getAddress().getValue());
+        Assert.assertEquals((long) IPV6_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
+
+        Assert.assertTrue(match.getLayer4Match() instanceof TcpMatch);
+        TcpMatch layer4Match = (TcpMatch) match.getLayer4Match();
+        Assert.assertEquals(50, layer4Match.getTcpDestinationPort().getValue().intValue());
+        int port = portSecurityIpv6Rule.getSecurityRulePortMin();
+        String expectedFlowId1 = "Ingress_TCP_" + SEGMENT_ID + "_" + MAC_ADDRESS +"_" + port + "_" + IPV6_DEST_IP_1 +
+                "_Permit";
+        String expectedFlowId2 = "Ingress_TCP_" + SEGMENT_ID + "_" + MAC_ADDRESS +"_" + port + "_" + IPV6_DEST_IP_2 +
+                "_Permit";
+        String actualFlowId = flowBuilder.getFlowName();
+        if (actualFlowId.equals(expectedFlowId1) || actualFlowId.equals(expectedFlowId2)) {
+            Assert.assertTrue(true);
+        } else {
+            Assert.assertTrue(false);
+        }
+    }
+
+    /**
+     *  Test IPv4 TCP add with port (All TCP) and CIDR selected.
      */
     @Test
     public void testProgramPortSecurityACLRuleAddTcpAll1() throws Exception {
@@ -360,6 +551,7 @@ public class IngressAclServiceTest {
         Match match = flowBuilder.getMatch();
         EthernetMatch ethMatch = match.getEthernetMatch();
         Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetDestination().getAddress().getValue());
+        Assert.assertEquals((long) IPV4_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
 
         Assert.assertTrue(match.getLayer4Match() instanceof TcpMatch);
         Assert.assertEquals("Ingress_TCP_" + SEGMENT_ID + "_" + MAC_ADDRESS + "_" + PORT_RANGE_MIN + "_" +
@@ -367,7 +559,32 @@ public class IngressAclServiceTest {
     }
 
     /**
-     *  Test TCP remove with port (All TCP) and CIDR selected.
+     *  Test IPv6 TCP add with port (All TCP) and CIDR selected.
+     */
+    @Test
+    public void testProgramPortSecurityACLRuleIpv6AddTcpAll1() throws Exception {
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("tcp");
+        when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(PORT_RANGE_MAX);
+        when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(PORT_RANGE_MIN);
+        when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
+        PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "writeFlow", any(FlowBuilder.class),
+                any(NodeBuilder.class));
+
+        ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroupIpv6,
+                PORT_UUID, true);
+
+        Match match = flowBuilder.getMatch();
+        EthernetMatch ethMatch = match.getEthernetMatch();
+        Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetDestination().getAddress().getValue());
+        Assert.assertEquals((long) IPV6_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
+
+        Assert.assertTrue(match.getLayer4Match() instanceof TcpMatch);
+        Assert.assertEquals("Ingress_TCP_" + SEGMENT_ID + "_" + MAC_ADDRESS + "_" + PORT_RANGE_MIN + "_" +
+                PORT_RANGE_MAX + "_::/64_Permit", flowBuilder.getFlowName());
+    }
+
+    /**
+     *  Test IPv4 TCP remove with port (All TCP) and CIDR selected.
      */
     @Test
     public void testProgramPortSecurityACLRuleRemoveTcpAll1() throws Exception {
@@ -384,6 +601,7 @@ public class IngressAclServiceTest {
         Match match = flowBuilder.getMatch();
         EthernetMatch ethMatch = match.getEthernetMatch();
         Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetDestination().getAddress().getValue());
+        Assert.assertEquals((long) IPV4_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
 
         Assert.assertTrue(match.getLayer4Match() instanceof TcpMatch);
         Assert.assertEquals("Ingress_TCP_" + SEGMENT_ID + "_" + MAC_ADDRESS + "_" + PORT_RANGE_MIN + "_" +
@@ -391,7 +609,32 @@ public class IngressAclServiceTest {
     }
 
     /**
-     *  Test TCP add with port (All TCP) and remote SG selected.
+     *  Test IPv6 TCP remove with port (All TCP) and CIDR selected.
+     */
+    @Test
+    public void testProgramPortSecurityACLRuleIpv6RemoveTcpAll1() throws Exception {
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("tcp");
+        when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(PORT_RANGE_MAX);
+        when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(PORT_RANGE_MIN);
+        when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
+        PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "removeFlow", any(FlowBuilder.class),
+                any(NodeBuilder.class));
+
+        ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroupIpv6,
+                PORT_UUID, false);
+
+        Match match = flowBuilder.getMatch();
+        EthernetMatch ethMatch = match.getEthernetMatch();
+        Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetDestination().getAddress().getValue());
+        Assert.assertEquals((long) IPV6_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
+
+        Assert.assertTrue(match.getLayer4Match() instanceof TcpMatch);
+        Assert.assertEquals("Ingress_TCP_" + SEGMENT_ID + "_" + MAC_ADDRESS + "_" + PORT_RANGE_MIN + "_" +
+                PORT_RANGE_MAX + "_::/64_Permit", flowBuilder.getFlowName());
+    }
+
+    /**
+     *  Test IPv4 TCP add with port (All TCP) and remote SG selected.
      */
     @Test
     public void testProgramPortSecurityACLRuleAddTcpAll2() throws Exception {
@@ -407,6 +650,7 @@ public class IngressAclServiceTest {
         Match match = flowBuilder.getMatch();
         EthernetMatch ethMatch = match.getEthernetMatch();
         Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetDestination().getAddress().getValue());
+        Assert.assertEquals((long) IPV4_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
 
         Assert.assertTrue(match.getLayer4Match() instanceof TcpMatch);
         String expectedFlowId1 = "Ingress_TCP_" + SEGMENT_ID + "_" + MAC_ADDRESS + "_" + PORT_RANGE_MIN + "_" +
@@ -422,7 +666,39 @@ public class IngressAclServiceTest {
     }
 
     /**
-     *  Test TCP remove with port (All TCP) and remote SG selected.
+     *  Test IPv6 TCP add with port (All TCP) and remote SG selected.
+     */
+    @Test
+    public void testProgramPortSecurityACLRuleIpv6AddTcpAll2() throws Exception {
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("tcp");
+        when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(PORT_RANGE_MAX);
+        when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(PORT_RANGE_MIN);
+        when(portSecurityIpv6Rule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
+        PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "writeFlow", any(FlowBuilder.class),
+                any(NodeBuilder.class));
+        ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroupIpv6,
+                PORT_UUID, true);
+
+        Match match = flowBuilder.getMatch();
+        EthernetMatch ethMatch = match.getEthernetMatch();
+        Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetDestination().getAddress().getValue());
+        Assert.assertEquals((long) IPV6_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
+
+        Assert.assertTrue(match.getLayer4Match() instanceof TcpMatch);
+        String expectedFlowId1 = "Ingress_TCP_" + SEGMENT_ID + "_" + MAC_ADDRESS + "_" + PORT_RANGE_MIN + "_" +
+                PORT_RANGE_MAX + "_" + IPV6_DEST_IP_1 + "_Permit";
+        String expectedFlowId2 = "Ingress_TCP_" + SEGMENT_ID + "_" + MAC_ADDRESS + "_" + PORT_RANGE_MIN + "_" +
+                PORT_RANGE_MAX + "_" + IPV6_DEST_IP_2 + "_Permit";
+        String actualFlowId = flowBuilder.getFlowName();
+        if (actualFlowId.equals(expectedFlowId1) || actualFlowId.equals(expectedFlowId2)) {
+            Assert.assertTrue(true);
+        } else {
+            Assert.assertTrue(false);
+        }
+    }
+
+    /**
+     *  Test IPv4 TCP remove with port (All TCP) and remote SG selected.
      */
     @Test
     public void testProgramPortSecurityACLRuleRemoveTcpAll2() throws Exception {
@@ -439,6 +715,7 @@ public class IngressAclServiceTest {
         Match match = flowBuilder.getMatch();
         EthernetMatch ethMatch = match.getEthernetMatch();
         Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetDestination().getAddress().getValue());
+        Assert.assertEquals((long) IPV4_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
 
         Assert.assertTrue(match.getLayer4Match() instanceof TcpMatch);
         TcpMatch layer4Match = (TcpMatch) match.getLayer4Match();
@@ -455,7 +732,41 @@ public class IngressAclServiceTest {
     }
 
     /**
-     *  Test UDP add with port no and CIDR selected.
+     *  Test IPv6 TCP remove with port (All TCP) and remote SG selected.
+     */
+    @Test
+    public void testProgramPortSecurityACLRuleIpv6RemoveTcpAll2() throws Exception {
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("tcp");
+        when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(PORT_RANGE_MAX);
+        when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(PORT_RANGE_MIN);
+        when(portSecurityIpv6Rule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
+        PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "removeFlow", any(FlowBuilder.class),
+                any(NodeBuilder.class));
+
+        ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroupIpv6,
+                PORT_UUID, false);
+
+        Match match = flowBuilder.getMatch();
+        EthernetMatch ethMatch = match.getEthernetMatch();
+        Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetDestination().getAddress().getValue());
+        Assert.assertEquals((long) IPV6_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
+
+        Assert.assertTrue(match.getLayer4Match() instanceof TcpMatch);
+        TcpMatch layer4Match = (TcpMatch) match.getLayer4Match();
+        String expectedFlowId1 = "Ingress_TCP_" + SEGMENT_ID + "_" + MAC_ADDRESS +"_" + PORT_RANGE_MIN + "_" +
+                PORT_RANGE_MAX + "_" + IPV6_DEST_IP_1 + "_Permit";
+        String expectedFlowId2 = "Ingress_TCP_" + SEGMENT_ID + "_" + MAC_ADDRESS +"_" + PORT_RANGE_MIN + "_" +
+                PORT_RANGE_MAX + "_" + IPV6_DEST_IP_2 + "_Permit";
+        String actualFlowId = flowBuilder.getFlowName();
+        if (actualFlowId.equals(expectedFlowId1) || actualFlowId.equals(expectedFlowId2)) {
+            Assert.assertTrue(true);
+        } else {
+            Assert.assertTrue(false);
+        }
+    }
+
+    /**
+     *  Test IPv4 UDP add with port no and CIDR selected.
      */
     @Test
     public void testProgramPortSecurityACLRuleAddUdp1() throws Exception {
@@ -472,6 +783,7 @@ public class IngressAclServiceTest {
         Match match = flowBuilder.getMatch();
         EthernetMatch ethMatch = match.getEthernetMatch();
         Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetDestination().getAddress().getValue());
+        Assert.assertEquals((long) IPV4_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
 
         Assert.assertTrue(match.getLayer4Match() instanceof UdpMatch);
         UdpMatch layer4Match = (UdpMatch) match.getLayer4Match();
@@ -482,7 +794,35 @@ public class IngressAclServiceTest {
     }
 
     /**
-     *  Test UDP remove with port no and CIDR selected.
+     *  Test IPv6 UDP add with port no and CIDR selected.
+     */
+    @Test
+    public void testProgramPortSecurityACLRuleIpv6AddUdp1() throws Exception {
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("udp");
+        when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(50);
+        when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(50);
+        when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
+        PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "writeFlow", any(FlowBuilder.class),
+                any(NodeBuilder.class));
+
+        ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroupIpv6,
+                PORT_UUID, true);
+
+        Match match = flowBuilder.getMatch();
+        EthernetMatch ethMatch = match.getEthernetMatch();
+        Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetDestination().getAddress().getValue());
+        Assert.assertEquals((long) IPV6_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
+
+        Assert.assertTrue(match.getLayer4Match() instanceof UdpMatch);
+        UdpMatch layer4Match = (UdpMatch) match.getLayer4Match();
+        Assert.assertEquals(50, layer4Match.getUdpDestinationPort().getValue().intValue());
+        int port = portSecurityIpv6Rule.getSecurityRulePortMin();
+        Assert.assertEquals("Ingress_UDP_" + SEGMENT_ID + "_" + MAC_ADDRESS +
+                "_" + port + "_::/64_Permit", flowBuilder.getFlowName());
+    }
+
+    /**
+     *  Test IPv4 UDP remove with port no and CIDR selected.
      */
     @Test
     public void testProgramPortSecurityACLRuleRemoveUdp1() throws Exception {
@@ -499,6 +839,7 @@ public class IngressAclServiceTest {
         Match match = flowBuilder.getMatch();
         EthernetMatch ethMatch = match.getEthernetMatch();
         Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetDestination().getAddress().getValue());
+        Assert.assertEquals((long) IPV4_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
 
         Assert.assertTrue(match.getLayer4Match() instanceof UdpMatch);
         UdpMatch layer4Match = (UdpMatch) match.getLayer4Match();
@@ -509,7 +850,35 @@ public class IngressAclServiceTest {
     }
 
     /**
-     *  Test UDP add with port no and remote SG selected.
+     *  Test IPv6 UDP remove with port no and CIDR selected.
+     */
+    @Test
+    public void testProgramPortSecurityACLRuleIpv6RemoveUdp1() throws Exception {
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("udp");
+        when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(50);
+        when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(50);
+        when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
+        PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "removeFlow", any(FlowBuilder.class),
+                any(NodeBuilder.class));
+
+        ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroupIpv6,
+                PORT_UUID, false);
+
+        Match match = flowBuilder.getMatch();
+        EthernetMatch ethMatch = match.getEthernetMatch();
+        Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetDestination().getAddress().getValue());
+        Assert.assertEquals((long) IPV6_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
+
+        Assert.assertTrue(match.getLayer4Match() instanceof UdpMatch);
+        UdpMatch layer4Match = (UdpMatch) match.getLayer4Match();
+        Assert.assertEquals(50, layer4Match.getUdpDestinationPort().getValue().intValue());
+        int port = portSecurityIpv6Rule.getSecurityRulePortMin();
+        Assert.assertEquals("Ingress_UDP_" + SEGMENT_ID + "_" + MAC_ADDRESS +
+                "_" + port + "_::/64_Permit", flowBuilder.getFlowName());
+    }
+
+    /**
+     *  Test IPv4 UDP add with port no and remote SG selected.
      */
     @Test
     public void testProgramPortSecurityACLRuleAddUdp2() throws Exception {
@@ -526,6 +895,7 @@ public class IngressAclServiceTest {
         Match match = flowBuilder.getMatch();
         EthernetMatch ethMatch = match.getEthernetMatch();
         Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetDestination().getAddress().getValue());
+        Assert.assertEquals((long) IPV4_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
 
         Assert.assertTrue(match.getLayer4Match() instanceof UdpMatch);
         UdpMatch layer4Match = (UdpMatch) match.getLayer4Match();
@@ -544,7 +914,43 @@ public class IngressAclServiceTest {
     }
 
     /**
-     *  Test UDP remove with port no and remote SG selected.
+     *  Test IPv6 UDP add with port no and remote SG selected.
+     */
+    @Test
+    public void testProgramPortSecurityACLRuleIpv6AddUdp2() throws Exception {
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("udp");
+        when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(50);
+        when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(50);
+        when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
+        when(portSecurityIpv6Rule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
+        PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "writeFlow", any(FlowBuilder.class),
+                any(NodeBuilder.class));
+        ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroupIpv6,
+                PORT_UUID, true);
+
+        Match match = flowBuilder.getMatch();
+        EthernetMatch ethMatch = match.getEthernetMatch();
+        Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetDestination().getAddress().getValue());
+        Assert.assertEquals((long) IPV6_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
+
+        Assert.assertTrue(match.getLayer4Match() instanceof UdpMatch);
+        UdpMatch layer4Match = (UdpMatch) match.getLayer4Match();
+        Assert.assertEquals(50, layer4Match.getUdpDestinationPort().getValue().intValue());
+        int port = portSecurityIpv6Rule.getSecurityRulePortMin();
+        String expectedFlowId1 = "Ingress_UDP_" + SEGMENT_ID + "_" + MAC_ADDRESS +"_" + port + "_" + IPV6_DEST_IP_1 +
+                "_Permit";
+        String expectedFlowId2 = "Ingress_UDP_" + SEGMENT_ID + "_" + MAC_ADDRESS +"_" + port + "_" + IPV6_DEST_IP_2 +
+                "_Permit";
+        String actualFlowId = flowBuilder.getFlowName();
+        if (actualFlowId.equals(expectedFlowId1) || actualFlowId.equals(expectedFlowId2)) {
+            Assert.assertTrue(true);
+        } else {
+            Assert.assertTrue(false);
+        }
+    }
+
+    /**
+     *  Test IPv4 UDP remove with port no and remote SG selected.
      */
     @Test
     public void testProgramPortSecurityACLRuleRemoveUdp2() throws Exception {
@@ -561,6 +967,7 @@ public class IngressAclServiceTest {
         Match match = flowBuilder.getMatch();
         EthernetMatch ethMatch = match.getEthernetMatch();
         Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetDestination().getAddress().getValue());
+        Assert.assertEquals((long) IPV4_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
 
         Assert.assertTrue(match.getLayer4Match() instanceof UdpMatch);
         UdpMatch layer4Match = (UdpMatch) match.getLayer4Match();
@@ -579,7 +986,43 @@ public class IngressAclServiceTest {
     }
 
     /**
-     *  Test UDP add with ports (All UDP) and CIDR selected.
+     *  Test IPv6 UDP remove with port no and remote SG selected.
+     */
+    @Test
+    public void testProgramPortSecurityACLRuleIpv6RemoveUdp2() throws Exception {
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("udp");
+        when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(50);
+        when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(50);
+        when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
+        when(portSecurityIpv6Rule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
+        PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "removeFlow", any(FlowBuilder.class),
+                any(NodeBuilder.class));
+        ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroupIpv6,
+                PORT_UUID, false);
+
+        Match match = flowBuilder.getMatch();
+        EthernetMatch ethMatch = match.getEthernetMatch();
+        Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetDestination().getAddress().getValue());
+        Assert.assertEquals((long) IPV6_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
+
+        Assert.assertTrue(match.getLayer4Match() instanceof UdpMatch);
+        UdpMatch layer4Match = (UdpMatch) match.getLayer4Match();
+        Assert.assertEquals(50, layer4Match.getUdpDestinationPort().getValue().intValue());
+        int port = portSecurityIpv6Rule.getSecurityRulePortMin();
+        String expectedFlowId1 = "Ingress_UDP_" + SEGMENT_ID + "_" + MAC_ADDRESS +"_" + port + "_" + IPV6_DEST_IP_1 +
+                "_Permit";
+        String expectedFlowId2 = "Ingress_UDP_" + SEGMENT_ID + "_" + MAC_ADDRESS +"_" + port + "_" + IPV6_DEST_IP_2 +
+                "_Permit";
+        String actualFlowId = flowBuilder.getFlowName();
+        if (actualFlowId.equals(expectedFlowId1) || actualFlowId.equals(expectedFlowId2)) {
+            Assert.assertTrue(true);
+        } else {
+            Assert.assertTrue(false);
+        }
+    }
+
+    /**
+     *  Test IPv4 UDP add with ports (All UDP) and CIDR selected.
      */
     @Test
     public void testProgramPortSecurityACLRuleAddUdpAll1() throws Exception {
@@ -596,6 +1039,7 @@ public class IngressAclServiceTest {
         Match match = flowBuilder.getMatch();
         EthernetMatch ethMatch = match.getEthernetMatch();
         Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetDestination().getAddress().getValue());
+        Assert.assertEquals((long) IPV4_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
 
         Assert.assertTrue(match.getLayer4Match() instanceof UdpMatch);
         Assert.assertEquals("Ingress_UDP_" + SEGMENT_ID + "_" + MAC_ADDRESS + "_" + PORT_RANGE_MIN  + "_" +
@@ -603,7 +1047,32 @@ public class IngressAclServiceTest {
     }
 
     /**
-     *  Test UDP remove with ports (All UDP) and CIDR selected.
+     *  Test IPv6 UDP add with ports (All UDP) and CIDR selected.
+     */
+    @Test
+    public void testProgramPortSecurityACLRuleIPv6AddUdpAll1() throws Exception {
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("udp");
+        when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(PORT_RANGE_MAX);
+        when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(PORT_RANGE_MIN);
+        when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
+        PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "writeFlow", any(FlowBuilder.class),
+                any(NodeBuilder.class));
+
+        ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroupIpv6,
+                PORT_UUID, true);
+
+        Match match = flowBuilder.getMatch();
+        EthernetMatch ethMatch = match.getEthernetMatch();
+        Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetDestination().getAddress().getValue());
+        Assert.assertEquals((long) IPV6_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
+
+        Assert.assertTrue(match.getLayer4Match() instanceof UdpMatch);
+        Assert.assertEquals("Ingress_UDP_" + SEGMENT_ID + "_" + MAC_ADDRESS + "_" + PORT_RANGE_MIN  + "_" +
+                PORT_RANGE_MAX + "_::/64_Permit", flowBuilder.getFlowName());
+    }
+
+    /**
+     *  Test IPv4 UDP remove with ports (All UDP) and CIDR selected.
      */
     @Test
     public void testProgramPortSecurityACLRuleRemoveUdpAll1() throws Exception {
@@ -620,6 +1089,7 @@ public class IngressAclServiceTest {
         Match match = flowBuilder.getMatch();
         EthernetMatch ethMatch = match.getEthernetMatch();
         Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetDestination().getAddress().getValue());
+        Assert.assertEquals((long) IPV4_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
 
         Assert.assertTrue(match.getLayer4Match() instanceof UdpMatch);
         Assert.assertEquals("Ingress_UDP_" + SEGMENT_ID + "_" + MAC_ADDRESS + "_" + PORT_RANGE_MIN  + "_" +
@@ -627,7 +1097,32 @@ public class IngressAclServiceTest {
     }
 
     /**
-     *  Test UDP add with ports (All UDP) and remote SG selected.
+     *  Test IPv6 UDP remove with ports (All UDP) and CIDR selected.
+     */
+    @Test
+    public void testProgramPortSecurityACLRuleIpv6RemoveUdpAll1() throws Exception {
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("udp");
+        when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(PORT_RANGE_MAX);
+        when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(PORT_RANGE_MIN);
+        when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
+        PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "removeFlow", any(FlowBuilder.class),
+                any(NodeBuilder.class));
+
+        ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroupIpv6,
+                PORT_UUID, false);
+
+        Match match = flowBuilder.getMatch();
+        EthernetMatch ethMatch = match.getEthernetMatch();
+        Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetDestination().getAddress().getValue());
+        Assert.assertEquals((long) IPV6_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
+
+        Assert.assertTrue(match.getLayer4Match() instanceof UdpMatch);
+        Assert.assertEquals("Ingress_UDP_" + SEGMENT_ID + "_" + MAC_ADDRESS + "_" + PORT_RANGE_MIN  + "_" +
+                PORT_RANGE_MAX + "_::/64_Permit", flowBuilder.getFlowName());
+    }
+
+    /**
+     *  Test IPv4 UDP add with ports (All UDP) and remote SG selected.
      */
     @Test
     public void testProgramPortSecurityACLRuleAddUdpAll2() throws Exception {
@@ -644,6 +1139,7 @@ public class IngressAclServiceTest {
         Match match = flowBuilder.getMatch();
         EthernetMatch ethMatch = match.getEthernetMatch();
         Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetDestination().getAddress().getValue());
+        Assert.assertEquals((long) IPV4_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
 
         Assert.assertTrue(match.getLayer4Match() instanceof UdpMatch);
         String expectedFlowId1 = "Ingress_UDP_" + SEGMENT_ID + "_" + MAC_ADDRESS +"_" + PORT_RANGE_MIN + "_" +
@@ -659,7 +1155,40 @@ public class IngressAclServiceTest {
     }
 
     /**
-     *  Test UDP remove with ports (All UDP) and remote SG selected.
+     *  Test IPv6 UDP add with ports (All UDP) and remote SG selected.
+     */
+    @Test
+    public void testProgramPortSecurityACLRuleIpv6AddUdpAll2() throws Exception {
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("udp");
+        when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(PORT_RANGE_MAX);
+        when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(PORT_RANGE_MIN);
+        when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
+        when(portSecurityIpv6Rule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
+        PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "writeFlow", any(FlowBuilder.class),
+                any(NodeBuilder.class));
+        ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroupIpv6,
+                PORT_UUID, true);
+
+        Match match = flowBuilder.getMatch();
+        EthernetMatch ethMatch = match.getEthernetMatch();
+        Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetDestination().getAddress().getValue());
+        Assert.assertEquals((long) IPV6_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
+
+        Assert.assertTrue(match.getLayer4Match() instanceof UdpMatch);
+        String expectedFlowId1 = "Ingress_UDP_" + SEGMENT_ID + "_" + MAC_ADDRESS +"_" + PORT_RANGE_MIN + "_" +
+                PORT_RANGE_MAX + "_" + IPV6_DEST_IP_1 + "_Permit";
+        String expectedFlowId2 = "Ingress_UDP_" + SEGMENT_ID + "_" + MAC_ADDRESS +"_" + PORT_RANGE_MIN + "_" +
+                PORT_RANGE_MAX + "_" + IPV6_DEST_IP_2 + "_Permit";
+        String actualFlowId = flowBuilder.getFlowName();
+        if (actualFlowId.equals(expectedFlowId1) || actualFlowId.equals(expectedFlowId2)) {
+            Assert.assertTrue(true);
+        } else {
+            Assert.assertTrue(false);
+        }
+    }
+
+    /**
+     *  Test IPv4 UDP remove with ports (All UDP) and remote SG selected.
      */
     @Test
     public void testProgramPortSecurityACLRuleRemoveUdpAll2() throws Exception {
@@ -676,6 +1205,7 @@ public class IngressAclServiceTest {
         Match match = flowBuilder.getMatch();
         EthernetMatch ethMatch = match.getEthernetMatch();
         Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetDestination().getAddress().getValue());
+        Assert.assertEquals((long) IPV4_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
 
         Assert.assertTrue(match.getLayer4Match() instanceof UdpMatch);
         String expectedFlowId1 = "Ingress_UDP_" + SEGMENT_ID + "_" + MAC_ADDRESS +"_" + PORT_RANGE_MIN + "_" +
@@ -690,6 +1220,39 @@ public class IngressAclServiceTest {
         }
     }
 
+    /**
+     *  Test IPv6 UDP remove with ports (All UDP) and remote SG selected.
+     */
+    @Test
+    public void testProgramPortSecurityACLRuleIpv6RemoveUdpAll2() throws Exception {
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("udp");
+        when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(PORT_RANGE_MAX);
+        when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(PORT_RANGE_MIN);
+        when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
+        when(portSecurityIpv6Rule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
+        PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "removeFlow", any(FlowBuilder.class),
+                any(NodeBuilder.class));
+        ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT, securityGroupIpv6,
+                PORT_UUID, false);
+
+        Match match = flowBuilder.getMatch();
+        EthernetMatch ethMatch = match.getEthernetMatch();
+        Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetDestination().getAddress().getValue());
+        Assert.assertEquals((long) IPV6_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
+
+        Assert.assertTrue(match.getLayer4Match() instanceof UdpMatch);
+        String expectedFlowId1 = "Ingress_UDP_" + SEGMENT_ID + "_" + MAC_ADDRESS +"_" + PORT_RANGE_MIN + "_" +
+                PORT_RANGE_MAX + "_" + IPV6_DEST_IP_1 + "_Permit";
+        String expectedFlowId2 = "Ingress_UDP_" + SEGMENT_ID + "_" + MAC_ADDRESS +"_" + PORT_RANGE_MIN + "_" +
+                PORT_RANGE_MAX + "_" + IPV6_DEST_IP_2 + "_Permit";
+        String actualFlowId = flowBuilder.getFlowName();
+        if (actualFlowId.equals(expectedFlowId1) || actualFlowId.equals(expectedFlowId2)) {
+            Assert.assertTrue(true);
+        } else {
+            Assert.assertTrue(false);
+        }
+    }
+
     /**
      *  Test ICMP add with code, type and CIDR selected.
      */
@@ -710,6 +1273,7 @@ public class IngressAclServiceTest {
         Assert.assertEquals(10, icmpv4Match.getIcmpv4Code().shortValue());
         EthernetMatch ethMatch = match.getEthernetMatch();
         Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetDestination().getAddress().getValue());
+        Assert.assertEquals((long) IPV4_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
         Short type = portSecurityRule.getSecurityRulePortMin().shortValue();
         Short code = portSecurityRule.getSecurityRulePortMax().shortValue();
         Assert.assertEquals("Ingress_ICMP_" + SEGMENT_ID + "_" + MAC_ADDRESS + "_" + type + "_" + code
@@ -717,6 +1281,35 @@ public class IngressAclServiceTest {
                             flowBuilder.getFlowName());
     }
 
+    /**
+     *  Test ICMPv6 add with code, type and CIDR selected.
+     */
+    @Test
+    public void testProgramPortSecurityACLRuleIpv6AddIcmp1() throws Exception {
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("icmpv6");
+        when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(10);
+        when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(10);
+        when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
+
+        PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "writeFlow", any(FlowBuilder.class),
+                any(NodeBuilder.class));
+        ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID,
+                MAC_ADDRESS, LOCAL_PORT, securityGroupIpv6, PORT_UUID, true);
+
+        Match match = flowBuilder.getMatch();
+        Icmpv6Match icmpv6Match = match.getIcmpv6Match();
+        Assert.assertEquals(10, icmpv6Match.getIcmpv6Type().shortValue());
+        Assert.assertEquals(10, icmpv6Match.getIcmpv6Code().shortValue());
+        EthernetMatch ethMatch = match.getEthernetMatch();
+        Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetDestination().getAddress().getValue());
+        Assert.assertEquals((long) IPV6_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
+        Short type = portSecurityIpv6Rule.getSecurityRulePortMin().shortValue();
+        Short code = portSecurityIpv6Rule.getSecurityRulePortMax().shortValue();
+        Assert.assertEquals("Ingress_ICMP_" + SEGMENT_ID + "_" + MAC_ADDRESS + "_" + type + "_" + code
+                        + "_::/64_Permit",
+                flowBuilder.getFlowName());
+    }
+
     /**
      *  Test ICMP remove with code, type and CIDR selected.
      */
@@ -737,6 +1330,7 @@ public class IngressAclServiceTest {
         Assert.assertEquals(20, icmpv4Match.getIcmpv4Code().shortValue());
         EthernetMatch ethMatch = match.getEthernetMatch();
         Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetDestination().getAddress().getValue());
+        Assert.assertEquals((long) IPV4_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
         Short type = portSecurityRule.getSecurityRulePortMin().shortValue();
         Short code = portSecurityRule.getSecurityRulePortMax().shortValue();
         Assert.assertEquals("Ingress_ICMP_" + SEGMENT_ID + "_" + MAC_ADDRESS + "_" + type + "_" + code
@@ -744,6 +1338,34 @@ public class IngressAclServiceTest {
                             flowBuilder.getFlowName());
     }
 
+    /**
+     *  Test ICMPv6 remove with code, type and CIDR selected.
+     */
+    @Test
+    public void testProgramPortSecurityACLRuleIpv6RemoveIcmp1() throws Exception {
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("icmpv6");
+        when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(20);
+        when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(20);
+        when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
+        PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "removeFlow", any(FlowBuilder.class),
+                any(NodeBuilder.class));
+
+        ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID,
+                MAC_ADDRESS, LOCAL_PORT, securityGroupIpv6, PORT_UUID, false);
+        Match match = flowBuilder.getMatch();
+        Icmpv6Match icmpv6Match = match.getIcmpv6Match();
+        Assert.assertEquals(20, icmpv6Match.getIcmpv6Type().shortValue());
+        Assert.assertEquals(20, icmpv6Match.getIcmpv6Code().shortValue());
+        EthernetMatch ethMatch = match.getEthernetMatch();
+        Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetDestination().getAddress().getValue());
+        Assert.assertEquals((long) IPV6_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
+        Short type = portSecurityIpv6Rule.getSecurityRulePortMin().shortValue();
+        Short code = portSecurityIpv6Rule.getSecurityRulePortMax().shortValue();
+        Assert.assertEquals("Ingress_ICMP_" + SEGMENT_ID + "_" + MAC_ADDRESS + "_" + type + "_" + code
+                        + "_::/64_Permit",
+                flowBuilder.getFlowName());
+    }
+
     /**
      *  Test ICMP add with code, type and remote SG selected.
      */
@@ -764,6 +1386,7 @@ public class IngressAclServiceTest {
         Assert.assertEquals(30, icmpv4Match.getIcmpv4Code().shortValue());
         EthernetMatch ethMatch = match.getEthernetMatch();
         Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetDestination().getAddress().getValue());
+        Assert.assertEquals((long) IPV4_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
         Short type = portSecurityRule.getSecurityRulePortMin().shortValue();
         Short code = portSecurityRule.getSecurityRulePortMax().shortValue();
         String expectedFlowId1 = "Ingress_ICMP_" + SEGMENT_ID + "_" + MAC_ADDRESS +"_" + type + "_" + code + "_"
@@ -778,6 +1401,42 @@ public class IngressAclServiceTest {
         }
     }
 
+    /**
+     *  Test ICMPv6 add with code, type and remote SG selected.
+     */
+    @Test
+    public void testProgramPortSecurityACLRuleIpv6AddIcmp2() throws Exception {
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("icmpv6");
+        when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(30);
+        when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(30);
+        when(portSecurityIpv6Rule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
+        PowerMockito.doAnswer(answer()).when(ingressAclServiceSpy, "writeFlow", any(FlowBuilder.class),
+                any(NodeBuilder.class));
+
+        ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID,
+                MAC_ADDRESS, LOCAL_PORT, securityGroupIpv6, PORT_UUID, true);
+        Match match = flowBuilder.getMatch();
+        Icmpv6Match icmpv6Match =match.getIcmpv6Match();
+        Assert.assertEquals(30, icmpv6Match.getIcmpv6Type().shortValue());
+        Assert.assertEquals(30, icmpv6Match.getIcmpv6Code().shortValue());
+        EthernetMatch ethMatch = match.getEthernetMatch();
+        Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetDestination().getAddress().getValue());
+        Assert.assertEquals((long) IPV6_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
+
+        Short type = portSecurityIpv6Rule.getSecurityRulePortMin().shortValue();
+        Short code = portSecurityIpv6Rule.getSecurityRulePortMax().shortValue();
+        String expectedFlowId1 = "Ingress_ICMP_" + SEGMENT_ID + "_" + MAC_ADDRESS +"_" + type + "_" + code + "_"
+                + IPV6_DEST_IP_1 + "_Permit";
+        String expectedFlowId2 = "Ingress_ICMP_" + SEGMENT_ID + "_" + MAC_ADDRESS +"_" + type + "_" + code + "_"
+                + IPV6_DEST_IP_2 + "_Permit";
+        String actualFlowId = flowBuilder.getFlowName();
+        if(actualFlowId.equals(expectedFlowId1) || actualFlowId.equals(expectedFlowId2)) {
+            Assert.assertTrue(true);
+        } else {
+            Assert.assertTrue(false);
+        }
+    }
+
     /**
      *  Test ICMP remove with code, type and remote SG selected.
      */
@@ -798,6 +1457,7 @@ public class IngressAclServiceTest {
         Assert.assertEquals(40, icmpv4Match.getIcmpv4Code().shortValue());
         EthernetMatch ethMatch = match.getEthernetMatch();
         Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetDestination().getAddress().getValue());
+        Assert.assertEquals((long) IPV4_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
         Short type = portSecurityRule.getSecurityRulePortMin().shortValue();
         Short code = portSecurityRule.getSecurityRulePortMax().shortValue();
         String expectedFlowId1 = "Ingress_ICMP_" + SEGMENT_ID + "_" + MAC_ADDRESS +"_" + type + "_" + code + "_"
@@ -812,12 +1472,47 @@ public class IngressAclServiceTest {
         }
     }
 
+    /**
+     *  Test ICMPv6 remove with code, type and remote SG selected.
+     */
+    @Test
+    public void testProgramPortSecurityACLRuleIpv6RemoveIcmp2() throws Exception {
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("icmpv6");
+        when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(40);
+        when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(40);
+        when(portSecurityIpv6Rule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
+        PowerMockito.doAnswer(answer())
+                .when(ingressAclServiceSpy, "removeFlow", any(FlowBuilder.class), any(NodeBuilder.class));
+
+        ingressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID,
+                MAC_ADDRESS, LOCAL_PORT, securityGroupIpv6, PORT_UUID, false);
+        Match match = flowBuilder.getMatch();
+        Icmpv6Match icmpv6Match = match.getIcmpv6Match();
+        Assert.assertEquals(40, icmpv6Match.getIcmpv6Type().shortValue());
+        Assert.assertEquals(40, icmpv6Match.getIcmpv6Code().shortValue());
+        EthernetMatch ethMatch = match.getEthernetMatch();
+        Assert.assertEquals(MAC_ADDRESS, ethMatch.getEthernetDestination().getAddress().getValue());
+        Assert.assertEquals((long) IPV6_ETHER_TYPE, (long) ethMatch.getEthernetType().getType().getValue());
+        Short type = portSecurityIpv6Rule.getSecurityRulePortMin().shortValue();
+        Short code = portSecurityIpv6Rule.getSecurityRulePortMax().shortValue();
+        String expectedFlowId1 = "Ingress_ICMP_" + SEGMENT_ID + "_" + MAC_ADDRESS +"_" + type + "_" + code + "_"
+                + IPV6_DEST_IP_1 + "_Permit";
+        String expectedFlowId2 = "Ingress_ICMP_" + SEGMENT_ID + "_" + MAC_ADDRESS +"_" + type + "_" + code + "_"
+                + IPV6_DEST_IP_2 + "_Permit";
+        String actualFlowId = flowBuilder.getFlowName();
+        if(actualFlowId.equals(expectedFlowId1) || actualFlowId.equals(expectedFlowId2)) {
+            Assert.assertTrue(true);
+        } else {
+            Assert.assertTrue(false);
+        }
+    }
+
     /**
      *  Test IPv4 invalid ether type test case.
      */
     @Test
     public void testProgramPortSecurityACLRuleInvalidEther() throws Exception {
-        when(portSecurityRule.getSecurityRuleEthertype()).thenReturn("IPV6");
+        when(portSecurityRule.getSecurityRuleEthertype()).thenReturn("IP");
 
         ingressAclServiceSpy.programPortSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 124, securityGroup,PORT_UUID,false);
 
@@ -875,7 +1570,7 @@ public class IngressAclServiceTest {
 
         ingressAclServiceSpy.programFixedSecurityGroup(Long.valueOf(1554), "2", DHCP_MAC_ADDRESS, 1, false, true, MAC_ADDRESS, true);
 
-        verify(writeTransaction, times(2)).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(Node.class), eq(true));
+        verify(writeTransaction, times(1)).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(Node.class), eq(true));
         verify(writeTransaction, times(1)).submit();
         verify(commitFuture, times(1)).checkedGet();
     }
@@ -927,7 +1622,7 @@ public class IngressAclServiceTest {
 
         ingressAclServiceSpy.programFixedSecurityGroup(Long.valueOf(1554), "2", DHCP_MAC_ADDRESS, 1, false, true, MAC_ADDRESS, true);
 
-        verify(writeTransaction, times(8)).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(Node.class), eq(true));
+        verify(writeTransaction, times(4)).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(Node.class), eq(true));
         verify(writeTransaction, times(4)).submit();
         verify(commitFuture, times(4)).checkedGet();
     }