use of org.eclipse.hono.util.EventBusMessage in project hono by eclipse.
the class TenantAmqpEndpoint method processRequest.
@Override
public final void processRequest(final Message msg, final ResourceIdentifier targetAddress, final HonoUser clientPrincipal) {
final EventBusMessage request = EventBusMessage.forOperation(msg).setReplyToAddress(msg).setAppCorrelationId(msg).setCorrelationId(msg).setTenant(msg).setJsonPayload(msg);
vertx.eventBus().send(TenantConstants.EVENT_BUS_ADDRESS_TENANT_IN, request.toJson());
}
use of org.eclipse.hono.util.EventBusMessage in project hono by eclipse.
the class BaseCredentialsServiceTest method testAddSucceedsForMinimalData.
/**
* Verifies that the base service accepts a request for adding
* credentials that contains the minimum required properties.
*
* @param ctx The vert.x test context.
*/
@Test
public void testAddSucceedsForMinimalData(final TestContext ctx) {
final JsonObject testData = createValidCredentialsObject();
final EventBusMessage msg = createRequestForPayload(CredentialsConstants.CredentialsAction.add, testData);
service.processRequest(msg).setHandler(ctx.asyncAssertSuccess(response -> {
ctx.assertEquals(HttpURLConnection.HTTP_CREATED, response.getStatus());
}));
}
use of org.eclipse.hono.util.EventBusMessage in project hono by eclipse.
the class BaseCredentialsServiceTest method testGetFailsForMissingAuthId.
/**
* Verifies that the base service fails a request for getting credentials
* with a 400 error code if the authentication identifier is missing.
*
* @param ctx The vert.x test context.
*/
@Test
public void testGetFailsForMissingAuthId(final TestContext ctx) {
// GIVEN a request for getting credentials that does not specify an auth ID
final CredentialsObject malformedPayload = new CredentialsObject().setType("my-type").addSecret(CredentialsObject.emptySecret(null, null));
final EventBusMessage request = createRequestForPayload(CredentialsConstants.CredentialsAction.get, JsonObject.mapFrom(malformedPayload));
// WHEN processing the request
service.processRequest(request).setHandler(ctx.asyncAssertFailure(t -> {
// THEN the response contains a 400 error code
ctx.assertEquals(HttpURLConnection.HTTP_BAD_REQUEST, ((ServiceInvocationException) t).getErrorCode());
}));
}
use of org.eclipse.hono.util.EventBusMessage in project hono by eclipse.
the class BaseCredentialsServiceTest method testAddFailsForShortTimestamp.
/**
* Verifies that the base service rejects a request for adding
* credentials that contains a secret with a time stamp that does
* not include an offset.
*
* @param ctx The vert.x test context.
*/
@Test
public void testAddFailsForShortTimestamp(final TestContext ctx) {
final JsonObject secret = new JsonObject().put(CredentialsConstants.FIELD_SECRETS_NOT_BEFORE, "2007-04-05T14:30");
final JsonObject testData = createValidCredentialsObject(secret);
final EventBusMessage msg = createRequestForPayload(CredentialsConstants.CredentialsAction.add, testData);
service.processRequest(msg).setHandler(ctx.asyncAssertFailure(t -> {
ctx.assertEquals(HttpURLConnection.HTTP_BAD_REQUEST, ((ServiceInvocationException) t).getErrorCode());
}));
}
use of org.eclipse.hono.util.EventBusMessage in project hono by eclipse.
the class BaseCredentialsServiceTest method testAddFailsForMalformedTimestamp.
/**
* Verifies that the base service rejects a request for adding
* credentials that contain a secret with a malformed time stamp.
*
* @param ctx The vert.x test context.
*/
@Test
public void testAddFailsForMalformedTimestamp(final TestContext ctx) {
final JsonObject secret = new JsonObject().put(CredentialsConstants.FIELD_SECRETS_NOT_BEFORE, "no-timestamp");
final JsonObject testData = createValidCredentialsObject(secret);
final EventBusMessage msg = createRequestForPayload(CredentialsConstants.CredentialsAction.add, testData);
service.processRequest(msg).setHandler(ctx.asyncAssertFailure(t -> {
ctx.assertEquals(HttpURLConnection.HTTP_BAD_REQUEST, ((ServiceInvocationException) t).getErrorCode());
}));
}
Aggregations