import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.mdsal.it.base.AbstractMdsalTestBase;
import org.opendaylight.lispflowmapping.implementation.LispMappingService;
import org.opendaylight.lispflowmapping.interfaces.lisp.IFlowMapping;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.maprequestnotification.MapRequestBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.Rloc;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.rloc.container.RlocBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.EidUri;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingDatabase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.VniUri;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKeyBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKeyKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.mapping.authkey.container.MappingAuthkey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.mapping.authkey.container.MappingAuthkeyBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.explicit.locator.path.explicit.locator.path.HopBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.source.dest.key.SourceDestKeyBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.mapping.database.VirtualNetworkIdentifier;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.mapping.database.VirtualNetworkIdentifierKey;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.PaxExam;
import org.ops4j.pax.exam.util.Filter;
public void mapRegisterWithMapNotify() throws SocketTimeoutException {
cleanUP();
- insertAuthDataToDataStore(LispAddressUtil.asIpv4PrefixBinaryEid("153.16.254.1/32"),
- NULL_AUTH_KEY);
- sleepForSeconds(1);
+ mapService.addAuthenticationKey(LispAddressUtil.asIpv4PrefixBinaryEid("153.16.254.1/32"), NULL_AUTH_KEY);
+
+ sleepForSeconds(2);
sendPacket(mapRegisterPacketWithNotify);
MapNotify reply = receiveMapNotify();
assertEquals(7, reply.getNonce().longValue());
}
- private void insertAuthDataToDataStore(final Eid eid, final MappingAuthkey authKey) {
- final DataBroker dataBroker = getSession().getSALService(DataBroker.class);
- final WriteTransaction wTx = dataBroker.newWriteOnlyTransaction();
- final EidUri eidUri = new EidUri("eidUri");
- final InstanceIdentifier<AuthenticationKey> iiToAuthenticationKey = InstanceIdentifier.create
- (MappingDatabase.class).child(VirtualNetworkIdentifier.class, new VirtualNetworkIdentifierKey(new
- VniUri("0"))).child(AuthenticationKey.class, new AuthenticationKeyKey(eidUri));
- final AuthenticationKey data = new AuthenticationKeyBuilder().setMappingAuthkey(authKey).setEid(eid).
- setEidUri(eidUri).build();
- wTx.put(LogicalDatastoreType.CONFIGURATION, iiToAuthenticationKey, data, true);
- wTx.submit();
- }
-
public void mapRegisterWithMapNotifyAndMapRequest() throws SocketTimeoutException {
cleanUP();
Eid eid = LispAddressUtil.asIpv4PrefixBinaryEid("1.2.3.4/32");
import java.util.List;
import java.util.Set;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
setConfigIniMappingMergeField(false);
}
- @Ignore /* commented due to difference at authentication data*/
@Test
public void handleMapRegisterTest_MappingMergeFalse() throws NoSuchFieldException, IllegalAccessException {
- Mockito.when(mapService.getAuthenticationKey(IPV4_EID_1)).thenReturn(MAPPING_AUTHKEY);
Mockito.when(mapService.getMapping(MappingOrigin.Southbound, IPV4_EID_1)).thenReturn(OLD_MAPPING_RECORD_1);
Mockito.when(mapService.getData(MappingOrigin.Southbound, IPV4_EID_1, SubKeys.SUBSCRIBERS))
.thenReturn(subscriberSetMock_1);
assertEquals(1, subscriberSetMock_1.size());
}
- @Ignore /* commented due to difference at authentication data*/
@Test
public void handleMapRegisterTest_MappingMergeTrue() throws NoSuchFieldException, IllegalAccessException {
setConfigIniMappingMergeField(true);
.setMappingRecordItem(new ArrayList<>());
mapNotifyBuilder.getMappingRecordItem().add(mappingRecordItemBuilder.build());
- Mockito.when(mapService.getAuthenticationKey(IPV4_EID_1)).thenReturn(MAPPING_AUTHKEY);
// no mapping changes
Mockito.when(mapService.getMapping(MappingOrigin.Southbound, IPV4_EID_1))
.thenReturn(OLD_MAPPING_RECORD_1);
Mockito.verify(notifyHandler).handleMapNotify(mapNotifyBuilder.build(), null);
}
- @Ignore /* commented due to difference at authentication data*/
@Test
public void handleMapRegisterTest_verifyTransportAddresses() throws NoSuchFieldException, IllegalAccessException {
setConfigIniMappingMergeField(true);
.setNonce(mapRegister.getNonce())
.setKeyId(mapRegister.getKeyId())
.setMergeEnabled(mapRegister.isMergeEnabled())
- .setMappingRecordItem(new ArrayList<>())
- .setAuthenticationData(new byte[]{});
+ .setMappingRecordItem(new ArrayList<>());
mapNotifyBuilder.getMappingRecordItem().add(getDefaultMappingRecordItemBuilder().build());
return mapNotifyBuilder;