Search in sources :

Example 96 with BytesMatcher

use of org.kaazing.k3po.lang.el.BytesMatcher in project zilla by aklivity.

the class ProxyFunctionsTest method shouldNotMatchInet6BeginExtensionProtocol.

@Test(expected = Exception.class)
public void shouldNotMatchInet6BeginExtensionProtocol() throws Exception {
    BytesMatcher matcher = ProxyFunctions.matchBeginEx().typeId(0x01).addressInet6().protocol("datagram").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();
    assertNull(matcher.match(byteBuf));
}
Also used : NONE(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyAddressFamily.NONE) UnsafeBuffer(org.agrona.concurrent.UnsafeBuffer) AUTHORITY(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyInfoType.AUTHORITY) VERSION(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxySecureInfoType.VERSION) ByteBuffer(java.nio.ByteBuffer) ProxyInfoFW(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyInfoFW) Assert.assertSame(org.junit.Assert.assertSame) ProxyBeginExFW(io.aklivity.zilla.specs.binding.proxy.internal.types.stream.ProxyBeginExFW) FunctionMapper(javax.el.FunctionMapper) BitUtil.fromHex(org.agrona.BitUtil.fromHex) Method(java.lang.reflect.Method) KEY(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxySecureInfoType.KEY) NAMESPACE(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyInfoType.NAMESPACE) SECURE(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyInfoType.SECURE) INET4(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyAddressFamily.INET4) Assert.assertNotNull(org.junit.Assert.assertNotNull) INET6(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyAddressFamily.INET6) CIPHER(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxySecureInfoType.CIPHER) Test(org.junit.Test) STREAM(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyAddressProtocol.STREAM) IDENTITY(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyInfoType.IDENTITY) UnknownHostException(java.net.UnknownHostException) BytesMatcher(org.kaazing.k3po.lang.el.BytesMatcher) Assert.assertNull(org.junit.Assert.assertNull) ExpressionContext(org.kaazing.k3po.lang.internal.el.ExpressionContext) ALPN(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyInfoType.ALPN) NAME(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxySecureInfoType.NAME) INET(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyAddressFamily.INET) UNIX(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyAddressFamily.UNIX) ELContext(javax.el.ELContext) SIGNATURE(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxySecureInfoType.SIGNATURE) Assert.assertEquals(org.junit.Assert.assertEquals) DirectBuffer(org.agrona.DirectBuffer) UnsafeBuffer(org.agrona.concurrent.UnsafeBuffer) BytesMatcher(org.kaazing.k3po.lang.el.BytesMatcher) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 97 with BytesMatcher

use of org.kaazing.k3po.lang.el.BytesMatcher in project zilla by aklivity.

the class ProxyFunctionsTest method shouldMatchUnixBeginExtensionTypeId.

@Test
public void shouldMatchUnixBeginExtensionTypeId() throws Exception {
    BytesMatcher matcher = ProxyFunctions.matchBeginEx().typeId(0x01).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));
}
Also used : NONE(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyAddressFamily.NONE) UnsafeBuffer(org.agrona.concurrent.UnsafeBuffer) AUTHORITY(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyInfoType.AUTHORITY) VERSION(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxySecureInfoType.VERSION) ByteBuffer(java.nio.ByteBuffer) ProxyInfoFW(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyInfoFW) Assert.assertSame(org.junit.Assert.assertSame) ProxyBeginExFW(io.aklivity.zilla.specs.binding.proxy.internal.types.stream.ProxyBeginExFW) FunctionMapper(javax.el.FunctionMapper) BitUtil.fromHex(org.agrona.BitUtil.fromHex) Method(java.lang.reflect.Method) KEY(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxySecureInfoType.KEY) NAMESPACE(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyInfoType.NAMESPACE) SECURE(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyInfoType.SECURE) INET4(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyAddressFamily.INET4) Assert.assertNotNull(org.junit.Assert.assertNotNull) INET6(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyAddressFamily.INET6) CIPHER(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxySecureInfoType.CIPHER) Test(org.junit.Test) STREAM(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyAddressProtocol.STREAM) IDENTITY(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyInfoType.IDENTITY) UnknownHostException(java.net.UnknownHostException) BytesMatcher(org.kaazing.k3po.lang.el.BytesMatcher) Assert.assertNull(org.junit.Assert.assertNull) ExpressionContext(org.kaazing.k3po.lang.internal.el.ExpressionContext) ALPN(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyInfoType.ALPN) NAME(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxySecureInfoType.NAME) INET(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyAddressFamily.INET) UNIX(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyAddressFamily.UNIX) ELContext(javax.el.ELContext) SIGNATURE(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxySecureInfoType.SIGNATURE) Assert.assertEquals(org.junit.Assert.assertEquals) DirectBuffer(org.agrona.DirectBuffer) UnsafeBuffer(org.agrona.concurrent.UnsafeBuffer) BytesMatcher(org.kaazing.k3po.lang.el.BytesMatcher) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.Test)

