package org.opendaylight.lispflowmapping.southbound.lisp;
import static io.netty.buffer.Unpooled.wrappedBuffer;
+import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import junitx.framework.ArrayAssert;
+import java.util.Map;
import org.apache.commons.lang3.ArrayUtils;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.mockito.AdditionalMatchers;
import org.mockito.ArgumentCaptor;
+import org.mockito.ArgumentMatchers;
import org.mockito.InOrder;
-import org.mockito.Matchers;
import org.mockito.Mockito;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.lispflowmapping.lisp.serializer.MapNotifySerializer;
import org.opendaylight.lispflowmapping.lisp.serializer.MapReplySerializer;
import org.opendaylight.lispflowmapping.lisp.type.LispMessage;
import org.opendaylight.lispflowmapping.southbound.lisp.cache.MapRegisterCache;
import org.opendaylight.lispflowmapping.southbound.lisp.exception.LispMalformedPacketException;
import org.opendaylight.lispflowmapping.tools.junit.BaseTestCase;
+import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana.afn.safi.rev130704.AddressFamily;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.InstanceIdType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.binary.address.types.rev160504.Ipv4BinaryAfi;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.map.register.cache.value.grouping.MapRegisterCacheValue;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.map.register.cache.value.grouping.MapRegisterCacheValueBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapnotifymessage.MapNotifyBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping._record.container.MappingRecord;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping._record.container.MappingRecord.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping._record.container.MappingRecordBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping._record.list.MappingRecordItem;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping._record.list.MappingRecordItemBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkeyBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord.Action;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapreplymessage.MapReplyBuilder;
import org.opendaylight.yangtools.yang.binding.Notification;
+import org.opendaylight.yangtools.yang.common.Uint16;
+import org.opendaylight.yangtools.yang.common.Uint32;
public class LispSouthboundHandlerTest extends BaseTestCase {
int LOCATOR = MapReplyIpv4SingleLocatorPos.LOCATOR + FIRST_LOCATOR_IPV4_LENGTH;
}
- @SuppressWarnings("unchecked")
@BeforeClass
public static void initTests() {
akdb = Mockito.mock(AuthKeyDb.class);
- Mockito.when(akdb.getAuthenticationKey(Matchers.eq(LispAddressUtil.asIpv4PrefixBinaryEid("10.10.10.10/8"))))
- .thenReturn(new MappingAuthkeyBuilder().setKeyType(1).setKeyString("password").build());
- Mockito.when(akdb.getAuthenticationKey(Matchers.eq(LispAddressUtil.asIpv6PrefixBinaryEid(
+ Mockito.when(akdb.getAuthenticationKey(ArgumentMatchers.eq(LispAddressUtil.asIpv4PrefixBinaryEid(
+ "10.10.10.10/8"))))
+ .thenReturn(new MappingAuthkeyBuilder().setKeyType(Uint16.ONE).setKeyString("password").build());
+ Mockito.when(akdb.getAuthenticationKey(ArgumentMatchers.eq(LispAddressUtil.asIpv6PrefixBinaryEid(
"2610:d0:ffff:192:0:0:0:1/128"))))
- .thenReturn(new MappingAuthkeyBuilder().setKeyType(1).setKeyString("password").build());
- Mockito.when(akdb.getAuthenticationKey(Matchers.eq(LispAddressUtil.asIpv4PrefixBinaryEid("153.16.254.1/32"))))
- .thenReturn(new MappingAuthkeyBuilder().setKeyType(1).setKeyString("password").build());
- Mockito.when(akdb.getAuthenticationKey(Matchers.eq(LispAddressUtil.asIpv4PrefixBinaryEid("125.124.123.122/8",
- new InstanceIdType(21L)))))
- .thenReturn(new MappingAuthkeyBuilder().setKeyType(1).setKeyString("password").build());
- Mockito.when(akdb.getAuthenticationKey(Matchers.eq(LispAddressUtil.asMacEid("0a:0b:0c:0d:0e:0f"))))
- .thenReturn(new MappingAuthkeyBuilder().setKeyType(1).setKeyString("password").build());
- Mockito.when(akdb.getAuthenticationKey(Matchers.eq(LispAddressUtil.asIpv6PrefixBinaryEid(
+ .thenReturn(new MappingAuthkeyBuilder().setKeyType(Uint16.ONE).setKeyString("password").build());
+ Mockito.when(akdb.getAuthenticationKey(ArgumentMatchers.eq(LispAddressUtil.asIpv4PrefixBinaryEid(
+ "153.16.254.1/32"))))
+ .thenReturn(new MappingAuthkeyBuilder().setKeyType(Uint16.ONE).setKeyString("password").build());
+ Mockito.when(akdb.getAuthenticationKey(ArgumentMatchers.eq(LispAddressUtil.asIpv4PrefixBinaryEid(
+ "125.124.123.122/8", new InstanceIdType(Uint32.valueOf(21))))))
+ .thenReturn(new MappingAuthkeyBuilder().setKeyType(Uint16.ONE).setKeyString("password").build());
+ Mockito.when(akdb.getAuthenticationKey(ArgumentMatchers.eq(LispAddressUtil.asMacEid(
+ "0a:0b:0c:0d:0e:0f"))))
+ .thenReturn(new MappingAuthkeyBuilder().setKeyType(Uint16.ONE).setKeyString("password").build());
+ Mockito.when(akdb.getAuthenticationKey(ArgumentMatchers.eq(LispAddressUtil.asIpv6PrefixBinaryEid(
"f0f:f0f:f0f:f0f:f0f:f0f:f0f:f0f/8"))))
- .thenReturn(new MappingAuthkeyBuilder().setKeyType(1).setKeyString("password").build());
- Mockito.when(akdb.getAuthenticationKey(Matchers.eq(LispAddressUtil.asIpv4PrefixBinaryEid("172.1.1.2/32"))))
- .thenReturn(new MappingAuthkeyBuilder().setKeyType(1).setKeyString("password").build());
+ .thenReturn(new MappingAuthkeyBuilder().setKeyType(Uint16.ONE).setKeyString("password").build());
+ Mockito.when(akdb.getAuthenticationKey(ArgumentMatchers.eq(LispAddressUtil.asIpv4PrefixBinaryEid(
+ "172.1.1.2/32"))))
+ .thenReturn(new MappingAuthkeyBuilder().setKeyType(Uint16.ONE).setKeyString("password").build());
akdl = Mockito.mock(AuthenticationKeyDataListener.class);
- Mockito.when(akdl.authKeysForEidsUnchanged(Mockito.anyList(), Mockito.anyLong())).thenReturn(true);
+ Mockito.when(akdl.authKeysForEidsUnchanged(Mockito.anyMap(), Mockito.anyLong())).thenReturn(true);
}
@Override
// Nonce: 0x3d8d2acd39c8d608
// ITR-RLOC AFI=1 Address=192.168.136.10
// Record 1: 1.2.3.4/32
- mapRequestPacket = extractWSUdpByteArray(new String(
+ mapRequestPacket = extractWSUdpByteArray(
"0000 00 00 00 00 00 00 00 00 00 00 00 00 08 00 45 00 "
+ "0010 00 58 00 00 40 00 40 11 3c 93 7f 00 00 01 7f 00 "
+ "0020 00 01 e4 c0 10 f6 00 44 fe 57 80 00 00 00 45 00 "
+ "0030 00 38 d4 31 00 00 ff 11 56 f3 c0 a8 88 0a 01 02 "
+ "0040 03 04 dd b4 10 f6 00 24 ef 3a 10 00 00 01 3d 8d "
+ "0050 2a cd 39 c8 d6 08 00 01 01 02 03 04 00 01 c0 a8 88 0a 00 20 "
- + "0060 00 01 01 02 03 04"));
+ + "0060 00 01 01 02 03 04");
mapReplyBuilder = new MapReplyBuilder();
mapReplyBuilder.setMappingRecordItem(new ArrayList<MappingRecordItem>());
mapReplyBuilder.setNonce((long) 0);
// 255/0
//
- mapRegisterPacket = extractWSUdpByteArray(new String(
+ mapRegisterPacket = extractWSUdpByteArray(
"0000 00 50 56 ee d1 4f 00 0c 29 7a ce 79 08 00 45 00 "
+ "0010 00 5c 00 00 40 00 40 11 d4 db c0 a8 88 0a 80 df "
+ "0020 9c 23 d6 40 10 f6 00 48 59 a4 38 00 01 01 00 00 "
+ "0030 00 00 00 00 00 00 00 01 00 14 0e a4 c6 d8 a4 06 "
+ "0040 71 7c 33 a4 5c 4a 83 1c de 74 53 03 0c ad 00 00 "
+ "0050 00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 "
- + "0060 ff 00 00 05 00 01 c0 a8 88 0a"));
+ + "0060 ff 00 00 05 00 01 c0 a8 88 0a");
mapNotifyBuilder = new MapNotifyBuilder();
mapNotifyBuilder.setAuthenticationData(new byte[0]);
}
@Test(expected = LispMalformedPacketException.class)
public void mapRegister__IllegalPacket() throws Exception {
- mapRegisterPacket = extractWSUdpByteArray(new String(
+ mapRegisterPacket = extractWSUdpByteArray(
"0000 00 0c 29 7a ce 8d 00 0c 29 e4 ef 70 08 00 45 00 "
+ "0010 00 68 00 00 40 00 40 11 26 15 0a 01 00 6e 0a 01 "
- + "0020 00 01 10 f6 10 f6 00 54 03 3b 38 00 01 01 00 00 "));
+ + "0020 00 01 10 f6 10 f6 00 54 03 3b 38 00 01 01 00 00 ");
handleMapRegisterPacket(mapRegisterPacket);
}
@Test(expected = LispMalformedPacketException.class)
public void mapRequest__IllegalPacket() throws Exception {
- mapRequestPacket = extractWSUdpByteArray(new String(
+ mapRequestPacket = extractWSUdpByteArray(
"0000 00 00 00 00 00 00 00 00 00 00 00 00 08 00 45 00 "
+ "0010 00 58 00 00 40 00 40 11 3c 93 7f 00 00 01 7f 00 "
+ "0020 00 01 e4 c0 10 f6 00 44 fe 57 80 00 00 00 45 00 "
+ "0030 00 38 d4 31 00 00 ff 11 56 f3 c0 a8 88 0a 01 02 "
- + "0040 03 04 dd b4 10 f6 00 24 ef 3a 10 00 00 01 3d 8d "));
+ + "0040 03 04 dd b4 10 f6 00 24 ef 3a 10 00 00 01 3d 8d ");
handleMapRequestPacket(mapRequestPacket);
}
@Test(expected = LispMalformedPacketException.class)
public void mapRequest__IllegalEncapsulatedPacket() throws Exception {
- mapRequestPacket = extractWSUdpByteArray(new String(
+ mapRequestPacket = extractWSUdpByteArray(
"0000 00 00 00 00 00 00 00 00 00 00 00 00 08 00 45 00 "
+ "0010 00 58 00 00 40 00 40 11 3c 93 7f 00 00 01 7f 00 "
- + "0020 00 01 e4 c0 10 f6 00 44 fe 57 80 00 00 00 45 00 "));
+ + "0020 00 01 e4 c0 10 f6 00 44 fe 57 80 00 00 00 45 00 ");
handleMapRequestPacket(mapRequestPacket);
}
// Priority/Weight: 255/0
// Local RLOC: 192.168.136.51, Reachable, Priority/Weight: 6/100,
// Multicast Priority/Weight: 255/0
- mapRegisterPacket = extractWSUdpByteArray(new String(
+ mapRegisterPacket = extractWSUdpByteArray(
"0000 00 0c 29 7a ce 8d 00 0c 29 e4 ef 70 08 00 45 00 "
+ "0010 00 68 00 00 40 00 40 11 26 15 0a 01 00 6e 0a 01 "
+ "0020 00 01 10 f6 10 f6 00 54 03 3b 38 00 01 01 00 00 "
+ "0040 e9 35 75 6e f1 29 27 a3 45 20 96 06 c2 e1 00 00 "
+ "0050 00 0a 02 20 10 00 00 00 00 01 ac 01 01 02 01 64 "
+ "0060 ff 00 00 05 00 01 0a 01 00 6e 06 64 ff 00 00 05 "
- + "0070 00 01 c0 a8 88 33"));
+ + "0070 00 01 c0 a8 88 33");
ArgumentCaptor<AddMapping> captor = ArgumentCaptor.forClass(AddMapping.class);
handleMapRegisterPacket(mapRegisterPacket);
// Local RLOC: 10.0.58.156, Reachable, Priority/Weight: 1/100, Multicast
// Priority/Weight: 255/0
- mapRegisterPacket = extractWSUdpByteArray(new String(
+ mapRegisterPacket = extractWSUdpByteArray(
"0000 00 0c 29 34 3e 1b 00 0c 29 f6 d6 0d 08 00 45 00 "
+ "0010 00 68 00 00 40 00 40 11 ea c3 0a 00 3a 9c 0a 00 "
+ "0020 01 26 10 f6 10 f6 00 54 f5 9a 38 00 03 01 00 00 "
+ "0040 0f 91 c6 c4 01 ef 7f bb 77 58 39 5c 92 23 00 00 "
+ "0050 00 0a 01 80 10 00 00 00 00 02 26 10 00 d0 ff ff "
+ "0060 01 92 00 00 00 00 00 00 00 01 01 64 ff 00 00 05 "
- + "0070 00 01 0a 00 3a 9c"));
+ + "0070 00 01 0a 00 3a 9c");
ArgumentCaptor<AddMapping> captor = ArgumentCaptor.forClass(AddMapping.class);
handleMapRegisterPacket(mapRegisterPacket);
assertEquals(LispAddressUtil.asIpv6PrefixBinaryEid("2610:d0:ffff:192:0:0:0:1/128"),
eidToLocatorRecord.getEid());
- assertEquals(Ipv6PrefixBinaryAfi.class, eidToLocatorRecord.getEid().getAddressType());
+ assertEquals(Ipv6PrefixBinaryAfi.VALUE, eidToLocatorRecord.getEid().getAddressType());
assertEquals(LispAddressUtil.asIpv4Rloc("10.0.58.156"), eidToLocatorRecord.getLocatorRecord().get(0).getRloc());
}
@Test
public void mapRegister__NonSetMBit() throws Exception {
- byte[] registerWithNonSetMBit = extractWSUdpByteArray(new String(
+ byte[] registerWithNonSetMBit = extractWSUdpByteArray(
"0000 00 50 56 ee d1 4f 00 0c 29 7a ce 79 08 00 45 00 "
+ "0010 00 5c 00 00 40 00 40 11 d4 db c0 a8 88 0a 80 df "
+ "0020 9c 23 d6 40 10 f6 00 48 59 a4 38 00 00 01 00 00 "
+ "0030 00 00 00 00 00 00 00 01 00 14 79 d1 44 66 19 99 "
+ "0040 83 63 a7 79 6e f0 40 97 54 26 3a 44 b4 eb 00 00 "
+ "0050 00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 "
- + "0060 ff 00 00 05 00 01 c0 a8 88 0a"));
+ + "0060 ff 00 00 05 00 01 c0 a8 88 0a");
ArgumentCaptor<AddMapping> captor = ArgumentCaptor.forClass(AddMapping.class);
handleMapRegisterPacket(registerWithNonSetMBit);
Mockito.verify(mockLispSouthboundPlugin).sendNotificationIfPossible(captor.capture());
- assertFalse(captor.getValue().getMapRegister().isWantMapNotify());
+ assertFalse(captor.getValue().getMapRegister().getWantMapNotify());
}
@Test
public void mapRegister__NonSetMBitWithNonZeroReservedBits() throws Exception {
- byte[] registerWithNonSetMBit = extractWSUdpByteArray(new String(
+ byte[] registerWithNonSetMBit = extractWSUdpByteArray(
"0000 00 50 56 ee d1 4f 00 0c 29 7a ce 79 08 00 45 00 "
+ "0010 00 5c 00 00 40 00 40 11 d4 db c0 a8 88 0a 80 df "
+ "0020 9c 23 d6 40 10 f6 00 48 59 a4 38 00 02 01 00 00 "
+ "0030 00 00 00 00 00 00 00 01 00 14 c0 c7 c5 2f 57 f6 "
+ "0040 e7 20 25 3d e8 b2 07 e2 63 de 62 2b 7a 20 00 00 "
+ "0050 00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 "
- + "0060 ff 00 00 05 00 01 c0 a8 88 0a"));
+ + "0060 ff 00 00 05 00 01 c0 a8 88 0a");
ArgumentCaptor<AddMapping> captor = ArgumentCaptor.forClass(AddMapping.class);
handleMapRegisterPacket(registerWithNonSetMBit);
Mockito.verify(mockLispSouthboundPlugin).sendNotificationIfPossible(captor.capture());
- assertFalse(captor.getValue().getMapRegister().isWantMapNotify());
+ assertFalse(captor.getValue().getMapRegister().getWantMapNotify());
}
@Test
public void mapRegister__SetMBitWithNonZeroReservedBits() throws Exception {
- byte[] registerWithNonSetMBit = extractWSUdpByteArray(new String(
+ byte[] registerWithNonSetMBit = extractWSUdpByteArray(
"0000 00 50 56 ee d1 4f 00 0c 29 7a ce 79 08 00 45 00 "
+ "0010 00 5c 00 00 40 00 40 11 d4 db c0 a8 88 0a 80 df "
+ "0020 9c 23 d6 40 10 f6 00 48 59 a4 38 00 03 01 00 00 "
+ "0030 00 00 00 00 00 00 00 01 00 14 a2 72 40 7b 1a ae "
+ "0040 4e 6b e2 e5 e1 01 40 8a c9 e1 d1 80 cb 72 00 00 "
+ "0050 00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 "
- + "0060 ff 00 00 05 00 01 c0 a8 88 0a"));
+ + "0060 ff 00 00 05 00 01 c0 a8 88 0a");
ArgumentCaptor<AddMapping> captor = ArgumentCaptor.forClass(AddMapping.class);
handleMapRegisterPacket(registerWithNonSetMBit);
Mockito.verify(mockLispSouthboundPlugin).sendNotificationIfPossible(captor.capture());
- assertTrue(captor.getValue().getMapRegister().isWantMapNotify());
+ assertTrue(captor.getValue().getMapRegister().getWantMapNotify());
}
/**
public void mapRegister_isMappingKeepAliveAndMapNotifyGenerated() throws InterruptedException,
UnknownHostException {
byte[] eidPrefixAfi = new byte[] {
- 0x00, 0x01 //eid-prefix-afi
+ //eid-prefix-afi
+ 0x00, 0x01
};
byte[] eidPrefix = new byte[] {
- 0x0a, 0x0a, 0x0a, 0x0a //ipv4 address
+ //ipv4 address
+ 0x0a, 0x0a, 0x0a, 0x0a
};
//send stream of byte -> map register message
@Test
public void mapRegister_cacheWithEidPrefixIpv4Test() throws InterruptedException {
byte[] eidPrefixAfi = new byte[] {
- 0x00, 0x01 //eid-prefix-afi
+ //eid-prefix-afi
+ 0x00, 0x01
};
byte[] eidPrefix = new byte[] {
- 0x0a, 0x0a, 0x0a, 0x0a //ipv4 address
+ //ipv4 address
+ 0x0a, 0x0a, 0x0a, 0x0a
};
cacheTest(eidPrefixAfi, eidPrefix, MapRegisterCacheTestUtil.AUTH_DATA);
@Test
public void mapRegister_cacheWithEidPrefixIpv6Test() throws InterruptedException {
byte[] eidPrefixAfi = new byte[] {
- 0x00, 0x02 //eid-prefix-afi
+ //eid-prefix-afi
+ 0x00, 0x02
};
byte[] eidPrefix = new byte[] {
- 0x0f, 0x0f, 0x0f, 0x0f, //ipv6 address
- 0x0f, 0x0f, 0x0f, 0x0f, //ipv6 address
- 0x0f, 0x0f, 0x0f, 0x0f, //ipv6 address
- 0x0f, 0x0f, 0x0f, 0x0f //ipv6 address
+ //ipv6 address
+ 0x0f, 0x0f, 0x0f, 0x0f,
+ //ipv6 address
+ 0x0f, 0x0f, 0x0f, 0x0f,
+ //ipv6 address
+ 0x0f, 0x0f, 0x0f, 0x0f,
+ //ipv6 address
+ 0x0f, 0x0f, 0x0f, 0x0f
};
- byte[] authenticationData = new byte[]{
+ byte[] authenticationData = new byte[] {
0x00, 0x14,
0x41,(byte)0x83,0x13,0x7C,
0x48,(byte)0xEE,0x75,(byte)0x9A,
@Test
public void mapRegister_cacheWithEidPrefixMac48Test() throws InterruptedException {
byte[] eidPrefixAfi = new byte[] {
- 0x40, 0x05 //eid-prefix-afi
+ //eid-prefix-afi
+ 0x40, 0x05
};
byte[] eidPrefix = new byte[] {
- 0x0a, 0x0b, 0x0c, 0x0d, //mac address
- 0x0e, 0x0f //mac address
+ //mac address
+ 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
};
- byte[] authenticationData = new byte[]{
+
+ byte[] authenticationData = new byte[] {
0x00, 0x14,
(byte)0xB2,(byte)0x8E,0x6,(byte)0x9D,
0x61,(byte)0xD8,0xC,0x24,
@Test
public void mapRegister_cacheWithEidPrefixLcafTest() throws InterruptedException {
byte[] eidPrefixAfi = new byte[] {
- 0x40, 0x03 //eid-prefix-afi
+ //eid-prefix-afi
+ 0x40, 0x03
};
//following lcaf prefixed variables are defined according to https://tools.ietf
byte[] eidPrefix = joinArrays(lcafRsvd1, lcafFlags, lcafType, lcafIIDMaskLength, lcafLength, lcafInstanceId,
lcafAfi, lcafAddress);
- byte[] authenticationData = new byte[]{
- 0x00, 0x14, //authentication data length
- 0x68, 0x1d, (byte) 0x9e, 0x6e, //auth data
- 0x5e, 0x32, (byte) 0x88, 0x1a, //auth data
- (byte) 0xae, 0x6b, (byte) 0xe3, 0x40, //auth data
- 0x30, (byte) 0x0b, (byte) 0xb6, (byte) 0xa0, //auth data
- 0x71, (byte) 0xf4, (byte) 0x8c, 0x5f //auth data
+ byte[] authenticationData = new byte[] {
+ //authentication data length
+ 0x00, 0x14,
+ //auth data
+ 0x68, 0x1d, (byte) 0x9e, 0x6e,
+ //auth data
+ 0x5e, 0x32, (byte) 0x88, 0x1a,
+ //auth data
+ (byte) 0xae, 0x6b, (byte) 0xe3, 0x40,
+ //auth data
+ 0x30, (byte) 0x0b, (byte) 0xb6, (byte) 0xa0,
+ //auth data
+ 0x71, (byte) 0xf4, (byte) 0x8c, 0x5f
};
MapRegisterCacheMetadataBuilder cacheMetadataBld = new MapRegisterCacheMetadataBuilder();
cacheMetadataBld.setTimestamp(System.currentTimeMillis() - (cacheRecordTimeouted ? CACHE_RECORD_TIMEOUT : 0L));
cacheMetadataBld.setWantMapNotify(false);
+ cacheMetadataBld.setEidLispAddress(Map.of());
MapRegisterCacheValueBuilder cacheValueBld = new MapRegisterCacheValueBuilder();
cacheValueBld.setMapRegisterCacheMetadata(cacheMetadataBld.build());
if (mapNotifyBuilder.getMappingRecordItem() == null) {
mapNotifyBuilder.setMappingRecordItem(new ArrayList<MappingRecordItem>());
}
- mapNotifyBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(
- mappingRecordBuilder.build()).build());
+ mapNotifyBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder()
+ .setMappingRecordItemId("foo")
+ .setMappingRecord(mappingRecordBuilder.build()).build());
mapNotifyBuilder.setNonce((long) 0);
mapNotifyBuilder.setKeyId((short) 0);
mapNotifyBuilder.setAuthenticationData(new byte[0]);
Arrays.copyOfRange(mapRegisterPacket, 36, mapRegisterPacket.length));
byte[] notifyWithoutTypeWithOutAuthenticationData = ArrayUtils.addAll(Arrays.copyOfRange(result, 3, 16),
Arrays.copyOfRange(result, 36, result.length));
- ArrayAssert.assertEquals(registerWithoutTypeWithoutAuthenticationData,
- notifyWithoutTypeWithOutAuthenticationData);
+ assertArrayEquals(registerWithoutTypeWithoutAuthenticationData, notifyWithoutTypeWithOutAuthenticationData);
}
@Ignore
List<EidItem> eids = captor.getValue().getMapRequest().getEidItem();
assertEquals(1, eids.size());
Eid lispAddress = eids.get(0).getEid();
- assertEquals(Ipv4PrefixBinaryAfi.class, lispAddress.getAddressType());
+ assertEquals(Ipv4PrefixBinaryAfi.VALUE, lispAddress.getAddressType());
assertEquals(LispAddressUtil.asIpv4PrefixBinaryEid("1.2.3.4/32"), lispAddress);
assertEquals(0x3d8d2acd39c8d608L, captor.getValue().getMapRequest().getNonce().longValue());
}
// Map-Reply Record: EID prefix: 2610:d0:ffff:192::1/128, TTL: 10,
// Authoritative, No-Action
- mapRequestPacket = extractWSUdpByteArray(new String(
+ mapRequestPacket = extractWSUdpByteArray(
"0000 00 0c 29 34 3e 1b 00 0c 29 f6 d6 0d 08 00 45 00 "
+ "0010 00 b0 00 00 40 00 40 11 ea 7b 0a 00 3a 9c 0a 00 "
+ "0020 01 26 10 f6 10 f6 00 9c 9b 19 80 00 00 00 60 00 "
+ "0080 3a 9c 00 80 00 02 26 10 00 d0 ff ff 01 92 00 00 "
+ "0090 00 00 00 00 00 02 00 00 00 0a 01 80 10 00 00 00 "
+ "00a0 00 02 26 10 00 d0 ff ff 01 92 00 00 00 00 00 00 "
- + "00b0 00 01 01 64 ff 00 00 05 00 01 0a 00 3a 9c"));
+ + "00b0 00 01 01 64 ff 00 00 05 00 01 0a 00 3a 9c");
ArgumentCaptor<RequestMapping> captor = ArgumentCaptor.forClass(RequestMapping.class);
handleMapRequestAsByteArray(mapRequestPacket);
// (2610:d0:ffff:192::2)
// encapsulated UDP source port: 4342
- mapRequestPacket = extractWSUdpByteArray(new String(
+ mapRequestPacket = extractWSUdpByteArray(
"0000 00 0c 29 34 3e 1b 00 0c 29 f6 d6 0d 08 00 45 00 "
+ "0010 00 b0 00 00 40 00 40 11 ea 7b 0a 00 3a 9c 0a 00 "
+ "0020 01 26 10 f6 10 f6 00 9c 9b 19 80 00 00 00 60 00 "
+ "0080 3a 9c 00 80 00 02 26 10 00 d0 ff ff 01 92 00 00 "
+ "0090 00 00 00 00 00 02 00 00 00 0a 01 80 10 00 00 00 "
+ "00a0 00 02 26 10 00 d0 ff ff 01 92 00 00 00 00 00 00 "
- + "00b0 00 01 01 64 ff 00 00 05 00 01 0a 00 3a 9c"));
+ + "00b0 00 01 01 64 ff 00 00 05 00 01 0a 00 3a 9c");
ArgumentCaptor<RequestMapping> captor = ArgumentCaptor.forClass(RequestMapping.class);
DatagramPacket replyPacket = handleMapRequestPacket(mapRequestPacket);
// encapsulated LISP packet
// Source EID = 153.16.254.1
- mapRequestPacket = extractWSUdpByteArray(new String(
+ mapRequestPacket = extractWSUdpByteArray(
"0000 00 0c 29 7a ce 83 00 15 17 c6 4a c9 08 00 45 00 "
+ "0010 00 78 00 00 40 00 3e 11 ec b1 0a 00 01 26 0a 00 "
+ "0020 3a 9e 10 f6 10 f6 00 64 c3 a5 80 00 00 00 45 00 "
+ "0050 ff 53 27 36 38 3a 00 01 99 10 fe 01 00 01 0a 00 "
+ "0060 01 26 00 20 00 01 0a 00 14 c8 00 00 00 0a 01 20 "
+ "0070 10 00 00 00 00 01 99 10 fe 01 01 64 ff 00 00 05 "
- + "0080 00 01 0a 00 01 26"));
+ + "0080 00 01 0a 00 01 26");
ArgumentCaptor<RequestMapping> captor = ArgumentCaptor.forClass(RequestMapping.class);
handleMapRequestAsByteArray(mapRequestPacket);
Mockito.verify(mockLispSouthboundPlugin).sendNotificationIfPossible(captor.capture());
- assertEquals(Ipv4BinaryAfi.class, captor.getValue().getMapRequest().getSourceEid().getEid().getAddressType());
+ assertEquals(Ipv4BinaryAfi.VALUE, captor.getValue().getMapRequest().getSourceEid().getEid().getAddressType());
}
assertEquals(AddressFamily.IpV6.getIntValue(), ByteUtil.getInt(result, MapReplyIpv4SingleLocatorPos.AFI_TYPE));
byte[] expectedIpv6 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 };
- ArrayAssert.assertEquals(expectedIpv6, Arrays.copyOfRange(result, 24, 40));
+ assertArrayEquals(expectedIpv6, Arrays.copyOfRange(result, 24, 40));
}
@Test
assertEquals(64, result.length);
byte[] expectedIpv6Eid = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 };
- ArrayAssert.assertEquals(expectedIpv6Eid, Arrays.copyOfRange(result, 24, 40));
+ assertArrayEquals(expectedIpv6Eid, Arrays.copyOfRange(result, 24, 40));
byte[] expectedIpv6Rloc = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2 };
- ArrayAssert.assertEquals(expectedIpv6Rloc, Arrays.copyOfRange(result, 48, 64));
+ assertArrayEquals(expectedIpv6Rloc, Arrays.copyOfRange(result, 48, 64));
}
@Ignore
assertEquals(AddressFamily.IpV6.getIntValue(), ByteUtil.getInt(result, MapReplyIpv4SecondLocatorPos.LOC_AFI));
byte[] expectedIpv6Rloc = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 };
- ArrayAssert.assertEquals(expectedIpv6Rloc, Arrays.copyOfRange(result, MapReplyIpv4SecondLocatorPos.LOCATOR,
+ assertArrayEquals(expectedIpv6Rloc, Arrays.copyOfRange(result, MapReplyIpv4SecondLocatorPos.LOCATOR,
MapReplyIpv4SecondLocatorPos.LOCATOR + 16));
assertEquals(0x01, result[MapReplyIpv4SecondLocatorPos.LOCATOR_RBIT] & 0x01);
// UDP: 49289 -> 4342
// LISP(Type = 14 UNKNOWN!!!, P=1, M=1
- byte[] unknownTypePacket = extractWSUdpByteArray(new String(
+ byte[] unknownTypePacket = extractWSUdpByteArray(
"0000 00 50 56 ee d1 4f 00 0c 29 7a ce 79 08 00 45 00 "
+ "0010 00 5c 00 00 40 00 40 11 d4 db c0 a8 88 0a 80 df "
+ "0020 9c 23 d6 40 10 f6 00 48 59 a4 F8 00 01 01 00 00 "
+ "0030 00 00 00 00 00 00 00 01 00 14 e8 f5 0b c5 c5 f2 "
+ "0040 b0 21 27 a8 21 41 04 f3 46 5a a5 68 89 ec 00 00 "
+ "0050 00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 "
- + "0060 ff 00 00 05 00 01 c0 a8 88 0a"));
+ + "0060 ff 00 00 05 00 01 c0 a8 88 0a");
assertNull(handlePacket(unknownTypePacket));
}
// ITR-RLOC 1: 10.1.0.111
// ITR-RLOC 2: 192.168.136.51
//
- mapRequestPacket = extractWSUdpByteArray(new String(
+ mapRequestPacket = extractWSUdpByteArray(
"0000 00 0c 29 7a ce 8d 00 0c 29 e4 ef 70 08 00 45 00 "
+ "0010 00 8a 00 00 40 00 40 11 25 f2 0a 01 00 6f 0a 01 "
+ "0020 00 01 10 f6 10 f6 00 76 06 1f 80 00 00 00 45 00 "
+ "0060 00 6f 00 01 c0 a8 88 33 00 20 00 01 08 08 08 08 "
+ "0070 00 00 00 0a 02 20 10 00 00 00 00 01 ac 01 01 02 "
+ "0080 01 64 ff 00 00 05 00 01 0a 01 00 6f 06 64 ff 00 "
- + "0090 00 05 00 01 c0 a8 88 33"));
+ + "0090 00 05 00 01 c0 a8 88 33");
handleMapRequestAsByteArray(mapRequestPacket);
Mockito.verify(mockLispSouthboundPlugin).sendNotificationIfPossible(Mockito.any(RequestMapping.class));
@Test(expected = LispMalformedPacketException.class)
public void mapRequest__NoIpItrRloc() throws Exception {
- mapRequestPacket = hexToByteBuffer("10 00 " //
- + "02 " // This means 3 ITR - RLOCs
- + "01 3d 8d 2a cd 39 c8 d6 08 00 00 " //
- + "40 05 c0 a8 88 0a 01 02 " // MAC (ITR-RLOC #1 of 3)
- + "40 05 00 00 00 00 00 00 " // MAC (ITR-RLOC #2 of 3)
- + "40 05 11 22 34 56 78 90 " // MAC (ITR-RLOC #3 of 3)
+ mapRequestPacket = hexToByteBuffer("10 00 "
+ // This means 3 ITR - RLOCs
+ + "02 "
+ + "01 3d 8d 2a cd 39 c8 d6 08 00 00 "
+ // MAC (ITR-RLOC #1 of 3)
+ + "40 05 c0 a8 88 0a 01 02 "
+ // MAC (ITR-RLOC #2 of 3)
+ + "40 05 00 00 00 00 00 00 "
+ // MAC (ITR-RLOC #3 of 3)
+ + "40 05 11 22 34 56 78 90 "
+ "00 20 00 01 01 02 03 04").array();
handleMapRequestPacket(mapRequestPacket);
}