use of org.eclipse.hono.client.ServiceInvocationException 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.client.ServiceInvocationException 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());
}));
}
use of org.eclipse.hono.client.ServiceInvocationException 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.client.ServiceInvocationException 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