Example 98 with BytesMatcher

use of org.kaazing.k3po.lang.el.BytesMatcher in project zilla by aklivity.

the class ProxyFunctionsTest method shouldNotMatchInet4BeginExtensionIdentity.

@Test(expected = Exception.class)
public void shouldNotMatchInet4BeginExtensionIdentity() throws Exception {
    BytesMatcher matcher = ProxyFunctions.matchBeginEx().typeId(0x01).info().identity(fromHex("12345679")).build().build();
    ByteBuffer byteBuf = ByteBuffer.allocate(1024);
    new ProxyBeginExFW.Builder().wrap(new UnsafeBuffer(byteBuf), 0, byteBuf.capacity()).typeId(0x01).address(a -> a.inet4(i -> i.protocol(p -> p.set(STREAM)).source(new UnsafeBuffer(fromHex("c0a80001")), 0, 4).destination(new UnsafeBuffer(fromHex("c0a800fe")), 0, 4).sourcePort(32768).destinationPort(443))).infosItem(i -> i.identity(id -> id.value(v -> v.set(fromHex("12345678"))))).build();
    assertNull(matcher.match(byteBuf));
}
Also used : NONE(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyAddressFamily.NONE) UnsafeBuffer(org.agrona.concurrent.UnsafeBuffer) AUTHORITY(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyInfoType.AUTHORITY) VERSION(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxySecureInfoType.VERSION) ByteBuffer(java.nio.ByteBuffer) ProxyInfoFW(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyInfoFW) Assert.assertSame(org.junit.Assert.assertSame) ProxyBeginExFW(io.aklivity.zilla.specs.binding.proxy.internal.types.stream.ProxyBeginExFW) FunctionMapper(javax.el.FunctionMapper) BitUtil.fromHex(org.agrona.BitUtil.fromHex) Method(java.lang.reflect.Method) KEY(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxySecureInfoType.KEY) NAMESPACE(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyInfoType.NAMESPACE) SECURE(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyInfoType.SECURE) INET4(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyAddressFamily.INET4) Assert.assertNotNull(org.junit.Assert.assertNotNull) INET6(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyAddressFamily.INET6) CIPHER(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxySecureInfoType.CIPHER) Test(org.junit.Test) STREAM(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyAddressProtocol.STREAM) IDENTITY(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyInfoType.IDENTITY) UnknownHostException(java.net.UnknownHostException) BytesMatcher(org.kaazing.k3po.lang.el.BytesMatcher) Assert.assertNull(org.junit.Assert.assertNull) ExpressionContext(org.kaazing.k3po.lang.internal.el.ExpressionContext) ALPN(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyInfoType.ALPN) NAME(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxySecureInfoType.NAME) INET(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyAddressFamily.INET) UNIX(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyAddressFamily.UNIX) ELContext(javax.el.ELContext) SIGNATURE(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxySecureInfoType.SIGNATURE) Assert.assertEquals(org.junit.Assert.assertEquals) DirectBuffer(org.agrona.DirectBuffer) UnsafeBuffer(org.agrona.concurrent.UnsafeBuffer) BytesMatcher(org.kaazing.k3po.lang.el.BytesMatcher) ByteBuffer(java.nio.ByteBuffer) ProxyBeginExFW(io.aklivity.zilla.specs.binding.proxy.internal.types.stream.ProxyBeginExFW) Test(org.junit.Test)

Example 99 with BytesMatcher

use of org.kaazing.k3po.lang.el.BytesMatcher in project zilla by aklivity.

the class ProxyFunctionsTest method shouldNotMatchInet4BeginExtensionSecureKey.

