use of org.kaazing.k3po.lang.el.BytesMatcher in project zilla by aklivity.
the class ProxyFunctionsTest method shouldMatchInet6BeginExtensionSource.
@Test
public void shouldMatchInet6BeginExtensionSource() throws Exception {
BytesMatcher matcher = ProxyFunctions.matchBeginEx().typeId(0x01).addressInet6().source("fd12:3456:789a:1::1").build().build();
ByteBuffer byteBuf = ByteBuffer.allocate(1024);
new ProxyBeginExFW.Builder().wrap(new UnsafeBuffer(byteBuf), 0, byteBuf.capacity()).typeId(0x01).address(a -> a.inet6(i -> i.protocol(p -> p.set(STREAM)).source(new UnsafeBuffer(fromHex("fd123456789a00010000000000000001")), 0, 16).destination(new UnsafeBuffer(fromHex("fd123456789a000100000000000000fe")), 0, 16).sourcePort(32768).destinationPort(443))).build();
assertNotNull(matcher.match(byteBuf));
}
use of org.kaazing.k3po.lang.el.BytesMatcher in project zilla by aklivity.
the class ProxyFunctionsTest method shouldNotMatchInetBeginExtensionDestinationPort.
@Test(expected = Exception.class)
public void shouldNotMatchInetBeginExtensionDestinationPort() throws Exception {
BytesMatcher matcher = ProxyFunctions.matchBeginEx().typeId(0x01).addressInet().destinationPort(444).build().build();
ByteBuffer byteBuf = ByteBuffer.allocate(1024);
new ProxyBeginExFW.Builder().wrap(new UnsafeBuffer(byteBuf), 0, byteBuf.capacity()).typeId(0x01).address(a -> a.inet(i -> i.protocol(p -> p.set(STREAM)).source("*").destination("example.com").sourcePort(32768).destinationPort(443))).build();
assertNull(matcher.match(byteBuf));
}
use of org.kaazing.k3po.lang.el.BytesMatcher in project zilla by aklivity.
the class ProxyFunctionsTest method shouldMatchInetBeginExtensionProtocol.
@Test
public void shouldMatchInetBeginExtensionProtocol() throws Exception {
BytesMatcher matcher = ProxyFunctions.matchBeginEx().typeId(0x01).addressInet().protocol("stream").build().build();
ByteBuffer byteBuf = ByteBuffer.allocate(1024);
new ProxyBeginExFW.Builder().wrap(new UnsafeBuffer(byteBuf), 0, byteBuf.capacity()).typeId(0x01).address(a -> a.inet(i -> i.protocol(p -> p.set(STREAM)).source("*").destination("example.com").sourcePort(32768).destinationPort(443))).build();
assertNotNull(matcher.match(byteBuf));
}
use of org.kaazing.k3po.lang.el.BytesMatcher in project zilla by aklivity.
the class ProxyFunctionsTest method shouldNotMatchInetBeginExtensionProtocol.
@Test(expected = Exception.class)
public void shouldNotMatchInetBeginExtensionProtocol() throws Exception {
BytesMatcher matcher = ProxyFunctions.matchBeginEx().typeId(0x01).addressInet().protocol("datagram").build().build();
ByteBuffer byteBuf = ByteBuffer.allocate(1024);
new ProxyBeginExFW.Builder().wrap(new UnsafeBuffer(byteBuf), 0, byteBuf.capacity()).typeId(0x01).address(a -> a.inet(i -> i.protocol(p -> p.set(STREAM)).source("*").destination("example.com").sourcePort(32768).destinationPort(443))).build();
assertNull(matcher.match(byteBuf));
}
use of org.kaazing.k3po.lang.el.BytesMatcher in project zilla by aklivity.
the class ProxyFunctionsTest method shouldMatchUnixBeginExtensionDestination.
@Test
public void shouldMatchUnixBeginExtensionDestination() throws Exception {
BytesMatcher matcher = ProxyFunctions.matchBeginEx().typeId(0x01).addressUnix().destination("destination-5678").build().build();
ByteBuffer byteBuf = ByteBuffer.allocate(1024);
new ProxyBeginExFW.Builder().wrap(new UnsafeBuffer(byteBuf), 0, byteBuf.capacity()).typeId(0x01).address(a -> a.unix(i -> i.protocol(p -> p.set(STREAM)).source(paddedUtf8("source-1234", 108), 0, 108).destination(paddedUtf8("destination-5678", 108), 0, 108))).build();
assertNotNull(matcher.match(byteBuf));
}
Aggregations