use of org.eclipse.hono.util.ResourceLimits in project hono by eclipse.
the class HonoEventConnectionEventProducerTest method testConnectedSucceeds.
@Test
void testConnectedSucceeds(final VertxTestContext ctx) {
final String tenantId = "tenant";
final Device authenticatedDevice = new Device(tenantId, "device");
tenant = new TenantObject(tenantId, true).setResourceLimits(new ResourceLimits().setMaxTtl(500));
when(tenantClient.get(anyString(), any())).thenReturn(Future.succeededFuture(tenant));
producer.connected(context, "device-internal-id", "custom-adapter", authenticatedDevice, new JsonObject(), null).onComplete(ctx.succeeding(ok -> {
ctx.verify(() -> {
verify(sender).sendEvent(eq(tenant), any(RegistrationAssertion.class), eq(EventConstants.EVENT_CONNECTION_NOTIFICATION_CONTENT_TYPE), any(), any(), any());
});
ctx.completeNow();
}));
}
use of org.eclipse.hono.util.ResourceLimits in project hono by eclipse.
the class PrometheusBasedAsyncCacheLoaderTest method testExecuteQuerySetsAuthHeader.
/**
* Verifies that the Basic authentication header is set if username and password have been
* configured.
*/
@Test
public void testExecuteQuerySetsAuthHeader() {
config.setUsername("hono");
config.setPassword("hono-secret");
givenCurrentConnections(0);
final TenantObject tenant = TenantObject.from(Constants.DEFAULT_TENANT, true).setResourceLimits(new ResourceLimits().setMaxConnections(10));
final var key = new LimitedResourceKey(tenant.getTenantId(), (tenantId, ctx) -> Future.succeededFuture(tenant));
final var result = loader.asyncLoad(key, executor);
assertThat(result.isDone()).isTrue();
verify(bufferReq).basicAuthentication(eq("hono"), eq("hono-secret"));
}
use of org.eclipse.hono.util.ResourceLimits in project hono by eclipse.
the class ProtonBasedDownstreamSenderTest method testDownstreamEventHasCreationTimeAndTtl.
/**
* Verifies that a downstream event always contains a creation-time
* and a time-to-live as defined at the tenant level.
*/
@Test
public void testDownstreamEventHasCreationTimeAndTtl() {
final TenantObject tenant = TenantObject.from(Constants.DEFAULT_TENANT, true);
final RegistrationAssertion device = new RegistrationAssertion("4711");
tenant.setResourceLimits(new ResourceLimits().setMaxTtl(60L));
// WHEN sending a message without specifying any properties
sender.sendEvent(tenant, device, "text/plain", Buffer.buffer("hello"), null, span.context());
// THEN the message contains a creation-time
verify(protonSender).send(argThat(message -> message.getCreationTime() > 0 && message.getTtl() == 60000L), VertxMockSupport.anyHandler());
}
Aggregations