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