summaryrefslogtreecommitdiffstats
path: root/ipsec/ipsec-impl/src/test/java/io/fd
diff options
context:
space:
mode:
authorMichal Cmarada <mcmarada@cisco.com>2019-02-27 13:17:34 +0100
committerMichal Cmarada <mcmarada@cisco.com>2019-02-28 09:57:45 +0100
commit1b0e8be823737a94e6e3dc0407fdb6734b06ebac (patch)
tree7e474e8a3aa6da795b8ce3c3966eb61089775c22 /ipsec/ipsec-impl/src/test/java/io/fd
parente4c3640eb7a140351cf804c48ff96ab5a650e1e6 (diff)
fix ikev2 implementation in ipsec
Ikev2 was moved from core to plugins, which needed some refactoring to be done in implementation of Ikev2 in ipsec. Change-Id: Icc5d1e2a3e8babe0ceae84d4e12a22ceef6ccb43 Signed-off-by: Michal Cmarada <mcmarada@cisco.com>
Diffstat (limited to 'ipsec/ipsec-impl/src/test/java/io/fd')
-rw-r--r--ipsec/ipsec-impl/src/test/java/io/fd/hc2vpp/ipsec/IpsecModuleTest.java14
-rw-r--r--ipsec/ipsec-impl/src/test/java/io/fd/hc2vpp/ipsec/write/Ikev2GlobalConfigurationCustomizerTest.java14
-rw-r--r--ipsec/ipsec-impl/src/test/java/io/fd/hc2vpp/ipsec/write/Ikev2PolicyCustomizerTest.java42
-rw-r--r--ipsec/ipsec-impl/src/test/java/io/fd/hc2vpp/ipsec/write/Ikev2PolicyIdentityCustomizerTest.java20
4 files changed, 57 insertions, 33 deletions
diff --git a/ipsec/ipsec-impl/src/test/java/io/fd/hc2vpp/ipsec/IpsecModuleTest.java b/ipsec/ipsec-impl/src/test/java/io/fd/hc2vpp/ipsec/IpsecModuleTest.java
index 42817d42a..878edd9ac 100644
--- a/ipsec/ipsec-impl/src/test/java/io/fd/hc2vpp/ipsec/IpsecModuleTest.java
+++ b/ipsec/ipsec-impl/src/test/java/io/fd/hc2vpp/ipsec/IpsecModuleTest.java
@@ -23,10 +23,12 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
import static org.mockito.MockitoAnnotations.initMocks;
import com.google.inject.Guice;
import com.google.inject.Inject;
+import com.google.inject.Provider;
import com.google.inject.testing.fieldbinder.Bind;
import com.google.inject.testing.fieldbinder.BoundFieldModule;
import io.fd.hc2vpp.ipsec.read.IpsecReaderFactory;
@@ -37,6 +39,7 @@ import io.fd.honeycomb.translate.read.ReaderFactory;
import io.fd.honeycomb.translate.util.YangDAG;
import io.fd.honeycomb.translate.write.WriterFactory;
import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import io.fd.vpp.jvpp.ikev2.future.FutureJVppIkev2Facade;
import java.util.HashSet;
import java.util.Set;
import org.junit.Before;
@@ -58,7 +61,8 @@ public class IpsecModuleTest {
@Before
public void setUp() {
initMocks(this);
- Guice.createInjector(new IpsecModule(), BoundFieldModule.of(this)).injectMembers(this);
+ Guice.createInjector(new IpsecModule(MockJVppIkev2Provider.class), BoundFieldModule.of(this))
+ .injectMembers(this);
}
@Test
@@ -80,4 +84,12 @@ public class IpsecModuleTest {
assertEquals(1, readerFactories.size());
assertTrue(readerFactories.iterator().next() instanceof IpsecReaderFactory);
}
+
+ private static final class MockJVppIkev2Provider implements Provider<FutureJVppIkev2Facade> {
+
+ @Override
+ public FutureJVppIkev2Facade get() {
+ return mock(FutureJVppIkev2Facade.class);
+ }
+ }
}
diff --git a/ipsec/ipsec-impl/src/test/java/io/fd/hc2vpp/ipsec/write/Ikev2GlobalConfigurationCustomizerTest.java b/ipsec/ipsec-impl/src/test/java/io/fd/hc2vpp/ipsec/write/Ikev2GlobalConfigurationCustomizerTest.java
index cf9e8b102..84ae9c7d6 100644
--- a/ipsec/ipsec-impl/src/test/java/io/fd/hc2vpp/ipsec/write/Ikev2GlobalConfigurationCustomizerTest.java
+++ b/ipsec/ipsec-impl/src/test/java/io/fd/hc2vpp/ipsec/write/Ikev2GlobalConfigurationCustomizerTest.java
@@ -23,9 +23,11 @@ import static org.mockito.Mockito.when;
import io.fd.hc2vpp.common.test.write.WriterCustomizerTest;
import io.fd.hc2vpp.ipsec.helpers.SchemaContextTestHelper;
import io.fd.honeycomb.translate.write.WriteFailedException;
-import io.fd.vpp.jvpp.core.dto.Ikev2SetLocalKey;
-import io.fd.vpp.jvpp.core.dto.Ikev2SetLocalKeyReply;
+import io.fd.vpp.jvpp.ikev2.dto.Ikev2SetLocalKey;
+import io.fd.vpp.jvpp.ikev2.dto.Ikev2SetLocalKeyReply;
+import io.fd.vpp.jvpp.ikev2.future.FutureJVppIkev2Facade;
import org.junit.Test;
+import org.mockito.Mock;
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.ipsec.rev181213.IpsecIkeGlobalConfAugmentation;
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.ipsec.rev181213.IpsecIkeGlobalConfAugmentationBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipsec.rev181214.Ikev2;
@@ -39,11 +41,13 @@ public class Ikev2GlobalConfigurationCustomizerTest extends WriterCustomizerTest
.child(IkeGlobalConfiguration.class);
private Ikev2GlobalConfigurationCustomizer customizer;
private static final String LOCAL_KEY_FILE = "/home/localadmin/certs/client-key.pem";
+ @Mock
+ protected FutureJVppIkev2Facade ikev2api;
@Override
protected void setUpTest() throws Exception {
- customizer = new Ikev2GlobalConfigurationCustomizer(api);
- when(api.ikev2SetLocalKey(any())).thenReturn(future(new Ikev2SetLocalKeyReply()));
+ customizer = new Ikev2GlobalConfigurationCustomizer(ikev2api);
+ when(ikev2api.ikev2SetLocalKey(any())).thenReturn(future(new Ikev2SetLocalKeyReply()));
}
@Test
@@ -55,6 +59,6 @@ public class Ikev2GlobalConfigurationCustomizerTest extends WriterCustomizerTest
customizer.writeCurrentAttributes(IID, dataAfterBuilder.build(), writeContext);
Ikev2SetLocalKey request = new Ikev2SetLocalKey();
request.keyFile = LOCAL_KEY_FILE.getBytes();
- verify(api).ikev2SetLocalKey(request);
+ verify(ikev2api).ikev2SetLocalKey(request);
}
}
diff --git a/ipsec/ipsec-impl/src/test/java/io/fd/hc2vpp/ipsec/write/Ikev2PolicyCustomizerTest.java b/ipsec/ipsec-impl/src/test/java/io/fd/hc2vpp/ipsec/write/Ikev2PolicyCustomizerTest.java
index e2062e56c..b53ab7024 100644
--- a/ipsec/ipsec-impl/src/test/java/io/fd/hc2vpp/ipsec/write/Ikev2PolicyCustomizerTest.java
+++ b/ipsec/ipsec-impl/src/test/java/io/fd/hc2vpp/ipsec/write/Ikev2PolicyCustomizerTest.java
@@ -30,15 +30,17 @@ import io.fd.hc2vpp.ipsec.helpers.SchemaContextTestHelper;
import io.fd.honeycomb.test.tools.HoneycombTestRunner;
import io.fd.honeycomb.test.tools.annotations.InjectTestData;
import io.fd.honeycomb.translate.write.WriteFailedException;
-import io.fd.vpp.jvpp.core.dto.Ikev2ProfileAddDel;
-import io.fd.vpp.jvpp.core.dto.Ikev2ProfileAddDelReply;
-import io.fd.vpp.jvpp.core.dto.Ikev2ProfileSetAuth;
-import io.fd.vpp.jvpp.core.dto.Ikev2ProfileSetAuthReply;
-import io.fd.vpp.jvpp.core.dto.Ikev2ProfileSetTs;
-import io.fd.vpp.jvpp.core.dto.Ikev2ProfileSetTsReply;
+import io.fd.vpp.jvpp.ikev2.dto.Ikev2ProfileAddDel;
+import io.fd.vpp.jvpp.ikev2.dto.Ikev2ProfileAddDelReply;
+import io.fd.vpp.jvpp.ikev2.dto.Ikev2ProfileSetAuth;
+import io.fd.vpp.jvpp.ikev2.dto.Ikev2ProfileSetAuthReply;
+import io.fd.vpp.jvpp.ikev2.dto.Ikev2ProfileSetTs;
+import io.fd.vpp.jvpp.ikev2.dto.Ikev2ProfileSetTsReply;
+import io.fd.vpp.jvpp.ikev2.future.FutureJVppIkev2Facade;
import java.nio.ByteBuffer;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.Mock;
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.ipsec.rev181213.IpsecIkev2PolicyAugmentation;
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.ipsec.rev181213.ikev2.policy.aug.grouping.TrafficSelectors;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipsec.rev181214.Ikev2;
@@ -53,13 +55,15 @@ public class Ikev2PolicyCustomizerTest extends WriterCustomizerTest implements S
private static final String IKEV2_PATH = "/hc2vpp-ietf-ipsec:ikev2";
private Ikev2PolicyCustomizer customizer;
+ @Mock
+ protected FutureJVppIkev2Facade ikev2api;
@Override
protected void setUpTest() throws Exception {
- customizer = new Ikev2PolicyCustomizer(api);
- when(api.ikev2ProfileAddDel(any())).thenReturn(future(new Ikev2ProfileAddDelReply()));
- when(api.ikev2ProfileSetTs(any())).thenReturn(future(new Ikev2ProfileSetTsReply()));
- when(api.ikev2ProfileSetAuth(any())).thenReturn(future(new Ikev2ProfileSetAuthReply()));
+ customizer = new Ikev2PolicyCustomizer(ikev2api);
+ when(ikev2api.ikev2ProfileAddDel(any())).thenReturn(future(new Ikev2ProfileAddDelReply()));
+ when(ikev2api.ikev2ProfileSetTs(any())).thenReturn(future(new Ikev2ProfileSetTsReply()));
+ when(ikev2api.ikev2ProfileSetAuth(any())).thenReturn(future(new Ikev2ProfileSetAuthReply()));
}
@Test
@@ -71,10 +75,10 @@ public class Ikev2PolicyCustomizerTest extends WriterCustomizerTest implements S
profileAddrequest.isAdd = BYTE_TRUE;
profileAddrequest.name = policy.getName().getBytes();
- verify(api).ikev2ProfileAddDel(profileAddrequest);
- verify(api).ikev2ProfileSetTs(translateTStoRequest(policy.augmentation(IpsecIkev2PolicyAugmentation.class)
+ verify(ikev2api).ikev2ProfileAddDel(profileAddrequest);
+ verify(ikev2api).ikev2ProfileSetTs(translateTStoRequest(policy.augmentation(IpsecIkev2PolicyAugmentation.class)
.getTrafficSelectors().get(0), policy.getName()));
- verify(api).ikev2ProfileSetAuth(translateAuthToRequest(policy));
+ verify(ikev2api).ikev2ProfileSetAuth(translateAuthToRequest(policy));
}
@Test
@@ -86,10 +90,10 @@ public class Ikev2PolicyCustomizerTest extends WriterCustomizerTest implements S
final Policy after = ikev2After.getPolicy().get(0);
customizer.updateCurrentAttributes(getId(before.getName()), before, after, writeContext);
- verify(api, times(0)).ikev2ProfileAddDel(any());
- verify(api).ikev2ProfileSetTs(translateTStoRequest(after.augmentation(IpsecIkev2PolicyAugmentation.class)
+ verify(ikev2api, times(0)).ikev2ProfileAddDel(any());
+ verify(ikev2api).ikev2ProfileSetTs(translateTStoRequest(after.augmentation(IpsecIkev2PolicyAugmentation.class)
.getTrafficSelectors().get(0), after.getName()));
- verify(api).ikev2ProfileSetAuth(translateAuthToRequest(after));
+ verify(ikev2api).ikev2ProfileSetAuth(translateAuthToRequest(after));
}
@Test
@@ -100,9 +104,9 @@ public class Ikev2PolicyCustomizerTest extends WriterCustomizerTest implements S
final Ikev2ProfileAddDel request = new Ikev2ProfileAddDel();
request.name = policy.getName().getBytes();
request.isAdd = BYTE_FALSE;
- verify(api).ikev2ProfileAddDel(request);
- verify(api, times(0)).ikev2ProfileSetTs(any());
- verify(api, times(0)).ikev2ProfileSetAuth(any());
+ verify(ikev2api).ikev2ProfileAddDel(request);
+ verify(ikev2api, times(0)).ikev2ProfileSetTs(any());
+ verify(ikev2api, times(0)).ikev2ProfileSetAuth(any());
}
private InstanceIdentifier<Policy> getId(final String name) {
diff --git a/ipsec/ipsec-impl/src/test/java/io/fd/hc2vpp/ipsec/write/Ikev2PolicyIdentityCustomizerTest.java b/ipsec/ipsec-impl/src/test/java/io/fd/hc2vpp/ipsec/write/Ikev2PolicyIdentityCustomizerTest.java
index 3f57acdbb..2a62b9494 100644
--- a/ipsec/ipsec-impl/src/test/java/io/fd/hc2vpp/ipsec/write/Ikev2PolicyIdentityCustomizerTest.java
+++ b/ipsec/ipsec-impl/src/test/java/io/fd/hc2vpp/ipsec/write/Ikev2PolicyIdentityCustomizerTest.java
@@ -28,10 +28,12 @@ import io.fd.hc2vpp.ipsec.helpers.SchemaContextTestHelper;
import io.fd.honeycomb.test.tools.HoneycombTestRunner;
import io.fd.honeycomb.test.tools.annotations.InjectTestData;
import io.fd.honeycomb.translate.write.WriteFailedException;
-import io.fd.vpp.jvpp.core.dto.Ikev2ProfileSetId;
-import io.fd.vpp.jvpp.core.dto.Ikev2ProfileSetIdReply;
+import io.fd.vpp.jvpp.ikev2.dto.Ikev2ProfileSetId;
+import io.fd.vpp.jvpp.ikev2.dto.Ikev2ProfileSetIdReply;
+import io.fd.vpp.jvpp.ikev2.future.FutureJVppIkev2Facade;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.Mock;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipsec.rev181214.Ikev2;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipsec.rev181214.ike.general.policy.profile.grouping.Identity;
@@ -52,11 +54,13 @@ public class Ikev2PolicyIdentityCustomizerTest extends WriterCustomizerTest impl
"/hc2vpp-ietf-ipsec:ikev2/hc2vpp-ietf-ipsec:policy[hc2vpp-ietf-ipsec:name='" + POLICY_NAME +
"']/hc2vpp-ietf-ipsec:identity";
private Ikev2PolicyIdentityCustomizer customizer;
+ @Mock
+ protected FutureJVppIkev2Facade ikev2api;
@Override
protected void setUpTest() throws Exception {
- customizer = new Ikev2PolicyIdentityCustomizer(api);
- when(api.ikev2ProfileSetId(any())).thenReturn(future(new Ikev2ProfileSetIdReply()));
+ customizer = new Ikev2PolicyIdentityCustomizer(ikev2api);
+ when(ikev2api.ikev2ProfileSetId(any())).thenReturn(future(new Ikev2ProfileSetIdReply()));
}
@Test
@@ -70,7 +74,7 @@ public class Ikev2PolicyIdentityCustomizerTest extends WriterCustomizerTest impl
request.isLocal = BYTE_TRUE;
request.data = ipv4AddressNoZoneToArray(IPV4_TYPE_DATA);
request.dataLen = request.data.length;
- verify(api).ikev2ProfileSetId(request);
+ verify(ikev2api).ikev2ProfileSetId(request);
}
@Test
@@ -84,7 +88,7 @@ public class Ikev2PolicyIdentityCustomizerTest extends WriterCustomizerTest impl
request.isLocal = BYTE_FALSE;
request.data = FQDN_TYPE_DATA.getBytes();
request.dataLen = request.data.length;
- verify(api).ikev2ProfileSetId(request);
+ verify(ikev2api).ikev2ProfileSetId(request);
}
@Test
@@ -98,7 +102,7 @@ public class Ikev2PolicyIdentityCustomizerTest extends WriterCustomizerTest impl
request.isLocal = BYTE_FALSE;
request.data = ipv6AddressNoZoneToArray(new Ipv6Address(IPV6_TYPE_DATA));
request.dataLen = request.data.length;
- verify(api).ikev2ProfileSetId(request);
+ verify(ikev2api).ikev2ProfileSetId(request);
}
@Test
@@ -113,7 +117,7 @@ public class Ikev2PolicyIdentityCustomizerTest extends WriterCustomizerTest impl
request.isLocal = BYTE_TRUE;
request.data = RFC822_TYPE_DATA.getBytes();
request.dataLen = request.data.length;
- verify(api).ikev2ProfileSetId(request);
+ verify(ikev2api).ikev2ProfileSetId(request);
}
private InstanceIdentifier<Identity> getId() {