use of org.eclipse.hono.service.management.credentials.Credentials in project hono by eclipse.
the class CredentialsApiTests method testGetCredentialsFailsForDisabledCredentials.
/**
* Verifies that the service fails when the credentials set is disabled.
*
* @param ctx The vert.x test context.
*/
@Timeout(value = 5, timeUnit = TimeUnit.SECONDS)
@Test
public void testGetCredentialsFailsForDisabledCredentials(final VertxTestContext ctx) {
final String deviceId = getHelper().getRandomDeviceId(tenantId);
final String authId = UUID.randomUUID().toString();
final CommonCredential credential = getRandomHashedPasswordCredential(authId);
credential.setEnabled(false);
getHelper().registry.registerDevice(tenantId, deviceId).compose(ok -> getHelper().registry.addCredentials(tenantId, deviceId, Collections.singleton(credential))).compose(ok -> getClient().get(tenantId, CredentialsConstants.SECRETS_TYPE_HASHED_PASSWORD, authId, spanContext)).onComplete(ctx.failing(t -> {
ctx.verify(() -> assertErrorCode(t, HttpURLConnection.HTTP_NOT_FOUND));
ctx.completeNow();
}));
}
use of org.eclipse.hono.service.management.credentials.Credentials in project hono by eclipse.
the class CredentialsApiTests method testGetCredentialsByClientContext.
/**
* Verifies that the service returns credentials for a given type, authentication ID and matching client context.
*
* @param ctx The vert.x test context.
*/
@Timeout(value = 5, timeUnit = TimeUnit.SECONDS)
@Test
public void testGetCredentialsByClientContext(final VertxTestContext ctx) {
final String deviceId = getHelper().getRandomDeviceId(tenantId);
final String authId = UUID.randomUUID().toString();
final CommonCredential credentials = getRandomHashedPasswordCredential(authId).putExtension("client-id", "gateway-one");
final JsonObject clientContext = new JsonObject().put("client-id", "gateway-one");
getHelper().registry.registerDevice(tenantId, deviceId).compose(httpResponse -> getHelper().registry.addCredentials(tenantId, deviceId, List.of(credentials))).compose(ok -> getClient().get(tenantId, CredentialsConstants.SECRETS_TYPE_HASHED_PASSWORD, authId, clientContext, spanContext)).onComplete(ctx.succeeding(result -> {
ctx.verify(() -> {
assertStandardProperties(result, deviceId, authId, CredentialsConstants.SECRETS_TYPE_HASHED_PASSWORD, 2);
});
ctx.completeNow();
}));
}
Aggregations