use of org.eclipse.hono.util.EventBusMessage in project hono by eclipse.
the class BaseCredentialsServiceTest method testCredentialsAddWithEmptySecret.
/**
* Verifies that the base service accepts a request for adding
* credentials that contain an empty secret.
*
* @param ctx The vert.x test context.
*/
@Test
public void testCredentialsAddWithEmptySecret(final TestContext ctx) {
final JsonObject testData = createValidCredentialsObject(new JsonObject());
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 testAddSucceedsForLongTimestamp.
/**
* Verifies that the base service accepts a request for adding
* credentials that contains a secret with a time stamp including
* an offset.
*
* @param ctx The vert.x test context.
*/
@Test
public void testAddSucceedsForLongTimestamp(final TestContext ctx) {
final JsonObject secret = new JsonObject().put(CredentialsConstants.FIELD_SECRETS_NOT_BEFORE, "2007-04-05T12:30-02:00");
final JsonObject testData = createValidCredentialsObject(secret);
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 testAddFailsForEmptySecrets.
/**
* Verifies that the base service rejects a request for adding
* credentials containing an empty <em>secrets</em> array.
*
* @param ctx The vert.x test context.
*/
@Test
public void testAddFailsForEmptySecrets(final TestContext ctx) {
final JsonObject testData = createValidCredentialsObject(null);
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 testAddFailsForMissingSecrets.
/**
* Verifies that the base service rejects a request for adding
* credentials that do not contain a <em>secrets</em> array at all.
*
* @param ctx The vert.x test context.
*/
@Test
public void testAddFailsForMissingSecrets(final TestContext ctx) {
final JsonObject testData = createValidCredentialsObject();
testData.remove(CredentialsConstants.FIELD_SECRETS);
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