use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkey in project lispflowmapping by opendaylight.
the class LispSouthboundPlugin method restoreDaoFromDatastore.
/**
* Restore all keys from MDSAL datastore.
*/
public void restoreDaoFromDatastore() {
final List<AuthenticationKey> authKeys = dsbe.getAllAuthenticationKeys();
LOG.info("Restoring {} keys from datastore into southbound DAO", authKeys.size());
for (AuthenticationKey authKey : authKeys) {
final Eid key = authKey.getEid();
final MappingAuthkey mappingAuthkey = authKey.getMappingAuthkey();
LOG.debug("Adding authentication key '{}' with key-ID {} for {}", mappingAuthkey.getKeyString(), mappingAuthkey.getKeyType(), LispAddressStringifier.getString(key));
akdb.addAuthenticationKey(key, mappingAuthkey);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkey in project lispflowmapping by opendaylight.
the class SubnetDataProcessorTest method createTest.
/**
* Tests {@link SubnetDataProcessor#create} method.
*/
@Test
public void createTest() throws ExecutionException, InterruptedException {
final MappingAuthkey mappingAuthkey = new MappingAuthkeyBuilder().setKeyString(UUID_STRING).setKeyType(1).build();
final AddKeyInput addKeyInput = new AddKeyInputBuilder().setEid(EID).setMappingAuthkey(mappingAuthkey).build();
commonStubbing();
Mockito.when(odlMappingserviceServiceMock.addKey(addKeyInput)).thenReturn(future);
subnetDataProcessor.create(subnet);
assertEquals(true, rpcResult.isSuccessful());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkey in project lispflowmapping by opendaylight.
the class MappingSystemTest method restoreDaoFromDatastoreTest.
/**
* Tests {@link MappingSystem#restoreDaoFromDatastore} method.
*/
@Test
public void restoreDaoFromDatastoreTest() {
final Mapping mapping_1 = new MappingBuilder().setOrigin(MappingOrigin.Northbound).setMappingRecord(getDefaultMappingRecordBuilder().setEid(EID_IPV4_1).build()).build();
final Mapping mapping_2 = new MappingBuilder().setOrigin(MappingOrigin.Northbound).setMappingRecord(getDefaultMappingRecordBuilder().setEid(EID_IPV4_2).build()).build();
final MappingAuthkey mappingAuthkey_1 = MAPPING_AUTHKEY_BUILDER.build();
final AuthenticationKey authenticationKey_1 = new AuthenticationKeyBuilder().setMappingAuthkey(mappingAuthkey_1).setEid(EID_IPV4_1).build();
final MappingAuthkey mappingAuthkey_2 = MAPPING_AUTHKEY_BUILDER.setKeyString("pass-2").build();
final AuthenticationKey authenticationKey_2 = new AuthenticationKeyBuilder().setMappingAuthkey(mappingAuthkey_2).setEid(EID_IPV4_2).build();
final List<Mapping> mappings = Lists.newArrayList(mapping_1, mapping_2);
final List<AuthenticationKey> authenticationKeys = Lists.newArrayList(authenticationKey_1, authenticationKey_2);
Mockito.when(dsbeMock.getLastUpdateTimestamp()).thenReturn(System.currentTimeMillis());
Mockito.when(dsbeMock.getAllMappings(LogicalDatastoreType.CONFIGURATION)).thenReturn(mappings);
Mockito.when(dsbeMock.getAllAuthenticationKeys()).thenReturn(authenticationKeys);
Mockito.when(tableMapMock.get(MappingOrigin.Northbound)).thenReturn(pmcMock);
mappingSystem.initialize();
ArgumentCaptor<MappingData> captor = ArgumentCaptor.forClass(MappingData.class);
Mockito.verify(pmcMock).addMapping(Mockito.eq(EID_IPV4_1), captor.capture());
assertEquals(captor.getValue().getRecord(), mapping_1.getMappingRecord());
Mockito.verify(pmcMock).addMapping(Mockito.eq(EID_IPV4_2), captor.capture());
assertEquals(captor.getValue().getRecord(), mapping_2.getMappingRecord());
Mockito.verify(akdbMock).addAuthenticationKey(EID_IPV4_1, mappingAuthkey_1);
Mockito.verify(akdbMock).addAuthenticationKey(EID_IPV4_2, mappingAuthkey_2);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkey in project lispflowmapping by opendaylight.
the class MappingServiceTest method updateKeyTest_withNullMapAuthkey.
/**
* Tests {@link MappingService#updateKey} method with null MappingAuthkey.
*/
@Test
public void updateKeyTest_withNullMapAuthkey() throws ExecutionException, InterruptedException {
final UpdateKeyInput updateKeyInput = new UpdateKeyInputBuilder().setEid(IPV4_EID).build();
Mockito.when(mappingSystem.getAuthenticationKey(IPV4_EID)).thenReturn(null);
// input
final RpcResult<Object> rpc = RpcResultBuilder.failed().withError(RpcError.ErrorType.PROTOCOL, "data-missing", "Key doesn't exist! Please use add-key if you want to create a new authentication key.").build();
final RpcError error = rpc.getErrors().iterator().next();
// result
final Future<RpcResult<Void>> result = mappingService.updateKey(updateKeyInput);
final RpcError errorResult = result.get().getErrors().iterator().next();
assertEquals(1, result.get().getErrors().size());
assertEquals(error.getMessage(), errorResult.getMessage());
assertEquals(error.getApplicationTag(), errorResult.getApplicationTag());
assertEquals(error.getCause(), errorResult.getCause());
assertEquals(error.getErrorType(), errorResult.getErrorType());
assertEquals(error.getInfo(), errorResult.getInfo());
assertEquals(error.getTag(), errorResult.getTag());
assertEquals(error.getSeverity(), errorResult.getSeverity());
assertEquals(rpc.getResult(), result.get().getResult());
assertEquals(rpc.isSuccessful(), result.get().isSuccessful());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkey in project lispflowmapping by opendaylight.
the class MappingServiceTest method getKeyTest_withNullMappingAuthkey.
/**
* Tests {@link MappingService#getKey} method with null MappingAuthkey.
*/
@Test
public void getKeyTest_withNullMappingAuthkey() throws ExecutionException, InterruptedException {
// input
final GetKeyInput getKeyInput = new GetKeyInputBuilder().setEid(IPV4_EID).build();
Mockito.when(mappingSystem.getAuthenticationKey(getKeyInput.getEid())).thenReturn(null);
final RpcResult<Object> rpc = RpcResultBuilder.failed().withError(RpcError.ErrorType.APPLICATION, "data-missing", "Key was not found in the mapping database").build();
final RpcError error = rpc.getErrors().iterator().next();
// result
final Future<RpcResult<GetKeyOutput>> result = mappingService.getKey(getKeyInput);
final RpcError errorResult = result.get().getErrors().iterator().next();
assertEquals(1, result.get().getErrors().size());
assertEquals(error.getMessage(), errorResult.getMessage());
assertEquals(error.getApplicationTag(), errorResult.getApplicationTag());
assertEquals(error.getCause(), errorResult.getCause());
assertEquals(error.getErrorType(), errorResult.getErrorType());
assertEquals(error.getInfo(), errorResult.getInfo());
assertEquals(error.getTag(), errorResult.getTag());
assertEquals(error.getSeverity(), errorResult.getSeverity());
assertEquals(rpc.getResult(), result.get().getResult());
assertEquals(rpc.isSuccessful(), result.get().isSuccessful());
}
Aggregations