summaryrefslogtreecommitdiffstats
path: root/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read
diff options
context:
space:
mode:
Diffstat (limited to 'acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read')
-rw-r--r--acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/AbstractAclCustomizerTest.java (renamed from acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/AbstractVppAclCustomizerTest.java)109
-rw-r--r--acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/AclCustomizerTest.java52
-rw-r--r--acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/EgressAclCustomizerTest.java (renamed from acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/EgressVppAclCustomizerTest.java)30
-rw-r--r--acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/IngressAclCustomizerTest.java (renamed from acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/IngressVppAclCustomizerTest.java)32
-rw-r--r--acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/MacIpAclCustomizerTest.java183
-rw-r--r--acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/VppMacIpAclCustomizerTest.java150
6 files changed, 319 insertions, 237 deletions
diff --git a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/AbstractVppAclCustomizerTest.java b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/AbstractAclCustomizerTest.java
index 074b25b29..beda3ccff 100644
--- a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/AbstractVppAclCustomizerTest.java
+++ b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/AbstractAclCustomizerTest.java
@@ -25,6 +25,7 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import io.fd.hc2vpp.acl.AclIIds;
import io.fd.hc2vpp.acl.util.AclContextManager;
import io.fd.hc2vpp.common.test.read.InitializingListReaderCustomizerTest;
import io.fd.hc2vpp.common.translate.util.NamingContext;
@@ -35,29 +36,34 @@ import io.fd.vpp.jvpp.acl.dto.AclDetailsReplyDump;
import io.fd.vpp.jvpp.acl.dto.AclInterfaceListDetails;
import io.fd.vpp.jvpp.acl.dto.AclInterfaceListDetailsReplyDump;
import io.fd.vpp.jvpp.acl.dto.AclInterfaceListDump;
+import io.fd.vpp.jvpp.acl.dto.MacipAclInterfaceGetReply;
+import io.fd.vpp.jvpp.acl.dto.MacipAclInterfaceListDetails;
+import io.fd.vpp.jvpp.acl.dto.MacipAclInterfaceListDetailsReplyDump;
import io.fd.vpp.jvpp.acl.future.FutureJVppAclFacade;
import java.util.ArrayList;
+import java.util.Collections;
import javax.annotation.Nonnull;
import org.junit.Test;
import org.mockito.Mock;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfacesState;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214.VppAclInterfaceStateAugmentation;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214._interface.acl.attributes.Acl;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214.vpp.acls.base.attributes.VppAcls;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214.vpp.acls.base.attributes.VppAclsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214.vpp.acls.base.attributes.VppAclsKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev170615.VppAcl;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points.Interface;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points.InterfaceKey;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points._interface.acl.acl.sets.AclSet;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points._interface.acl.acl.sets.AclSetBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points._interface.acl.acl.sets.AclSetKey;
import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
-public abstract class AbstractVppAclCustomizerTest
- extends InitializingListReaderCustomizerTest<VppAcls, VppAclsKey, VppAclsBuilder> {
+public abstract class AbstractAclCustomizerTest
+ extends InitializingListReaderCustomizerTest<AclSet, AclSetKey, AclSetBuilder> {
protected static final String IF_NAME = "eth1";
protected static final int IF_ID = 1;
+ protected static final int ACL_ID = 1;
+ protected static final int ACL_MAC_ID = 2;
+ private static final String ACL_NAME = "acl-name";
+ private static final String ACL_MAC_NAME = "acl-mac-name";
protected static final String IF_NAME_NO_ACL = "eth2";
protected static final int IF_ID_NO_ACL = 2;
@@ -73,32 +79,39 @@ public abstract class AbstractVppAclCustomizerTest
@Mock
protected AclContextManager standardAclContext;
- protected AbstractVppAclCustomizerTest(final Class<? extends Builder<? extends DataObject>> parentBuilderClass) {
- super(VppAcls.class, parentBuilderClass);
+ @Mock
+ protected AclContextManager macIpAclContext;
+
+ protected AbstractAclCustomizerTest(final Class<? extends Builder<? extends DataObject>> parentBuilderClass) {
+ super(AclSet.class, parentBuilderClass);
}
- protected static InstanceIdentifier<Acl> getAclId(final String ifName) {
- return InstanceIdentifier.create(InterfacesState.class).child(Interface.class, new InterfaceKey(ifName))
- .augmentation(VppAclInterfaceStateAugmentation.class).child(Acl.class);
+ protected static KeyedInstanceIdentifier<Interface, InterfaceKey> getAclId(final String ifName) {
+ return AclIIds.ACLS_AP.child(Interface.class, new InterfaceKey(ifName));
}
@Override
protected void setUp() throws Exception {
defineMapping(mappingContext, IF_NAME, IF_ID, IFC_CTX_NAME);
defineMapping(mappingContext, IF_NAME_NO_ACL, IF_ID_NO_ACL, IFC_CTX_NAME);
+ when(macIpAclContext.getAclName(ACL_MAC_ID, mappingContext)).thenReturn(ACL_MAC_NAME);
+ when(standardAclContext.getAclName(ACL_ID, mappingContext)).thenReturn(ACL_NAME);
+ when(macIpAclContext.containsAcl(ACL_MAC_NAME, mappingContext)).thenReturn(true);
+ when(standardAclContext.containsAcl(ACL_NAME, mappingContext)).thenReturn(true);
+ final MacipAclInterfaceListDetailsReplyDump macReply = macAaclInterfaceDump(0);
+ when(aclApi.macipAclInterfaceListDump(any())).thenReturn(future(macReply));
+ final AclInterfaceListDetailsReplyDump reply = aclInterfaceDump((byte) 0);
+ when(aclApi.aclInterfaceListDump(any())).thenReturn(future(reply));
}
@Test
public void testGetAllIdsNoAclConfigured() throws ReadFailedException {
- final AclInterfaceListDetailsReplyDump reply = aclInterfaceDump((byte) 0);
- when(aclApi.aclInterfaceListDump(any())).thenReturn(future(reply));
assertTrue(getCustomizer().getAllIds(getWildcardedIid(IF_NAME), ctx).isEmpty());
}
@Test
public void testRead() throws ReadFailedException {
final String aclName = "acl-name";
- final Class<VppAcl> aclType = VppAcl.class;
defineMapping(mappingContext, aclName, 1, ACL_CTX_NAME);
final AclDetailsReplyDump reply = new AclDetailsReplyDump();
@@ -108,19 +121,25 @@ public abstract class AbstractVppAclCustomizerTest
reply.aclDetails.add(detail);
when(aclApi.aclDump(any())).thenReturn(future(reply));
- final VppAclsBuilder builder = mock(VppAclsBuilder.class);
- getCustomizer().readCurrentAttributes(getIid(IF_NAME, new VppAclsKey(aclName, aclType)), builder, ctx);
+ final AclSetBuilder builder = mock(AclSetBuilder.class);
+ getCustomizer().readCurrentAttributes(getIid(IF_NAME, new AclSetKey(aclName)), builder, ctx);
verify(builder).setName(aclName);
- verify(builder).setType(aclType);
}
@Test
public void testReadAllTwoIfacesInOneTx() throws ReadFailedException {
final AclInterfaceListDetailsReplyDump reply = aclInterfaceDump((byte) 2, "acl1", "acl2", "acl3");
+ final MacipAclInterfaceListDetailsReplyDump macReply = macAaclInterfaceDump(0);
+ final MacipAclInterfaceListDetailsReplyDump macReply2 = macAaclInterfaceDump(1);
+ final MacipAclInterfaceGetReply interfaceGet = macipAclInterfaceGetReply();
+
+
when(aclApi.aclInterfaceListDump(aclInterfaceRequest(IF_ID))).thenReturn(future(reply));
+ when(aclApi.macipAclInterfaceListDump(any())).thenReturn(future(macReply));
+ when(aclApi.macipAclInterfaceGet(any())).thenReturn(future(interfaceGet));
when(aclApi.aclInterfaceListDump(aclInterfaceRequest(IF_ID_NO_ACL)))
- .thenReturn(future(aclInterfaceDump((byte) 0)));
+ .thenReturn(future(aclInterfaceDump((byte) 0)));
// read all for interface with defined ACLs:
assertFalse(getCustomizer().getAllIds(getWildcardedIid(IF_NAME), ctx).isEmpty());
@@ -128,19 +147,28 @@ public abstract class AbstractVppAclCustomizerTest
assertEquals(0, getCustomizer().getAllIds(getWildcardedIid(IF_NAME_NO_ACL), ctx).size());
}
+ protected MacipAclInterfaceGetReply macipAclInterfaceGetReply(final String... aclNames) {
+ final MacipAclInterfaceGetReply reply = new MacipAclInterfaceGetReply();
+ reply.acls = new int[aclNames.length];
+ for (int i = 0; i < aclNames.length; ++i) {
+ defineMapping(mappingContext, aclNames[i], i, ACL_CTX_NAME);
+ reply.acls[i] = i;
+ }
+ reply.count = (byte) aclNames.length;
+ return reply;
+ }
+
@Test
public void testInit() {
final String aclName = "acl-name";
- final Class<VppAcl> aclType = VppAcl.class;
defineMapping(mappingContext, aclName, 1, ACL_CTX_NAME);
- final VppAcls readValue = new VppAclsBuilder().build();
+ final AclSet readValue = new AclSetBuilder().build();
final Initialized<? extends DataObject> cfgValue =
- getCustomizer().init(getIid(IF_NAME, new VppAclsKey(aclName, aclType)), readValue, ctx);
+ getCustomizer().init(getIid(IF_NAME, new AclSetKey(aclName)), readValue, ctx);
assertEquals(readValue, cfgValue.getData());
- assertNotNull(cfgValue.getId().firstKeyOf(
- org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface.class));
- assertEquals(cfgValue.getId().getTargetType(), VppAcls.class);
+ assertNotNull(cfgValue.getId().firstKeyOf(Interface.class));
+ assertEquals(cfgValue.getId().getTargetType(), AclSet.class);
}
protected AclInterfaceListDump aclInterfaceRequest(final int swIfIndex) {
@@ -157,12 +185,31 @@ public abstract class AbstractVppAclCustomizerTest
defineMapping(mappingContext, aclNames[i], i, ACL_CTX_NAME);
details.acls[i] = i;
}
+ details.count = (byte) aclNames.length;
details.nInput = nInput;
reply.aclInterfaceListDetails.add(details);
return reply;
}
- protected abstract InstanceIdentifier<VppAcls> getWildcardedIid(@Nonnull final String ifName);
+ protected MacipAclInterfaceListDetailsReplyDump macAaclInterfaceDump(int swIfIndex, final String... aclNames) {
+ final MacipAclInterfaceListDetailsReplyDump assignedAcls = new MacipAclInterfaceListDetailsReplyDump();
+
+ MacipAclInterfaceListDetails details = new MacipAclInterfaceListDetails();
+ details.swIfIndex = swIfIndex;
+ details.count = (byte) aclNames.length;
+ details.acls = new int[aclNames.length];
+ for (int i = 0; i < aclNames.length; ++i) {
+ defineMapping(mappingContext, aclNames[i], i, ACL_CTX_NAME);
+ details.acls[i] = i;
+ }
+
+ assignedAcls.macipAclInterfaceListDetails.add(details);
+ assignedAcls.macipAclInterfaceListDetails = Collections.singletonList(details);
+
+ return assignedAcls;
+ }
+
+ protected abstract InstanceIdentifier<AclSet> getWildcardedIid(@Nonnull final String ifName);
- protected abstract InstanceIdentifier<VppAcls> getIid(@Nonnull final String ifName, @Nonnull final VppAclsKey key);
+ protected abstract InstanceIdentifier<AclSet> getIid(@Nonnull final String ifName, @Nonnull final AclSetKey key);
} \ No newline at end of file
diff --git a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/AclCustomizerTest.java b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/AclCustomizerTest.java
index 1b4403b2d..7501815a6 100644
--- a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/AclCustomizerTest.java
+++ b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/AclCustomizerTest.java
@@ -35,18 +35,15 @@ import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import org.mockito.Mock;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.AccessLists;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.AccessListsBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.access.lists.Acl;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.access.lists.AclBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.access.lists.AclKey;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.access.lists.acl.access.list.entries.Ace;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.access.lists.acl.access.list.entries.ace.actions.packet.handling.Deny;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev170615.VppAcl;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev170615.VppMacipAcl;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev170615.access.lists.acl.access.list.entries.ace.matches.ace.type.VppAce;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev170615.access.lists.acl.access.list.entries.ace.matches.ace.type.vpp.ace.VppAceNodes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev170615.acl.ip.protocol.header.fields.ip.protocol.Other;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.Acls;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.AclsBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.Drop;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.Acl;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.AclBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.AclKey;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.Ace;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.matches.L4;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.acl.aces.ace.matches.l4.Icmp;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
@@ -58,7 +55,7 @@ public class AclCustomizerTest extends InitializingListReaderCustomizerTest<Acl,
private static final String MACIP_ACL_NAME = "vpp-macip-acl";
private static final String MACIP_ACE_NAME = "vpp-macip-ace";
private static final int MACIP_ACL_INDEX = 456;
- private static final short PROTOCOL = 2;
+ private static final short PROTOCOL = 1;
@Mock
private FutureJVppAclFacade aclApi;
@Mock
@@ -66,13 +63,12 @@ public class AclCustomizerTest extends InitializingListReaderCustomizerTest<Acl,
@Mock
private AclContextManager macipAclContext;
private KeyedInstanceIdentifier<Acl, AclKey> ACL_IID =
- InstanceIdentifier.create(AccessLists.class).child(Acl.class, new AclKey(
- ACL_NAME, VppAcl.class));
+ InstanceIdentifier.create(Acls.class).child(Acl.class, new AclKey(ACL_NAME));
private KeyedInstanceIdentifier<Acl, AclKey> MACIP_ACL_IID =
- InstanceIdentifier.create(AccessLists.class).child(Acl.class, new AclKey(MACIP_ACL_NAME, VppMacipAcl.class));
+ InstanceIdentifier.create(Acls.class).child(Acl.class, new AclKey(MACIP_ACL_NAME));
public AclCustomizerTest() {
- super(Acl.class, AccessListsBuilder.class);
+ super(Acl.class, AclsBuilder.class);
}
@Override
@@ -103,15 +99,18 @@ public class AclCustomizerTest extends InitializingListReaderCustomizerTest<Acl,
when(standardAclContext.getAclName(ACL_INDEX, mappingContext)).thenReturn(ACL_NAME);
when(standardAclContext.getAclIndex(ACL_NAME, mappingContext)).thenReturn(ACL_INDEX);
when(standardAclContext.getAceName(ACL_NAME, 0, mappingContext)).thenReturn(ACE_NAME);
+ when(standardAclContext.containsAcl(ACL_NAME, mappingContext)).thenReturn(true);
when(macipAclContext.getAclName(MACIP_ACL_INDEX, mappingContext)).thenReturn(MACIP_ACL_NAME);
when(macipAclContext.getAclIndex(MACIP_ACL_NAME, mappingContext)).thenReturn(MACIP_ACL_INDEX);
when(macipAclContext.getAceName(MACIP_ACL_NAME, 0, mappingContext)).thenReturn(MACIP_ACE_NAME);
+ when(macipAclContext.containsAcl(MACIP_ACL_NAME, mappingContext)).thenReturn(true);
}
@Test
public void testGetAllIds() throws ReadFailedException {
- final List<AclKey> allIds = getCustomizer().getAllIds(InstanceIdentifier.create(AccessLists.class).child(Acl.class), ctx);
+ final List<AclKey> allIds =
+ getCustomizer().getAllIds(InstanceIdentifier.create(Acls.class).child(Acl.class), ctx);
assertEquals(2, allIds.size());
assertEquals(ACL_IID.getKey(), allIds.get(0));
assertEquals(MACIP_ACL_IID.getKey(), allIds.get(1));
@@ -122,14 +121,13 @@ public class AclCustomizerTest extends InitializingListReaderCustomizerTest<Acl,
final AclBuilder builder = new AclBuilder();
getCustomizer().readCurrentAttributes(ACL_IID, builder, ctx);
assertEquals(ACL_IID.getKey(), builder.key());
- final List<Ace> aces = builder.getAccessListEntries().getAce();
+ final List<Ace> aces = builder.getAces().getAce();
assertEquals(1, aces.size());
final Ace ace = aces.get(0);
- assertEquals(ACE_NAME, ace.key().getRuleName());
- assertTrue(ace.getActions().getPacketHandling() instanceof Deny);
- final VppAceNodes nodes = ((VppAce) (ace.getMatches().getAceType())).getVppAceNodes();
- assertEquals(PROTOCOL, ((Other) nodes.getIpProtocol()).getOtherNodes().getProtocol().shortValue());
-
+ assertEquals(ACE_NAME, ace.key().getName());
+ assertTrue(ace.getActions().getForwarding().equals(Drop.class));
+ final L4 l4 = ((ace.getMatches())).getL4();
+ assertEquals(Icmp.class, l4.getImplementedInterface());
}
@Test
@@ -137,10 +135,10 @@ public class AclCustomizerTest extends InitializingListReaderCustomizerTest<Acl,
final AclBuilder builder = new AclBuilder();
getCustomizer().readCurrentAttributes(MACIP_ACL_IID, builder, ctx);
assertEquals(MACIP_ACL_IID.getKey(), builder.key());
- final List<Ace> aces = builder.getAccessListEntries().getAce();
+ final List<Ace> aces = builder.getAces().getAce();
assertEquals(1, aces.size());
final Ace ace = aces.get(0);
- assertEquals(MACIP_ACE_NAME, ace.key().getRuleName());
- assertTrue(ace.getActions().getPacketHandling() instanceof Deny);
+ assertEquals(MACIP_ACE_NAME, ace.key().getName());
+ assertTrue(ace.getActions().getForwarding().equals(Drop.class));
}
} \ No newline at end of file
diff --git a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/EgressVppAclCustomizerTest.java b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/EgressAclCustomizerTest.java
index 967b8200a..18f1978ef 100644
--- a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/EgressVppAclCustomizerTest.java
+++ b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/EgressAclCustomizerTest.java
@@ -25,21 +25,23 @@ import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.vpp.jvpp.acl.dto.AclInterfaceListDetailsReplyDump;
import javax.annotation.Nonnull;
import org.junit.Test;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214._interface.acl.attributes.acl.Egress;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214._interface.acl.attributes.acl.EgressBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214.vpp.acls.base.attributes.VppAcls;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214.vpp.acls.base.attributes.VppAclsKey;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points._interface.Egress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points._interface.acl.AclSets;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points._interface.acl.AclSetsBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points._interface.acl.acl.sets.AclSet;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points._interface.acl.acl.sets.AclSetKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
-public class EgressVppAclCustomizerTest extends AbstractVppAclCustomizerTest {
+public class EgressAclCustomizerTest extends AbstractAclCustomizerTest {
- public EgressVppAclCustomizerTest() {
- super(EgressBuilder.class);
+ public EgressAclCustomizerTest() {
+ super(AclSetsBuilder.class);
}
@Override
- protected EgressVppAclCustomizer initCustomizer() {
- return new EgressVppAclCustomizer(aclApi, interfaceContext, standardAclContext);
+ protected EgressAclCustomizer initCustomizer() {
+ return new EgressAclCustomizer(aclApi, interfaceContext, standardAclContext);
}
@Test
@@ -57,12 +59,12 @@ public class EgressVppAclCustomizerTest extends AbstractVppAclCustomizerTest {
}
@Override
- protected InstanceIdentifier<VppAcls> getWildcardedIid(@Nonnull final String ifName) {
- return getAclId(ifName).child(Egress.class).child(VppAcls.class);
+ protected InstanceIdentifier<AclSet> getWildcardedIid(@Nonnull final String ifName) {
+ return getAclId(ifName).child(Egress.class).child(AclSets.class).child(AclSet.class);
}
- @Override
- protected InstanceIdentifier<VppAcls> getIid(@Nonnull final String ifName, @Nonnull final VppAclsKey key) {
- return getAclId(ifName).child(Egress.class).child(VppAcls.class, key);
+ protected KeyedInstanceIdentifier<AclSet, AclSetKey> getIid(@Nonnull final String ifName,
+ @Nonnull final AclSetKey key) {
+ return getAclId(ifName).child(Egress.class).child(AclSets.class).child(AclSet.class, key);
}
} \ No newline at end of file
diff --git a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/IngressVppAclCustomizerTest.java b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/IngressAclCustomizerTest.java
index 42a798e88..666f6d8c9 100644
--- a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/IngressVppAclCustomizerTest.java
+++ b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/IngressAclCustomizerTest.java
@@ -16,31 +16,33 @@
package io.fd.hc2vpp.acl.read;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static io.fd.vpp.jvpp.Assertions.assertEquals;
+import static junit.framework.TestCase.assertTrue;
import static org.mockito.Mockito.when;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.vpp.jvpp.acl.dto.AclInterfaceListDetailsReplyDump;
import javax.annotation.Nonnull;
import org.junit.Test;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214._interface.acl.attributes.acl.Ingress;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214._interface.acl.attributes.acl.IngressBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214.vpp.acls.base.attributes.VppAcls;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214.vpp.acls.base.attributes.VppAclsKey;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points._interface.Ingress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points._interface.acl.AclSets;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points._interface.acl.AclSetsBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points._interface.acl.acl.sets.AclSet;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points._interface.acl.acl.sets.AclSetKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-public class IngressVppAclCustomizerTest extends AbstractVppAclCustomizerTest {
+public class IngressAclCustomizerTest extends AbstractAclCustomizerTest {
- public IngressVppAclCustomizerTest() {
- super(IngressBuilder.class);
+ public IngressAclCustomizerTest() {
+ super(AclSetsBuilder.class);
}
@Override
- protected IngressVppAclCustomizer initCustomizer() {
- return new IngressVppAclCustomizer(aclApi, interfaceContext, standardAclContext);
+ protected IngressAclCustomizer initCustomizer() {
+ return new IngressAclCustomizer(aclApi, interfaceContext, standardAclContext, macIpAclContext);
}
+
@Test
public void testGetAllIdsNoInputAclConfigured() throws ReadFailedException {
final AclInterfaceListDetailsReplyDump reply = aclInterfaceDump((byte) 0, "acl1");
@@ -57,12 +59,12 @@ public class IngressVppAclCustomizerTest extends AbstractVppAclCustomizerTest {
}
@Override
- protected InstanceIdentifier<VppAcls> getWildcardedIid(@Nonnull final String ifName) {
- return getAclId(ifName).child(Ingress.class).child(VppAcls.class);
+ protected InstanceIdentifier<AclSet> getWildcardedIid(@Nonnull final String ifName) {
+ return getAclId(ifName).child(Ingress.class).child(AclSets.class).child(AclSet.class);
}
@Override
- protected InstanceIdentifier<VppAcls> getIid(@Nonnull final String ifName, @Nonnull final VppAclsKey key) {
- return getAclId(ifName).child(Ingress.class).child(VppAcls.class, key);
+ protected InstanceIdentifier<AclSet> getIid(@Nonnull final String ifName, @Nonnull final AclSetKey key) {
+ return getAclId(ifName).child(Ingress.class).child(AclSets.class).child(AclSet.class, key);
}
} \ No newline at end of file
diff --git a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/MacIpAclCustomizerTest.java b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/MacIpAclCustomizerTest.java
new file mode 100644
index 000000000..6678ab53a
--- /dev/null
+++ b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/MacIpAclCustomizerTest.java
@@ -0,0 +1,183 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.acl.read;
+
+import static io.fd.hc2vpp.acl.read.IngressAclCustomizer.ACL_NOT_ASSIGNED;
+import static junit.framework.TestCase.assertEquals;
+import static junit.framework.TestCase.assertNotNull;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyZeroInteractions;
+import static org.mockito.Mockito.when;
+
+import io.fd.hc2vpp.common.translate.util.NamingContext;
+import io.fd.honeycomb.translate.read.ReadFailedException;
+import io.fd.honeycomb.translate.spi.read.Initialized;
+import io.fd.vpp.jvpp.acl.dto.AclInterfaceListDetailsReplyDump;
+import io.fd.vpp.jvpp.acl.dto.MacipAclDetails;
+import io.fd.vpp.jvpp.acl.dto.MacipAclDetailsReplyDump;
+import io.fd.vpp.jvpp.acl.dto.MacipAclDump;
+import io.fd.vpp.jvpp.acl.dto.MacipAclInterfaceGetReply;
+import io.fd.vpp.jvpp.acl.dto.MacipAclInterfaceListDetailsReplyDump;
+import io.fd.vpp.jvpp.acl.future.FutureJVppAclFacade;
+import javax.annotation.Nonnull;
+import org.junit.Assert;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points.Interface;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points._interface.Ingress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points._interface.acl.AclSets;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points._interface.acl.AclSetsBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points._interface.acl.acl.sets.AclSet;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points._interface.acl.acl.sets.AclSetBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev181001.acls.attachment.points._interface.acl.acl.sets.AclSetKey;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class MacIpAclCustomizerTest extends AbstractAclCustomizerTest {
+
+ protected static final String IF_NAME_NO_ACL = "eth2";
+ protected static final int IF_ID_NO_ACL = 1;
+ protected static final String IFC_CTX_NAME = "interface-context";
+ private static final String IF_NAME = "eth1";
+ private static final int IF_ID = 1;
+ private static final String ACL_NAME = "acl-name";
+ private static final int ACL_ID = 1;
+ @Mock
+ protected FutureJVppAclFacade aclApi;
+ protected NamingContext interfaceContext = new NamingContext("iface", IFC_CTX_NAME);
+
+ public MacIpAclCustomizerTest() {
+ super(AclSetsBuilder.class);
+ }
+
+ @Override
+ protected IngressAclCustomizer initCustomizer() {
+ return new IngressAclCustomizer(aclApi, interfaceContext, standardAclContext, macIpAclContext);
+ }
+
+ @Override
+ protected void setUp() {
+ defineMapping(mappingContext, IF_NAME, IF_ID, IFC_CTX_NAME);
+ defineMapping(mappingContext, IF_NAME_NO_ACL, IF_ID_NO_ACL, IFC_CTX_NAME);
+ when(macIpAclContext.getAclName(ACL_ID, mappingContext)).thenReturn(ACL_NAME);
+ when(macIpAclContext.containsAcl(ACL_NAME, mappingContext)).thenReturn(true);
+ when(standardAclContext.containsAcl(ACL_NAME, mappingContext)).thenReturn(false);
+ final AclInterfaceListDetailsReplyDump reply = aclInterfaceDump((byte) 0);
+ when(aclApi.aclInterfaceListDump(any())).thenReturn(future(reply));
+ final MacipAclInterfaceListDetailsReplyDump macReply = macAaclInterfaceDump(1, "acl-name");
+ when(aclApi.macipAclInterfaceListDump(any())).thenReturn(future(macReply));
+ }
+
+
+ @Test
+ public void testRead() throws ReadFailedException {
+ final AclSetBuilder builder = mock(AclSetBuilder.class);
+
+ final MacipAclInterfaceGetReply assignedAcls = new MacipAclInterfaceGetReply();
+ assignedAcls.count = 2;
+ assignedAcls.acls = new int[]{ACL_NOT_ASSIGNED, ACL_ID};
+ when(aclApi.macipAclInterfaceGet(any())).thenReturn(future(assignedAcls));
+
+ final MacipAclDump request = new MacipAclDump();
+ request.aclIndex = ACL_ID;
+ final MacipAclDetailsReplyDump reply = new MacipAclDetailsReplyDump();
+ final MacipAclDetails details = new MacipAclDetails();
+ details.aclIndex = ACL_ID;
+ reply.macipAclDetails.add(details);
+ when(aclApi.macipAclDump(request)).thenReturn(future(reply));
+
+ getCustomizer().readCurrentAttributes(getIid(IF_NAME_NO_ACL, new AclSetKey(ACL_NAME)), builder, ctx);
+ verify(builder).setName(ACL_NAME);
+ }
+
+ @Test
+ public void testReadNotAssigned() throws ReadFailedException {
+ final AclSetBuilder builder = mock(AclSetBuilder.class);
+
+ final MacipAclInterfaceGetReply assignedAcls = new MacipAclInterfaceGetReply();
+ // pretending we have 3 interfaces, IF_NAME does not have MacipAcl assigned
+ assignedAcls.count = 3;
+ assignedAcls.acls = new int[]{ACL_NOT_ASSIGNED, ACL_NOT_ASSIGNED, ACL_NOT_ASSIGNED};
+ when(aclApi.macipAclInterfaceGet(any())).thenReturn(future(assignedAcls));
+
+ final MacipAclDump request = new MacipAclDump();
+ request.aclIndex = ACL_ID;
+ final MacipAclDetailsReplyDump reply = new MacipAclDetailsReplyDump();
+ final MacipAclDetails details = new MacipAclDetails();
+ details.aclIndex = ACL_ID;
+ reply.macipAclDetails.add(details);
+ when(aclApi.macipAclDump(request)).thenReturn(future(reply));
+
+ getCustomizer().readCurrentAttributes(getIid(IF_NAME_NO_ACL, new AclSetKey(ACL_NAME)), builder, ctx);
+ verifyZeroInteractions(builder);
+ }
+
+ @Test
+ public void testReadNoAcls() throws ReadFailedException {
+ final AclSetBuilder builder = mock(AclSetBuilder.class);
+ final MacipAclInterfaceGetReply assignedAcls = new MacipAclInterfaceGetReply();
+ assignedAcls.count = 0;
+ assignedAcls.acls = new int[0];
+ when(aclApi.macipAclInterfaceGet(any())).thenReturn(future(assignedAcls));
+ getCustomizer().readCurrentAttributes(getIid(IF_NAME_NO_ACL, new AclSetKey(ACL_NAME)), builder, ctx);
+ verifyZeroInteractions(builder);
+ }
+
+ @Test
+ public void testGetAllIdsNoAclConfigured() throws ReadFailedException {
+ final MacipAclInterfaceListDetailsReplyDump macReply = macAaclInterfaceDump(1);
+ when(aclApi.macipAclInterfaceListDump(any())).thenReturn(future(macReply));
+ assertTrue(getCustomizer().getAllIds(getWildcardedIid(IF_NAME_NO_ACL), ctx).isEmpty());
+ }
+
+ @Test
+ public void testReadAllTwoIfacesInOneTx() throws ReadFailedException {
+ final MacipAclInterfaceListDetailsReplyDump macReply = macAaclInterfaceDump(1);
+ final MacipAclInterfaceGetReply interfaceGet = macipAclInterfaceGetReply();
+ // read all for interface with defined ACLs:
+ assertFalse(getCustomizer().getAllIds(getWildcardedIid(IF_NAME), ctx).isEmpty());
+ // read all for interface without ACLs defined:
+ when(aclApi.macipAclInterfaceListDump(any())).thenReturn(future(macReply));
+ when(aclApi.macipAclInterfaceGet(any())).thenReturn(future(interfaceGet));
+ Assert.assertEquals(0, getCustomizer().getAllIds(getWildcardedIid(IF_NAME_NO_ACL), ctx).size());
+ }
+
+ @Test
+ public void testInit() {
+ final AclSet readValue = new AclSetBuilder().build();
+ final Initialized<? extends DataObject>
+ cfgValue = getCustomizer().init(getWildcardedIid(IF_NAME), readValue, ctx);
+ assertEquals(cfgValue.getData(), readValue);
+ assertNotNull(cfgValue.getId().firstKeyOf(Interface.class));
+ assertEquals(cfgValue.getId().getTargetType(), AclSet.class);
+
+ }
+
+ @Override
+ protected InstanceIdentifier<AclSet> getWildcardedIid(@Nonnull final String ifName) {
+ return getAclId(ifName).child(Ingress.class).child(AclSets.class).child(AclSet.class);
+ }
+
+ @Override
+ protected InstanceIdentifier<AclSet> getIid(@Nonnull final String ifName, @Nonnull final AclSetKey key) {
+ return getAclId(ifName).child(Ingress.class).child(AclSets.class).child(AclSet.class, key);
+ }
+} \ No newline at end of file
diff --git a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/VppMacIpAclCustomizerTest.java b/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/VppMacIpAclCustomizerTest.java
deleted file mode 100644
index 23ce85640..000000000
--- a/acl/acl-impl/src/test/java/io/fd/hc2vpp/acl/read/VppMacIpAclCustomizerTest.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Copyright (c) 2016 Cisco and/or its affiliates.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.fd.hc2vpp.acl.read;
-
-import static io.fd.hc2vpp.acl.read.VppMacIpAclCustomizer.ACL_NOT_ASSIGNED;
-import static io.fd.hc2vpp.acl.read.AbstractVppAclCustomizerTest.getAclId;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyZeroInteractions;
-import static org.mockito.Mockito.when;
-
-import io.fd.hc2vpp.acl.util.AclContextManager;
-import io.fd.hc2vpp.common.test.read.InitializingReaderCustomizerTest;
-import io.fd.hc2vpp.common.translate.util.NamingContext;
-import io.fd.honeycomb.translate.read.ReadFailedException;
-import io.fd.honeycomb.translate.spi.read.Initialized;
-import io.fd.vpp.jvpp.acl.dto.MacipAclDetails;
-import io.fd.vpp.jvpp.acl.dto.MacipAclDetailsReplyDump;
-import io.fd.vpp.jvpp.acl.dto.MacipAclDump;
-import io.fd.vpp.jvpp.acl.dto.MacipAclInterfaceGetReply;
-import io.fd.vpp.jvpp.acl.future.FutureJVppAclFacade;
-import javax.annotation.Nonnull;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.AclBase;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214._interface.acl.attributes.acl.Ingress;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214._interface.acl.attributes.acl.IngressBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214.vpp.macip.acls.base.attributes.VppMacipAcl;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang._interface.acl.rev161214.vpp.macip.acls.base.attributes.VppMacipAclBuilder;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-public class VppMacIpAclCustomizerTest extends InitializingReaderCustomizerTest<VppMacipAcl, VppMacipAclBuilder> {
-
- protected static final String IF_NAME_NO_ACL = "eth2";
- protected static final int IF_ID_NO_ACL = 2;
- protected static final String IFC_CTX_NAME = "interface-context";
- private static final String IF_NAME = "eth1";
- private static final int IF_ID = 1;
- private static final String ACL_NAME = "acl-name";
- private static final int ACL_ID = 1;
- private static final Class<? extends AclBase> ACL_TYPE =
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev170615.VppMacipAcl.class;
- @Mock
- protected FutureJVppAclFacade aclApi;
- protected NamingContext interfaceContext = new NamingContext("iface", IFC_CTX_NAME);
- @Mock
- protected AclContextManager macIpAclContext;
-
- public VppMacIpAclCustomizerTest() {
- super(VppMacipAcl.class, IngressBuilder.class);
- }
-
- @Override
- protected VppMacIpAclCustomizer initCustomizer() {
- return new VppMacIpAclCustomizer(aclApi, interfaceContext, macIpAclContext);
- }
-
- @Override
- protected void setUp() {
- defineMapping(mappingContext, IF_NAME, IF_ID, IFC_CTX_NAME);
- defineMapping(mappingContext, IF_NAME_NO_ACL, IF_ID_NO_ACL, IFC_CTX_NAME);
- when(macIpAclContext.getAclName(ACL_ID, mappingContext)).thenReturn(ACL_NAME);
- }
-
- @Test
- public void testRead() throws ReadFailedException {
- final VppMacipAclBuilder builder = mock(VppMacipAclBuilder.class);
-
- final MacipAclInterfaceGetReply assignedAcls = new MacipAclInterfaceGetReply();
- assignedAcls.count = 2;
- assignedAcls.acls = new int[] {ACL_NOT_ASSIGNED, ACL_ID};
- when(aclApi.macipAclInterfaceGet(any())).thenReturn(future(assignedAcls));
-
- final MacipAclDump request = new MacipAclDump();
- request.aclIndex = ACL_ID;
- final MacipAclDetailsReplyDump reply = new MacipAclDetailsReplyDump();
- final MacipAclDetails details = new MacipAclDetails();
- details.aclIndex = ACL_ID;
- reply.macipAclDetails.add(details);
- when(aclApi.macipAclDump(request)).thenReturn(future(reply));
-
- getCustomizer().readCurrentAttributes(getIid(IF_NAME), builder, ctx);
- verify(builder).setName(ACL_NAME);
- verify(builder).setType(ACL_TYPE);
- }
-
- @Test
- public void testReadNotAssigned() throws ReadFailedException {
- final VppMacipAclBuilder builder = mock(VppMacipAclBuilder.class);
-
- final MacipAclInterfaceGetReply assignedAcls = new MacipAclInterfaceGetReply();
- // pretending we have 3 interfaces, IF_NAME does not have MacipAcl assigned
- assignedAcls.count = 3;
- assignedAcls.acls = new int[] {ACL_NOT_ASSIGNED, ACL_NOT_ASSIGNED, ACL_ID};
- when(aclApi.macipAclInterfaceGet(any())).thenReturn(future(assignedAcls));
-
- final MacipAclDump request = new MacipAclDump();
- request.aclIndex = ACL_ID;
- final MacipAclDetailsReplyDump reply = new MacipAclDetailsReplyDump();
- final MacipAclDetails details = new MacipAclDetails();
- details.aclIndex = ACL_ID;
- reply.macipAclDetails.add(details);
- when(aclApi.macipAclDump(request)).thenReturn(future(reply));
-
- getCustomizer().readCurrentAttributes(getIid(IF_NAME), builder, ctx);
- verifyZeroInteractions(builder);
- }
-
- @Test
- public void testReadNoAcls() throws ReadFailedException {
- final VppMacipAclBuilder builder = mock(VppMacipAclBuilder.class);
- when(aclApi.macipAclInterfaceGet(any())).thenReturn(future(new MacipAclInterfaceGetReply()));
- getCustomizer().readCurrentAttributes(getIid(IF_NAME_NO_ACL), builder, ctx);
- verifyZeroInteractions(builder);
- }
-
- @Test
- public void testInit() {
- final VppMacipAcl readValue = new VppMacipAclBuilder().build();
- final Initialized<? extends DataObject> cfgValue = getCustomizer().init(getIid(IF_NAME), readValue, ctx);
- assertEquals(cfgValue.getData(), readValue);
- assertNotNull(cfgValue.getId().firstKeyOf(Interface.class));
- assertEquals(cfgValue.getId().getTargetType(), VppMacipAcl.class);
-
- }
-
- protected InstanceIdentifier<VppMacipAcl> getIid(@Nonnull final String ifName) {
- return getAclId(ifName).child(Ingress.class).child(VppMacipAcl.class);
- }
-
-} \ No newline at end of file