use of org.eclipse.hono.service.management.credentials.GenericCredential in project hono by eclipse.
the class CredentialsManagementIT method testGetAllCredentialsForDeviceSucceeds.
/**
* Verifies that the service returns all credentials registered for a given device regardless of
* authentication identifier and type.
* <p>
* The returned JsonArray must contain exactly the same credentials as originally added.
*
* @param context The vert.x test context.
*/
@Test
public void testGetAllCredentialsForDeviceSucceeds(final VertxTestContext context) {
final List<CommonCredential> credentialsListToAdd = new ArrayList<>();
credentialsListToAdd.add(pskCredentials);
credentialsListToAdd.add(hashedPasswordCredential);
credentialsListToAdd.add(X509CertificateCredential.fromSubjectDn("CN=Acme", List.of(new X509CertificateSecret())));
for (int i = 0; i < 3; i++) {
final GenericSecret secret = new GenericSecret();
secret.setAdditionalProperties(Map.of("field-" + i, "setec astronomy"));
final GenericCredential credential = new GenericCredential("type-" + i, getRandomAuthId(PREFIX_AUTH_ID), List.of(secret));
credentialsListToAdd.add(credential);
}
registry.addCredentials(tenantId, deviceId, credentialsListToAdd).compose(ar -> registry.getCredentials(tenantId, deviceId)).onComplete(context.succeeding(httpResponse -> {
context.verify(() -> assertResponseBodyContainsAllCredentials(httpResponse.bodyAsJsonArray(), credentialsListToAdd));
context.completeNow();
}));
}
Aggregations