summaryrefslogtreecommitdiffstats
path: root/nat/nat2vpp/src/test
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2018-05-30 13:45:41 +0200
committerMarek Gradzki <mgradzki@cisco.com>2018-05-31 09:09:49 +0000
commit7d961bf199719410b2e4111c830fbf35b41c83c2 (patch)
tree8f5a5dbd0502b7e9046f3b672aa21173c392296f /nat/nat2vpp/src/test
parenta626d4ad0333762de57eb3298b9c7b3f9f19f82e (diff)
HC2VPP-325: use ip-prefix instead of ip-address in ietf-nat@2018-02-23.yang
Only /32 prefix for IPv4 and /128 for IPv6 are supported. Change-Id: I875b1eb6c2cb43da54de0a731aeeb9757b39c39c Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'nat/nat2vpp/src/test')
-rw-r--r--nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/MappingEntryCustomizerTest.java8
-rw-r--r--nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/util/MappingEntryContextTest.java32
-rw-r--r--nat/nat2vpp/src/test/resources/nat44/static-mapping-address-update.json4
-rw-r--r--nat/nat2vpp/src/test/resources/nat44/static-mapping-unsupported-proto.json4
-rw-r--r--nat/nat2vpp/src/test/resources/nat44/static-mapping.json4
-rw-r--r--nat/nat2vpp/src/test/resources/nat64/static-mapping-address-update.json4
-rw-r--r--nat/nat2vpp/src/test/resources/nat64/static-mapping-unsupported-proto.json4
-rw-r--r--nat/nat2vpp/src/test/resources/nat64/static-mapping.json4
8 files changed, 32 insertions, 32 deletions
diff --git a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/MappingEntryCustomizerTest.java b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/MappingEntryCustomizerTest.java
index 7f38dc9b9..9ce42dafe 100644
--- a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/MappingEntryCustomizerTest.java
+++ b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/read/MappingEntryCustomizerTest.java
@@ -98,9 +98,9 @@ public class MappingEntryCustomizerTest
getCustomizer().readCurrentAttributes(mappingEntryId, builder, ctx);
assertEquals(NAT_MAPPING_ID, builder.getIndex().longValue());
- assertEquals("192.168.3.8", builder.getExternalSrcAddress().getValue());
+ assertEquals("192.168.3.8/32", builder.getExternalSrcAddress().getIpv4Prefix().getValue());
assertEquals(6874, builder.getExternalSrcPort().getStartPortNumber().getValue().intValue());
- assertArrayEquals("192.168.2.2".toCharArray(), builder.getInternalSrcAddress().getValue());
+ assertEquals("192.168.2.2/32", builder.getInternalSrcAddress().getIpv4Prefix().getValue());
assertEquals(1274, builder.getInternalSrcPort().getStartPortNumber().getValue().intValue());
}
@@ -128,9 +128,9 @@ public class MappingEntryCustomizerTest
getCustomizer().readCurrentAttributes(mappingEntryId, builder, ctx);
assertEquals(NAT_MAPPING_ID, builder.getIndex().longValue());
- assertEquals("192.168.64.3", builder.getExternalSrcAddress().getValue());
+ assertEquals("192.168.64.3/32", builder.getExternalSrcAddress().getIpv4Prefix().getValue());
assertEquals(6874, builder.getExternalSrcPort().getStartPortNumber().getValue().intValue());
- assertArrayEquals("2001:db8:85a3::8a2e:370:7303".toCharArray(), builder.getInternalSrcAddress().getValue());
+ assertEquals("2001:db8:85a3::8a2e:370:7303/128", builder.getInternalSrcAddress().getIpv6Prefix().getValue());
assertEquals(1274, builder.getInternalSrcPort().getStartPortNumber().getValue().intValue());
}
diff --git a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/util/MappingEntryContextTest.java b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/util/MappingEntryContextTest.java
index df5912bce..3af318c3e 100644
--- a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/util/MappingEntryContextTest.java
+++ b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/util/MappingEntryContextTest.java
@@ -26,8 +26,8 @@ import static org.mockito.MockitoAnnotations.initMocks;
import com.google.common.base.Optional;
import com.google.common.collect.Lists;
-import io.fd.honeycomb.translate.MappingContext;
import io.fd.hc2vpp.common.translate.util.Ipv4Translator;
+import io.fd.honeycomb.translate.MappingContext;
import io.fd.vpp.jvpp.nat.dto.Nat44StaticMappingDetails;
import java.util.Collections;
import java.util.List;
@@ -35,8 +35,8 @@ import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.nat.context.rev161214.mapping.entry.context.attributes.nat.mapping.entry.context.nat.instance.MappingTableBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.nat.rev180223.nat.instances.instance.mapping.table.MappingEntry;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.nat.rev180223.nat.instances.instance.mapping.table.MappingEntryBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.nat.rev180223.nat.instances.instance.mapping.table.MappingEntryKey;
@@ -59,7 +59,7 @@ public class MappingEntryContextTest implements Ipv4Translator {
when(mappingCtx.read(any(InstanceIdentifier.class))).thenReturn(Optional.absent());
final long natId = 7;
final long entryId = 99;
- final MappingEntry entry = getEntry(natId, "192.168.1.5", "17.14.4.6");
+ final MappingEntry entry = getEntry(natId, "192.168.1.5/32", "17.14.4.6/32");
ctx.addEntry(natId, entryId, entry, mappingCtx);
@@ -69,7 +69,7 @@ public class MappingEntryContextTest implements Ipv4Translator {
@Test
public void testRemove() throws Exception {
final long natId = 0;
- final MappingEntry entry = getEntry(natId, "192.168.1.5", "17.14.4.6");
+ final MappingEntry entry = getEntry(natId, "192.168.1.5/32", "17.14.4.6/32");
ctx.removeEntry(natId, entry, mappingCtx);
@@ -80,7 +80,7 @@ public class MappingEntryContextTest implements Ipv4Translator {
public void testGetExistingIndex() throws Exception {
final long natId = 0;
final long entryId = 12;
- final MappingEntry entry = getEntry(entryId, "192.168.1.5", "17.14.4.6");
+ final MappingEntry entry = getEntry(entryId, "192.168.1.5/32", "17.14.4.6/32");
final Nat44StaticMappingDetails details = getDetails(entryId, "192.168.1.5", "17.14.4.6");
when(mappingCtx.read(MappingEntryContext.getId(natId, MappingEntryContext.entryToKey(entry))))
@@ -93,9 +93,9 @@ public class MappingEntryContextTest implements Ipv4Translator {
@Test
public void testFindDetails() throws Exception {
final long natId = 0;
- final MappingEntry entry = getEntry(0, "192.168.1.5", "17.14.4.6");
+ final MappingEntry entry = getEntry(0, "192.168.1.5/32", "17.14.4.6/32");
final Nat44StaticMappingDetails details = getDetails(0, "192.168.1.5", "17.14.4.6");
- final MappingEntry entry2 = getEntry(1, "192.168.1.8", "17.14.4.10");
+ final MappingEntry entry2 = getEntry(1, "192.168.1.8/32", "17.14.4.10/32");
final Nat44StaticMappingDetails details2 = getDetails(1, "192.168.1.8", "17.14.4.10");
final List<Nat44StaticMappingDetails> someDetails = Lists.newArrayList(details, details2);
@@ -138,16 +138,16 @@ public class MappingEntryContextTest implements Ipv4Translator {
public void testGetArtificialIndex() throws Exception {
final long natId = 0;
final long entryId = 0;
- final MappingEntry entry = getEntry(entryId, "192.168.1.5", "17.14.4.6");
+ final MappingEntry entry = getEntry(entryId, "192.168.1.5/32", "17.14.4.6/32");
final long entryId2 = 55;
- final MappingEntry entry2 = getEntry(entryId2, "192.168.1.6", "17.14.4.7");
+ final MappingEntry entry2 = getEntry(entryId2, "192.168.1.6/32", "17.14.4.7/32");
final long entryId3 = 18954;
- final MappingEntry entry3 = getEntry(entryId3, "192.168.1.7", "17.14.4.8");
+ final MappingEntry entry3 = getEntry(entryId3, "192.168.1.7/32", "17.14.4.8/32");
final long entryId4 = 18955;
- final MappingEntry entry4 = getEntry(entryId4, "192.168.1.8", "17.14.4.9");
+ final MappingEntry entry4 = getEntry(entryId4, "192.168.1.8/32", "17.14.4.9/32");
final long newEntryId = 18956;
- final MappingEntry newEntry = getEntry(newEntryId, "192.168.1.99", "17.14.4.99");
+ final MappingEntry newEntry = getEntry(newEntryId, "192.168.1.99/32", "17.14.4.99/32");
final Nat44StaticMappingDetails newDetails = getDetails(newEntryId, "192.168.1.99", "17.14.4.99");
when(mappingCtx.read(MappingEntryContext.getId(natId, MappingEntryContext.entryToKey(newEntry))))
.thenReturn(Optional.absent());
@@ -178,7 +178,7 @@ public class MappingEntryContextTest implements Ipv4Translator {
public void testAddExisting() throws Exception {
final long natId = 7;
final long entryId = 99;
- final MappingEntry entry = getEntry(natId, "192.168.1.5", "17.14.4.6");
+ final MappingEntry entry = getEntry(natId, "192.168.1.5/32", "17.14.4.6/32");
final org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.nat.context.rev161214.mapping.entry.context.attributes.nat.mapping.entry.context.nat.instance.mapping.table.MappingEntry
data = MappingEntryContext.toCtxMapEntry(entry, entryId);
when(mappingCtx.read(any(InstanceIdentifier.class))).thenReturn(Optional.of(data));
@@ -190,8 +190,8 @@ public class MappingEntryContextTest implements Ipv4Translator {
return new MappingEntryBuilder()
.setKey(new MappingEntryKey(id))
.setType(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.nat.rev180223.MappingEntry.Type.Static)
- .setInternalSrcAddress(new IpAddress(new Ipv4Address(longernalIpv4)))
- .setExternalSrcAddress(new Ipv4Address(externalIpv4))
+ .setInternalSrcAddress(new IpPrefix(new Ipv4Prefix(longernalIpv4)))
+ .setExternalSrcAddress(new IpPrefix(new Ipv4Prefix(externalIpv4)))
.build();
}
} \ No newline at end of file
diff --git a/nat/nat2vpp/src/test/resources/nat44/static-mapping-address-update.json b/nat/nat2vpp/src/test/resources/nat44/static-mapping-address-update.json
index 224a62a6b..6fe329db0 100644
--- a/nat/nat2vpp/src/test/resources/nat44/static-mapping-address-update.json
+++ b/nat/nat2vpp/src/test/resources/nat44/static-mapping-address-update.json
@@ -4,8 +4,8 @@
"index": 22,
"type": "static",
"transport-protocol": 17,
- "internal-src-address": "192.168.1.86",
- "external-src-address": "45.1.5.6"
+ "internal-src-address": "192.168.1.86/32",
+ "external-src-address": "45.1.5.6/32"
}
}
}
diff --git a/nat/nat2vpp/src/test/resources/nat44/static-mapping-unsupported-proto.json b/nat/nat2vpp/src/test/resources/nat44/static-mapping-unsupported-proto.json
index 455465d20..a701e263d 100644
--- a/nat/nat2vpp/src/test/resources/nat44/static-mapping-unsupported-proto.json
+++ b/nat/nat2vpp/src/test/resources/nat44/static-mapping-unsupported-proto.json
@@ -4,8 +4,8 @@
"index": 22,
"type": "static",
"transport-protocol": 123,
- "internal-src-address": "192.168.1.87",
- "external-src-address": "45.1.5.7"
+ "internal-src-address": "192.168.1.87/32",
+ "external-src-address": "45.1.5.7/32"
}
}
}
diff --git a/nat/nat2vpp/src/test/resources/nat44/static-mapping.json b/nat/nat2vpp/src/test/resources/nat44/static-mapping.json
index b1561a46b..a5b5caa4d 100644
--- a/nat/nat2vpp/src/test/resources/nat44/static-mapping.json
+++ b/nat/nat2vpp/src/test/resources/nat44/static-mapping.json
@@ -4,8 +4,8 @@
"index": 22,
"type": "static",
"transport-protocol": 17,
- "internal-src-address": "192.168.1.87",
- "external-src-address": "45.1.5.7"
+ "internal-src-address": "192.168.1.87/32",
+ "external-src-address": "45.1.5.7/32"
}
}
}
diff --git a/nat/nat2vpp/src/test/resources/nat64/static-mapping-address-update.json b/nat/nat2vpp/src/test/resources/nat64/static-mapping-address-update.json
index 2e836ce91..32bfface1 100644
--- a/nat/nat2vpp/src/test/resources/nat64/static-mapping-address-update.json
+++ b/nat/nat2vpp/src/test/resources/nat64/static-mapping-address-update.json
@@ -4,8 +4,8 @@
"index": 58,
"type": "static",
"transport-protocol": 58,
- "internal-src-address": "2001:db8:85a3::8a2e:370:7334",
- "external-src-address": "10.1.1.4",
+ "internal-src-address": "2001:db8:85a3::8a2e:370:7334/128",
+ "external-src-address": "10.1.1.4/32",
"internal-src-port" : {
"start-port-number" : 1234
},
diff --git a/nat/nat2vpp/src/test/resources/nat64/static-mapping-unsupported-proto.json b/nat/nat2vpp/src/test/resources/nat64/static-mapping-unsupported-proto.json
index bbe8a20d3..44432c55b 100644
--- a/nat/nat2vpp/src/test/resources/nat64/static-mapping-unsupported-proto.json
+++ b/nat/nat2vpp/src/test/resources/nat64/static-mapping-unsupported-proto.json
@@ -4,8 +4,8 @@
"index": 58,
"type": "static",
"transport-protocol": 123,
- "internal-src-address": "2001:db8:85a3::8a2e:370:7333",
- "external-src-address": "10.1.1.3"
+ "internal-src-address": "2001:db8:85a3::8a2e:370:7333/128",
+ "external-src-address": "10.1.1.3/32"
}
}
}
diff --git a/nat/nat2vpp/src/test/resources/nat64/static-mapping.json b/nat/nat2vpp/src/test/resources/nat64/static-mapping.json
index 9fff452a2..4312a8841 100644
--- a/nat/nat2vpp/src/test/resources/nat64/static-mapping.json
+++ b/nat/nat2vpp/src/test/resources/nat64/static-mapping.json
@@ -4,11 +4,11 @@
"index": 58,
"type": "static",
"transport-protocol": 58,
- "internal-src-address": "2001:db8:85a3::8a2e:370:7333",
+ "internal-src-address": "2001:db8:85a3::8a2e:370:7333/128",
"internal-src-port": {
"start-port-number": 123
},
- "external-src-address": "10.1.1.3",
+ "external-src-address": "10.1.1.3/32",
"external-src-port": {
"start-port-number": 456
}