Search in sources :

Example 1 with PskSecret

use of org.eclipse.hono.service.management.credentials.PskSecret in project hono by eclipse.

the class RegistryServiceTest method testGetDisabledCredentials.

@Test
void testGetDisabledCredentials(final VertxTestContext context) {
    Future.succeededFuture().flatMap(x -> {
        final var device = new Device();
        return this.registrationManagement.createDevice(DEFAULT_TENANT, Optional.of("d1"), device, SPAN).onComplete(context.succeeding(result -> {
            context.verify(() -> {
                assertThat(result.getStatus()).isEqualTo(HttpURLConnection.HTTP_CREATED);
            });
        }));
    }).flatMap(x -> {
        final var credentials = new LinkedList<CommonCredential>();
        final var psk = new PskCredential("a1", List.of(new PskSecret().setKey(new byte[] { 1, 2, 3, 4 })));
        psk.setEnabled(false);
        credentials.add(psk);
        return this.credentialsManagement.updateCredentials(DEFAULT_TENANT, "d1", credentials, Optional.empty(), SPAN).onFailure(context::failNow);
    }).flatMap(x -> {
        return this.credentialsAdapter.get(DEFAULT_TENANT, CredentialsConstants.SECRETS_TYPE_PRESHARED_KEY, "d1").onComplete(context.succeeding(result -> {
            context.verify(() -> {
                assertThat(result.getStatus()).isEqualTo(HttpURLConnection.HTTP_NOT_FOUND);
            });
        }));
    }).onComplete(context.succeedingThenComplete());
}
Also used : HttpURLConnection(java.net.HttpURLConnection) VertxTestContext(io.vertx.junit5.VertxTestContext) Device(org.eclipse.hono.service.management.device.Device) RegistrationConstants(org.eclipse.hono.util.RegistrationConstants) Truth.assertThat(com.google.common.truth.Truth.assertThat) VertxExtension(io.vertx.junit5.VertxExtension) Future(io.vertx.core.Future) CredentialsConstants(org.eclipse.hono.util.CredentialsConstants) Test(org.junit.jupiter.api.Test) List(java.util.List) CommonCredential(org.eclipse.hono.service.management.credentials.CommonCredential) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) PskCredential(org.eclipse.hono.service.management.credentials.PskCredential) Optional(java.util.Optional) Assertions(org.eclipse.hono.deviceregistry.util.Assertions) PskSecret(org.eclipse.hono.service.management.credentials.PskSecret) LinkedList(java.util.LinkedList) PskCredential(org.eclipse.hono.service.management.credentials.PskCredential) Device(org.eclipse.hono.service.management.device.Device) PskSecret(org.eclipse.hono.service.management.credentials.PskSecret) LinkedList(java.util.LinkedList) Test(org.junit.jupiter.api.Test)

Aggregations

Truth.assertThat (com.google.common.truth.Truth.assertThat)1 Future (io.vertx.core.Future)1 VertxExtension (io.vertx.junit5.VertxExtension)1 VertxTestContext (io.vertx.junit5.VertxTestContext)1 HttpURLConnection (java.net.HttpURLConnection)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Optional (java.util.Optional)1 Assertions (org.eclipse.hono.deviceregistry.util.Assertions)1 CommonCredential (org.eclipse.hono.service.management.credentials.CommonCredential)1 PskCredential (org.eclipse.hono.service.management.credentials.PskCredential)1 PskSecret (org.eclipse.hono.service.management.credentials.PskSecret)1 Device (org.eclipse.hono.service.management.device.Device)1 CredentialsConstants (org.eclipse.hono.util.CredentialsConstants)1 RegistrationConstants (org.eclipse.hono.util.RegistrationConstants)1 Test (org.junit.jupiter.api.Test)1 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)1