/** * Copyright (C) 2015-2017 Regents of the University of California. * @author: Jeff Thompson <jefft0@remap.ucla.edu> * From ndn-cxx unit tests: * https://github.com/named-data/ndn-cxx/blob/master/tests/unit-tests/link.t.cpp * https://github.com/named-data/ndn-cxx/blob/master/tests/unit-tests/interest.t.cpp * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * A copy of the GNU Lesser General Public License is in the file COPYING. */ package net.named_data.jndn.tests.unit_tests; import java.nio.ByteBuffer; import java.util.logging.Level; import java.util.logging.Logger; import net.named_data.jndn.DelegationSet; import net.named_data.jndn.Interest; import net.named_data.jndn.Link; import net.named_data.jndn.Name; import net.named_data.jndn.encoding.EncodingException; import net.named_data.jndn.security.KeyChain; import net.named_data.jndn.security.KeyType; import net.named_data.jndn.security.SecurityException; import net.named_data.jndn.security.identity.IdentityManager; import net.named_data.jndn.security.identity.MemoryIdentityStorage; import net.named_data.jndn.security.identity.MemoryPrivateKeyStorage; import net.named_data.jndn.security.policy.SelfVerifyPolicyManager; import net.named_data.jndn.util.Blob; import org.junit.Test; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import org.junit.Before; public class TestLink { // Convert the int array to a ByteBuffer. public static ByteBuffer toBuffer(int[] array) { ByteBuffer result = ByteBuffer.allocate(array.length); for (int i = 0; i < array.length; ++i) result.put((byte)(array[i] & 0xff)); result.flip(); return result; } private static final ByteBuffer LinkTest = toBuffer(new int[] { 0x06, 0xda, // Data 0x07, 0x14, // Name 0x08, 0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x08, 0x03, 0x6e, 0x64, 0x6e, 0x08, 0x06, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x14, 0x07, // MetaInfo 0x18, 0x01, // ContentType 0x01, 0x19, 0x02, // FreshnessPeriod 0x27, 0x10, 0x15, 0x1a, // Content 0x1f, 0x0c, // LinkDelegation 0x1e, 0x01, // LinkPreference 0x0a, 0x07, 0x07, // Name 0x08, 0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x1f, 0x0a, // LinkDelegation 0x1e, 0x01, // LinkPreference 0x14, 0x07, 0x05, // Name 0x08, 0x03, 0x6e, 0x64, 0x6e, 0x16, 0x1b, // SignatureInfo 0x1b, 0x01, // SignatureType 0x01, 0x1c, 0x16, // KeyLocator 0x07, 0x14, // Name 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x03, 0x6b, 0x65, 0x79, 0x08, 0x07, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x6f, 0x72, 0x17, 0x80, // SignatureValue 0x2f, 0xd6, 0xf1, 0x6e, 0x80, 0x6f, 0x10, 0xbe, 0xb1, 0x6f, 0x3e, 0x31, 0xec, 0xe3, 0xb9, 0xea, 0x83, 0x30, 0x40, 0x03, 0xfc, 0xa0, 0x13, 0xd9, 0xb3, 0xc6, 0x25, 0x16, 0x2d, 0xa6, 0x58, 0x41, 0x69, 0x62, 0x56, 0xd8, 0xb3, 0x6a, 0x38, 0x76, 0x56, 0xea, 0x61, 0xb2, 0x32, 0x70, 0x1c, 0xb6, 0x4d, 0x10, 0x1d, 0xdc, 0x92, 0x8e, 0x52, 0xa5, 0x8a, 0x1d, 0xd9, 0x96, 0x5e, 0xc0, 0x62, 0x0b, 0xcf, 0x3a, 0x9d, 0x7f, 0xca, 0xbe, 0xa1, 0x41, 0x71, 0x85, 0x7a, 0x8b, 0x5d, 0xa9, 0x64, 0xd6, 0x66, 0xb4, 0xe9, 0x8d, 0x0c, 0x28, 0x43, 0xee, 0xa6, 0x64, 0xe8, 0x55, 0xf6, 0x1c, 0x19, 0x0b, 0xef, 0x99, 0x25, 0x1e, 0xdc, 0x78, 0xb3, 0xa7, 0xaa, 0x0d, 0x14, 0x58, 0x30, 0xe5, 0x37, 0x6a, 0x6d, 0xdb, 0x56, 0xac, 0xa3, 0xfc, 0x90, 0x7a, 0xb8, 0x66, 0x9c, 0x0e, 0xf6, 0xb7, 0x64, 0xd1 }); private static final ByteBuffer IncorrectContentTypeLink = toBuffer(new int[] { 0x06, 0xda, // Data 0x07, 0x14, // Name 0x08, 0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x08, 0x03, 0x6e, 0x64, 0x6e, 0x08, 0x06, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x14, 0x07, // MetaInfo 0x18, 0x01, // ContentType 0x02, 0x19, 0x02, // FreshnessPeriod 0x27, 0x10, 0x15, 0x1a, // Content 0x1f, 0x0c, // LinkDelegation 0x1e, 0x01, // LinkPreference 0x0a, 0x07, 0x07, // Name 0x08, 0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x1f, 0x0a, // LinkDelegation 0x1e, 0x01, // LinkPreference 0x14, 0x07, 0x05, // Name 0x08, 0x03, 0x6e, 0x64, 0x6e, 0x16, 0x1b, // SignatureInfo 0x1b, 0x01, // SignatureType 0x01, 0x1c, 0x16, // KeyLocator 0x07, 0x14, // Name 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x03, 0x6b, 0x65, 0x79, 0x08, 0x07, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x6f, 0x72, 0x17, 0x80, // SignatureValue 0x2f, 0xd6, 0xf1, 0x6e, 0x80, 0x6f, 0x10, 0xbe, 0xb1, 0x6f, 0x3e, 0x31, 0xec, 0xe3, 0xb9, 0xea, 0x83, 0x30, 0x40, 0x03, 0xfc, 0xa0, 0x13, 0xd9, 0xb3, 0xc6, 0x25, 0x16, 0x2d, 0xa6, 0x58, 0x41, 0x69, 0x62, 0x56, 0xd8, 0xb3, 0x6a, 0x38, 0x76, 0x56, 0xea, 0x61, 0xb2, 0x32, 0x70, 0x1c, 0xb6, 0x4d, 0x10, 0x1d, 0xdc, 0x92, 0x8e, 0x52, 0xa5, 0x8a, 0x1d, 0xd9, 0x96, 0x5e, 0xc0, 0x62, 0x0b, 0xcf, 0x3a, 0x9d, 0x7f, 0xca, 0xbe, 0xa1, 0x41, 0x71, 0x85, 0x7a, 0x8b, 0x5d, 0xa9, 0x64, 0xd6, 0x66, 0xb4, 0xe9, 0x8d, 0x0c, 0x28, 0x43, 0xee, 0xa6, 0x64, 0xe8, 0x55, 0xf6, 0x1c, 0x19, 0x0b, 0xef, 0x99, 0x25, 0x1e, 0xdc, 0x78, 0xb3, 0xa7, 0xaa, 0x0d, 0x14, 0x58, 0x30, 0xe5, 0x37, 0x6a, 0x6d, 0xdb, 0x56, 0xac, 0xa3, 0xfc, 0x90, 0x7a, 0xb8, 0x66, 0x9c, 0x0e, 0xf6, 0xb7, 0x64, 0xd1 }); private static final ByteBuffer MissingPreferenceLink = toBuffer(new int[] { 0x06, 0xd7, // Data 0x07, 0x14, // Name 0x08, 0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x08, 0x03, 0x6e, 0x64, 0x6e, 0x08, 0x06, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x14, 0x07, // MetaInfo 0x18, 0x01, // ContentType 0x01, 0x19, 0x02, // FreshnessPeriod 0x27, 0x10, 0x15, 0x17, // Content 0x1f, 0x09, // LinkDelegation 0x07, 0x07, // Name 0x08, 0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x1f, 0x0a, // LinkDelegation 0x1e, 0x01, // LinkPreference 0x14, 0x07, 0x05, // Name 0x08, 0x03, 0x6e, 0x64, 0x6e, 0x16, 0x1b, // SignatureInfo 0x1b, 0x01, // SignatureType 0x01, 0x1c, 0x16, // KeyLocator 0x07, 0x14, // Name 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x03, 0x6b, 0x65, 0x79, 0x08, 0x07, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x6f, 0x72, 0x17, 0x80, // SignatureValue 0x2f, 0xd6, 0xf1, 0x6e, 0x80, 0x6f, 0x10, 0xbe, 0xb1, 0x6f, 0x3e, 0x31, 0xec, 0xe3, 0xb9, 0xea, 0x83, 0x30, 0x40, 0x03, 0xfc, 0xa0, 0x13, 0xd9, 0xb3, 0xc6, 0x25, 0x16, 0x2d, 0xa6, 0x58, 0x41, 0x69, 0x62, 0x56, 0xd8, 0xb3, 0x6a, 0x38, 0x76, 0x56, 0xea, 0x61, 0xb2, 0x32, 0x70, 0x1c, 0xb6, 0x4d, 0x10, 0x1d, 0xdc, 0x92, 0x8e, 0x52, 0xa5, 0x8a, 0x1d, 0xd9, 0x96, 0x5e, 0xc0, 0x62, 0x0b, 0xcf, 0x3a, 0x9d, 0x7f, 0xca, 0xbe, 0xa1, 0x41, 0x71, 0x85, 0x7a, 0x8b, 0x5d, 0xa9, 0x64, 0xd6, 0x66, 0xb4, 0xe9, 0x8d, 0x0c, 0x28, 0x43, 0xee, 0xa6, 0x64, 0xe8, 0x55, 0xf6, 0x1c, 0x19, 0x0b, 0xef, 0x99, 0x25, 0x1e, 0xdc, 0x78, 0xb3, 0xa7, 0xaa, 0x0d, 0x14, 0x58, 0x30, 0xe5, 0x37, 0x6a, 0x6d, 0xdb, 0x56, 0xac, 0xa3, 0xfc, 0x90, 0x7a, 0xb8, 0x66, 0x9c, 0x0e, 0xf6, 0xb7, 0x64, 0xd1 }); private static final ByteBuffer MissingNameLink = toBuffer(new int[] { 0x06, 0xd1, // Data 0x07, 0x14, // Name 0x08, 0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x08, 0x03, 0x6e, 0x64, 0x6e, 0x08, 0x06, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x14, 0x07, // MetaInfo 0x18, 0x01, // ContentType 0x01, 0x19, 0x02, // FreshnessPeriod 0x27, 0x10, 0x15, 0x11, // Content 0x1f, 0x03, // LinkDelegation 0x1e, 0x01, // LinkPreference 0x0a, 0x1f, 0x0a, // LinkDelegation 0x1e, 0x01, // LinkPreference 0x14, 0x07, 0x05, // Name 0x08, 0x03, 0x6e, 0x64, 0x6e, 0x16, 0x1b, // SignatureInfo 0x1b, 0x01, // SignatureType 0x01, 0x1c, 0x16, // KeyLocator 0x07, 0x14, // Name 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x03, 0x6b, 0x65, 0x79, 0x08, 0x07, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x6f, 0x72, 0x17, 0x80, // SignatureValue 0x2f, 0xd6, 0xf1, 0x6e, 0x80, 0x6f, 0x10, 0xbe, 0xb1, 0x6f, 0x3e, 0x31, 0xec, 0xe3, 0xb9, 0xea, 0x83, 0x30, 0x40, 0x03, 0xfc, 0xa0, 0x13, 0xd9, 0xb3, 0xc6, 0x25, 0x16, 0x2d, 0xa6, 0x58, 0x41, 0x69, 0x62, 0x56, 0xd8, 0xb3, 0x6a, 0x38, 0x76, 0x56, 0xea, 0x61, 0xb2, 0x32, 0x70, 0x1c, 0xb6, 0x4d, 0x10, 0x1d, 0xdc, 0x92, 0x8e, 0x52, 0xa5, 0x8a, 0x1d, 0xd9, 0x96, 0x5e, 0xc0, 0x62, 0x0b, 0xcf, 0x3a, 0x9d, 0x7f, 0xca, 0xbe, 0xa1, 0x41, 0x71, 0x85, 0x7a, 0x8b, 0x5d, 0xa9, 0x64, 0xd6, 0x66, 0xb4, 0xe9, 0x8d, 0x0c, 0x28, 0x43, 0xee, 0xa6, 0x64, 0xe8, 0x55, 0xf6, 0x1c, 0x19, 0x0b, 0xef, 0x99, 0x25, 0x1e, 0xdc, 0x78, 0xb3, 0xa7, 0xaa, 0x0d, 0x14, 0x58, 0x30, 0xe5, 0x37, 0x6a, 0x6d, 0xdb, 0x56, 0xac, 0xa3, 0xfc, 0x90, 0x7a, 0xb8, 0x66, 0x9c, 0x0e, 0xf6, 0xb7, 0x64, 0xd1 }); private static final ByteBuffer InterestWithLink = toBuffer(new int[] { 0x05, 0xfb, // Interest 0x07, 0x14, // Name 0x08, 0x5, // NameComponent 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x08, 0x3, // NameComponent 0x6e, 0x64, 0x6e, 0x08, 0x6, // NameComponent 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x0a, 0x4, // Nonce 0x1, 0x0, 0x0, 0x00, 0x06, 0xda, // Data 0x07, 0x14, // Name 0x08, 0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x08, 0x03, 0x6e, 0x64, 0x6e, 0x08, 0x06, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x14, 0x07, // MetaInfo 0x18, 0x01, // ContentType 0x01, 0x19, 0x02, // FreshnessPeriod 0x27, 0x10, 0x15, 0x1a, // Content 0x1f, 0x0c, // LinkDelegation 0x1e, 0x01, // LinkPreference 0x0a, 0x07, 0x07, // Name 0x08, 0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x1f, 0x0a, // LinkDelegation 0x1e, 0x01, // LinkPreference 0x14, 0x07, 0x05, // Name 0x08, 0x03, 0x6e, 0x64, 0x6e, 0x16, 0x1b, // SignatureInfo 0x1b, 0x01, // SignatureType 0x01, 0x1c, 0x16, // KeyLocator 0x07, 0x14, // Name 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x03, 0x6b, 0x65, 0x79, 0x08, 0x07, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x6f, 0x72, 0x17, 0x80, // SignatureValue 0x2f, 0xd6, 0xf1, 0x6e, 0x80, 0x6f, 0x10, 0xbe, 0xb1, 0x6f, 0x3e, 0x31, 0xec, 0xe3, 0xb9, 0xea, 0x83, 0x30, 0x40, 0x03, 0xfc, 0xa0, 0x13, 0xd9, 0xb3, 0xc6, 0x25, 0x16, 0x2d, 0xa6, 0x58, 0x41, 0x69, 0x62, 0x56, 0xd8, 0xb3, 0x6a, 0x38, 0x76, 0x56, 0xea, 0x61, 0xb2, 0x32, 0x70, 0x1c, 0xb6, 0x4d, 0x10, 0x1d, 0xdc, 0x92, 0x8e, 0x52, 0xa5, 0x8a, 0x1d, 0xd9, 0x96, 0x5e, 0xc0, 0x62, 0x0b, 0xcf, 0x3a, 0x9d, 0x7f, 0xca, 0xbe, 0xa1, 0x41, 0x71, 0x85, 0x7a, 0x8b, 0x5d, 0xa9, 0x64, 0xd6, 0x66, 0xb4, 0xe9, 0x8d, 0x0c, 0x28, 0x43, 0xee, 0xa6, 0x64, 0xe8, 0x55, 0xf6, 0x1c, 0x19, 0x0b, 0xef, 0x99, 0x25, 0x1e, 0xdc, 0x78, 0xb3, 0xa7, 0xaa, 0x0d, 0x14, 0x58, 0x30, 0xe5, 0x37, 0x6a, 0x6d, 0xdb, 0x56, 0xac, 0xa3, 0xfc, 0x90, 0x7a, 0xb8, 0x66, 0x9c, 0x0e, 0xf6, 0xb7, 0x64, 0xd1, 0x20, 0x01, // SelectedDelegation 0x00 }); private static final ByteBuffer LINK = toBuffer(new int[] { 0x06, 0xda, // Data 0x07, 0x14, // Name 0x08, 0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x08, 0x03, 0x6e, 0x64, 0x6e, 0x08, 0x06, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x14, 0x07, // MetaInfo 0x18, 0x01, // ContentType 0x01, 0x19, 0x02, // FreshnessPeriod 0x27, 0x10, 0x15, 0x1a, // Content 0x1f, 0x0c, // LinkDelegation 0x1e, 0x01, // LinkPreference 0x0a, 0x07, 0x07, // Name 0x08, 0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x1f, 0x0a, // LinkDelegation 0x1e, 0x01, // LinkPreference 0x14, 0x07, 0x05, // Name 0x08, 0x03, 0x6e, 0x64, 0x6e, 0x16, 0x1b, // SignatureInfo 0x1b, 0x01, // SignatureType 0x01, 0x1c, 0x16, // KeyLocator 0x07, 0x14, // Name 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x03, 0x6b, 0x65, 0x79, 0x08, 0x07, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x6f, 0x72, 0x17, 0x80, // SignatureValue 0x2f, 0xd6, 0xf1, 0x6e, 0x80, 0x6f, 0x10, 0xbe, 0xb1, 0x6f, 0x3e, 0x31, 0xec, 0xe3, 0xb9, 0xea, 0x83, 0x30, 0x40, 0x03, 0xfc, 0xa0, 0x13, 0xd9, 0xb3, 0xc6, 0x25, 0x16, 0x2d, 0xa6, 0x58, 0x41, 0x69, 0x62, 0x56, 0xd8, 0xb3, 0x6a, 0x38, 0x76, 0x56, 0xea, 0x61, 0xb2, 0x32, 0x70, 0x1c, 0xb6, 0x4d, 0x10, 0x1d, 0xdc, 0x92, 0x8e, 0x52, 0xa5, 0x8a, 0x1d, 0xd9, 0x96, 0x5e, 0xc0, 0x62, 0x0b, 0xcf, 0x3a, 0x9d, 0x7f, 0xca, 0xbe, 0xa1, 0x41, 0x71, 0x85, 0x7a, 0x8b, 0x5d, 0xa9, 0x64, 0xd6, 0x66, 0xb4, 0xe9, 0x8d, 0x0c, 0x28, 0x43, 0xee, 0xa6, 0x64, 0xe8, 0x55, 0xf6, 0x1c, 0x19, 0x0b, 0xef, 0x99, 0x25, 0x1e, 0xdc, 0x78, 0xb3, 0xa7, 0xaa, 0x0d, 0x14, 0x58, 0x30, 0xe5, 0x37, 0x6a, 0x6d, 0xdb, 0x56, 0xac, 0xa3, 0xfc, 0x90, 0x7a, 0xb8, 0x66, 0x9c, 0x0e, 0xf6, 0xb7, 0x64, 0xd1 }); private static final ByteBuffer InterestWithLinkMissingContentType = toBuffer(new int[] { 0x05, 0xf8, // Interest 0x07, 0x14, // Name 0x08, 0x5, // NameComponent 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x08, 0x3, // NameComponent 0x6e, 0x64, 0x6e, 0x08, 0x6, // NameComponent 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x0a, 0x4, // Nonce 0x1, 0x0, 0x0, 0x00, 0x06, 0xd7, // Data 0x07, 0x14, // Name 0x08, 0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x08, 0x03, 0x6e, 0x64, 0x6e, 0x08, 0x06, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x14, 0x04, // MetaInfo 0x19, 0x02, // FreshnessPeriod 0x27, 0x10, 0x15, 0x1a, // Content 0x1f, 0x0c, // LinkDelegation 0x1e, 0x01, // LinkPreference 0x0a, 0x07, 0x07, // Name 0x08, 0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x1f, 0x0a, // LinkDelegation 0x1e, 0x01, // LinkPreference 0x14, 0x07, 0x05, // Name 0x08, 0x03, 0x6e, 0x64, 0x6e, 0x16, 0x1b, // SignatureInfo 0x1b, 0x01, // SignatureType 0x01, 0x1c, 0x16, // KeyLocator 0x07, 0x14, // Name 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x03, 0x6b, 0x65, 0x79, 0x08, 0x07, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x6f, 0x72, 0x17, 0x80, // SignatureValue 0x2f, 0xd6, 0xf1, 0x6e, 0x80, 0x6f, 0x10, 0xbe, 0xb1, 0x6f, 0x3e, 0x31, 0xec, 0xe3, 0xb9, 0xea, 0x83, 0x30, 0x40, 0x03, 0xfc, 0xa0, 0x13, 0xd9, 0xb3, 0xc6, 0x25, 0x16, 0x2d, 0xa6, 0x58, 0x41, 0x69, 0x62, 0x56, 0xd8, 0xb3, 0x6a, 0x38, 0x76, 0x56, 0xea, 0x61, 0xb2, 0x32, 0x70, 0x1c, 0xb6, 0x4d, 0x10, 0x1d, 0xdc, 0x92, 0x8e, 0x52, 0xa5, 0x8a, 0x1d, 0xd9, 0x96, 0x5e, 0xc0, 0x62, 0x0b, 0xcf, 0x3a, 0x9d, 0x7f, 0xca, 0xbe, 0xa1, 0x41, 0x71, 0x85, 0x7a, 0x8b, 0x5d, 0xa9, 0x64, 0xd6, 0x66, 0xb4, 0xe9, 0x8d, 0x0c, 0x28, 0x43, 0xee, 0xa6, 0x64, 0xe8, 0x55, 0xf6, 0x1c, 0x19, 0x0b, 0xef, 0x99, 0x25, 0x1e, 0xdc, 0x78, 0xb3, 0xa7, 0xaa, 0x0d, 0x14, 0x58, 0x30, 0xe5, 0x37, 0x6a, 0x6d, 0xdb, 0x56, 0xac, 0xa3, 0xfc, 0x90, 0x7a, 0xb8, 0x66, 0x9c, 0x0e, 0xf6, 0xb7, 0x64, 0xd1, 0x20, 0x01, // SelectedDelegation 0x00 }); private static final ByteBuffer InterestWithLinkNoMetaInfo = toBuffer(new int[] { 0x05, 0xf2, // Interest 0x07, 0x14, // Name 0x08, 0x5, // NameComponent 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x08, 0x3, // NameComponent 0x6e, 0x64, 0x6e, 0x08, 0x6, // NameComponent 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x0a, 0x4, // Nonce 0x1, 0x0, 0x0, 0x00, 0x06, 0xd1, // Data 0x07, 0x14, // Name 0x08, 0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x08, 0x03, 0x6e, 0x64, 0x6e, 0x08, 0x06, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x15, 0x1a, // Content 0x1f, 0x0c, // LinkDelegation 0x1e, 0x01, // LinkPreference 0x0a, 0x07, 0x07, // Name 0x08, 0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x1f, 0x0a, // LinkPreference 0x1e, 0x01, // LinkPreference 0x14, 0x07, 0x05, // Name 0x08, 0x03, 0x6e, 0x64, 0x6e, 0x16, 0x1b, // SignatureInfo 0x1b, 0x01, // SignatureType 0x01, 0x1c, 0x16, // KeyLocator 0x07, 0x14, // Name 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x03, 0x6b, 0x65, 0x79, 0x08, 0x07, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x6f, 0x72, 0x17, 0x80, // SignatureValue 0x2f, 0xd6, 0xf1, 0x6e, 0x80, 0x6f, 0x10, 0xbe, 0xb1, 0x6f, 0x3e, 0x31, 0xec, 0xe3, 0xb9, 0xea, 0x83, 0x30, 0x40, 0x03, 0xfc, 0xa0, 0x13, 0xd9, 0xb3, 0xc6, 0x25, 0x16, 0x2d, 0xa6, 0x58, 0x41, 0x69, 0x62, 0x56, 0xd8, 0xb3, 0x6a, 0x38, 0x76, 0x56, 0xea, 0x61, 0xb2, 0x32, 0x70, 0x1c, 0xb6, 0x4d, 0x10, 0x1d, 0xdc, 0x92, 0x8e, 0x52, 0xa5, 0x8a, 0x1d, 0xd9, 0x96, 0x5e, 0xc0, 0x62, 0x0b, 0xcf, 0x3a, 0x9d, 0x7f, 0xca, 0xbe, 0xa1, 0x41, 0x71, 0x85, 0x7a, 0x8b, 0x5d, 0xa9, 0x64, 0xd6, 0x66, 0xb4, 0xe9, 0x8d, 0x0c, 0x28, 0x43, 0xee, 0xa6, 0x64, 0xe8, 0x55, 0xf6, 0x1c, 0x19, 0x0b, 0xef, 0x99, 0x25, 0x1e, 0xdc, 0x78, 0xb3, 0xa7, 0xaa, 0x0d, 0x14, 0x58, 0x30, 0xe5, 0x37, 0x6a, 0x6d, 0xdb, 0x56, 0xac, 0xa3, 0xfc, 0x90, 0x7a, 0xb8, 0x66, 0x9c, 0x0e, 0xf6, 0xb7, 0x64, 0xd1, 0x20, 0x01, // SelectedDelegation 0x00 }); private static final ByteBuffer InterestWithLinkWrongContentType = toBuffer(new int[] { 0x05, 0xfb, // Interest 0x07, 0x14, // Name 0x08, 0x5, // NameComponent 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x08, 0x3, // NameComponent 0x6e, 0x64, 0x6e, 0x08, 0x6, // NameComponent 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x0a, 0x4, // Nonce 0x1, 0x0, 0x0, 0x00, 0x06, 0xda, // Data 0x07, 0x14, // Name 0x08, 0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x08, 0x03, 0x6e, 0x64, 0x6e, 0x08, 0x06, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x14, 0x07, // MetaInfo 0x18, 0x01, // ContentType 0x00, 0x19, 0x02, // FreshnessPeriod 0x27, 0x10, 0x15, 0x1a, // Content 0x1f, 0x0c, // LinkDelegation 0x1e, 0x01, // LinkPreference 0x0a, 0x07, 0x07, // Name 0x08, 0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x1f, 0x0a, // LinkDelegation 0x1e, 0x01, // LinkPreference 0x14, 0x07, 0x05, // Name 0x08, 0x03, 0x6e, 0x64, 0x6e, 0x16, 0x1b, // SignatureInfo 0x1b, 0x01, // SignatureType 0x01, 0x1c, 0x16, // KeyLocator 0x07, 0x14, // Name 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x03, 0x6b, 0x65, 0x79, 0x08, 0x07, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x6f, 0x72, 0x17, 0x80, // SignatureValue 0x2f, 0xd6, 0xf1, 0x6e, 0x80, 0x6f, 0x10, 0xbe, 0xb1, 0x6f, 0x3e, 0x31, 0xec, 0xe3, 0xb9, 0xea, 0x83, 0x30, 0x40, 0x03, 0xfc, 0xa0, 0x13, 0xd9, 0xb3, 0xc6, 0x25, 0x16, 0x2d, 0xa6, 0x58, 0x41, 0x69, 0x62, 0x56, 0xd8, 0xb3, 0x6a, 0x38, 0x76, 0x56, 0xea, 0x61, 0xb2, 0x32, 0x70, 0x1c, 0xb6, 0x4d, 0x10, 0x1d, 0xdc, 0x92, 0x8e, 0x52, 0xa5, 0x8a, 0x1d, 0xd9, 0x96, 0x5e, 0xc0, 0x62, 0x0b, 0xcf, 0x3a, 0x9d, 0x7f, 0xca, 0xbe, 0xa1, 0x41, 0x71, 0x85, 0x7a, 0x8b, 0x5d, 0xa9, 0x64, 0xd6, 0x66, 0xb4, 0xe9, 0x8d, 0x0c, 0x28, 0x43, 0xee, 0xa6, 0x64, 0xe8, 0x55, 0xf6, 0x1c, 0x19, 0x0b, 0xef, 0x99, 0x25, 0x1e, 0xdc, 0x78, 0xb3, 0xa7, 0xaa, 0x0d, 0x14, 0x58, 0x30, 0xe5, 0x37, 0x6a, 0x6d, 0xdb, 0x56, 0xac, 0xa3, 0xfc, 0x90, 0x7a, 0xb8, 0x66, 0x9c, 0x0e, 0xf6, 0xb7, 0x64, 0xd1, 0x20, 0x01, // SelectedDelegation 0x00 }); private static final ByteBuffer InterestWithSelectedDelegationButNoLink = toBuffer(new int[] { 0x05, 0x1f, // Interest 0x07, 0x14, // Name 0x08, 0x5, // NameComponent 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x08, 0x3, // NameComponent 0x6e, 0x64, 0x6e, 0x08, 0x6, // NameComponent 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x0a, 0x4, // Nonce 0x1, 0x0, 0x0, 0x00, 0x20, 0x01, // SelectedDelegation 0x00 }); private static final ByteBuffer InterestWithLinkNotNonIntegerSelectedDelegation = toBuffer(new int[] { 0x05, 0xfb, // Interest 0x07, 0x14, // Name 0x08, 0x5, // NameComponent 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x08, 0x3, // NameComponent 0x6e, 0x64, 0x6e, 0x08, 0x6, // NameComponent 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x0a, 0x4, // Nonce 0x1, 0x0, 0x0, 0x00, 0x06, 0xda, // Data 0x07, 0x14, // Name 0x08, 0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x08, 0x03, 0x6e, 0x64, 0x6e, 0x08, 0x06, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x14, 0x07, // MetaInfo 0x18, 0x01, // ContentType 0x01, 0x19, 0x02, // FreshnessPeriod 0x27, 0x10, 0x15, 0x1a, // Content 0x1f, 0x0c, // LinkDelegation 0x1e, 0x01, // LinkPreference 0x0a, 0x07, 0x07, // Name 0x08, 0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x1f, 0x0a, // LinkDelegation 0x1e, 0x01, // LinkPreference 0x14, 0x07, 0x05, // Name 0x08, 0x03, 0x6e, 0x64, 0x6e, 0x16, 0x1b, // SignatureInfo 0x1b, 0x01, // SignatureType 0x01, 0x1c, 0x16, // KeyLocator 0x07, 0x14, // Name 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x03, 0x6b, 0x65, 0x79, 0x08, 0x07, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x6f, 0x72, 0x17, 0x78, // SignatureValue 0x2f, 0xd6, 0xf1, 0x6e, 0x80, 0x6f, 0x10, 0xbe, 0xb1, 0x6f, 0x3e, 0x31, 0xec, 0xe3, 0xb9, 0xea, 0x83, 0x30, 0x40, 0x03, 0xfc, 0xa0, 0x13, 0xd9, 0xb3, 0xc6, 0x25, 0x16, 0x2d, 0xa6, 0x58, 0x41, 0x69, 0x62, 0x56, 0xd8, 0xb3, 0x6a, 0x38, 0x76, 0x56, 0xea, 0x61, 0xb2, 0x32, 0x70, 0x1c, 0xb6, 0x4d, 0x10, 0x1d, 0xdc, 0x92, 0x8e, 0x52, 0xa5, 0x8a, 0x1d, 0xd9, 0x96, 0x5e, 0xc0, 0x62, 0x0b, 0xcf, 0x3a, 0x9d, 0x7f, 0xca, 0xbe, 0xa1, 0x41, 0x71, 0x85, 0x7a, 0x8b, 0x5d, 0xa9, 0x64, 0xd6, 0x66, 0xb4, 0xe9, 0x8d, 0x0c, 0x28, 0x43, 0xee, 0xa6, 0x64, 0xe8, 0x55, 0xf6, 0x1c, 0x19, 0x0b, 0xef, 0x99, 0x25, 0x1e, 0xdc, 0x78, 0xb3, 0xa7, 0xaa, 0x0d, 0x14, 0x58, 0x30, 0xe5, 0x37, 0x6a, 0x6d, 0xdb, 0x56, 0xac, 0xa3, 0xfc, 0x90, 0x7a, 0xb8, 0x66, 0x9c, 0x0e, 0xf6, 0xb7, 0x20, 0x03, // SelectedDelegation 0xAA, 0xAA, 0xAA }); private static final ByteBuffer InterestWithLinkNonDecreasingOrder = toBuffer(new int[] { 0x05, 0xfb, // Interest 0x07, 0x14, // Name 0x08, 0x5, // NameComponent 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x08, 0x3, // NameComponent 0x6e, 0x64, 0x6e, 0x08, 0x6, // NameComponent 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x0a, 0x4, // Nonce 0x1, 0x0, 0x0, 0x00, 0x06, 0xda, // Data 0x07, 0x14, // Name 0x08, 0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x08, 0x03, 0x6e, 0x64, 0x6e, 0x08, 0x06, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x14, 0x07, // MetaInfo 0x18, 0x01, // ContentType 0x01, 0x19, 0x02, // FreshnessPeriod 0x27, 0x10, 0x15, 0x1a, // Content 0x1f, 0x0c, // LinkDelegation 0x1e, 0x01, // LinkPreference 0x14, 0x07, 0x07, // Name 0x08, 0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x1f, 0x0a, // LinkDelegation 0x1e, 0x01, // LinkPreference 0x0a, 0x07, 0x05, // Name 0x08, 0x03, 0x6e, 0x64, 0x6e, 0x16, 0x1b, // SignatureInfo 0x1b, 0x01, // SignatureType 0x01, 0x1c, 0x16, // KeyLocator 0x07, 0x14, // Name 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x03, 0x6b, 0x65, 0x79, 0x08, 0x07, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x6f, 0x72, 0x17, 0x80, // SignatureValue 0x2f, 0xd6, 0xf1, 0x6e, 0x80, 0x6f, 0x10, 0xbe, 0xb1, 0x6f, 0x3e, 0x31, 0xec, 0xe3, 0xb9, 0xea, 0x83, 0x30, 0x40, 0x03, 0xfc, 0xa0, 0x13, 0xd9, 0xb3, 0xc6, 0x25, 0x16, 0x2d, 0xa6, 0x58, 0x41, 0x69, 0x62, 0x56, 0xd8, 0xb3, 0x6a, 0x38, 0x76, 0x56, 0xea, 0x61, 0xb2, 0x32, 0x70, 0x1c, 0xb6, 0x4d, 0x10, 0x1d, 0xdc, 0x92, 0x8e, 0x52, 0xa5, 0x8a, 0x1d, 0xd9, 0x96, 0x5e, 0xc0, 0x62, 0x0b, 0xcf, 0x3a, 0x9d, 0x7f, 0xca, 0xbe, 0xa1, 0x41, 0x71, 0x85, 0x7a, 0x8b, 0x5d, 0xa9, 0x64, 0xd6, 0x66, 0xb4, 0xe9, 0x8d, 0x0c, 0x28, 0x43, 0xee, 0xa6, 0x64, 0xe8, 0x55, 0xf6, 0x1c, 0x19, 0x0b, 0xef, 0x99, 0x25, 0x1e, 0xdc, 0x78, 0xb3, 0xa7, 0xaa, 0x0d, 0x14, 0x58, 0x30, 0xe5, 0x37, 0x6a, 0x6d, 0xdb, 0x56, 0xac, 0xa3, 0xfc, 0x90, 0x7a, 0xb8, 0x66, 0x9c, 0x0e, 0xf6, 0xb7, 0x64, 0xd1, 0x20, 0x01, // SelectedDelegation 0x01 }); private static final ByteBuffer DEFAULT_RSA_PUBLIC_KEY_DER = toBuffer(new int[] { 0x30, 0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xd4, 0x4f, 0xd9, 0xae, 0x7a, 0xd2, 0x87, 0x80, 0x67, 0x11, 0x31, 0xb8, 0x5b, 0xac, 0x8b, 0x5f, 0xf2, 0x21, 0x28, 0x2c, 0x70, 0xec, 0x66, 0xe9, 0x18, 0xee, 0x5e, 0xf1, 0xe3, 0xef, 0x09, 0xcb, 0x5e, 0xe0, 0xcd, 0xe4, 0x39, 0x6a, 0x3f, 0x43, 0x2a, 0x3e, 0x1a, 0x06, 0xf2, 0xcc, 0xb0, 0x0f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e, 0xa9, 0x39, 0x49, 0xdc, 0xa5, 0x4e, 0x7d, 0x3b, 0xc9, 0xbf, 0x18, 0x41, 0x5e, 0xc0, 0x55, 0x4f, 0x90, 0x66, 0xfb, 0x19, 0xc8, 0x4b, 0x11, 0x93, 0xff, 0x02, 0x03, 0x01, 0x00, 0x01 }); // Java uses an unencrypted PKCS #8 PrivateKeyInfo, not a PKCS #1 RSAPrivateKey. private static final ByteBuffer DEFAULT_RSA_PRIVATE_KEY_DER = toBuffer(new int[] { 0x30, 0x82, 0x04, 0xbe, 0x02, 0x01, 0x00, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x04, 0x82, 0x04, 0xa8, 0x30, 0x82, 0x04, 0xa4, 0x02, 0x01, 0x00, 0x02, 0x82, 0x01, 0x01, 0x00, 0xd4, 0x4f, 0xd9, 0xae, 0x7a, 0xd2, 0x87, 0x80, 0x67, 0x11, 0x31, 0xb8, 0x5b, 0xac, 0x8b, 0x5f, 0xf2, 0x21, 0x28, 0x2c, 0x70, 0xec, 0x66, 0xe9, 0x18, 0xee, 0x5e, 0xf1, 0xe3, 0xef, 0x09, 0xcb, 0x5e, 0xe0, 0xcd, 0xe4, 0x39, 0x6a, 0x3f, 0x43, 0x2a, 0x3e, 0x1a, 0x06, 0xf2, 0xcc, 0xb0, 0x0f, 0x5b, 0xd8, 0xa1, 0x3f, 0x1c, 0xb8, 0xfa, 0x8c, 0xa4, 0xbf, 0xa0, 0x57, 0x61, 0xcb, 0x35, 0xa9, 0x0f, 0x56, 0x76, 0x57, 0x05, 0xa4, 0x56, 0x90, 0x64, 0x3d, 0x0e, 0x6e, 0x24, 0x43, 0x5e, 0x54, 0x02, 0x99, 0x5b, 0xbe, 0x05, 0xab, 0xc9, 0xfb, 0xb7, 0x8f, 0x17, 0xcb, 0x59, 0xc0, 0x42, 0x47, 0x79, 0xb1, 0xb8, 0x5c, 0x97, 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, 0x11, 0x72, 0x6c, 0x8b, 0xf9, 0xf9, 0x35, 0xf6, 0x42, 0x17, 0xf3, 0x95, 0xdf, 0xbd, 0xc9, 0x55, 0x4f, 0x30, 0xba, 0xf8, 0xf6, 0xad, 0xb2, 0xfd, 0xbb, 0x36, 0x42, 0xe9, 0x02, 0x81, 0x81, 0x00, 0xad, 0xf0, 0xc0, 0xfc, 0x55, 0x47, 0x8a, 0x03, 0x2b, 0x5c, 0x1c, 0x6e, 0xef, 0xf6, 0x96, 0x68, 0xee, 0xa8, 0xd0, 0x6d, 0x70, 0x4f, 0x7f, 0x3e, 0x17, 0x2b, 0xfd, 0x7e, 0x22, 0x8c, 0xea, 0x25, 0xe3, 0xbb, 0xa4, 0xa1, 0x57, 0xe7, 0x3e, 0xc0, 0x47, 0xf8, 0x7b, 0xa6, 0xd2, 0x48, 0x68, 0xc0, 0x8a, 0xe0, 0xb2, 0x6b, 0x5d, 0xf9, 0x32, 0x6e, 0x70, 0x5a, 0xb9, 0x77, 0xd9, 0xbf, 0x6d, 0xea, 0x53, 0xe2, 0x4f, 0xa8, 0x4c, 0x1c, 0xfa, 0x69, 0x49, 0x26, 0x48, 0x8a, 0xc5, 0x92, 0x77, 0x6b, 0x7a, 0x89, 0xc3, 0xef, 0x6d, 0x1c, 0x44, 0x10, 0xe6, 0xaf, 0x47, 0x18, 0x9f, 0x99, 0x09, 0xb4, 0x3b, 0x63, 0xf7, 0xbf, 0xe4, 0xe7, 0xe5, 0x98, 0xe2, 0x57, 0x85, 0xbb, 0x78, 0xb5, 0xd1, 0xc3, 0x64, 0x8d, 0x4d, 0x4f, 0x02, 0xdb, 0x2c, 0x51, 0x58, 0xa3, 0xc7, 0x35, 0xf1, 0x2d, 0x7a, 0x0a }); KeyChain keyChain; Name certificateName; @Before public void setUp() { MemoryIdentityStorage identityStorage = new MemoryIdentityStorage(); MemoryPrivateKeyStorage privateKeyStorage = new MemoryPrivateKeyStorage(); keyChain = new KeyChain (new IdentityManager(identityStorage, privateKeyStorage), new SelfVerifyPolicyManager(identityStorage)); // Initialize the storage. Name keyName = new Name("/testname/DSK-123"); certificateName = keyName.getSubName(0, keyName.size() - 1).append ("KEY").append(keyName.get(-1)).append("ID-CERT").append("0"); try { identityStorage.addKey (keyName, KeyType.RSA, new Blob(DEFAULT_RSA_PUBLIC_KEY_DER, false)); privateKeyStorage.setKeyPairForKeyName (keyName, KeyType.RSA, DEFAULT_RSA_PUBLIC_KEY_DER, DEFAULT_RSA_PRIVATE_KEY_DER); } catch (SecurityException ex) { // We don't expect this to happen. Logger.getLogger(TestLink.class.getName()).log(Level.SEVERE, null, ex); } } //////////////////////////////// // Tests from ndn-cxx link.t.cpp //////////////////////////////// @Test public void testInsertDelegation() { Link link = new Link(); link.setName(new Name("test")); link.addDelegation(10, new Name("/test1")); link.addDelegation(20, new Name("/test2")); link.addDelegation(100, new Name("/test3")); link.addDelegation(30, new Name("/test4")); DelegationSet delegations = link.getDelegations(); for (int i = 0; i < delegations.size(); ++i) { if (i == 0) { assertEquals(10, delegations.get(i).getPreference()); assertEquals(new Name("/test1"), delegations.get(i).getName()); } if (i == 1) { assertEquals(20, delegations.get(i).getPreference()); assertEquals(new Name("/test2"), delegations.get(i).getName()); } if (i == 2) { assertEquals(30, delegations.get(i).getPreference()); assertEquals(new Name("/test4"), delegations.get(i).getName()); } if (i == 3) { assertEquals(100, delegations.get(i).getPreference()); assertEquals(new Name("/test3"), delegations.get(i).getName()); } } } @Test public void testRemoveDelegation() { Link link = new Link(); link.setName(new Name("test")); link.addDelegation(10, new Name("/test1")); link.addDelegation(20, new Name("/test2")); link.addDelegation(100, new Name("/test3")); link.removeDelegation(new Name("/test2")); DelegationSet delegations = link.getDelegations(); for (int i = 0; i < delegations.size(); ++i) { if (i == 0) { assertEquals(10, delegations.get(i).getPreference()); assertEquals(new Name("/test1"), delegations.get(i).getName()); } if (i == 1) { assertEquals(100, delegations.get(i).getPreference()); assertEquals(new Name("/test3"), delegations.get(i).getName()); } } } @Test public void testEncodeDecode() { Link link1 = new Link(); link1.setName(new Name("test")); link1.addDelegation(10, new Name("/test1")); link1.addDelegation(20, new Name("/test2")); link1.addDelegation(100, new Name("/test3")); try { keyChain.sign(link1, certificateName); } catch (SecurityException ex) { fail(ex.getMessage()); } Blob wireEncoding = link1.wireEncode(); Link link2 = new Link(); try { link2.wireDecode(wireEncoding); } catch (EncodingException ex) { fail(ex.getMessage()); } Name name = link2.getName(); assertEquals(new Name("test"), name); DelegationSet delegations = link2.getDelegations(); for (int i = 0; i < delegations.size(); ++i) { if (i == 0) { assertEquals(10, delegations.get(i).getPreference()); assertEquals(new Name("/test1"), delegations.get(i).getName()); } if (i == 1) { assertEquals(20, delegations.get(i).getPreference()); assertEquals(new Name("/test2"), delegations.get(i).getName()); } if (i == 2) { assertEquals(100, delegations.get(i).getPreference()); assertEquals(new Name("/test3"), delegations.get(i).getName()); } } } @Test public void testDecode() { Link link = new Link(); try { link.wireDecode(new Blob(LinkTest, false)); } catch (EncodingException ex) { fail(ex.getMessage()); } assertEquals(new Name("/local/ndn/prefix"), link.getName()); DelegationSet delegations = link.getDelegations(); for (int i = 0; i < delegations.size(); ++i) { if (i == 0) { assertEquals(10, delegations.get(i).getPreference()); assertEquals(new Name("local"), delegations.get(i).getName()); } if (i == 1) { assertEquals(20, delegations.get(i).getPreference()); assertEquals(new Name("ndn"), delegations.get(i).getName()); } } } @Test public void testIncorrectContentType() { Link link = new Link(); try { link.wireDecode(new Blob(IncorrectContentTypeLink, false)); fail("Expected error decoding IncorrectContentTypeLink"); } catch (EncodingException ex) {} } @Test public void testMissingPreferenceEncoding() { Link link = new Link(); try { link.wireDecode(new Blob(MissingPreferenceLink, false)); fail("Expected error decoding MissingPreferenceLink"); } catch (EncodingException ex) {} } @Test public void testMissingNameEncoding() { Link link = new Link(); try { link.wireDecode(new Blob(MissingNameLink, false)); fail("Expected error decoding MissingNameLink"); } catch (EncodingException ex) {} } //////////////////////////////////// // Tests from ndn-cxx interest.t.cpp //////////////////////////////////// @Test public void testInterestLinkObject() { Link link1 = new Link(); link1.setName(new Name("test")); link1.addDelegation(10, new Name("/test1")); link1.addDelegation(20, new Name("/test2")); link1.addDelegation(100, new Name("/test3")); try { keyChain.sign(link1, certificateName); } catch (SecurityException ex) { fail(ex.getMessage()); } Blob linkEncoding = link1.wireEncode(); Interest interestA = new Interest(); Link link2 = null; try { interestA.setLinkWireEncoding(linkEncoding); link2 = interestA.getLink(); } catch (Exception ex) { fail(ex.getMessage()); } assertTrue(link2 != null); Name name = link2.getName(); assertEquals(new Name("test"), name); DelegationSet delegations = link2.getDelegations(); for (int i = 0; i < delegations.size(); ++i) { if (i == 0) { assertEquals(10, delegations.get(i).getPreference()); assertEquals(new Name("/test1"), delegations.get(i).getName()); } if (i == 1) { assertEquals(20, delegations.get(i).getPreference()); assertEquals(new Name("/test2"), delegations.get(i).getName()); } if (i == 2) { assertEquals(100, delegations.get(i).getPreference()); assertEquals(new Name("/test3"), delegations.get(i).getName()); } } interestA.setLinkWireEncoding(new Blob(LINK, false)); Link link3 = null; try { link3 = interestA.getLink(); } catch (Exception ex) { fail(ex.getMessage()); } assertEquals(2, link3.getDelegations().size()); interestA.unsetLink(); assertEquals(false, interestA.hasLink()); } @Test public void testInterestSelectedDelegation() { Link link = new Link(); link.setName(new Name("test")); link.addDelegation(10, new Name("/test1")); link.addDelegation(20, new Name("/test2")); link.addDelegation(100, new Name("/test3")); try { keyChain.sign(link, certificateName); } catch (SecurityException ex) { fail(ex.getMessage()); } Blob linkEncoding = link.wireEncode(); Interest interestA = new Interest(); interestA.setLinkWireEncoding(linkEncoding); assertTrue(interestA.getSelectedDelegationIndex() < 0); interestA.setSelectedDelegationIndex (link.getDelegations().find(new Name("test2"))); assertTrue(interestA.getSelectedDelegationIndex() >= 0); Link link2 = null; try { link2 = interestA.getLink(); } catch (Exception ex) { fail(ex.getMessage()); } assertEquals (new Name("test2"), link2.getDelegations().get(interestA.getSelectedDelegationIndex()).getName()); interestA.setSelectedDelegationIndex(-1); assertTrue(interestA.getSelectedDelegationIndex() < 0); } @Test public void testEncodeDecodeInterestWithLink() { Link link1 = new Link(); link1.setName(new Name("test")); link1.addDelegation(10, new Name("/test1")); link1.addDelegation(20, new Name("/test2")); link1.addDelegation(100, new Name("/test3")); try { keyChain.sign(link1, certificateName); } catch (SecurityException ex) { fail(ex.getMessage()); } Interest interestA = new Interest(); interestA.setName(new Name("/Test/Encode/Decode/With/Link")); interestA.setChildSelector(1); interestA.setInterestLifetimeMilliseconds(10000); interestA.setLinkWireEncoding(link1.wireEncode()); Blob interestEncoding = interestA.wireEncode(); Interest interestB = new Interest(); try { interestB.wireDecode(interestEncoding); } catch (EncodingException ex) { fail(ex.getMessage()); } assertEquals(interestA.getName(), interestB.getName()); Link link2 = null; try { link2 = interestB.getLink(); } catch (Exception ex) { fail("interestB.getLink(): " + ex.getMessage()); } assertTrue("Interest link object not specified", link2 != null); DelegationSet delegations = link2.getDelegations(); for (int i = 0; i < delegations.size(); ++i) { if (i == 0) { assertEquals(10, delegations.get(i).getPreference()); assertEquals(new Name("/test1"), delegations.get(i).getName()); } if (i == 1) { assertEquals(20, delegations.get(i).getPreference()); assertEquals(new Name("/test2"), delegations.get(i).getName()); } if (i == 2) { assertEquals(100, delegations.get(i).getPreference()); assertEquals(new Name("/test3"), delegations.get(i).getName()); } } } @Test public void testDecodeInterestWithLink() { Interest interest = new Interest(); Link link = null; try { interest.wireDecode(new Blob(InterestWithLink, false)); link = interest.getLink(); } catch (Exception ex) { fail("Decoding InterestWithLink: " + ex.getMessage()); } assertTrue("Interest link object not specified", link != null); assertEquals(new Name("/local/ndn/prefix"), link.getName()); DelegationSet delegations = link.getDelegations(); for (int i = 0; i < delegations.size(); ++i) { if (i == 0) { assertEquals(10, delegations.get(i).getPreference()); assertEquals(new Name("local"), delegations.get(i).getName()); } if (i == 1) { assertEquals(20, delegations.get(i).getPreference()); assertEquals(new Name("ndn"), delegations.get(i).getName()); } } assertTrue("Interest selected delegation not specified", interest.getSelectedDelegationIndex() >= 0); assertEquals (new Name("local"), delegations.get(interest.getSelectedDelegationIndex()).getName()); } @Test public void testDecodeInterestWithLinkNonDecreasingOrder() { Interest interest = new Interest(); Link link = null; try { interest.wireDecode(new Blob(InterestWithLinkNonDecreasingOrder, false)); link = interest.getLink(); } catch (Exception ex) { fail("Decoding InterestWithLinkNonDecreasingOrder: " + ex.getMessage()); } assertTrue(interest.getSelectedDelegationIndex() >= 0); assertEquals (new Name("ndn"), link.getDelegations().get(interest.getSelectedDelegationIndex()).getName()); } @Test public void testInterestLinkObjectMissingContentType() { Interest interest = new Interest(); try { interest.wireDecode(new Blob(InterestWithLinkMissingContentType, false)); } catch (Exception ex) { fail("Decoding InterestWithLinkMissingContentType: " + ex.getMessage()); } try { interest.getLink(); fail("Expected error decoding a link with missing content type"); } catch (Exception ex) {} } @Test public void testInterestLinkObjectNoMetaInfo() { Interest interest = new Interest(); try { interest.wireDecode(new Blob(InterestWithLinkNoMetaInfo, false)); } catch (Exception ex) { fail("Decoding InterestWithLinkNoMetaInfo: " + ex.getMessage()); } try { interest.getLink(); fail("Expected error decoding a link with no meta info"); } catch (Exception ex) {} } @Test public void testInterestLinkObjectWrongContentType() { Interest interest = new Interest(); try { interest.wireDecode(new Blob(InterestWithLinkWrongContentType, false)); } catch (Exception ex) { fail("Decoding InterestWithLinkWrongContentType: " + ex.getMessage()); } try { interest.getLink(); fail("Expected error decoding a link with the wrong content type"); } catch (Exception ex) {} } @Test public void testInterestContainingSelectedDelegationButNoLink() { Interest interest = new Interest(); try { interest.wireDecode(new Blob(InterestWithSelectedDelegationButNoLink, false)); fail("Expected error decoding an interest with a selected delegation but no link"); } catch (Exception ex) {} } @Test public void testSelectedDelegationIsNotNonNegativeInteger() { Interest interest = new Interest(); try { interest.wireDecode(new Blob(InterestWithLinkNotNonIntegerSelectedDelegation, false)); fail("Expected error decoding an interest with selected delegation not a non-negative integer"); } catch (Exception ex) {} } }