use of org.kaazing.k3po.lang.el.BytesMatcher in project zilla by aklivity.
the class ProxyFunctionsTest method shouldNotMatchInetBeginExtensionSourcePort.
@Test(expected = Exception.class)
public void shouldNotMatchInetBeginExtensionSourcePort() throws Exception {
BytesMatcher matcher = ProxyFunctions.matchBeginEx().typeId(0x01).addressInet().sourcePort(32767).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 KafkaFunctionsTest method shouldMatchMergedDataExtensionHeader.
@Test
public void shouldMatchMergedDataExtensionHeader() throws Exception {
BytesMatcher matcher = KafkaFunctions.matchDataEx().merged().header("name", "value").build().build();
ByteBuffer byteBuf = ByteBuffer.allocate(1024);
new KafkaDataExFW.Builder().wrap(new UnsafeBuffer(byteBuf), 0, byteBuf.capacity()).typeId(0x01).merged(f -> f.timestamp(12345678L).partition(p -> p.partitionId(0).partitionOffset(0L)).progressItem(p -> p.partitionId(0).partitionOffset(1L)).key(k -> k.length(5).value(v -> v.set("match".getBytes(UTF_8)))).delta(d -> d.type(t -> t.set(KafkaDeltaType.NONE))).headersItem(h -> h.nameLen(4).name(n -> n.set("name".getBytes(UTF_8))).valueLen(5).value(v -> v.set("value".getBytes(UTF_8))))).build();
assertNotNull(matcher.match(byteBuf));
}
use of org.kaazing.k3po.lang.el.BytesMatcher in project zilla by aklivity.
the class KafkaFunctionsTest method shouldMatchMergedDataExtensionWithByteValue.
@Test
public void shouldMatchMergedDataExtensionWithByteValue() throws Exception {
BytesMatcher matcher = KafkaFunctions.matchDataEx().typeId(0x01).merged().partition(0, 0L).progress(0, 1L).timestamp(12345678L).key("match").headerByte("name", (byte) 1).build().build();
ByteBuffer byteBuf = ByteBuffer.allocate(1024);
byte[] value = ByteBuffer.allocate(1).put((byte) 1).array();
new KafkaDataExFW.Builder().wrap(new UnsafeBuffer(byteBuf), 0, byteBuf.capacity()).typeId(0x01).merged(f -> f.timestamp(12345678L).partition(p -> p.partitionId(0).partitionOffset(0L)).progressItem(p -> p.partitionId(0).partitionOffset(1L)).key(k -> k.length(5).value(v -> v.set("match".getBytes(UTF_8)))).delta(d -> d.type(t -> t.set(KafkaDeltaType.NONE))).headersItem(h -> h.nameLen(4).name(n -> n.set("name".getBytes(UTF_8))).valueLen(1).value(v -> v.set(value)))).build();
assertNotNull(matcher.match(byteBuf));
}
use of org.kaazing.k3po.lang.el.BytesMatcher in project zilla by aklivity.
the class ProxyFunctionsTest method shouldNotMatchInetBeginExtensionSecureCipher.
@Test(expected = Exception.class)
public void shouldNotMatchInetBeginExtensionSecureCipher() throws Exception {
BytesMatcher matcher = ProxyFunctions.matchBeginEx().typeId(0x01).info().secure().cipher("ECDHE-RSA-AES128-GCM-SHA257").build().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))).infosItem(i -> i.secure(s -> s.cipher("ECDHE-RSA-AES128-GCM-SHA256"))).build();
assertNull(matcher.match(byteBuf));
}
use of org.kaazing.k3po.lang.el.BytesMatcher in project zilla by aklivity.
the class ProxyFunctionsTest method shouldNotMatchInetBeginExtensionSecureSignature.
@Test(expected = Exception.class)
public void shouldNotMatchInetBeginExtensionSecureSignature() 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.inet(i -> i.protocol(p -> p.set(STREAM)).source("*").destination("example.com").sourcePort(32768).destinationPort(443))).infosItem(i -> i.secure(s -> s.signature("SHA256"))).build();
assertNull(matcher.match(byteBuf));
}
Aggregations