Use constants for NeutronSecurityRule
authorStephen Kitt <skitt@redhat.com>
Mon, 1 Feb 2016 16:39:43 +0000 (17:39 +0100)
committerStephen Kitt <skitt@redhat.com>
Mon, 1 Feb 2016 16:39:43 +0000 (17:39 +0100)
This patch introduces constants for the directions, protocols and
ethertypes in NeutronSecurityRule.

There's also a bunch of small clean-ups in the affected classes.

Change-Id: Ia07efa48eb431f560d9f1f947170e1fb68e24ddb
Signed-off-by: Stephen Kitt <skitt@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
openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/SecurityServicesImpl.java
openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/translator/NeutronSecurityRule.java
openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/translator/crud/impl/NeutronSecurityRuleInterface.java
openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/translator/iaware/impl/NeutronSecurityRuleDataChangeListener.java
openstack/net-virt/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/impl/SecurityServicesImplTest.java

index 32f00d8844dbdd28b36d23e588a33c4ccfbcf804..db03e23035de9a25dfaebe50b31fdb0db806d95d 100644 (file)
@@ -25,18 +25,13 @@ import org.opendaylight.ovsdb.utils.mdsal.openflow.FlowUtils;
 import org.opendaylight.ovsdb.utils.mdsal.openflow.InstructionUtils;
 import org.opendaylight.ovsdb.utils.mdsal.openflow.MatchUtils;
 import org.opendaylight.ovsdb.utils.servicehelper.ServiceHelper;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefixBuilder;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Prefix;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
@@ -55,7 +50,6 @@ import org.osgi.framework.ServiceReference;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.math.BigInteger;
 import java.net.Inet4Address;
 import java.net.Inet6Address;
 import java.net.InetAddress;
@@ -74,8 +68,6 @@ 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;
 
@@ -115,7 +107,7 @@ public class EgressAclService extends AbstractServiceInstance implements EgressA
                 continue;
             }
 