@Test(expected = Exception.class)
public void shouldNotMatchInet4BeginExtensionSecureKey() throws Exception {
    BytesMatcher matcher = ProxyFunctions.matchBeginEx().typeId(0x01).info().secure().key("RSA2049").build().build().build();
    ByteBuffer byteBuf = ByteBuffer.allocate(1024);
    new ProxyBeginExFW.Builder().wrap(new UnsafeBuffer(byteBuf), 0, byteBuf.capacity()).typeId(0x01).address(a -> a.inet4(i -> i.protocol(p -> p.set(STREAM)).source(new UnsafeBuffer(fromHex("c0a80001")), 0, 4).destination(new UnsafeBuffer(fromHex("c0a800fe")), 0, 4).sourcePort(32768).destinationPort(443))).infosItem(i -> i.secure(s -> s.key("RSA2048"))).build();
    assertNull(matcher.match(byteBuf));
}
Also used : NONE(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyAddressFamily.NONE) UnsafeBuffer(org.agrona.concurrent.UnsafeBuffer) AUTHORITY(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyInfoType.AUTHORITY) VERSION(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxySecureInfoType.VERSION) ByteBuffer(java.nio.ByteBuffer) ProxyInfoFW(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyInfoFW) Assert.assertSame(org.junit.Assert.assertSame) ProxyBeginExFW(io.aklivity.zilla.specs.binding.proxy.internal.types.stream.ProxyBeginExFW) FunctionMapper(javax.el.FunctionMapper) BitUtil.fromHex(org.agrona.BitUtil.fromHex) Method(java.lang.reflect.Method) KEY(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxySecureInfoType.KEY) NAMESPACE(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyInfoType.NAMESPACE) SECURE(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyInfoType.SECURE) INET4(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyAddressFamily.INET4) Assert.assertNotNull(org.junit.Assert.assertNotNull) INET6(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyAddressFamily.INET6) CIPHER(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxySecureInfoType.CIPHER) Test(org.junit.Test) STREAM(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyAddressProtocol.STREAM) IDENTITY(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyInfoType.IDENTITY) UnknownHostException(java.net.UnknownHostException) BytesMatcher(org.kaazing.k3po.lang.el.BytesMatcher) Assert.assertNull(org.junit.Assert.assertNull) ExpressionContext(org.kaazing.k3po.lang.internal.el.ExpressionContext) ALPN(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyInfoType.ALPN) NAME(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxySecureInfoType.NAME) INET(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyAddressFamily.INET) UNIX(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyAddressFamily.UNIX) ELContext(javax.el.ELContext) SIGNATURE(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxySecureInfoType.SIGNATURE) Assert.assertEquals(org.junit.Assert.assertEquals) DirectBuffer(org.agrona.DirectBuffer) UnsafeBuffer(org.agrona.concurrent.UnsafeBuffer) BytesMatcher(org.kaazing.k3po.lang.el.BytesMatcher) ByteBuffer(java.nio.ByteBuffer) ProxyBeginExFW(io.aklivity.zilla.specs.binding.proxy.internal.types.stream.ProxyBeginExFW) Test(org.junit.Test)

Example 100 with BytesMatcher

use of org.kaazing.k3po.lang.el.BytesMatcher in project zilla by aklivity.

the class ProxyFunctionsTest method shouldMatchInet4BeginExtension.

