Migrate lisp-proto implementation to IETF YANG model
[lispflowmapping.git] / mappingservice / lisp-proto / src / test / java / org / opendaylight / lispflowmapping / serializer / MapNotifySerializationTest.java
1 /*
2  * Copyright (c) 2014 Contextream, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.lispflowmapping.serializer;
10
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertFalse;
13 import static org.junit.Assert.assertTrue;
14
15 import java.nio.ByteBuffer;
16 import java.util.ArrayList;
17
18 import junitx.framework.ArrayAssert;
19
20 import org.junit.Test;
21 import org.opendaylight.lispflowmapping.lisp.serializer.MapNotifySerializer;
22 import org.opendaylight.lispflowmapping.lisp.serializer.exception.LispSerializationException;
23 import org.opendaylight.lispflowmapping.lisp.util.LispAddressUtil;
24 import org.opendaylight.lispflowmapping.tools.junit.BaseTestCase;
25 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.NoAddressAfi;
26 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address;
27 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.NoAddressBuilder;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapNotify;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.EidBuilder;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.locatorrecords.LocatorRecord;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapnotifymessage.MapNotifyBuilder;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord.Action;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecordBuilder;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItemBuilder;
37
38 public class MapNotifySerializationTest extends BaseTestCase {
39
40     @Test
41     public void serialize__Fields() throws Exception {
42         MapNotifyBuilder mnBuilder = new MapNotifyBuilder();
43         mnBuilder.setMappingRecordItem(new ArrayList<MappingRecordItem>());
44         mnBuilder.getMappingRecordItem().add(
45                 new MappingRecordItemBuilder().setMappingRecord(
46                         new MappingRecordBuilder().setEid(LispAddressUtil.asIpv4PrefixEid("0.0.0.1/32")).build())
47                         .build());
48         mnBuilder.getMappingRecordItem().add(
49                 new MappingRecordItemBuilder().setMappingRecord(
50                         new MappingRecordBuilder().setEid(LispAddressUtil.asIpv4PrefixEid("0.0.0.73/32")).build())
51                         .build());
52
53         mnBuilder.setNonce(6161616161L);
54         mnBuilder.setKeyId((short) 0x0001);
55         byte[] authenticationData = new byte[] { (byte) 0x16, (byte) 0x98, (byte) 0x96, (byte) 0xeb, (byte) 0x88, (byte) 0x2d, (byte) 0x4d,
56                 (byte) 0x22, (byte) 0xe5, (byte) 0x8f, (byte) 0xe6, (byte) 0x89, (byte) 0x64, (byte) 0xb9, (byte) 0x17, (byte) 0xa4, (byte) 0xba,
57                 (byte) 0x4e, (byte) 0x8c, (byte) 0x41 };
58         mnBuilder.setAuthenticationData(authenticationData);
59
60         ByteBuffer bb = MapNotifySerializer.getInstance().serialize(mnBuilder.build());
61         assertHexEquals((byte) 0x40, bb.get()); // Type + MSByte of reserved
62         assertEquals(0, bb.getShort()); // Rest of reserved
63         assertEquals(2, bb.get()); // Record Count
64         assertEquals(6161616161L, bb.getLong()); // Nonce
65         assertHexEquals((short) 0x0001, bb.getShort()); // Key ID
66         assertEquals(authenticationData.length, bb.getShort());
67
68         byte[] actualAuthenticationData = new byte[20];
69         bb.get(actualAuthenticationData);
70         ArrayAssert.assertEquals(authenticationData, actualAuthenticationData);
71
72         bb.position(bb.position() + 12); /* EID in first record */
73         assertEquals(0x1, bb.getInt());
74
75         bb.position(bb.position() + 12); /* EID in second record */
76         assertEquals(73, bb.getInt());
77
78         assertEquals(bb.position(), bb.capacity());
79     }
80
81     @Test
82     public void serialize__deserialize() throws Exception {
83         MapNotifyBuilder mnBuilder = new MapNotifyBuilder();
84         mnBuilder.setMappingRecordItem(new ArrayList<MappingRecordItem>());
85         mnBuilder.getMappingRecordItem().add(
86                 new MappingRecordItemBuilder().setMappingRecord(
87                         new MappingRecordBuilder().setEid(LispAddressUtil.asIpv4PrefixEid("0.0.0.1/32")).build())
88                         .build());
89         mnBuilder.getMappingRecordItem().add(
90                 new MappingRecordItemBuilder().setMappingRecord(
91                         new MappingRecordBuilder().setEid(LispAddressUtil.asIpv4PrefixEid("0.0.0.73/32")).build())
92                         .build());
93
94         mnBuilder.setNonce(6161616161L);
95         mnBuilder.setKeyId((short) 0x0001);
96         byte[] authenticationData = new byte[] { (byte) 0x16, (byte) 0x98, (byte) 0x96, (byte) 0xeb, (byte) 0x88, (byte) 0x2d, (byte) 0x4d,
97                 (byte) 0x22, (byte) 0xe5, (byte) 0x8f, (byte) 0xe6, (byte) 0x89, (byte) 0x64, (byte) 0xb9, (byte) 0x17, (byte) 0xa4, (byte) 0xba,
98                 (byte) 0x4e, (byte) 0x8c, (byte) 0x41 };
99         mnBuilder.setAuthenticationData(authenticationData);
100
101         MapNotify mn = mnBuilder.build();
102         ArrayAssert.assertEquals(
103                 MapNotifySerializer.getInstance().serialize(mn).array(),
104                 MapNotifySerializer.getInstance()
105                         .serialize(MapNotifySerializer.getInstance().deserialize(MapNotifySerializer.getInstance().serialize(mn))).array());
106
107     }
108
109     @Test
110     public void deserialize__AllFields() throws Exception {
111         // LISP(Type = 4 Map-Notify, I=1
112         // Record Counter: 1
113         // Nonce: (something)
114         // Key ID: 0x0000
115         // AuthDataLength: 00 Data:
116         // EID prefix: 153.16.254.1/32 (EID=0x9910FE01), TTL: 10, Authoritative,
117         // No-Action
118         // Local RLOC: 192.168.136.10 (RLOC=0xC0A8880A), Reachable,
119         // Priority/Weight: 1/100, Multicast Priority/Weight: 255/0
120         // xTR-ID 1
121         // Site-ID 1
122         MapNotify mn = MapNotifySerializer.getInstance().deserialize(hexToByteBuffer("48 00 00 01 FF BB "
123         //
124                 + "00 00 00 00 00 00 00 00 00 00 00 00 " //
125                 + "00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 " //
126                 + "ff 00 00 05 00 01 c0 a8 88 0a "
127                 + "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 " // xTR-ID
128                 + "00 00 00 00 00 00 00 01 " // Site-ID
129                 ));
130
131
132         assertTrue(mn.isXtrSiteIdPresent());
133
134         assertEquals(1, mn.getMappingRecordItem().size());
135         assertEquals(0xFFBB000000000000L, mn.getNonce().longValue());
136         assertEquals(0x0000, mn.getKeyId().shortValue());
137         byte[] expectedAuthenticationData = {};
138         ArrayAssert.assertEquals(expectedAuthenticationData, mn.getAuthenticationData());
139     }
140
141     @Test
142     public void serialize__NoAuthenticationData() throws Exception {
143         MapNotifyBuilder mnBuilder = new MapNotifyBuilder();
144         mnBuilder.setMappingRecordItem(new ArrayList<MappingRecordItem>());
145         mnBuilder.getMappingRecordItem().add(
146                 new MappingRecordItemBuilder().setMappingRecord(
147                         new MappingRecordBuilder().setEid(LispAddressUtil.asIpv4PrefixEid("0.0.0.1/32"))
148                         .setRecordTtl(55).build()).build());
149
150         ByteBuffer bb = MapNotifySerializer.getInstance().serialize(mnBuilder.build());
151         bb.position(bb.position() + 14); // jump to AuthenticationDataLength
152         assertEquals(0, bb.getShort());
153         assertEquals(55, bb.getInt());
154
155         mnBuilder.setAuthenticationData(null);
156
157         bb = MapNotifySerializer.getInstance().serialize(mnBuilder.build());
158         bb.position(bb.position() + 14); // jump to AuthenticationDataLength
159         assertEquals(0, bb.getShort());
160         assertEquals(55, bb.getInt());
161
162         mnBuilder.setAuthenticationData(new byte[0]);
163
164         bb = MapNotifySerializer.getInstance().serialize(mnBuilder.build());
165         bb.position(bb.position() + 14); // jump to AuthenticationDataLength
166         assertEquals(0, bb.getShort());
167         assertEquals(55, bb.getInt());
168     }
169
170     @Test
171     public void serialize__NoPrefixInEidToLocator() throws Exception {
172         MapNotifyBuilder mnBuilder = new MapNotifyBuilder();
173         mnBuilder.setMappingRecordItem(new ArrayList<MappingRecordItem>());
174         mnBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(
175                 new MappingRecordBuilder().build()).build());
176         mnBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord
177                 (new MappingRecordBuilder().setEid(null).build()).build());
178         mnBuilder.getMappingRecordItem().add(new MappingRecordItemBuilder().setMappingRecord(
179                 new MappingRecordBuilder().setEid(new EidBuilder().setAddressType(NoAddressAfi.class).setAddress(
180                         (Address) new NoAddressBuilder().setNoAddress(true).build()).build()).build()).build());
181
182         ByteBuffer bb = MapNotifySerializer.getInstance().serialize(mnBuilder.build());
183         bb.position(bb.position() + 16); // jump to first record prefix AFI
184         assertEquals(0, bb.getShort());
185
186         bb.position(bb.position() + 10); // jump to second record prefix AFI
187         assertEquals(0, bb.getShort());
188
189         bb.position(bb.position() + 10); // jump to third record prefix AFI
190         assertEquals(0, bb.getShort());
191     }
192
193     @Test
194     public void deserialize__MultipleRecords() throws Exception {
195         // LISP(Type = 4 Map-Notify, I=1
196         // Record Counter: 4
197         // EID prefixes: 153.16.254.1 -- 152.16.254.1 -- 151.16.254.1 --
198         // 150.16.254.1
199         // Local RLOCs: 192.168.136.10 -- 192.168.136.11 -- 192.168.136.12 --
200         // 192.168.136.13
201         //
202         MapNotify mn = MapNotifySerializer.getInstance().deserialize(hexToByteBuffer("40 00 00 "
203         //
204                 + "04 " // Record count
205                 + "FF BB 00 00 00 00 00 00 00 01 00 14 87 c1 33 cd " //
206                 + "d1 1e bc 80 fd 3e 71 11 81 17 40 74 26 25 44 bd " //
207                 + "00 00 00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 " // Record
208                 // 1
209                 + "ff 00 00 05 00 01 c0 a8 88 0a " // contd
210                 + "00 00 00 0a 01 20 10 00 00 00 00 01 98 10 fe 01 01 64 " // Record
211                 // 2
212                 + "ff 00 00 05 00 01 c0 a8 88 0b " // contd
213                 + "00 00 00 0a 01 20 10 00 00 00 00 01 97 10 fe 01 01 64 " // Record
214                 // 3
215                 + "ff 00 00 05 00 01 c0 a8 88 0c " // contd
216                 + "00 00 00 0a 01 20 10 00 00 00 00 01 96 10 fe 01 01 64 " // Record
217                 // 4
218                 + "ff 00 00 05 00 01 c0 a8 88 0d " // contd
219         ));
220
221         assertEquals(4, mn.getMappingRecordItem().size());
222         assertEquals(LispAddressUtil.asIpv4PrefixEid("153.16.254.1/32"), mn.getMappingRecordItem().get(0)
223                 .getMappingRecord().getEid());
224         assertEquals(LispAddressUtil.asIpv4PrefixEid("151.16.254.1/32"), mn.getMappingRecordItem().get(2)
225                 .getMappingRecord().getEid());
226         assertEquals(LispAddressUtil.asIpv4Rloc("192.168.136.11"), mn.getMappingRecordItem().get(1)
227                 .getMappingRecord().getLocatorRecord().get(0).getRloc());
228         assertEquals(LispAddressUtil.asIpv4Rloc("192.168.136.13"), mn.getMappingRecordItem().get(3)
229                 .getMappingRecord().getLocatorRecord().get(0).getRloc());
230     }
231
232     @Test
233     public void deserialize__Locators() throws Exception {
234         MapNotify mn = MapNotifySerializer.getInstance().deserialize(hexToByteBuffer("40 00 01 01 "
235         //
236                 + "FF BB 00 00 00 00 00 00 00 01 00 14 f1 b8 ab f0 " //
237                 + "66 bb 2e ef 12 70 74 46 6f 6b 8e ca bf 1e 68 40 " //
238                 + "00 00 00 0a " //
239                 + "03 " // Locator Count
240                 + "20 10 00 00 00 00 01 99 10 fe 01 "
241                 // Locator 1
242                 + "01 64 1f 00 " // priorities + weights
243                 + "00 05 " // Flags
244                 + "00 01 c0 a8 88 0a " // Locator
245                 // Locator 2
246                 + "67 00 30 34 " // priorities + weights
247                 + "00 02 " // Flags
248                 + "00 01 cc aa AA 11 " // Locator
249                 // Locator 3
250                 + "60 11 34 A4 " // priorities + weights
251                 + "00 03 " // Flags
252                 + "00 01 c0 a8 88 0a " // Locator
253         ));
254
255         assertEquals(1, mn.getMappingRecordItem().size());
256         MappingRecordItem eidToLocator = mn.getMappingRecordItem().get(0);
257         assertEquals(3, eidToLocator.getMappingRecord().getLocatorRecord().size());
258         LocatorRecord loc0 = eidToLocator.getMappingRecord().getLocatorRecord().get(0);
259         LocatorRecord loc1 = eidToLocator.getMappingRecord().getLocatorRecord().get(1);
260         LocatorRecord loc2 = eidToLocator.getMappingRecord().getLocatorRecord().get(2);
261         assertEquals((byte) 0x01, loc0.getPriority().byteValue());
262         assertEquals((byte) 0x67, loc1.getPriority().byteValue());
263         assertEquals((byte) 0x60, loc2.getPriority().byteValue());
264
265         assertEquals((byte) 0x64, loc0.getWeight().byteValue());
266         assertEquals((byte) 0x00, loc1.getWeight().byteValue());
267         assertEquals((byte) 0x11, loc2.getWeight().byteValue());
268
269         assertEquals((byte) 0x1F, loc0.getMulticastPriority().byteValue());
270         assertEquals((byte) 0x30, loc1.getMulticastPriority().byteValue());
271         assertEquals((byte) 0x34, loc2.getMulticastPriority().byteValue());
272
273         assertEquals((byte) 0x00, loc0.getMulticastWeight().byteValue());
274         assertEquals((byte) 0x34, loc1.getMulticastWeight().byteValue());
275         assertEquals((byte) 0xA4, loc2.getMulticastWeight().byteValue());
276
277         assertTrue(loc0.isLocalLocator());
278         assertFalse(loc1.isLocalLocator());
279         assertFalse(loc2.isLocalLocator());
280
281         assertFalse(loc0.isRlocProbed());
282         assertTrue(loc1.isRlocProbed());
283         assertTrue(loc2.isRlocProbed());
284
285         assertTrue(loc0.isRouted());
286         assertFalse(loc1.isRouted());
287         assertTrue(loc2.isRouted());
288
289         assertEquals(LispAddressUtil.asIpv4Rloc("192.168.136.10"), loc0.getRloc());
290         assertEquals(LispAddressUtil.asIpv4Rloc("204.170.170.17"), loc1.getRloc());
291     }
292
293     @Test
294     public void deserialize__SomeEidToLocatorFiels() throws Exception {
295         // LISP(Type = 4 Map-Notify, I=0
296         // Record Counter: 4
297         // EID prefixes: 153.16.254.1 -- 152.16.254.1 -- 151.16.254.1 --
298         // 150.16.254.1
299         // Local RLOCs: 192.168.136.10 -- 192.168.136.11 -- 192.168.136.12 --
300         // 192.168.136.13
301         //
302         MapNotify mn = MapNotifySerializer.getInstance().deserialize(hexToByteBuffer("40 00 00 "
303         //
304                 + "04 " // Record count
305                 + "FF BB 00 00 00 00 00 00 00 01 00 14 b9 cd 7b 89 " //
306                 + "65 c2 56 03 be dd 81 20 47 e5 c3 4f 56 02 e1 59 " //
307                 + "00 00 00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 " // Record
308                 // 0
309                 + "ff 00 00 05 00 01 c0 a8 88 0a " // contd
310                 + "00 00 00 0b 01 17 50 00 01 11 00 01 98 10 fe 01 01 64 " // Record
311                 // 1
312                 + "ff 00 00 05 00 01 c0 a8 88 0b " // contd
313                 + "00 00 00 0c 01 20 00 00 02 22 00 01 97 10 fe 01 01 64 " // Record
314                 // 2
315                 + "ff 00 00 05 00 01 c0 a8 88 0c " // contd
316                 + "00 00 00 0d 01 20 20 00 03 33 00 01 96 10 fe 01 01 64 " // Record
317                 // 3
318                 + "ff 00 00 05 00 01 c0 a8 88 0d " // contd
319         ));
320
321         assertEquals(4, mn.getMappingRecordItem().size());
322
323         MappingRecord record0 = mn.getMappingRecordItem().get(0).getMappingRecord();
324         MappingRecord record1 = mn.getMappingRecordItem().get(1).getMappingRecord();
325         MappingRecord record2 = mn.getMappingRecordItem().get(2).getMappingRecord();
326         MappingRecord record3 = mn.getMappingRecordItem().get(3).getMappingRecord();
327
328         assertEquals(10, record0.getRecordTtl().intValue());
329         assertEquals(13, record3.getRecordTtl().intValue());
330
331         assertEquals(32, record0.getMaskLength().intValue());
332         assertEquals(23, record1.getMaskLength().intValue());
333
334         assertEquals(Action.NoAction, record0.getAction());
335         assertEquals(Action.SendMapRequest, record1.getAction());
336         assertEquals(Action.NoAction, record2.getAction());
337         assertEquals(Action.NativelyForward, record3.getAction());
338
339         assertTrue(record0.isAuthoritative());
340         assertTrue(record1.isAuthoritative());
341         assertFalse(record2.isAuthoritative());
342         assertFalse(record3.isAuthoritative());
343
344         assertEquals(0x000, record0.getMapVersion().shortValue());
345         assertEquals(0x111, record1.getMapVersion().shortValue());
346         assertEquals(0x222, record2.getMapVersion().shortValue());
347         assertEquals(0x333, record3.getMapVersion().shortValue());
348     }
349
350     @Test
351     public void deserialize__IllegalAction() throws Exception {
352         MapNotify mn = MapNotifySerializer.getInstance().deserialize(hexToByteBuffer("40 00 01 01 FF BB "
353         //
354                 + "00 00 00 00 00 00 00 01 00 14 ec 47 1e 53 25 91 " //
355                 + "2f 68 10 75 13 dd 2c e8 6e 3c ac 94 ed e4 00 00 " //
356                 + "00 0a 01 20 F0 00 00 00 00 01 99 10 fe 01 01 64 " //
357                 + "ff 00 00 05 00 01 c0 a8 88 0a"));
358
359         assertEquals(1, mn.getMappingRecordItem().size());
360         assertEquals(Action.NoAction, mn.getMappingRecordItem().get(0).getMappingRecord().getAction());
361     }
362
363     @Test(expected = LispSerializationException.class)
364     public void deserialize_WrongAuthenticationLength() throws Exception {
365         // LISP(Type = 4 Map-Notify, I=0
366         // Record Counter: 1
367         // Nonce: (something)
368         // Key ID: 0x0000
369         // AuthDataLength: 20 Data:
370         // e8:f5:0b:c5:c5:f2:b0:21:27:a8:a5:68:89:ec
371         // EID prefix: 153.16.254.1/32 (EID=0x9910FE01), TTL: 10, Authoritative,
372         // No-Action
373         // Local RLOC: 192.168.136.10 (RLOC=0xC0A8880A), Reachable,
374         // Priority/Weight: 1/100, Multicast Priority/Weight: 255/0
375         //
376         MapNotifySerializer.getInstance().deserialize(hexToByteBuffer("48 00 00 01 FF BB "
377         //
378                 + "00 00 00 00 00 00 00 00 00 14 e8 f5 0b c5 c5 f2 " //
379                 + "b0 21 27 a8 21 a5 68 89 ec 00 00 " //
380                 + "00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 " //
381                 + "ff 00 00 05 00 01 c0 a8 88 0a"));
382     }
383
384     @Test
385     public void deserialize__SHA1() throws Exception {
386         // LISP(Type = 4 Map-Notify, I=0
387         // Record Counter: 1
388         // Nonce: (something)
389         // Key ID: 0x0001
390         // AuthDataLength: 20 Data:
391         // b2:dd:1a:25:c0:60:b1:46:e8:dc:6d:a6:ae:2e:92:92:a6:ca:b7:9d
392         // EID prefix: 153.16.254.1/32 (EID=0x9910FE01), TTL: 10, Authoritative,
393         // No-Action
394         // Local RLOC: 192.168.136.10 (RLOC=0xC0A8880A), Reachable,
395         // Priority/Weight: 1/100, Multicast Priority/Weight: 255/0
396         //
397         MapNotify mn = MapNotifySerializer.getInstance().deserialize(hexToByteBuffer("40 00 00 01 FF BB "
398         //
399                 + "00 00 00 00 00 00 00 01 00 14 2c 61 b9 c9 9a 20 " //
400                 + "ba d8 f5 40 d3 55 6f 5f 6e 5a b2 0a bf b5 00 00 " //
401                 + "00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 " //
402                 + "ff 00 00 05 00 01 c0 a8 88 0a"));
403
404         assertFalse(mn.isXtrSiteIdPresent());
405
406         assertEquals(1, mn.getMappingRecordItem().size());
407         assertEquals(0xFFBB000000000000L, mn.getNonce().longValue());
408         assertEquals(0x0001, mn.getKeyId().shortValue());
409         byte[] expectedAuthenticationData = { (byte) 0x2c, (byte) 0x61, (byte) 0xb9, (byte) 0xc9, (byte) 0x9a, (byte) 0x20, (byte) 0xba, (byte) 0xd8, //
410                 (byte) 0xf5, (byte) 0x40, (byte) 0xd3, (byte) 0x55, (byte) 0x6f, (byte) 0x5f, (byte) 0x6e, (byte) 0x5a, //
411                 (byte) 0xb2, (byte) 0x0a, (byte) 0xbf, (byte) 0xb5 };
412         ArrayAssert.assertEquals(expectedAuthenticationData, mn.getAuthenticationData());
413     }
414
415     @Test
416     public void deserialize__SHA256() throws Exception {
417         // LISP(Type = 4 Map-Notify, I=0
418         // Record Counter: 1
419         // Nonce: (something)
420         // Key ID: 0x0002
421         // AuthDataLength: 32 Data:
422         // 70 30 d4 c6 10 44 0d 83 be 4d bf fd a9 8c 57 6d 68 a5 bf 32 11 c9 7b
423         // 58 c4 b9 9f 06 11 23 b9 38
424         // EID prefix: 153.16.254.1/32 (EID=0x9910FE01), TTL: 10, Authoritative,
425         // No-Action
426         // Local RLOC: 192.168.136.10 (RLOC=0xC0A8880A), Reachable,
427         // Priority/Weight: 1/100, Multicast Priority/Weight: 255/0
428         //
429         MapNotify mn = MapNotifySerializer.getInstance().deserialize(hexToByteBuffer("40 00 00 01 FF BB "
430         //
431                 + "00 00 00 00 00 00 00 02 00 20 70 30 d4 c6 10 44 0d 83 be 4d bf fd a9 8c 57 6d 68 a5 bf 32 "
432                 //
433                 + "11 c9 7b 58 c4 b9 9f 06 11 23 b9 38 00 00 " //
434                 + "00 0a 01 20 10 00 00 00 00 01 99 10 fe 01 01 64 " //
435                 + "ff 00 00 05 00 01 c0 a8 88 0a"));
436
437         assertFalse(mn.isXtrSiteIdPresent());
438
439         assertEquals(1, mn.getMappingRecordItem().size());
440         assertEquals(0xFFBB000000000000L, mn.getNonce().longValue());
441         assertEquals(0x0002, mn.getKeyId().shortValue());
442         byte[] expectedAuthenticationData = { (byte) 0x70, (byte) 0x30, (byte) 0xd4, (byte) 0xc6, (byte) 0x10, (byte) 0x44, (byte) 0x0d, (byte) 0x83,
443                 (byte) 0xbe, (byte) 0x4d, (byte) 0xbf, (byte) 0xfd, (byte) 0xa9, (byte) 0x8c, (byte) 0x57, (byte) 0x6d, (byte) 0x68, (byte) 0xa5,
444                 (byte) 0xbf, (byte) 0x32, (byte) 0x11, (byte) 0xc9, (byte) 0x7b, (byte) 0x58, (byte) 0xc4, (byte) 0xb9, (byte) 0x9f, (byte) 0x06,
445                 (byte) 0x11, (byte) 0x23, (byte) 0xb9, (byte) 0x38 };
446         ArrayAssert.assertEquals(expectedAuthenticationData, mn.getAuthenticationData());
447     }
448 }