Search in sources :

Example 31 with BytesMatcher

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

the class ProxyFunctionsTest method shouldNotMatchInet6BeginExtensionDestinationPort.

@Test(expected = Exception.class)
public void shouldNotMatchInet6BeginExtensionDestinationPort() throws Exception {
    BytesMatcher matcher = ProxyFunctions.matchBeginEx().typeId(0x01).addressInet6().destinationPort(444).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 32 with BytesMatcher

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

the class ProxyFunctionsTest method shouldNotMatchNoneBeginExtension.

@Test(expected = Exception.class)
public void shouldNotMatchNoneBeginExtension() throws Exception {
    BytesMatcher matcher = ProxyFunctions.matchBeginEx().typeId(0x01).addressNone().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))).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 33 with BytesMatcher

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

the class ProxyFunctionsTest method shouldNotMatchInet4BeginExtensionSource.

@Test(expected = Exception.class)
public void shouldNotMatchInet4BeginExtensionSource() throws Exception {
    BytesMatcher matcher = ProxyFunctions.matchBeginEx().typeId(0x01).addressInet4().source("192.168.0.2").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))).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 34 with BytesMatcher

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

the class ProxyFunctionsTest method shouldNotMatchUnixBeginExtensionDestination.

@Test(expected = Exception.class)
public void shouldNotMatchUnixBeginExtensionDestination() throws Exception {
    BytesMatcher matcher = ProxyFunctions.matchBeginEx().typeId(0x01).addressUnix().destination("destination-56789").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();
    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 35 with BytesMatcher

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

the class ProxyFunctionsTest method shouldNotMatchInet4BeginExtensionSecureSignature.

@Test(expected = Exception.class)
public void shouldNotMatchInet4BeginExtensionSecureSignature() throws Exception {
    BytesMatcher matcher = ProxyFunctions.matchBeginEx().typeId(0x01).info().secure().signature("SHA257").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.signature("SHA256"))).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)

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