@Test
public void shouldMatchInet4BeginExtension() throws Exception {
    BytesMatcher matcher = ProxyFunctions.matchBeginEx().typeId(0x01).addressInet4().source("192.168.0.1").destination("192.168.0.254").sourcePort(32768).destinationPort(443).build().info().alpn("echo").authority("example.com").identity(fromHex("12345678")).namespace("example").secure().version("TLSv1.3").cipher("ECDHE-RSA-AES128-GCM-SHA256").signature("SHA256").name("name@domain").key("RSA2048").build().build().build();
    ByteBuffer byteBuf = ByteBuffer.allocate(1024);
    new ProxyBeginExFW.Builder().wrap(new UnsafeBuffer(byteBuf), 0, byteBuf.capacity()).typeId(0x01).address(a -> a.inet4(i -> i.protocol(p -> p.set(STREAM)).source(new UnsafeBuffer(fromHex("c0a80001")), 0, 4).destination(new UnsafeBuffer(fromHex("c0a800fe")), 0, 4).sourcePort(32768).destinationPort(443))).infosItem(i -> i.alpn("echo")).infosItem(i -> i.authority("example.com")).infosItem(i -> i.identity(id -> id.value(v -> v.set(fromHex("12345678"))))).infosItem(i -> i.namespace("example")).infosItem(i -> i.secure(s -> s.version("TLSv1.3"))).infosItem(i -> i.secure(s -> s.cipher("ECDHE-RSA-AES128-GCM-SHA256"))).infosItem(i -> i.secure(s -> s.signature("SHA256"))).infosItem(i -> i.secure(s -> s.name("name@domain"))).infosItem(i -> i.secure(s -> s.key("RSA2048"))).build();
    assertNotNull(matcher.match(byteBuf));
}
Also used : NONE(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyAddressFamily.NONE) UnsafeBuffer(org.agrona.concurrent.UnsafeBuffer) AUTHORITY(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyInfoType.AUTHORITY) VERSION(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxySecureInfoType.VERSION) ByteBuffer(java.nio.ByteBuffer) ProxyInfoFW(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyInfoFW) Assert.assertSame(org.junit.Assert.assertSame) ProxyBeginExFW(io.aklivity.zilla.specs.binding.proxy.internal.types.stream.ProxyBeginExFW) FunctionMapper(javax.el.FunctionMapper) BitUtil.fromHex(org.agrona.BitUtil.fromHex) Method(java.lang.reflect.Method) KEY(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxySecureInfoType.KEY) NAMESPACE(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyInfoType.NAMESPACE) SECURE(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyInfoType.SECURE) INET4(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyAddressFamily.INET4) Assert.assertNotNull(org.junit.Assert.assertNotNull) INET6(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyAddressFamily.INET6) CIPHER(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxySecureInfoType.CIPHER) Test(org.junit.Test) STREAM(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyAddressProtocol.STREAM) IDENTITY(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyInfoType.IDENTITY) UnknownHostException(java.net.UnknownHostException) BytesMatcher(org.kaazing.k3po.lang.el.BytesMatcher) Assert.assertNull(org.junit.Assert.assertNull) ExpressionContext(org.kaazing.k3po.lang.internal.el.ExpressionContext) ALPN(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyInfoType.ALPN) NAME(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxySecureInfoType.NAME) INET(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyAddressFamily.INET) UNIX(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxyAddressFamily.UNIX) ELContext(javax.el.ELContext) SIGNATURE(io.aklivity.zilla.specs.binding.proxy.internal.types.ProxySecureInfoType.SIGNATURE) Assert.assertEquals(org.junit.Assert.assertEquals) DirectBuffer(org.agrona.DirectBuffer) UnsafeBuffer(org.agrona.concurrent.UnsafeBuffer) BytesMatcher(org.kaazing.k3po.lang.el.BytesMatcher) ByteBuffer(java.nio.ByteBuffer) ProxyBeginExFW(io.aklivity.zilla.specs.binding.proxy.internal.types.stream.ProxyBeginExFW) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)142 BytesMatcher (org.kaazing.k3po.lang.el.BytesMatcher)142 ByteBuffer (java.nio.ByteBuffer)134 ELContext (javax.el.ELContext)129 DirectBuffer (org.agrona.DirectBuffer)129 UnsafeBuffer (org.agrona.concurrent.UnsafeBuffer)129 Assert.assertEquals (org.junit.Assert.assertEquals)129 Assert.assertNotNull (org.junit.Assert.assertNotNull)129 Assert.assertNull (org.junit.Assert.assertNull)129 ExpressionContext (org.kaazing.k3po.lang.internal.el.ExpressionContext)129 UTF_8 (java.nio.charset.StandardCharsets.UTF_8)69 Assert.assertTrue (org.junit.Assert.assertTrue)69 Method (java.lang.reflect.Method)65 FunctionMapper (javax.el.FunctionMapper)65 Assert.assertSame (org.junit.Assert.assertSame)65 ExpressionFactory (javax.el.ExpressionFactory)64 ValueExpression (javax.el.ValueExpression)64 Assert.assertArrayEquals (org.junit.Assert.assertArrayEquals)64 Before (org.junit.Before)64 ExpressionFactoryUtils.newExpressionFactory (org.kaazing.k3po.lang.internal.el.ExpressionFactoryUtils.newExpressionFactory)64