Search in sources :

Example 1 with CredentialsService

use of org.eclipse.hono.service.credentials.CredentialsService in project hono by eclipse.

the class FileBasedCredentialsServiceTest method assertRegistered.

private static void assertRegistered(final CredentialsService svc, final String tenant, final String authId, final String type, final TestContext ctx) {
    Async registration = ctx.async();
    svc.get(tenant, type, authId, ctx.asyncAssertSuccess(t -> {
        assertThat(t.getStatus(), is(HttpURLConnection.HTTP_OK));
        registration.complete();
    }));
    registration.await(300);
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) HttpURLConnection(java.net.HttpURLConnection) TestContext(io.vertx.ext.unit.TestContext) Async(io.vertx.ext.unit.Async) RunWith(org.junit.runner.RunWith) Constants(org.eclipse.hono.util.Constants) Context(io.vertx.core.Context) Assert.assertThat(org.junit.Assert.assertThat) ArgumentCaptor(org.mockito.ArgumentCaptor) EventBus(io.vertx.core.eventbus.EventBus) Matchers.eq(org.mockito.Matchers.eq) JsonObject(io.vertx.core.json.JsonObject) Before(org.junit.Before) Vertx(io.vertx.core.Vertx) Test(org.junit.Test) VertxUnitRunner(io.vertx.ext.unit.junit.VertxUnitRunner) Future(io.vertx.core.Future) StandardCharsets(java.nio.charset.StandardCharsets) CredentialsConstants(org.eclipse.hono.util.CredentialsConstants) Matchers.any(org.mockito.Matchers.any) Mockito(org.mockito.Mockito) JsonArray(io.vertx.core.json.JsonArray) Buffer(io.vertx.core.buffer.Buffer) FileSystem(io.vertx.core.file.FileSystem) CredentialsService(org.eclipse.hono.service.credentials.CredentialsService) Handler(io.vertx.core.Handler) CredentialsObject(org.eclipse.hono.util.CredentialsObject) Async(io.vertx.ext.unit.Async)

Example 2 with CredentialsService

use of org.eclipse.hono.service.credentials.CredentialsService in project hono by eclipse.

the class FileBasedCredentialsServiceTest method register.

private static void register(final CredentialsService svc, final String tenant, final String deviceId, final String authId, final String type, final JsonArray secrets, final TestContext ctx) {
    JsonObject data = new JsonObject().put(CredentialsConstants.FIELD_PAYLOAD_DEVICE_ID, deviceId).put(CredentialsConstants.FIELD_AUTH_ID, authId).put(CredentialsConstants.FIELD_TYPE, type).put(CredentialsConstants.FIELD_SECRETS, secrets);
    Async registration = ctx.async();
    svc.add("tenant", data, ctx.asyncAssertSuccess(s -> {
        assertThat(s.getStatus(), is(HttpURLConnection.HTTP_CREATED));
        registration.complete();
    }));
    registration.await(300);
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) HttpURLConnection(java.net.HttpURLConnection) TestContext(io.vertx.ext.unit.TestContext) Async(io.vertx.ext.unit.Async) RunWith(org.junit.runner.RunWith) Constants(org.eclipse.hono.util.Constants) Context(io.vertx.core.Context) Assert.assertThat(org.junit.Assert.assertThat) ArgumentCaptor(org.mockito.ArgumentCaptor) EventBus(io.vertx.core.eventbus.EventBus) Matchers.eq(org.mockito.Matchers.eq) JsonObject(io.vertx.core.json.JsonObject) Before(org.junit.Before) Vertx(io.vertx.core.Vertx) Test(org.junit.Test) VertxUnitRunner(io.vertx.ext.unit.junit.VertxUnitRunner) Future(io.vertx.core.Future) StandardCharsets(java.nio.charset.StandardCharsets) CredentialsConstants(org.eclipse.hono.util.CredentialsConstants) Matchers.any(org.mockito.Matchers.any) Mockito(org.mockito.Mockito) JsonArray(io.vertx.core.json.JsonArray) Buffer(io.vertx.core.buffer.Buffer) FileSystem(io.vertx.core.file.FileSystem) CredentialsService(org.eclipse.hono.service.credentials.CredentialsService) Handler(io.vertx.core.Handler) CredentialsObject(org.eclipse.hono.util.CredentialsObject) Async(io.vertx.ext.unit.Async) JsonObject(io.vertx.core.json.JsonObject)

Example 3 with CredentialsService

use of org.eclipse.hono.service.credentials.CredentialsService in project hono by eclipse.

the class FileBasedCredentialsServiceTest method assertNotRegistered.

private static void assertNotRegistered(final CredentialsService svc, final String tenant, final String authId, final String type, final TestContext ctx) {
    Async registration = ctx.async();
    svc.get(tenant, type, authId, ctx.asyncAssertSuccess(t -> {
        assertThat(t.getStatus(), is(HttpURLConnection.HTTP_NOT_FOUND));
        registration.complete();
    }));
    registration.await(300);
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) HttpURLConnection(java.net.HttpURLConnection) TestContext(io.vertx.ext.unit.TestContext) Async(io.vertx.ext.unit.Async) RunWith(org.junit.runner.RunWith) Constants(org.eclipse.hono.util.Constants) Context(io.vertx.core.Context) Assert.assertThat(org.junit.Assert.assertThat) ArgumentCaptor(org.mockito.ArgumentCaptor) EventBus(io.vertx.core.eventbus.EventBus) Matchers.eq(org.mockito.Matchers.eq) JsonObject(io.vertx.core.json.JsonObject) Before(org.junit.Before) Vertx(io.vertx.core.Vertx) Test(org.junit.Test) VertxUnitRunner(io.vertx.ext.unit.junit.VertxUnitRunner) Future(io.vertx.core.Future) StandardCharsets(java.nio.charset.StandardCharsets) CredentialsConstants(org.eclipse.hono.util.CredentialsConstants) Matchers.any(org.mockito.Matchers.any) Mockito(org.mockito.Mockito) JsonArray(io.vertx.core.json.JsonArray) Buffer(io.vertx.core.buffer.Buffer) FileSystem(io.vertx.core.file.FileSystem) CredentialsService(org.eclipse.hono.service.credentials.CredentialsService) Handler(io.vertx.core.Handler) CredentialsObject(org.eclipse.hono.util.CredentialsObject) Async(io.vertx.ext.unit.Async)

Aggregations

Context (io.vertx.core.Context)3 Future (io.vertx.core.Future)3 Handler (io.vertx.core.Handler)3 Vertx (io.vertx.core.Vertx)3 Buffer (io.vertx.core.buffer.Buffer)3 EventBus (io.vertx.core.eventbus.EventBus)3 FileSystem (io.vertx.core.file.FileSystem)3 JsonArray (io.vertx.core.json.JsonArray)3 JsonObject (io.vertx.core.json.JsonObject)3 Async (io.vertx.ext.unit.Async)3 TestContext (io.vertx.ext.unit.TestContext)3 VertxUnitRunner (io.vertx.ext.unit.junit.VertxUnitRunner)3 HttpURLConnection (java.net.HttpURLConnection)3 StandardCharsets (java.nio.charset.StandardCharsets)3 CredentialsService (org.eclipse.hono.service.credentials.CredentialsService)3 Constants (org.eclipse.hono.util.Constants)3 CredentialsConstants (org.eclipse.hono.util.CredentialsConstants)3 CredentialsObject (org.eclipse.hono.util.CredentialsObject)3 CoreMatchers.is (org.hamcrest.CoreMatchers.is)3 Assert.assertThat (org.junit.Assert.assertThat)3