-            if (portSecurityRule.getSecurityRuleDirection().equals("egress")) {
+            if (NeutronSecurityRule.DIRECTION_EGRESS.equals(portSecurityRule.getSecurityRuleDirection())) {
                 LOG.debug("programPortSecurityGroup: Acl Rule matching IP and ingress is: {} ", portSecurityRule);
                 if (null != portSecurityRule.getSecurityRemoteGroupID()) {
                     //Remote Security group is selected
@@ -152,8 +144,8 @@ public class EgressAclService extends AbstractServiceInstance implements EgressA
                                         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)) {
+        boolean isIpv6 = NeutronSecurityRule.ETHERTYPE_IPV6.equals(securityRuleEtherType);
+        if (!isIpv6 && !NeutronSecurityRule.ETHERTYPE_IPV4.equals(securityRuleEtherType)) {
             LOG.debug("programPortSecurityRule: SecurityRuleEthertype {} does not match IPv4/v6.", securityRuleEtherType);
             return;
         }
@@ -448,7 +440,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(IP_VERSION_6);
+        boolean isIpv6 = NeutronSecurityRule.ETHERTYPE_IPV6.equals(portSecurityRule.getSecurityRuleEthertype());
         if (isIpv6) {
             matchBuilder = MatchUtils.createV6EtherMatchWithType(matchBuilder,srcMac,null);
         } else {
@@ -512,7 +504,7 @@ public class EgressAclService extends AbstractServiceInstance implements EgressA
             NeutronSecurityRule portSecurityRule, String dstAddress,
             boolean write, Integer protoPortMatchPriority) {
 
-        boolean isIpv6 = portSecurityRule.getSecurityRuleEthertype().equals(IP_VERSION_6);
+        boolean isIpv6 = NeutronSecurityRule.ETHERTYPE_IPV6.equals(portSecurityRule.getSecurityRuleEthertype());
         if (isIpv6) {
             egressAclIcmpV6(dpidLong, segmentationId, srcMac, portSecurityRule, dstAddress, write, protoPortMatchPriority);
         } else {
@@ -633,7 +625,7 @@ 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(IP_VERSION_6);
+        boolean isIpv6 = NeutronSecurityRule.ETHERTYPE_IPV6.equals(portSecurityRule.getSecurityRuleEthertype());
         if (isIpv6) {
             matchBuilder = MatchUtils.createV6EtherMatchWithType(matchBuilder,srcMac,null);
         } else {
index b59d9130f84cb9c3c10d8bedc08e3a184f363d5c..651d8ffd93fca5294689f07549d728e6699c8847 100644 (file)
@@ -69,8 +69,6 @@ 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);
@@ -109,7 +107,7 @@ public class IngressAclService extends AbstractServiceInstance implements Ingres
                 continue;
             }
 
-            if ("ingress".equals(portSecurityRule.getSecurityRuleDirection())) {
+            if (NeutronSecurityRule.DIRECTION_INGRESS.equals(portSecurityRule.getSecurityRuleDirection())) {
                 LOG.debug("programPortSecurityGroup: Rule matching IP and ingress is: {} ", portSecurityRule);
                 if (null != portSecurityRule.getSecurityRemoteGroupID()) {
                     //Remote Security group is selected
@@ -145,8 +143,8 @@ public class IngressAclService extends AbstractServiceInstance implements Ingres
                                         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)) {
+        boolean isIpv6 = NeutronSecurityRule.ETHERTYPE_IPV6.equals(securityRuleEtherType);
+        if (!isIpv6 && !NeutronSecurityRule.ETHERTYPE_IPV4.equals(securityRuleEtherType)) {
             LOG.debug("programPortSecurityRule: SecurityRuleEthertype {} does not match IPv4/v6.", securityRuleEtherType);
             return;
         }
@@ -422,7 +420,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(IP_VERSION_6);
+        boolean isIpv6 = NeutronSecurityRule.ETHERTYPE_IPV6.equals(portSecurityRule.getSecurityRuleEthertype());
         if (isIpv6) {
             matchBuilder = MatchUtils.createV6EtherMatchWithType(matchBuilder,null,dstMac);
         } else {
@@ -500,7 +498,7 @@ public class IngressAclService extends AbstractServiceInstance implements Ingres
                                NeutronSecurityRule portSecurityRule, String srcAddress,
                                boolean write, Integer protoPortMatchPriority ) {
         boolean portRange = false;
-        boolean isIpv6 = portSecurityRule.getSecurityRuleEthertype().equals(IP_VERSION_6);
+        boolean isIpv6 = NeutronSecurityRule.ETHERTYPE_IPV6.equals(portSecurityRule.getSecurityRuleEthertype());
         MatchBuilder matchBuilder = new MatchBuilder();
         String flowId = "Ingress_UDP_" + segmentationId + "_" + dstMac + "_";
         if (isIpv6)  {
@@ -568,7 +566,7 @@ public class IngressAclService extends AbstractServiceInstance implements Ingres
             NeutronSecurityRule portSecurityRule, String srcAddress,
             boolean write, Integer protoPortMatchPriority) {
 
-        boolean isIpv6 = portSecurityRule.getSecurityRuleEthertype().equals(IP_VERSION_6);
+        boolean isIpv6 = NeutronSecurityRule.ETHERTYPE_IPV6.equals(portSecurityRule.getSecurityRuleEthertype());
         if (isIpv6) {
             ingressAclIcmpV6(dpidLong, segmentationId, dstMac, portSecurityRule, srcAddress, write, protoPortMatchPriority);
         } else {
index 73162c6efd3f8166768535b48b7dd91316fd913c..17c41edeb50b368e20b375342bc0eac2e1457dd2 100644 (file)
@@ -129,10 +129,10 @@ public class EgressAclServiceTest {
         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");
+        when(portSecurityRule.getSecurityRuleEthertype()).thenReturn(NeutronSecurityRule.ETHERTYPE_IPV4);
+        when(portSecurityRule.getSecurityRuleDirection()).thenReturn(NeutronSecurityRule.DIRECTION_EGRESS);
+        when(portSecurityIpv6Rule.getSecurityRuleEthertype()).thenReturn(NeutronSecurityRule.ETHERTYPE_IPV6);
+        when(portSecurityIpv6Rule.getSecurityRuleDirection()).thenReturn(NeutronSecurityRule.DIRECTION_EGRESS);
 
         List<NeutronSecurityRule> portSecurityList = new ArrayList<>();
         portSecurityList.add(portSecurityRule);
@@ -177,15 +177,15 @@ public class EgressAclServiceTest {
     @Test
     public void testProgramPortSecurityGroupWithIncompleteRule() throws Exception {
         NeutronSecurityRule portSecurityRule1 = mock(NeutronSecurityRule.class);
-        when(portSecurityRule1.getSecurityRuleEthertype()).thenReturn("IPv4");
+        when(portSecurityRule1.getSecurityRuleEthertype()).thenReturn(NeutronSecurityRule.ETHERTYPE_IPV4);
         when(portSecurityRule1.getSecurityRuleDirection()).thenReturn("not_egress");  // other direction
 
         NeutronSecurityRule portSecurityRule2 = mock(NeutronSecurityRule.class);
         when(portSecurityRule2.getSecurityRuleEthertype()).thenReturn(null);
-        when(portSecurityRule2.getSecurityRuleDirection()).thenReturn("egress");
+        when(portSecurityRule2.getSecurityRuleDirection()).thenReturn(NeutronSecurityRule.DIRECTION_EGRESS);
 
         NeutronSecurityRule portSecurityRule3 = mock(NeutronSecurityRule.class);
-        when(portSecurityRule3.getSecurityRuleEthertype()).thenReturn("IPv4");
+        when(portSecurityRule3.getSecurityRuleEthertype()).thenReturn(NeutronSecurityRule.ETHERTYPE_IPV4);
         when(portSecurityRule3.getSecurityRuleDirection()).thenReturn(null);
 
         NeutronSecurityRule portSecurityRule4 = mock(NeutronSecurityRule.class);
@@ -277,7 +277,7 @@ public class EgressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleAddTcp1() throws Exception {
-        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn("tcp");
+        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_TCP);
         when(portSecurityRule.getSecurityRulePortMax()).thenReturn(20);
         when(portSecurityRule.getSecurityRulePortMin()).thenReturn(20);
         when(portSecurityRule.getSecurityRuleRemoteIpPrefix()).thenReturn("0.0.0.0/24");
@@ -304,7 +304,7 @@ public class EgressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleIpv6AddTcp1() throws Exception {
-        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("tcp");
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_TCP);
         when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(20);
         when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(20);
         when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
@@ -331,7 +331,7 @@ public class EgressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleRemoveTcp1() throws Exception {
-        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn("tcp");
+        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_TCP);
         when(portSecurityRule.getSecurityRulePortMax()).thenReturn(30);
         when(portSecurityRule.getSecurityRulePortMin()).thenReturn(30);
         when(portSecurityRule.getSecurityRuleRemoteIpPrefix()).thenReturn("0.0.0.0/24");
@@ -359,7 +359,7 @@ public class EgressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleIpv6RemoveTcp1() throws Exception {
-        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("tcp");
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_TCP);
         when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(30);
         when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(30);
         when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
@@ -387,7 +387,7 @@ public class EgressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleAddTcp2() throws Exception {
-        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn("tcp");
+        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_TCP);
         when(portSecurityRule.getSecurityRulePortMax()).thenReturn(40);
         when(portSecurityRule.getSecurityRulePortMin()).thenReturn(40);
         when(portSecurityRule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
@@ -421,7 +421,7 @@ public class EgressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleIpv6AddTcp2() throws Exception {
-        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("tcp");
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_TCP);
         when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(40);
         when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(40);
         when(portSecurityIpv6Rule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
@@ -455,7 +455,7 @@ public class EgressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleRemoveTcp2() throws Exception {
-        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn("tcp");
+        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_TCP);
         when(portSecurityRule.getSecurityRulePortMax()).thenReturn(50);
         when(portSecurityRule.getSecurityRulePortMin()).thenReturn(50);
         when(portSecurityRule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
@@ -490,7 +490,7 @@ public class EgressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleIpv6RemoveTcp2() throws Exception {
-        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("tcp");
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_TCP);
         when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(50);
         when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(50);
         when(portSecurityIpv6Rule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
@@ -525,7 +525,7 @@ public class EgressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleAddTcpAll1() throws Exception {
-        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn("tcp");
+        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_TCP);
         when(portSecurityRule.getSecurityRulePortMax()).thenReturn(PORT_RANGE_MAX);
         when(portSecurityRule.getSecurityRulePortMin()).thenReturn(PORT_RANGE_MIN);
         when(portSecurityRule.getSecurityRuleRemoteIpPrefix()).thenReturn("0.0.0.0/24");
@@ -547,7 +547,7 @@ public class EgressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleIpv6AddTcpAll1() throws Exception {
-        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("tcp");
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_TCP);
         when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(PORT_RANGE_MAX);
         when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(PORT_RANGE_MIN);
         when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
@@ -569,7 +569,7 @@ public class EgressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleRemoveTcpAll1() throws Exception {
-        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn("tcp");
+        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_TCP);
         when(portSecurityRule.getSecurityRulePortMax()).thenReturn(PORT_RANGE_MAX);
         when(portSecurityRule.getSecurityRulePortMin()).thenReturn(PORT_RANGE_MIN);
         when(portSecurityRule.getSecurityRuleRemoteIpPrefix()).thenReturn("0.0.0.0/24");
@@ -593,7 +593,7 @@ public class EgressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleIpv6RemoveTcpAll1() throws Exception {
-        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("tcp");
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_TCP);
         when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(PORT_RANGE_MAX);
         when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(PORT_RANGE_MIN);
         when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
@@ -617,7 +617,7 @@ public class EgressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleAddTcpAll2() throws Exception {
-        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn("tcp");
+        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_TCP);
         when(portSecurityRule.getSecurityRulePortMax()).thenReturn(PORT_RANGE_MAX);
         when(portSecurityRule.getSecurityRulePortMin()).thenReturn(PORT_RANGE_MIN);
         when(portSecurityRule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
@@ -649,7 +649,7 @@ public class EgressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleIpv6AddTcpAll2() throws Exception {
-        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("tcp");
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_TCP);
         when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(PORT_RANGE_MAX);
         when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(PORT_RANGE_MIN);
         when(portSecurityIpv6Rule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
@@ -681,7 +681,7 @@ public class EgressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleRemoveTcpAll2() throws Exception {
-        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn("tcp");
+        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_TCP);
         when(portSecurityRule.getSecurityRulePortMax()).thenReturn(PORT_RANGE_MAX);
         when(portSecurityRule.getSecurityRulePortMin()).thenReturn(PORT_RANGE_MIN);
         when(portSecurityRule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
@@ -714,7 +714,7 @@ public class EgressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleIpv6RemoveTcpAll2() throws Exception {
-        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("tcp");
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_TCP);
         when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(PORT_RANGE_MAX);
         when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(PORT_RANGE_MIN);
         when(portSecurityIpv6Rule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
@@ -747,7 +747,7 @@ public class EgressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleAddUdp1() throws Exception {
-        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn("udp");
+        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_UDP);
         when(portSecurityRule.getSecurityRulePortMax()).thenReturn(50);
         when(portSecurityRule.getSecurityRulePortMin()).thenReturn(50);
         when(portSecurityRule.getSecurityRuleRemoteIpPrefix()).thenReturn("0.0.0.0/24");
@@ -774,7 +774,7 @@ public class EgressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleIpv6AddUdp1() throws Exception {
-        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("udp");
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_UDP);
         when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(50);
         when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(50);
         when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
@@ -801,7 +801,7 @@ public class EgressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleRemoveUdp1() throws Exception {
-        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn("udp");
+        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_UDP);
         when(portSecurityRule.getSecurityRulePortMax()).thenReturn(50);
         when(portSecurityRule.getSecurityRulePortMin()).thenReturn(50);
         when(portSecurityRule.getSecurityRuleRemoteIpPrefix()).thenReturn("0.0.0.0/24");
@@ -828,7 +828,7 @@ public class EgressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleIpv6RemoveUdp1() throws Exception {
-        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("udp");
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_UDP);
         when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(50);
         when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(50);
         when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
@@ -855,7 +855,7 @@ public class EgressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleAddUdp2() throws Exception {
-        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn("udp");
+        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_UDP);
         when(portSecurityRule.getSecurityRulePortMax()).thenReturn(50);
         when(portSecurityRule.getSecurityRulePortMin()).thenReturn(50);
         when(portSecurityRule.getSecurityRuleRemoteIpPrefix()).thenReturn("0.0.0.0/24");
@@ -891,7 +891,7 @@ public class EgressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleIpv6AddUdp2() throws Exception {
-        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("udp");
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_UDP);
         when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(50);
         when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(50);
         when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
@@ -927,7 +927,7 @@ public class EgressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleRemoveUdp2() throws Exception {
-        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn("udp");
+        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_UDP);
         when(portSecurityRule.getSecurityRulePortMax()).thenReturn(50);
         when(portSecurityRule.getSecurityRulePortMin()).thenReturn(50);
         when(portSecurityRule.getSecurityRuleRemoteIpPrefix()).thenReturn("0.0.0.0/24");
@@ -963,7 +963,7 @@ public class EgressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleIpv6RemoveUdp2() throws Exception {
-        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("udp");
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_UDP);
         when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(50);
         when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(50);
         when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
@@ -999,7 +999,7 @@ public class EgressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleAddUdpAll1() throws Exception {
-        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn("udp");
+        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_UDP);
         when(portSecurityRule.getSecurityRulePortMax()).thenReturn(PORT_RANGE_MAX);
         when(portSecurityRule.getSecurityRulePortMin()).thenReturn(PORT_RANGE_MIN);
         when(portSecurityRule.getSecurityRuleRemoteIpPrefix()).thenReturn("0.0.0.0/24");
@@ -1023,7 +1023,7 @@ public class EgressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleIpv6AddUdpAll1() throws Exception {
-        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("udp");
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_UDP);
         when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(PORT_RANGE_MAX);
         when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(PORT_RANGE_MIN);
         when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
@@ -1047,7 +1047,7 @@ public class EgressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleRemoveUdpAll1() throws Exception {
-        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn("udp");
+        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_UDP);
         when(portSecurityRule.getSecurityRulePortMax()).thenReturn(PORT_RANGE_MAX);
         when(portSecurityRule.getSecurityRulePortMin()).thenReturn(PORT_RANGE_MIN);
         when(portSecurityRule.getSecurityRuleRemoteIpPrefix()).thenReturn("0.0.0.0/24");
@@ -1071,7 +1071,7 @@ public class EgressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleIpv6RemoveUdpAll1() throws Exception {
-        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("udp");
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_UDP);
         when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(PORT_RANGE_MAX);
         when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(PORT_RANGE_MIN);
         when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
@@ -1095,7 +1095,7 @@ public class EgressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleAddUdpAll2() throws Exception {
-        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn("udp");
+        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_UDP);
         when(portSecurityRule.getSecurityRulePortMax()).thenReturn(PORT_RANGE_MAX);
         when(portSecurityRule.getSecurityRulePortMin()).thenReturn(PORT_RANGE_MIN);
         when(portSecurityRule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
@@ -1127,7 +1127,7 @@ public class EgressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleIpv6AddUdpAll2() throws Exception {
-        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("udp");
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_UDP);
         when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(PORT_RANGE_MAX);
         when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(PORT_RANGE_MIN);
         when(portSecurityIpv6Rule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
@@ -1159,7 +1159,7 @@ public class EgressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleRemoveUdpAll2() throws Exception {
-        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn("udp");
+        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_UDP);
         when(portSecurityRule.getSecurityRulePortMax()).thenReturn(PORT_RANGE_MAX);
         when(portSecurityRule.getSecurityRulePortMin()).thenReturn(PORT_RANGE_MIN);
         when(portSecurityRule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
@@ -1191,7 +1191,7 @@ public class EgressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleIpv6RemoveUdpAll2() throws Exception {
-        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("udp");
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_UDP);
         when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(PORT_RANGE_MAX);
         when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(PORT_RANGE_MIN);
         when(portSecurityIpv6Rule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
@@ -1223,7 +1223,7 @@ public class EgressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleAddIcmp1() throws Exception {
-        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn("icmp");
+        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_ICMP);
         when(portSecurityRule.getSecurityRulePortMax()).thenReturn(10);
         when(portSecurityRule.getSecurityRulePortMin()).thenReturn(10);
         when(portSecurityRule.getSecurityRuleRemoteIpPrefix()).thenReturn("0.0.0.0/24");
@@ -1251,7 +1251,7 @@ public class EgressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleIpv6AddIcmp1() throws Exception {
-        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("icmpv6");
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_ICMPV6);
         when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(10);
         when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(10);
         when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
@@ -1279,7 +1279,7 @@ public class EgressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleRemoveIcmp1() throws Exception {
-        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn("icmp");
+        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_ICMP);
         when(portSecurityRule.getSecurityRulePortMax()).thenReturn(20);
         when(portSecurityRule.getSecurityRulePortMin()).thenReturn(20);
         when(portSecurityRule.getSecurityRuleRemoteIpPrefix()).thenReturn("0.0.0.0/24");
@@ -1307,7 +1307,7 @@ public class EgressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleIpv6RemoveIcmp1() throws Exception {
-        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("icmpv6");
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_ICMPV6);
         when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(20);
         when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(20);
         when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
@@ -1335,7 +1335,7 @@ public class EgressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleAddIcmp2() throws Exception {
-        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn("icmp");
+        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_ICMP);
         when(portSecurityRule.getSecurityRulePortMax()).thenReturn(30);
         when(portSecurityRule.getSecurityRulePortMin()).thenReturn(30);
         when(portSecurityRule.getSecurityRuleRemoteIpPrefix()).thenReturn("0.0.0.0/24");
@@ -1372,7 +1372,7 @@ public class EgressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleIpv6AddIcmp2() throws Exception {
-        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("icmpv6");
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_ICMPV6);
         when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(30);
         when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(30);
         when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
@@ -1409,7 +1409,7 @@ public class EgressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleRemoveIcmp2() throws Exception {
-        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn("icmp");
+        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_ICMP);
         when(portSecurityRule.getSecurityRulePortMax()).thenReturn(40);
         when(portSecurityRule.getSecurityRulePortMin()).thenReturn(40);
         when(portSecurityRule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
@@ -1445,7 +1445,7 @@ public class EgressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleIpv6RemoveIcmp2() throws Exception {
-        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("icmpv6");
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_ICMPV6);
         when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(40);
         when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(40);
         when(portSecurityIpv6Rule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
@@ -1495,7 +1495,7 @@ public class EgressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleInvalidDirection() throws Exception {
-        when(portSecurityRule.getSecurityRuleDirection()).thenReturn("ingress");
+        when(portSecurityRule.getSecurityRuleDirection()).thenReturn(NeutronSecurityRule.DIRECTION_INGRESS);
 
         egressAclServiceSpy.programPortSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 124, securityGroup,PORT_UUID,false);
 
index 37f87492acecce4769a6191e841c79c17373e4e0..74c7f8cb161d080a735d83a272332725927441ff 100644 (file)
@@ -128,8 +128,8 @@ public class IngressAclServiceTest {
         when(orchestrator.getNextServiceInPipeline(any(Service.class))).thenReturn(Service.ARP_RESPONDER);
 
         portSecurityRule = mock(NeutronSecurityRule.class);
-        when(portSecurityRule.getSecurityRuleEthertype()).thenReturn("IPv4");
-        when(portSecurityRule.getSecurityRuleDirection()).thenReturn("ingress");
+        when(portSecurityRule.getSecurityRuleEthertype()).thenReturn(NeutronSecurityRule.ETHERTYPE_IPV4);
+        when(portSecurityRule.getSecurityRuleDirection()).thenReturn(NeutronSecurityRule.DIRECTION_INGRESS);
 
         List<NeutronSecurityRule> portSecurityList = new ArrayList<>();
         portSecurityList.add(portSecurityRule);
@@ -147,8 +147,8 @@ public class IngressAclServiceTest {
         neutronDestIpList.add(neutron_ip_dest_2);
 
         portSecurityIpv6Rule = mock(NeutronSecurityRule.class);
-        when(portSecurityIpv6Rule.getSecurityRuleEthertype()).thenReturn("IPv6");
-        when(portSecurityIpv6Rule.getSecurityRuleDirection()).thenReturn("ingress");
+        when(portSecurityIpv6Rule.getSecurityRuleEthertype()).thenReturn(NeutronSecurityRule.ETHERTYPE_IPV6);
+        when(portSecurityIpv6Rule.getSecurityRuleDirection()).thenReturn(NeutronSecurityRule.DIRECTION_INGRESS);
 
         List<NeutronSecurityRule> portSecurityIpv6List = new ArrayList<>();
         portSecurityIpv6List.add(portSecurityIpv6Rule);
@@ -177,15 +177,15 @@ public class IngressAclServiceTest {
     @Test
     public void testProgramPortSecurityGroupWithIncompleteRule() throws Exception {
         NeutronSecurityRule portSecurityRule1 = mock(NeutronSecurityRule.class);
-        when(portSecurityRule1.getSecurityRuleEthertype()).thenReturn("IPv4");
+        when(portSecurityRule1.getSecurityRuleEthertype()).thenReturn(NeutronSecurityRule.ETHERTYPE_IPV4);
         when(portSecurityRule1.getSecurityRuleDirection()).thenReturn("not_ingress");  // other direction
 
         NeutronSecurityRule portSecurityRule2 = mock(NeutronSecurityRule.class);
         when(portSecurityRule2.getSecurityRuleEthertype()).thenReturn(null);
-        when(portSecurityRule2.getSecurityRuleDirection()).thenReturn("ingress");
+        when(portSecurityRule2.getSecurityRuleDirection()).thenReturn(NeutronSecurityRule.DIRECTION_INGRESS);
 
         NeutronSecurityRule portSecurityRule3 = mock(NeutronSecurityRule.class);
-        when(portSecurityRule3.getSecurityRuleEthertype()).thenReturn("IPv4");
+        when(portSecurityRule3.getSecurityRuleEthertype()).thenReturn(NeutronSecurityRule.ETHERTYPE_IPV4);
         when(portSecurityRule3.getSecurityRuleDirection()).thenReturn(null);
 
         NeutronSecurityRule portSecurityRule4 = mock(NeutronSecurityRule.class);
@@ -279,7 +279,7 @@ public class IngressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleAddTcp1() throws Exception {
-        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn("tcp");
+        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_TCP);
         when(portSecurityRule.getSecurityRulePortMax()).thenReturn(20);
         when(portSecurityRule.getSecurityRulePortMin()).thenReturn(20);
         when(portSecurityRule.getSecurityRuleRemoteIpPrefix()).thenReturn("0.0.0.0/24");
@@ -307,7 +307,7 @@ public class IngressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleIpv6AddTcp1() throws Exception {
-        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("tcp");
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_TCP);
         when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(20);
         when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(20);
         when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
@@ -335,7 +335,7 @@ public class IngressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleRemoveTcp1() throws Exception {
-        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn("tcp");
+        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_TCP);
         when(portSecurityRule.getSecurityRulePortMax()).thenReturn(15);
         when(portSecurityRule.getSecurityRulePortMin()).thenReturn(15);
         when(portSecurityRule.getSecurityRuleRemoteIpPrefix()).thenReturn("0.0.0.0/24");
@@ -363,7 +363,7 @@ public class IngressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleIpv6RemoveTcp1() throws Exception {
-        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("tcp");
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_TCP);
         when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(15);
         when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(15);
         when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
@@ -391,7 +391,7 @@ public class IngressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleAddTcp2() throws Exception {
-        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn("tcp");
+        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_TCP);
         when(portSecurityRule.getSecurityRulePortMax()).thenReturn(50);
         when(portSecurityRule.getSecurityRulePortMin()).thenReturn(50);
         when(portSecurityRule.getSecurityRuleRemoteIpPrefix()).thenReturn("0.0.0.0/24");
@@ -427,7 +427,7 @@ public class IngressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleIpv6AddTcp2() throws Exception {
-        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("tcp");
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_TCP);
         when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(50);
         when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(50);
         when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
@@ -463,7 +463,7 @@ public class IngressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleRemoveTcp2() throws Exception {
-        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn("tcp");
+        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_TCP);
         when(portSecurityRule.getSecurityRulePortMax()).thenReturn(50);
         when(portSecurityRule.getSecurityRulePortMin()).thenReturn(50);
         when(portSecurityRule.getSecurityRuleRemoteIpPrefix()).thenReturn("0.0.0.0/24");
@@ -501,7 +501,7 @@ public class IngressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleIpv6RemoveTcp2() throws Exception {
-        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("tcp");
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_TCP);
         when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(50);
         when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(50);
         when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
@@ -538,7 +538,7 @@ public class IngressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleAddTcpAll1() throws Exception {
-        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn("tcp");
+        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_TCP);
         when(portSecurityRule.getSecurityRulePortMax()).thenReturn(PORT_RANGE_MAX);
         when(portSecurityRule.getSecurityRulePortMin()).thenReturn(PORT_RANGE_MIN);
         when(portSecurityRule.getSecurityRuleRemoteIpPrefix()).thenReturn("0.0.0.0/24");
@@ -563,7 +563,7 @@ public class IngressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleIpv6AddTcpAll1() throws Exception {
-        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("tcp");
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_TCP);
         when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(PORT_RANGE_MAX);
         when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(PORT_RANGE_MIN);
         when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
@@ -588,7 +588,7 @@ public class IngressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleRemoveTcpAll1() throws Exception {
-        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn("tcp");
+        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_TCP);
         when(portSecurityRule.getSecurityRulePortMax()).thenReturn(PORT_RANGE_MAX);
         when(portSecurityRule.getSecurityRulePortMin()).thenReturn(PORT_RANGE_MIN);
         when(portSecurityRule.getSecurityRuleRemoteIpPrefix()).thenReturn("0.0.0.0/24");
@@ -613,7 +613,7 @@ public class IngressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleIpv6RemoveTcpAll1() throws Exception {
-        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("tcp");
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_TCP);
         when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(PORT_RANGE_MAX);
         when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(PORT_RANGE_MIN);
         when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
@@ -638,7 +638,7 @@ public class IngressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleAddTcpAll2() throws Exception {
-        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn("tcp");
+        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_TCP);
         when(portSecurityRule.getSecurityRulePortMax()).thenReturn(PORT_RANGE_MAX);
         when(portSecurityRule.getSecurityRulePortMin()).thenReturn(PORT_RANGE_MIN);
         when(portSecurityRule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
@@ -670,7 +670,7 @@ public class IngressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleIpv6AddTcpAll2() throws Exception {
-        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("tcp");
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_TCP);
         when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(PORT_RANGE_MAX);
         when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(PORT_RANGE_MIN);
         when(portSecurityIpv6Rule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
@@ -702,7 +702,7 @@ public class IngressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleRemoveTcpAll2() throws Exception {
-        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn("tcp");
+        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_TCP);
         when(portSecurityRule.getSecurityRulePortMax()).thenReturn(PORT_RANGE_MAX);
         when(portSecurityRule.getSecurityRulePortMin()).thenReturn(PORT_RANGE_MIN);
         when(portSecurityRule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
@@ -736,7 +736,7 @@ public class IngressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleIpv6RemoveTcpAll2() throws Exception {
-        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("tcp");
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_TCP);
         when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(PORT_RANGE_MAX);
         when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(PORT_RANGE_MIN);
         when(portSecurityIpv6Rule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
@@ -770,7 +770,7 @@ public class IngressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleAddUdp1() throws Exception {
-        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn("udp");
+        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_UDP);
         when(portSecurityRule.getSecurityRulePortMax()).thenReturn(50);
         when(portSecurityRule.getSecurityRulePortMin()).thenReturn(50);
         when(portSecurityRule.getSecurityRuleRemoteIpPrefix()).thenReturn("0.0.0.0/24");
@@ -798,7 +798,7 @@ public class IngressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleIpv6AddUdp1() throws Exception {
-        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("udp");
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_UDP);
         when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(50);
         when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(50);
         when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
@@ -826,7 +826,7 @@ public class IngressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleRemoveUdp1() throws Exception {
-        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn("udp");
+        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_UDP);
         when(portSecurityRule.getSecurityRulePortMax()).thenReturn(50);
         when(portSecurityRule.getSecurityRulePortMin()).thenReturn(50);
         when(portSecurityRule.getSecurityRuleRemoteIpPrefix()).thenReturn("0.0.0.0/24");
@@ -854,7 +854,7 @@ public class IngressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleIpv6RemoveUdp1() throws Exception {
-        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("udp");
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_UDP);
         when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(50);
         when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(50);
         when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
@@ -882,7 +882,7 @@ public class IngressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleAddUdp2() throws Exception {
-        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn("udp");
+        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_UDP);
         when(portSecurityRule.getSecurityRulePortMax()).thenReturn(50);
         when(portSecurityRule.getSecurityRulePortMin()).thenReturn(50);
         when(portSecurityRule.getSecurityRuleRemoteIpPrefix()).thenReturn("0.0.0.0/24");
@@ -918,7 +918,7 @@ public class IngressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleIpv6AddUdp2() throws Exception {
-        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("udp");
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_UDP);
         when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(50);
         when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(50);
         when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
@@ -954,7 +954,7 @@ public class IngressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleRemoveUdp2() throws Exception {
-        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn("udp");
+        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_UDP);
         when(portSecurityRule.getSecurityRulePortMax()).thenReturn(50);
         when(portSecurityRule.getSecurityRulePortMin()).thenReturn(50);
         when(portSecurityRule.getSecurityRuleRemoteIpPrefix()).thenReturn("0.0.0.0/24");
@@ -990,7 +990,7 @@ public class IngressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleIpv6RemoveUdp2() throws Exception {
-        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("udp");
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_UDP);
         when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(50);
         when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(50);
         when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
@@ -1026,7 +1026,7 @@ public class IngressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleAddUdpAll1() throws Exception {
-        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn("udp");
+        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_UDP);
         when(portSecurityRule.getSecurityRulePortMax()).thenReturn(PORT_RANGE_MAX);
         when(portSecurityRule.getSecurityRulePortMin()).thenReturn(PORT_RANGE_MIN);
         when(portSecurityRule.getSecurityRuleRemoteIpPrefix()).thenReturn("0.0.0.0/24");
@@ -1051,7 +1051,7 @@ public class IngressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleIPv6AddUdpAll1() throws Exception {
-        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("udp");
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_UDP);
         when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(PORT_RANGE_MAX);
         when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(PORT_RANGE_MIN);
         when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
@@ -1076,7 +1076,7 @@ public class IngressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleRemoveUdpAll1() throws Exception {
-        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn("udp");
+        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_UDP);
         when(portSecurityRule.getSecurityRulePortMax()).thenReturn(PORT_RANGE_MAX);
         when(portSecurityRule.getSecurityRulePortMin()).thenReturn(PORT_RANGE_MIN);
         when(portSecurityRule.getSecurityRuleRemoteIpPrefix()).thenReturn("0.0.0.0/24");
@@ -1101,7 +1101,7 @@ public class IngressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleIpv6RemoveUdpAll1() throws Exception {
-        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("udp");
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_UDP);
         when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(PORT_RANGE_MAX);
         when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(PORT_RANGE_MIN);
         when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
@@ -1126,7 +1126,7 @@ public class IngressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleAddUdpAll2() throws Exception {
-        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn("udp");
+        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_UDP);
         when(portSecurityRule.getSecurityRulePortMax()).thenReturn(PORT_RANGE_MAX);
         when(portSecurityRule.getSecurityRulePortMin()).thenReturn(PORT_RANGE_MIN);
         when(portSecurityRule.getSecurityRuleRemoteIpPrefix()).thenReturn("0.0.0.0/24");
@@ -1159,7 +1159,7 @@ public class IngressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleIpv6AddUdpAll2() throws Exception {
-        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("udp");
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_UDP);
         when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(PORT_RANGE_MAX);
         when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(PORT_RANGE_MIN);
         when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
@@ -1192,7 +1192,7 @@ public class IngressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleRemoveUdpAll2() throws Exception {
-        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn("udp");
+        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_UDP);
         when(portSecurityRule.getSecurityRulePortMax()).thenReturn(PORT_RANGE_MAX);
         when(portSecurityRule.getSecurityRulePortMin()).thenReturn(PORT_RANGE_MIN);
         when(portSecurityRule.getSecurityRuleRemoteIpPrefix()).thenReturn("0.0.0.0/24");
@@ -1225,7 +1225,7 @@ public class IngressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleIpv6RemoveUdpAll2() throws Exception {
-        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("udp");
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_UDP);
         when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(PORT_RANGE_MAX);
         when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(PORT_RANGE_MIN);
         when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
@@ -1258,7 +1258,7 @@ public class IngressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleAddIcmp1() throws Exception {
-        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn("icmp");
+        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_ICMP);
         when(portSecurityRule.getSecurityRulePortMax()).thenReturn(10);
         when(portSecurityRule.getSecurityRulePortMin()).thenReturn(10);
         when(portSecurityRule.getSecurityRuleRemoteIpPrefix()).thenReturn("0.0.0.0/24");
@@ -1286,7 +1286,7 @@ public class IngressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleIpv6AddIcmp1() throws Exception {
-        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("icmpv6");
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_ICMPV6);
         when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(10);
         when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(10);
         when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
@@ -1315,7 +1315,7 @@ public class IngressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleRemoveIcmp1() throws Exception {
-        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn("icmp");
+        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_ICMP);
         when(portSecurityRule.getSecurityRulePortMax()).thenReturn(20);
         when(portSecurityRule.getSecurityRulePortMin()).thenReturn(20);
         when(portSecurityRule.getSecurityRuleRemoteIpPrefix()).thenReturn("0.0.0.0/24");
@@ -1343,7 +1343,7 @@ public class IngressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleIpv6RemoveIcmp1() throws Exception {
-        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("icmpv6");
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_ICMPV6);
         when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(20);
         when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(20);
         when(portSecurityIpv6Rule.getSecurityRuleRemoteIpPrefix()).thenReturn("::/64");
@@ -1371,7 +1371,7 @@ public class IngressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleAddIcmp2() throws Exception {
-        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn("icmp");
+        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_ICMP);
         when(portSecurityRule.getSecurityRulePortMax()).thenReturn(30);
         when(portSecurityRule.getSecurityRulePortMin()).thenReturn(30);
         when(portSecurityRule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
@@ -1406,7 +1406,7 @@ public class IngressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleIpv6AddIcmp2() throws Exception {
-        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("icmpv6");
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_ICMPV6);
         when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(30);
         when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(30);
         when(portSecurityIpv6Rule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
@@ -1442,7 +1442,7 @@ public class IngressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleRemoveIcmp2() throws Exception {
-        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn("icmp");
+        when(portSecurityRule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_ICMP);
         when(portSecurityRule.getSecurityRulePortMax()).thenReturn(40);
         when(portSecurityRule.getSecurityRulePortMin()).thenReturn(40);
         when(portSecurityRule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
@@ -1477,7 +1477,7 @@ public class IngressAclServiceTest {
      */
     @Test
     public void testProgramPortSecurityACLRuleIpv6RemoveIcmp2() throws Exception {
-        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn("icmpv6");
+        when(portSecurityIpv6Rule.getSecurityRuleProtocol()).thenReturn(NeutronSecurityRule.PROTOCOL_ICMPV6);
         when(portSecurityIpv6Rule.getSecurityRulePortMax()).thenReturn(40);
         when(portSecurityIpv6Rule.getSecurityRulePortMin()).thenReturn(40);
         when(portSecurityIpv6Rule.getSecurityRemoteGroupID()).thenReturn("85cc3048-abc3-43cc-89b3-377341426ac5");
index fe878c3cc6eb032b46cac74f7de87921649ceb59..f6bcd574655c636e46f2ac7fa95bdf00f40f7b65 100644 (file)
@@ -498,15 +498,14 @@ public class SecurityServicesImpl implements ConfigInterface, SecurityServicesMa
             if (dpid == 0L) {
                 return;
             }
-            if ("IPv4".equals(securityRule.getSecurityRuleEthertype())
-                    && "ingress".equals(securityRule.getSecurityRuleDirection())) {
-
-                ingressAclProvider.programPortSecurityRule(dpid, segmentationId, attachedMac, localPort,
-                                                           securityRule, vmIp, write);
-            } else if (securityRule.getSecurityRuleEthertype().equals("IPv4")
-                    && securityRule.getSecurityRuleDirection().equals("egress")) {
-                egressAclProvider.programPortSecurityRule(dpid, segmentationId, attachedMac, localPort,
-                                                          securityRule, vmIp, write);
+            if (NeutronSecurityRule.ETHERTYPE_IPV4.equals(securityRule.getSecurityRuleEthertype())) {
+                if (NeutronSecurityRule.DIRECTION_INGRESS.equals(securityRule.getSecurityRuleDirection())) {
+                    ingressAclProvider.programPortSecurityRule(dpid, segmentationId, attachedMac, localPort,
+                            securityRule, vmIp, write);
+                } else if (NeutronSecurityRule.DIRECTION_EGRESS.equals(securityRule.getSecurityRuleDirection())) {
+                    egressAclProvider.programPortSecurityRule(dpid, segmentationId, attachedMac, localPort,
+                            securityRule, vmIp, write);
+                }
             }
         }
     }
index b8b9228a3e914e8bcfdd9721feecec026741128d..e8707dd7028316fe127be2fbcd2e492e2b6ee00b 100644 (file)
@@ -41,9 +41,17 @@ public class NeutronSecurityRule implements Serializable, INeutronObject {
     @XmlElement(name = "id")
     String securityRuleUUID;
 
+    public static final String DIRECTION_EGRESS = "egress";
+    public static final String DIRECTION_INGRESS = "ingress";
+
     @XmlElement(name = "direction")
     String securityRuleDirection;
 
+    public static final String PROTOCOL_ICMP = "icmp";
+    public static final String PROTOCOL_TCP = "tcp";
+    public static final String PROTOCOL_UDP = "udp";
+    public static final String PROTOCOL_ICMPV6 = "icmpv6";
+
     @XmlElement(name = "protocol")
     String securityRuleProtocol;
 
@@ -53,6 +61,9 @@ public class NeutronSecurityRule implements Serializable, INeutronObject {
     @XmlElement(name = "port_range_max")
     Integer securityRulePortMax;
 
+    public static final String ETHERTYPE_IPV4 = "IPv4";
+    public static final String ETHERTYPE_IPV6 = "IPv6";
+
     @XmlElement(name = "ethertype")
     String securityRuleEthertype;
 
index 8218c84f43a7923dd77f4202e8911c0a0f660918..0340011674eb0bb2d5de014233e95a13b7aeb565 100644 (file)
@@ -48,23 +48,17 @@ public class NeutronSecurityRuleInterface extends AbstractNeutronInterface<Secur
 
     private static final Logger LOGGER = LoggerFactory.getLogger(NeutronSecurityRuleInterface.class);
 
-    private static final ImmutableBiMap<Class<? extends DirectionBase>,String> DIRECTION_MAP
-    = new ImmutableBiMap.Builder<Class<? extends DirectionBase>,String>()
-    .put(DirectionEgress.class,"egress")
-    .put(DirectionIngress.class,"ingress")
-    .build();
-    private static final ImmutableBiMap<Class<? extends ProtocolBase>,String> PROTOCOL_MAP
-    = new ImmutableBiMap.Builder<Class<? extends ProtocolBase>,String>()
-    .put(ProtocolIcmp.class,"icmp")
-    .put(ProtocolTcp.class,"tcp")
-    .put(ProtocolUdp.class,"udp")
-    .put(ProtocolIcmpV6.class,"icmpv6")
-    .build();
-    private static final ImmutableBiMap<Class<? extends EthertypeBase>,String> ETHERTYPE_MAP
-    = new ImmutableBiMap.Builder<Class<? extends EthertypeBase>,String>()
-    .put(EthertypeV4.class,"IPv4")
-    .put(EthertypeV6.class,"IPv6")
-    .build();
+    private static final ImmutableBiMap<Class<? extends DirectionBase>, String> DIRECTION_MAP = ImmutableBiMap.of(
+            DirectionEgress.class, NeutronSecurityRule.DIRECTION_EGRESS,
+            DirectionIngress.class, NeutronSecurityRule.DIRECTION_INGRESS);
+    private static final ImmutableBiMap<Class<? extends ProtocolBase>, String> PROTOCOL_MAP = ImmutableBiMap.of(
+            ProtocolIcmp.class, NeutronSecurityRule.PROTOCOL_ICMP,
+            ProtocolTcp.class, NeutronSecurityRule.PROTOCOL_TCP,
+            ProtocolUdp.class, NeutronSecurityRule.PROTOCOL_UDP,
+            ProtocolIcmpV6.class, NeutronSecurityRule.PROTOCOL_ICMPV6);
+    private static final ImmutableBiMap<Class<? extends EthertypeBase>,String> ETHERTYPE_MAP = ImmutableBiMap.of(
+            EthertypeV4.class, NeutronSecurityRule.ETHERTYPE_IPV4,
+            EthertypeV6.class, NeutronSecurityRule.ETHERTYPE_IPV6);
 
     NeutronSecurityRuleInterface(ProviderContext providerContext) {
         super(providerContext);
@@ -107,10 +101,7 @@ public class NeutronSecurityRuleInterface extends AbstractNeutronInterface<Secur
     @Override
     public boolean neutronSecurityRuleExists(String uuid) {
         SecurityRule rule = readMd(createInstanceIdentifier(toMd(uuid)));
-        if (rule == null) {
-            return false;
-        }
-        return true;
+        return rule != null;
     }
 
     @Override
@@ -132,9 +123,7 @@ public class NeutronSecurityRuleInterface extends AbstractNeutronInterface<Secur
             }
         }
         LOGGER.debug("Exiting getSecurityRule, Found {} OpenStackSecurityRule", allSecurityRules.size());
-        List<NeutronSecurityRule> ans = new ArrayList<>();
-        ans.addAll(allSecurityRules);
-        return ans;
+        return new ArrayList<>(allSecurityRules);
     }
 
     @Override
@@ -197,10 +186,10 @@ public class NeutronSecurityRuleInterface extends AbstractNeutronInterface<Secur
             answer.setSecurityRuleEthertype(ETHERTYPE_MAP.get(rule.getEthertype()));
         }
         if (rule.getPortRangeMin() != null) {
-            answer.setSecurityRulePortMin(Integer.valueOf(rule.getPortRangeMin()));
+            answer.setSecurityRulePortMin(rule.getPortRangeMin());
         }
         if (rule.getPortRangeMax() != null) {
-            answer.setSecurityRulePortMax(Integer.valueOf(rule.getPortRangeMax()));
+            answer.setSecurityRulePortMax(rule.getPortRangeMax());
         }
         if (rule.getId() != null) {
             answer.setID(rule.getId().getValue());
@@ -240,10 +229,10 @@ public class NeutronSecurityRuleInterface extends AbstractNeutronInterface<Secur
             securityRuleBuilder.setEthertype(mapper.get(securityRule.getSecurityRuleEthertype()));
         }
         if (securityRule.getSecurityRulePortMin() != null) {
-            securityRuleBuilder.setPortRangeMin(Integer.valueOf(securityRule.getSecurityRulePortMin()));
+            securityRuleBuilder.setPortRangeMin(securityRule.getSecurityRulePortMin());
         }
         if (securityRule.getSecurityRulePortMax() != null) {
-            securityRuleBuilder.setPortRangeMax(Integer.valueOf(securityRule.getSecurityRulePortMax()));
+            securityRuleBuilder.setPortRangeMax(securityRule.getSecurityRulePortMax());
         }
         if (securityRule.getID() != null) {
             securityRuleBuilder.setId(toUuid(securityRule.getID()));
index cd474608c19b5cd9e2c243efaf6094006cea583c..a6cfd573a792901afaa49a8bbcf86a6cfe1cbb9f 100644 (file)
@@ -43,33 +43,26 @@ public class NeutronSecurityRuleDataChangeListener implements ClusteredDataChang
 
     private static final Logger LOG = LoggerFactory.getLogger(NeutronSecurityRuleDataChangeListener.class);
 
-    private static final ImmutableBiMap<Class<? extends DirectionBase>, String> DIRECTION_MAP
-        = new ImmutableBiMap.Builder<Class<? extends DirectionBase>, String>()
-        .put(DirectionEgress.class, "egress")
-        .put(DirectionIngress.class, "ingress").build();
-    private static final ImmutableBiMap<Class<? extends ProtocolBase>,String> PROTOCOL_MAP
-            = new ImmutableBiMap.Builder<Class<? extends ProtocolBase>,String>()
-            .put(ProtocolIcmp.class,"icmp")
-            .put(ProtocolTcp.class,"tcp")
-            .put(ProtocolUdp.class,"udp")
-            .put(ProtocolIcmpV6.class,"icmpv6")
-            .build();
-    private static final ImmutableBiMap<Class<? extends EthertypeBase>,String> ETHERTYPE_MAP
-            = new ImmutableBiMap.Builder<Class<? extends EthertypeBase>,String>()
-            .put(EthertypeV4.class,"IPv4")
-            .put(EthertypeV6.class,"IPv6")
-            .build();
+    private static final ImmutableBiMap<Class<? extends DirectionBase>, String> DIRECTION_MAP = ImmutableBiMap.of(
+            DirectionEgress.class, NeutronSecurityRule.DIRECTION_EGRESS,
+            DirectionIngress.class, NeutronSecurityRule.DIRECTION_INGRESS);
+    private static final ImmutableBiMap<Class<? extends ProtocolBase>, String> PROTOCOL_MAP = ImmutableBiMap.of(
+            ProtocolIcmp.class, NeutronSecurityRule.PROTOCOL_ICMP,
+            ProtocolTcp.class, NeutronSecurityRule.PROTOCOL_TCP,
+            ProtocolUdp.class, NeutronSecurityRule.PROTOCOL_UDP,
+            ProtocolIcmpV6.class, NeutronSecurityRule.PROTOCOL_ICMPV6);
+    private static final ImmutableBiMap<Class<? extends EthertypeBase>,String> ETHERTYPE_MAP = ImmutableBiMap.of(
+            EthertypeV4.class, NeutronSecurityRule.ETHERTYPE_IPV4,
+            EthertypeV6.class, NeutronSecurityRule.ETHERTYPE_IPV6);
 
     private ListenerRegistration<DataChangeListener> registration;
-    private DataBroker db;
 
     public NeutronSecurityRuleDataChangeListener(DataBroker db) {
-        this.db = db;
         InstanceIdentifier<SecurityRule> path = InstanceIdentifier
                 .create(Neutron.class).child(SecurityRules.class)
                 .child(SecurityRule.class);
         LOG.debug("Register listener for Neutron Secutiry rules model data changes");
-        registration = this.db.registerDataChangeListener(
+        registration = db.registerDataChangeListener(
                 LogicalDatastoreType.CONFIGURATION, path, this,
                 DataChangeScope.ONE);
 
@@ -164,12 +157,10 @@ public class NeutronSecurityRuleDataChangeListener implements ClusteredDataChang
                     .getEthertype()));
         }
         if (rule.getPortRangeMin() != null) {
-            answer.setSecurityRulePortMin(Integer.valueOf(rule
-                    .getPortRangeMin()));
+            answer.setSecurityRulePortMin(rule.getPortRangeMin());
         }
         if (rule.getPortRangeMax() != null) {
-            answer.setSecurityRulePortMax(Integer.valueOf(rule
-                    .getPortRangeMax()));
+            answer.setSecurityRulePortMax(rule.getPortRangeMax());
         }
         if (rule.getId() != null) {
             answer.setID(rule.getId().getValue());
index c471b4c5592cc1be952ce0968433c322a52a02f0..6506431d2731d73d340c3f6b139fe3c3c6e1cfdf 100644 (file)
@@ -161,7 +161,7 @@ public class SecurityServicesImplTest {
     }
 
     /**
-     * Test method {@link SecurityServicesImpl#isPortSecurityReady(Interface)}
+     * Test method {@link SecurityServicesImpl#isPortSecurityReady(OvsdbTerminationPointAugmentation)}
      */
     @Test
     public void testIsPortSecurityReady(){
@@ -169,7 +169,7 @@ public class SecurityServicesImplTest {
     }
 
     /**
-     * Test method {@link SecurityServicesImpl#getSecurityGroupInPortList(Interface)}
+     * Test method {@link SecurityServicesImpl#getSecurityGroupInPortList(OvsdbTerminationPointAugmentation)}
      */
     @Test
     public void testSecurityGroupInPort(){
@@ -458,8 +458,8 @@ public class SecurityServicesImplTest {
     public void testSyncSecurityRuleAdditionEgress() {
         List<NeutronSecurityRule> securityRuleList = new ArrayList<>();
         securityRuleList.add(neutronSecurityRule_1);
-        when(neutronSecurityRule_1.getSecurityRuleDirection()).thenReturn("egress");
-        when(neutronSecurityRule_1.getSecurityRuleEthertype()).thenReturn("IPv4");
+        when(neutronSecurityRule_1.getSecurityRuleDirection()).thenReturn(NeutronSecurityRule.DIRECTION_EGRESS);
+        when(neutronSecurityRule_1.getSecurityRuleEthertype()).thenReturn(NeutronSecurityRule.ETHERTYPE_IPV4);
         securityServicesImpl.syncSecurityRule(neutronPort_Vm1, neutronSecurityRule_1, neutron_ip_1, true);
         verify(egressAclService, times(1)).programPortSecurityRule(eq(new Long(1)), eq("1000"), eq("attached-mac"), eq(2L), eq(neutronSecurityRule_1), eq(neutron_ip_1), eq(true));
     }
@@ -471,8 +471,8 @@ public class SecurityServicesImplTest {
     public void testSyncSecurityRuleAdditionIngress() {
         List<NeutronSecurityRule> securityRuleList = new ArrayList<>();
         securityRuleList.add(neutronSecurityRule_1);
-        when(neutronSecurityRule_1.getSecurityRuleDirection()).thenReturn("ingress");
-        when(neutronSecurityRule_1.getSecurityRuleEthertype()).thenReturn("IPv4");
+        when(neutronSecurityRule_1.getSecurityRuleDirection()).thenReturn(NeutronSecurityRule.DIRECTION_INGRESS);
+        when(neutronSecurityRule_1.getSecurityRuleEthertype()).thenReturn(NeutronSecurityRule.ETHERTYPE_IPV4);
         securityServicesImpl.syncSecurityRule(neutronPort_Vm1, neutronSecurityRule_1, neutron_ip_1, true);
         verify(ingressAclService, times(1)).programPortSecurityRule(eq(new Long(1)), eq("1000"), eq("attached-mac"), eq(2L), eq(neutronSecurityRule_1), eq(neutron_ip_1), eq(true));
     }
@@ -484,8 +484,8 @@ public class SecurityServicesImplTest {
     public void testSyncSecurityRuleDeletionEgress() {
         List<NeutronSecurityRule> securityRuleList = new ArrayList<>();
         securityRuleList.add(neutronSecurityRule_1);
-        when(neutronSecurityRule_1.getSecurityRuleDirection()).thenReturn("egress");
-        when(neutronSecurityRule_1.getSecurityRuleEthertype()).thenReturn("IPv4");
+        when(neutronSecurityRule_1.getSecurityRuleDirection()).thenReturn(NeutronSecurityRule.DIRECTION_EGRESS);
+        when(neutronSecurityRule_1.getSecurityRuleEthertype()).thenReturn(NeutronSecurityRule.ETHERTYPE_IPV4);
         securityServicesImpl.syncSecurityRule(neutronPort_Vm1, neutronSecurityRule_1, neutron_ip_1, false);
         verify(egressAclService, times(1)).programPortSecurityRule(eq(new Long(1)), eq("1000"), eq("attached-mac"), eq(2L), eq(neutronSecurityRule_1), eq(neutron_ip_1), eq(false));
     }
@@ -497,8 +497,8 @@ public class SecurityServicesImplTest {
     public void testSyncSecurityRuleDeletionIngress() {
         List<NeutronSecurityRule> securityRuleList = new ArrayList<>();
         securityRuleList.add(neutronSecurityRule_1);
-        when(neutronSecurityRule_1.getSecurityRuleDirection()).thenReturn("ingress");
-        when(neutronSecurityRule_1.getSecurityRuleEthertype()).thenReturn("IPv4");
+        when(neutronSecurityRule_1.getSecurityRuleDirection()).thenReturn(NeutronSecurityRule.DIRECTION_INGRESS);
+        when(neutronSecurityRule_1.getSecurityRuleEthertype()).thenReturn(NeutronSecurityRule.ETHERTYPE_IPV4);
         securityServicesImpl.syncSecurityRule(neutronPort_Vm1, neutronSecurityRule_1, neutron_ip_1, false);
         verify(ingressAclService, times(1)).programPortSecurityRule(eq(new Long(1)), eq("1000"), eq("attached-mac"), eq(2L), eq(neutronSecurityRule_1), eq(neutron_ip_1), eq(false));
     }
@@ -510,8 +510,8 @@ public class SecurityServicesImplTest {
     public void testSyncSecurityRuleDeletionIngressPortNull() {
         List<NeutronSecurityRule> securityRuleList = new ArrayList<>();
         securityRuleList.add(neutronSecurityRule_1);
-        when(neutronSecurityRule_1.getSecurityRuleDirection()).thenReturn("ingress");
-        when(neutronSecurityRule_1.getSecurityRuleEthertype()).thenReturn("IPv4");
+        when(neutronSecurityRule_1.getSecurityRuleDirection()).thenReturn(NeutronSecurityRule.DIRECTION_INGRESS);
+        when(neutronSecurityRule_1.getSecurityRuleEthertype()).thenReturn(NeutronSecurityRule.ETHERTYPE_IPV4);
         securityServicesImpl.syncSecurityRule(null, neutronSecurityRule_1, neutron_ip_1, false);
         verify(ingressAclService, times(0)).programPortSecurityRule(eq(new Long(1)), eq("1000"), eq("attached-mac"), eq(2L), eq(neutronSecurityRule_1), eq(neutron_ip_1), eq(false));
     }
@@ -524,8 +524,8 @@ public class SecurityServicesImplTest {
         List<NeutronSecurityRule> securityRuleList = new ArrayList<>();
         securityRuleList.add(neutronSecurityRule_1);
         when(neutronPort_Vm1.getSecurityGroups()).thenReturn(null);
-        when(neutronSecurityRule_1.getSecurityRuleDirection()).thenReturn("ingress");
-        when(neutronSecurityRule_1.getSecurityRuleEthertype()).thenReturn("IPv4");
+        when(neutronSecurityRule_1.getSecurityRuleDirection()).thenReturn(NeutronSecurityRule.DIRECTION_INGRESS);
+        when(neutronSecurityRule_1.getSecurityRuleEthertype()).thenReturn(NeutronSecurityRule.ETHERTYPE_IPV4);
         securityServicesImpl.syncSecurityRule(neutronPort_Vm1, neutronSecurityRule_1, neutron_ip_1, false);
         verify(ingressAclService, times(0)).programPortSecurityRule(eq(new Long(1)), eq("1000"), eq("attached-mac"), eq(2L), eq(neutronSecurityRule_1), eq(neutron_ip_1), eq(false));
     }
@@ -537,8 +537,8 @@ public class SecurityServicesImplTest {
     public void testSyncSecurityRuleDeletionIngressAttachedMacNull() {
         List<NeutronSecurityRule> securityRuleList = new ArrayList<>();
         securityRuleList.add(neutronSecurityRule_1);
-        when(neutronSecurityRule_1.getSecurityRuleDirection()).thenReturn("ingress");
-        when(neutronSecurityRule_1.getSecurityRuleEthertype()).thenReturn("IPv4");
+        when(neutronSecurityRule_1.getSecurityRuleDirection()).thenReturn(NeutronSecurityRule.DIRECTION_INGRESS);
+        when(neutronSecurityRule_1.getSecurityRuleEthertype()).thenReturn(NeutronSecurityRule.ETHERTYPE_IPV4);
         when(southbound.getInterfaceExternalIdsValue(any(OvsdbTerminationPointAugmentation.class),eq("attached-mac"))).thenReturn(null);
         securityServicesImpl.syncSecurityRule(neutronPort_Vm1, neutronSecurityRule_1, neutron_ip_1, false);
         verify(ingressAclService, times(0)).programPortSecurityRule(eq(new Long(1)), eq("1000"), eq("attached-mac"), eq(2L), eq(neutronSecurityRule_1), eq(neutron_ip_1), eq(false));
@@ -552,8 +552,8 @@ public class SecurityServicesImplTest {
     public void testSyncSecurityRuleDeletionIngressNonIpV4() {
         List<NeutronSecurityRule> securityRuleList = new ArrayList<>();
         securityRuleList.add(neutronSecurityRule_1);
-        when(neutronSecurityRule_1.getSecurityRuleDirection()).thenReturn("ingress");
-        when(neutronSecurityRule_1.getSecurityRuleEthertype()).thenReturn("IPv6");
+        when(neutronSecurityRule_1.getSecurityRuleDirection()).thenReturn(NeutronSecurityRule.DIRECTION_INGRESS);
+        when(neutronSecurityRule_1.getSecurityRuleEthertype()).thenReturn(NeutronSecurityRule.ETHERTYPE_IPV6);
         securityServicesImpl.syncSecurityRule(neutronPort_Vm1, neutronSecurityRule_1, neutron_ip_1, false);
         verify(ingressAclService, times(0)).programPortSecurityRule(eq(new Long(1)), eq("1000"), eq("attached-mac"), eq(2L), eq(neutronSecurityRule_1), eq(neutron_ip_1), eq(false));
     }
@@ -566,7 +566,7 @@ public class SecurityServicesImplTest {
         List<NeutronSecurityRule> securityRuleList = new ArrayList<>();
         securityRuleList.add(neutronSecurityRule_1);
         when(neutronSecurityRule_1.getSecurityRuleDirection()).thenReturn("outgress");
-        when(neutronSecurityRule_1.getSecurityRuleEthertype()).thenReturn("IPv4");
+        when(neutronSecurityRule_1.getSecurityRuleEthertype()).thenReturn(NeutronSecurityRule.ETHERTYPE_IPV4);
         securityServicesImpl.syncSecurityRule(neutronPort_Vm1, neutronSecurityRule_1, neutron_ip_1, false);
         verify(ingressAclService, times(0)).programPortSecurityRule(eq(new Long(1)), eq("1000"), eq("attached-mac"), eq(2L), eq(neutronSecurityRule_1), eq(neutron_ip_1), eq(false));
     }